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

            while (PeekToken(TokenKind.STAR, TokenKind.DIV, TokenKind.MOD))
            {
                var t      = TakeToken(); // consume STAR/DIV/MOD
                var rhExpr = EatPowerIncDecExpression();
                CheckOperands(t, expr, rhExpr);
                if (t.Kind == TokenKind.STAR)
                {
                    expr = new OpMultiply(t.StartPos, t.EndPos, expr, rhExpr);
                }
                else if (t.Kind == TokenKind.DIV)
                {
                    expr = new OpDivide(t.StartPos, t.EndPos, expr, rhExpr);
                }
                else
                {
                    if (t.Kind != TokenKind.MOD)
                    {
                        throw new InvalidOperationException("Mod token expected");
                    }

                    expr = new OpModulus(t.StartPos, t.EndPos, expr, rhExpr);
                }
            }

            return(expr);
        }
示例#2
0
 public GetOperation()
 {
     operationIndex["1"] = new OpSum();
     operationIndex["2"] = new OpSubtraction();
     operationIndex["3"] = new OpMultiply();
     operationIndex["4"] = new OpDivide();
     operationIndex["5"] = new OpSquare();
     operationIndex["6"] = new OpSquareRoot();
 }
示例#3
0
 public static void Rule(BinaryOp400 lhs, OpMultiply op)
 {
     lhs.CodeFunctor = new CodeFunctor(op.Text, 2, true);
 }
示例#4
0
 public static void Rule(BinaryOp400 lhs, OpMultiply op)
 {
     lhs.CodeFunctor = new CodeFunctor(op.Text, 2, true);
 }