Ejemplo n.º 1
0
 public static void AreEqual(Expression expected, Expression actual, string message = "")
 {
     Assert.AreEqual(expected.GetType(), actual.GetType(), message + "/Type");
     if (expected is SpaceGroupExpression) {
         AreEqual((SpaceGroupExpression)expected, (SpaceGroupExpression)actual, message);
     } else if (expected is CommaGroupExpression) {
         AreEqual((CommaGroupExpression)expected, (CommaGroupExpression)actual, message);
     } else if (expected is UnitExpression) {
         AreEqual((UnitExpression)expected, (UnitExpression)actual, message);
     } else if (expected is NumberExpression) {
         AreEqual((NumberExpression)expected, (NumberExpression)actual, message);
     } else if (expected is LiteralExpression) {
         AreEqual((LiteralExpression)expected, (LiteralExpression)actual, message);
     } else if (expected is AddExpression) {
         AreEqual((AddExpression)expected, (AddExpression)actual, message);
     } else {
         throw new AssertionException("unknown value type " + expected.GetType().Name);
     }
 }
Ejemplo n.º 2
0
 private static Expression ProcessBinaryExpression(Token opToken, Expression left, TokensQueue tokens)
 {
     var tokenPriority = GetPriority(opToken.Type);
     var other = ParseWithPriority(tokens, tokenPriority + 1);
     switch (opToken.Type) {
         case TokenType.Plus: return new AddExpression(left, other);
         case TokenType.Minus: return new SubExpression(left, other);
         case TokenType.Multiply: return new MulExpression(left, other);
         case TokenType.Divide: return new DivExpression(left, other);
         case TokenType.Percentage: return new ModExpression(left, other);
         case TokenType.Whitespace:
             if (left is SpaceGroupExpression) {
                 return ((SpaceGroupExpression)left).Add(other);
             }
             return new SpaceGroupExpression(left, other);
         case TokenType.Comma:
             if (left is CommaGroupExpression) {
                 return ((CommaGroupExpression)left).Add(other);
             }
             return new CommaGroupExpression(left, other);
         default:
             throw new TokenException("unexpected operator " + opToken.Type, opToken);
     }
 }
 public RoundFunctionExpression(Expression inner)
 {
     _inner = inner;
 }
Ejemplo n.º 4
0
 public SubExpression(Expression left, Expression right)
     : base(left, right)
 {
 }
Ejemplo n.º 5
0
 public NegateExpression(Expression inner)
     : base(inner)
 {
 }