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]); }
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); } }
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); } }
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]); }
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]); }
public static void Rule(CompoundTerm lhs, Functor functor, OpenParenthesis openParenthesis, CompoundTermBody compoundTermBody, CloseParenthesis closeParenthesis) { }
public static void Rule(OptionalTermBody lhs, OpenParenthesis openParenthesis, CompoundTermBody compoundTermBody, CloseParenthesis closeParenthesis) { }
public static void Rule(Element lhs, OpenParenthesis openParenthesis, BinaryElementExpression700 binaryElementExpression, CloseParenthesis closeParenthesis) { lhs.CodeTerm = binaryElementExpression.CodeTerm; }
private NospaceExpression(OpenParenthesis openParenthesis, Expression expression, CloseParenthesis closeParenthesis) : base(openParenthesis, expression, closeParenthesis) { Expression = expression; }