Esempio n. 1
0
 private Expression ParseAdditiveExpressionRest(Expression lhs)
 {
     if (Current.TokenType == TokenType.Plus
         || Current.TokenType == TokenType.Minus)
     {
         Token tok = Consume(); // +, -
         Expression rhs = ParseMultiplyExpression();
         BinaryExpression lhsChild = new BinaryExpression(lhs.Line, lhs.Column, lhs, tok.TokenType, rhs);
         return ParseAdditiveExpressionRest(lhsChild);
     }
     else
     {
         return lhs;
     }
 }
Esempio n. 2
0
        private Expression ParseMultiplyExpressionRest(Expression lhs)
        {
            if (Current.TokenType == TokenType.Mult
                || Current.TokenType == TokenType.Div
                || Current.TokenType == TokenType.Mod)
            {
                Token tok = Consume(); // *, /, %
                Expression rhs = ParseUnaryExpression();
                BinaryExpression lhsChild = new BinaryExpression(lhs.Line, lhs.Column, lhs, tok.TokenType, rhs);
                return ParseMultiplyExpressionRest(lhsChild);
            }

            return lhs;
        }
Esempio n. 3
0
 private Expression ParseLogicalExpressionRest(Expression lhs)
 {
     if (Current.TokenType == TokenType.And || Current.TokenType == TokenType.Or)
     {
         Consume(); // &&, ||
         Expression rhs = ParseRelationalExpression();
         BinaryExpression lhsChild = new BinaryExpression(lhs.Line, lhs.Column, lhs, TokenType.And, rhs);
         return ParseLogicalExpressionRest(lhsChild);
     }
     else
     {
         return lhs;
     }
 }