Ejemplo n.º 1
0
            public void CanTranslateExpressionUsingParenthesisPrecedence()
            {
                // Prepare (x OR y) AND z
                var x   = new FakeEvaluableExpression();
                var y   = new FakeEvaluableExpression();
                var z   = new FakeEvaluableExpression();
                var and = new AndExpression();
                var or  = new OrExpression();
                var lp  = new OpenParenthesis();
                var rp  = new CloseParenthesis();

                Tokens.Add(lp);
                Tokens.Add(x);
                Tokens.Add(or);
                Tokens.Add(y);
                Tokens.Add(rp);
                Tokens.Add(and);
                Tokens.Add(z);

                // Act
                var result = Parser.TransformInfixToPostfix(Tokens).ToList();

                // Verify
                Assert.IsTrue(result.Count == 5);
                Assert.AreSame(x, result[0]);
                Assert.AreSame(y, result[1]);
                Assert.AreSame(or, result[2]);
                Assert.AreSame(z, result[3]);
                Assert.AreSame(and, result[4]);
            }
Ejemplo n.º 2
0
 public static void Rule(OptionalTermBody lhs, OpenParenthesis openParenthesis, OptionalCompoundTermBody optionalCompoundTermBody, CloseParenthesis closeParenthesis)
 {
     lhs.CodeTerms = new List <CodeTerm>();
     if (optionalCompoundTermBody.CodeTerms != null)
     {
         lhs.CodeTerms.AddRange(optionalCompoundTermBody.CodeTerms);
     }
 }
Ejemplo n.º 3
0
 public static void Rule(OptionalTermBody lhs, OpenParenthesis openParenthesis, OptionalCompoundTermBody optionalCompoundTermBody, CloseParenthesis closeParenthesis)
 {
     lhs.CodeTerms = new List<CodeTerm>();
     if (optionalCompoundTermBody.CodeTerms != null)
     {
         lhs.CodeTerms.AddRange(optionalCompoundTermBody.CodeTerms);
     }
 }
Ejemplo n.º 4
0
            public void CanTranslateExpressionWithParenthesis()
            {
                // Prepare (x)
                var x  = new FakeEvaluableExpression();
                var lp = new OpenParenthesis();
                var rp = new CloseParenthesis();

                Tokens.Add(lp);
                Tokens.Add(x);
                Tokens.Add(rp);

                // Act
                var result = Parser.TransformInfixToPostfix(Tokens).ToList();

                // Verify
                Assert.IsTrue(result.Count == 1);
                Assert.AreSame(x, result[0]);
            }
Ejemplo n.º 5
0
            public void CanTranslateExpressionWithParenthesisAndBinaryOperator()
            {
                // Prepare (x AND y)
                var x   = new FakeEvaluableExpression();
                var y   = new FakeEvaluableExpression();
                var and = new AndExpression();
                var lp  = new OpenParenthesis();
                var rp  = new CloseParenthesis();

                Tokens.Add(lp);
                Tokens.Add(x);
                Tokens.Add(and);
                Tokens.Add(y);
                Tokens.Add(rp);

                // Act
                var result = Parser.TransformInfixToPostfix(Tokens).ToList();

                // Verify
                Assert.IsTrue(result.Count == 3);
                Assert.AreSame(x, result[0]);
                Assert.AreSame(y, result[1]);
                Assert.AreSame(and, result[2]);
            }
Ejemplo n.º 6
0
 public static void Rule(CompoundTerm lhs, Functor functor, OpenParenthesis openParenthesis, CompoundTermBody compoundTermBody, CloseParenthesis closeParenthesis)
 {
 }
Ejemplo n.º 7
0
 public static void Rule(OptionalTermBody lhs, OpenParenthesis openParenthesis, CompoundTermBody compoundTermBody, CloseParenthesis closeParenthesis)
 {
 }
Ejemplo n.º 8
0
 public static void Rule(CompoundTerm lhs, Functor functor, OpenParenthesis openParenthesis, CompoundTermBody compoundTermBody, CloseParenthesis closeParenthesis)
 {
 }
Ejemplo n.º 9
0
 public static void Rule(OptionalTermBody lhs, OpenParenthesis openParenthesis, CompoundTermBody compoundTermBody, CloseParenthesis closeParenthesis)
 {
 }
Ejemplo n.º 10
0
 public static void Rule(Element lhs, OpenParenthesis openParenthesis, BinaryElementExpression700 binaryElementExpression, CloseParenthesis closeParenthesis)
 {
     lhs.CodeTerm = binaryElementExpression.CodeTerm;
 }
Ejemplo n.º 11
0
 public static void Rule(Element lhs, OpenParenthesis openParenthesis, BinaryElementExpression700 binaryElementExpression, CloseParenthesis closeParenthesis)
 {
     lhs.CodeTerm = binaryElementExpression.CodeTerm;
 }
Ejemplo n.º 12
0
 private NospaceExpression(OpenParenthesis openParenthesis, Expression expression, CloseParenthesis closeParenthesis)
     : base(openParenthesis, expression, closeParenthesis)
 {
     Expression = expression;
 }