private SpelNode EatSumExpression()
        {
            var expr = EatProductExpression();

            while (PeekToken(TokenKind.PLUS, TokenKind.MINUS, TokenKind.INC))
            {
                // consume PLUS or MINUS or INC
                var t      = TakeToken();
                var rhExpr = EatProductExpression();
                CheckRightOperand(t, rhExpr);
                if (t.Kind == TokenKind.PLUS)
                {
                    expr = new OpPlus(t.StartPos, t.EndPos, expr, rhExpr);
                }
                else if (t.Kind == TokenKind.MINUS)
                {
                    expr = new OpMinus(t.StartPos, t.EndPos, expr, rhExpr);
                }
            }

            return(expr);
        }
예제 #2
0
 public static Expr _UnaryMinus(OpMinus op, Expr rhs)
 {
     return(new UnaryMinusExpr(rhs));
 }
예제 #3
0
 public static Expr _Sub(Expr lhs, OpMinus op, Expr rhs)
 {
     return(new SubExpr(lhs, rhs));
 }