예제 #1
0
 public override Expr VisitAddSub([NotNull] ExprParser.AddSubContext context)
 {
     return(new FunctionExpr(context.op.Type == ExprParser.PLUS ? "+" : "-")
     {
         Arguments = context.expr().Select(Visit).ToArray()
     });
 }
예제 #2
0
        public override int VisitAddSub([NotNull] ExprParser.AddSubContext context)
        {
            int left  = Visit(context.expr(0));
            int right = Visit(context.expr(1));

            if (context.op.Type == ExprParser.ADD)
            {
                return(left + right);
            }
            else
            {
                Debug.Assert(context.op.Type == ExprParser.SUB);
                return(left - right);
            }
        }
예제 #3
0
        public override Expression VisitAddSub(ExprParser.AddSubContext context)
        {
            Expression left  = Visit(context.expression(0));
            Expression right = Visit(context.expression(1));

            Expression e = new Expression(context.op.Text);

            e.AddOperand(left);
            e.AddOperand(right);

            if (context.op.Type == ExprParser.ADD)
            {
                e.Operation = Operation.ADD;
            }
            else if (context.op.Type == ExprParser.SUB)
            {
                e.Operation = Operation.SUB;
            }

            return(e);
        }