Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/01/13 12:08:25 (11 years ago)
Author:
jkarder
Message:

#2069:

  • refactored grammar and symbols
  • fixed cloning and storable ctors
  • fixed plugin dependencies
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/LogicalExpression.cs

    r9790 r10011  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3738
    3839    [StorableConstructor]
    39     private LogicalExpression(bool deserializing) : base(deserializing) { }
    40     private LogicalExpression(LogicalExpression original, Cloner cloner)
    41       : base(original, cloner) {
    42     }
     40    protected LogicalExpression(bool deserializing) : base(deserializing) { }
     41    protected LogicalExpression(LogicalExpression original, Cloner cloner) : base(original, cloner) { }
    4342
    44     public LogicalExpression()
    45       : base("LogicalExpression", "A LogicalExpression.") {
    46       this.Prefix = "";
    47       this.Suffix = "";
    48     }
     43    public LogicalExpression() : base("LogicalExpression", "A logical expression.") { }
    4944
    5045    public override IDeepCloneable Clone(Cloner cloner) {
     
    5247    }
    5348
    54     public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     49    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
    5550      var enumerator = children.GetEnumerator();
     51      if (!enumerator.MoveNext()) throw new System.Exception("LogicalExpression was not given a child.");
    5652
    57       if (!enumerator.MoveNext()) throw new System.Exception("LogicalExpression was not given a child.");
    5853      var symbol = enumerator.Current.Symbol;
    59 
    60       if (!(symbol is LogicalValue || symbol is LogicalComparison ||
    61           symbol is NumericalComparison || symbol is Negation))
    62         throw new System.Exception("LogicalExpression was given a child of type " + symbol.GetType().ToString() +
    63             ". The expected child must be of type " + typeof(LogicalValue).ToString() + " or " +
    64             typeof(LogicalComparison).ToString() + " or " + typeof(NumericalComparison).ToString() + " or " +
    65             typeof(Negation).ToString() + ".");
     54      if (!(symbol is LogicalValue || symbol is Conjunction || symbol is Disjunction || symbol is Negation))
     55        throw new System.Exception("LogicalExpression was given a child of type " + symbol.GetType() +
     56            ". The expected child must be of type " + typeof(LogicalValue)
     57                                           + " or " + typeof(Conjunction)
     58                                           + " or " + typeof(Disjunction)
     59                                           + " or " + typeof(Negation) + ".");
    6660
    6761      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    6862      if (enumerator.MoveNext()) throw new System.Exception("LogicalExpression was given more than one child.");
    6963
    70       return this.Prefix + result + this.Suffix;
     64      return result;
    7165    }
    7266  }
Note: See TracChangeset for help on using the changeset viewer.