public void ExitComparison(QueryParser.ComparisonContext context) { var opToken = context.REL_OP(); if (opToken == null) { return; } var op = opToken.Symbol; var right = _expressions.Pop(); var left = _expressions.Pop(); BinaryOperatorExpression value = null; switch (op.Text) { case "<": value = new LessThanOperator(op.Line, op.Column, left, right); break; case "<=": value = new LessThanOrEqualOperator(op.Line, op.Column, left, right); break; case "<>": case "!=": value = new NotEqualOperator(op.Line, op.Column, left, right); break; case "==": case "=": value = new EqualOperator(op.Line, op.Column, left, right); break; case ">": value = new GreaterThanOperator(op.Line, op.Column, left, right); break; case ">=": value = new GreaterThanOrEqualOperator(op.Line, op.Column, left, right); break; } Trace.Assert(value != null, "Invalid comparison operator " + op.Text); _expressions.Push(value); }
public void CreateExpressionTest1() { // Arrange Expression parameterExpression = Expression.Parameter(typeof(Employee), "sample"); Expression expressionProperty = Expression.Property(parameterExpression, nameof(Employee.Age)); Expression expressionConstant = Expression.Constant(20); Expression expectedExpression = Expression.NotEqual(expressionProperty, expressionConstant); var _operator = new NotEqualOperator(); // Act Expression resultExpression = _operator.CreateExpression(expressionProperty, expressionConstant); // Assert Assert.AreEqual(expectedExpression.ToString(), resultExpression.ToString(), "Expression not correct"); }
public Bitmap Visit(NotEqualOperator expr) { return(ComputeFunction(expr)); }