public void Visit(BinaryOperationExpression binaryOperationExpression) { if (_innerVisitor != null) { binaryOperationExpression.Accept(_innerVisitor); } binaryOperationExpression.Left.Accept(this); binaryOperationExpression.Right.Accept(this); }
public void CanUsePropertyAccessors() { var a = new BinaryOperationExpression(); a.OperandLeft = 1; a.OperandRight = 2; a.Operator = BinaryOperator.Add; Assert.AreEqual("1+2;", a.ToString()); }
void simple_expr(ref Expression expr) { if (la.kind == 27 || la.kind == 28) { Expression e = null; Operators op = Operators.Add; signe(ref op); terme(ref e); expr = new UnaryOperationExpression { Operator = op, Location = e.Location, Expression = e }; } else if (StartOf(4)) { Expression e = null; Operators op = Operators.Add; terme(ref expr); if (StartOf(5)) { } else if (la.kind == 27 || la.kind == 28) { signe(ref op); simple_expr(ref e); expr = new BinaryOperationExpression { Left = expr, Right = e, Operator = op, Location = expr.Location }; } else if (la.kind == 16) { Get(); simple_expr(ref e); expr = new BinaryOperationExpression { Left = expr, Right = e, Operator = Operators.Or, Location = expr.Location }; } else { SynErr(56); } } else { SynErr(57); } }
private IExpression Expression(IExpression left, int minPrecedence) { while (IsBinaryOp()) { var token = Current; var type = BinaryOperator(); var precidence = (int)type / 100; var right = PrimaryExpression(); if (minPrecedence >= precidence) { right = Expression(right, precidence); } left = new BinaryOperationExpression { Token = token, Left = left, Type = type, Right = right }; } return(left); }
void expr(ref Expression expr) { simple_expr(ref expr); if (StartOf(2)) { } else if (StartOf(3)) { Expression e = null; Operators op = Operators.Add; oprel(ref op); simple_expr(ref e); expr = new BinaryOperationExpression { Left = expr, Right = e, Operator = op, Location = expr.Location }; } else { SynErr(54); } }
public async Task <Expression> Parse(Parser owner) { Expression leftMost = await ParseNext(owner); if (leftMost == null) { throw new NotImplementedException(); } while (!owner.eof) { bool progress = false; foreach (BinaryOpSpec op in operators) { if (await owner.MaybeToken(op.token, op.alphaNum)) { Expression right = await ParseNext(owner); if (right == null) { throw new NotImplementedException(); } leftMost = new BinaryOperationExpression { Operator = op.op, Left = leftMost, Right = right }; progress = true; break; } } if (!progress) { return(leftMost); } } throw new NotImplementedException(); }
void terme(ref Expression expr) { Expression e = null; facteur(ref e); if (StartOf(6)) { Expression right = null; Operators op = Operators.Add; opmul(ref op); terme(ref right); expr = new BinaryOperationExpression { Left = e, Right = right, Operator = op, Location = e.Location }; } else if (StartOf(7)) { expr = e; } else { SynErr(60); } }
public void Visit(BinaryOperationExpression expression) { string op; switch (expression.Type) { case BinaryType.Addition: op = " + "; break; case BinaryType.BitwiseAnd: op = " & "; break; case BinaryType.BitwiseOr: op = " | "; break; case BinaryType.BitwiseXor: op = " ^ "; break; case BinaryType.Division: op = " / "; break; case BinaryType.Modulus: op = " % "; break; case BinaryType.Multiply: op = " * "; break; case BinaryType.Subtraction: op = " - "; break; default: throw new NotSupportedException(); } Visit(expression.Left); Write(op); Visit(expression.Right); }
public void BinaryOperationExpressionRefusesUnknownEnum() { var a = new BinaryOperationExpression(null, null, (BinaryOperator)int.MaxValue); Expect.Throw <InvalidOperationException>(() => a.ToString()); }
public void AssignWithThrowsOnNull() { BinaryOperationExpression none = null; Expect.Throw <ArgumentNullException>(() => none.AndAssign()); }
public void CanAddTwoNulls() { var a = new BinaryOperationExpression(null, null, BinaryOperator.Add); Assert.AreEqual("null+null;", a.ToString()); }
public void BinaryOperationExpressionSupportsMultipleEvaluation() { var b = new BinaryOperationExpression(A, B, BinaryOperator.MultipleEvaluation); Assert.AreEqual("a,b;", b.ToString()); }
protected virtual Expression VisitBinaryOperation(BinaryOperationExpression node) => base.VisitExtension(node);
public void CanUsePropertyAccessors() { var a = new BinaryOperationExpression(); a.OperandLeft = 1; a.OperandRight = 2; a.Operator = BinaryOperator.Add; Assert.AreEqual("1+2;", a.ToString()); }
public void BinaryOperationExpressionSupportsMultipleEvaluation() { var b = new BinaryOperationExpression(A, B, BinaryOperator.MultipleEvaluation); Assert.AreEqual("a,b;", b.ToString()); }
public void CanAddTwoNulls() { var a = new BinaryOperationExpression(null, null, BinaryOperator.Add); Assert.AreEqual("null+null;", a.ToString()); }
public ConstantFolding(Operators op, BinaryOperationExpression oper) { _op = op; _operation = oper; }
public void BinaryOperationExpressionRefusesUnknownEnum() { var a = new BinaryOperationExpression(null, null, (BinaryOperator)int.MaxValue); Expect.Throw < InvalidOperationException>(() => a.ToString()); }
public void Visit(BinaryOperationExpression binaryOperationExpression) { }