Exemplo n.º 1
0
        // additive_expression: multiplicative_expression ( <add_op> multiplicative_expression )*
        private Expression ParseAdditiveExpression()
        {
            Expression ret = ParseMultiplicativeExpression();
            if (ret == null)
                return ret;

            while (IsAdditiveToken(PeekToken()))
            {
                Token t = NextToken();
                var start = ret.StartIndex;
                ret = new BinaryExpression(t.Kind, ret, ParseMultiplicativeExpression());
                ret.SetLoc(_globalParent, start, GetEnd());
            }
            return ret;
        }
Exemplo n.º 2
0
        // equality_expression: relational_expression ( <eq_op> relational_expression )*
        private Expression ParseEqualityExpression()
        {
            Expression ret = ParseRelationalExpression();
            if (ret == null)
                return ret;

            if (IsEqualityToken(PeekToken()))
            {
                Token t = NextToken();
                var start = ret.StartIndex;
                ret = new BinaryExpression(t.Kind, ret, ParseEqualityExpression());
                ret.SetLoc(_globalParent, start, GetEnd());
            }
            return ret;
        }
Exemplo n.º 3
0
        // logical_or_expression: logical_and_expression ( '||' logical_and_expression )*
        private Expression ParseLogicalOrExpression()
        {
            Expression ret = ParseLogicalAndExpression();
            if (ret == null)
                return ret;

            while (MaybeEat(TokenKind.LogicalOr))
            {
                var start = ret.StartIndex;
                ret = new BinaryExpression(TokenKind.LogicalOr, ret, ParseLogicalAndExpression());
                ret.SetLoc(_globalParent, start, GetEnd());
            }
            return ret;
        }