Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/24/14 16:45:06 (10 years ago)
Author:
mkommend
Message:

#2268: Moved all grammar classes into a new folder. Added new EmptySymbolicExpressionTreeGrammar which is immutable and forwards all calls to the default grammar object.

Location:
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionGrammar.cs

    r11490 r11494  
    110110      set { defunSymbol = (Defun)value; }
    111111    }
     112
     113    private readonly ISymbolicExpressionTreeGrammar emptyGrammar;
    112114    #endregion
    113115
     
    117119        RegisterSymbolEvents(symbol);
    118120    }
     121
    119122    [StorableConstructor]
    120     protected SymbolicExpressionGrammar(bool deserializing) : base(deserializing) { }
     123    protected SymbolicExpressionGrammar(bool deserializing)
     124      : base(deserializing) {
     125      emptyGrammar = new EmptySymbolicExpressionTreeGrammar(this);
     126    }
    121127    protected SymbolicExpressionGrammar(SymbolicExpressionGrammar original, Cloner cloner)
    122128      : base(original, cloner) {
     129      emptyGrammar = new EmptySymbolicExpressionTreeGrammar(this);
     130
    123131      foreach (ISymbol symbol in symbols.Values)
    124132        RegisterSymbolEvents(symbol);
     
    134142    }
    135143
    136     public SymbolicExpressionGrammar(string name, string description)
     144    protected SymbolicExpressionGrammar(string name, string description)
    137145      : base(name, description) {
     146      emptyGrammar = new EmptySymbolicExpressionTreeGrammar(this);
     147
    138148      programRootSymbol = new ProgramRootSymbol();
    139149      AddSymbol(programRootSymbol);
     
    160170        AddAllowedChildSymbol(programRootSymbol, defunSymbol, argumentIndex);
    161171      }
     172    }
     173
     174    public ISymbolicExpressionTreeGrammar CreateExpressionTreeGrammar() {
     175      if (MaximumFunctionDefinitions == 0) return emptyGrammar;
     176      else return new SymbolicExpressionTreeGrammar(this);
    162177    }
    163178
Note: See TracChangeset for help on using the changeset viewer.