Search in sources :

Example 81 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project cuba by cuba-platform.

the class JPA2Parser method aggregate_expression.

// $ANTLR start "aggregate_expression"
// JPA2.g:189:1: aggregate_expression : ( aggregate_expression_function_name '(' ( DISTINCT )? arithmetic_expression ')' -> ^( T_AGGREGATE_EXPR[] aggregate_expression_function_name '(' ( 'DISTINCT' )? arithmetic_expression ')' ) | 'COUNT' '(' ( DISTINCT )? count_argument ')' -> ^( T_AGGREGATE_EXPR[] 'COUNT' '(' ( 'DISTINCT' )? count_argument ')' ) | function_invocation );
public final JPA2Parser.aggregate_expression_return aggregate_expression() throws RecognitionException {
    JPA2Parser.aggregate_expression_return retval = new JPA2Parser.aggregate_expression_return();
    retval.start = input.LT(1);
    Object root_0 = null;
    Token char_literal121 = null;
    Token DISTINCT122 = null;
    Token char_literal124 = null;
    Token string_literal125 = null;
    Token char_literal126 = null;
    Token DISTINCT127 = null;
    Token char_literal129 = null;
    ParserRuleReturnScope aggregate_expression_function_name120 = null;
    ParserRuleReturnScope arithmetic_expression123 = null;
    ParserRuleReturnScope count_argument128 = null;
    ParserRuleReturnScope function_invocation130 = null;
    Object char_literal121_tree = null;
    Object DISTINCT122_tree = null;
    Object char_literal124_tree = null;
    Object string_literal125_tree = null;
    Object char_literal126_tree = null;
    Object DISTINCT127_tree = null;
    Object char_literal129_tree = null;
    RewriteRuleTokenStream stream_DISTINCT = new RewriteRuleTokenStream(adaptor, "token DISTINCT");
    RewriteRuleTokenStream stream_LPAREN = new RewriteRuleTokenStream(adaptor, "token LPAREN");
    RewriteRuleTokenStream stream_COUNT = new RewriteRuleTokenStream(adaptor, "token COUNT");
    RewriteRuleTokenStream stream_RPAREN = new RewriteRuleTokenStream(adaptor, "token RPAREN");
    RewriteRuleSubtreeStream stream_arithmetic_expression = new RewriteRuleSubtreeStream(adaptor, "rule arithmetic_expression");
    RewriteRuleSubtreeStream stream_count_argument = new RewriteRuleSubtreeStream(adaptor, "rule count_argument");
    RewriteRuleSubtreeStream stream_aggregate_expression_function_name = new RewriteRuleSubtreeStream(adaptor, "rule aggregate_expression_function_name");
    try {
        // JPA2.g:190:5: ( aggregate_expression_function_name '(' ( DISTINCT )? arithmetic_expression ')' -> ^( T_AGGREGATE_EXPR[] aggregate_expression_function_name '(' ( 'DISTINCT' )? arithmetic_expression ')' ) | 'COUNT' '(' ( DISTINCT )? count_argument ')' -> ^( T_AGGREGATE_EXPR[] 'COUNT' '(' ( 'DISTINCT' )? count_argument ')' ) | function_invocation )
        int alt41 = 3;
        alt41 = dfa41.predict(input);
        switch(alt41) {
            case 1:
                // JPA2.g:190:7: aggregate_expression_function_name '(' ( DISTINCT )? arithmetic_expression ')'
                {
                    pushFollow(FOLLOW_aggregate_expression_function_name_in_aggregate_expression1568);
                    aggregate_expression_function_name120 = aggregate_expression_function_name();
                    state._fsp--;
                    if (state.failed)
                        return retval;
                    if (state.backtracking == 0)
                        stream_aggregate_expression_function_name.add(aggregate_expression_function_name120.getTree());
                    char_literal121 = (Token) match(input, LPAREN, FOLLOW_LPAREN_in_aggregate_expression1570);
                    if (state.failed)
                        return retval;
                    if (state.backtracking == 0)
                        stream_LPAREN.add(char_literal121);
                    // JPA2.g:190:45: ( DISTINCT )?
                    int alt39 = 2;
                    int LA39_0 = input.LA(1);
                    if ((LA39_0 == DISTINCT)) {
                        alt39 = 1;
                    }
                    switch(alt39) {
                        case 1:
                            // JPA2.g:190:46: DISTINCT
                            {
                                DISTINCT122 = (Token) match(input, DISTINCT, FOLLOW_DISTINCT_in_aggregate_expression1572);
                                if (state.failed)
                                    return retval;
                                if (state.backtracking == 0)
                                    stream_DISTINCT.add(DISTINCT122);
                            }
                            break;
                    }
                    pushFollow(FOLLOW_arithmetic_expression_in_aggregate_expression1576);
                    arithmetic_expression123 = arithmetic_expression();
                    state._fsp--;
                    if (state.failed)
                        return retval;
                    if (state.backtracking == 0)
                        stream_arithmetic_expression.add(arithmetic_expression123.getTree());
                    char_literal124 = (Token) match(input, RPAREN, FOLLOW_RPAREN_in_aggregate_expression1577);
                    if (state.failed)
                        return retval;
                    if (state.backtracking == 0)
                        stream_RPAREN.add(char_literal124);
                    // wildcard labels:
                    if (state.backtracking == 0) {
                        retval.tree = root_0;
                        RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
                        root_0 = (Object) adaptor.nil();
                        // 191:5: -> ^( T_AGGREGATE_EXPR[] aggregate_expression_function_name '(' ( 'DISTINCT' )? arithmetic_expression ')' )
                        {
                            // JPA2.g:191:8: ^( T_AGGREGATE_EXPR[] aggregate_expression_function_name '(' ( 'DISTINCT' )? arithmetic_expression ')' )
                            {
                                Object root_1 = (Object) adaptor.nil();
                                root_1 = (Object) adaptor.becomeRoot(new AggregateExpressionNode(T_AGGREGATE_EXPR), root_1);
                                adaptor.addChild(root_1, stream_aggregate_expression_function_name.nextTree());
                                adaptor.addChild(root_1, stream_LPAREN.nextNode());
                                // JPA2.g:191:93: ( 'DISTINCT' )?
                                if (stream_DISTINCT.hasNext()) {
                                    adaptor.addChild(root_1, (Object) adaptor.create(DISTINCT, "DISTINCT"));
                                }
                                stream_DISTINCT.reset();
                                adaptor.addChild(root_1, stream_arithmetic_expression.nextTree());
                                adaptor.addChild(root_1, stream_RPAREN.nextNode());
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
            case 2:
                // JPA2.g:192:7: 'COUNT' '(' ( DISTINCT )? count_argument ')'
                {
                    string_literal125 = (Token) match(input, COUNT, FOLLOW_COUNT_in_aggregate_expression1611);
                    if (state.failed)
                        return retval;
                    if (state.backtracking == 0)
                        stream_COUNT.add(string_literal125);
                    char_literal126 = (Token) match(input, LPAREN, FOLLOW_LPAREN_in_aggregate_expression1613);
                    if (state.failed)
                        return retval;
                    if (state.backtracking == 0)
                        stream_LPAREN.add(char_literal126);
                    // JPA2.g:192:18: ( DISTINCT )?
                    int alt40 = 2;
                    int LA40_0 = input.LA(1);
                    if ((LA40_0 == DISTINCT)) {
                        alt40 = 1;
                    }
                    switch(alt40) {
                        case 1:
                            // JPA2.g:192:19: DISTINCT
                            {
                                DISTINCT127 = (Token) match(input, DISTINCT, FOLLOW_DISTINCT_in_aggregate_expression1615);
                                if (state.failed)
                                    return retval;
                                if (state.backtracking == 0)
                                    stream_DISTINCT.add(DISTINCT127);
                            }
                            break;
                    }
                    pushFollow(FOLLOW_count_argument_in_aggregate_expression1619);
                    count_argument128 = count_argument();
                    state._fsp--;
                    if (state.failed)
                        return retval;
                    if (state.backtracking == 0)
                        stream_count_argument.add(count_argument128.getTree());
                    char_literal129 = (Token) match(input, RPAREN, FOLLOW_RPAREN_in_aggregate_expression1621);
                    if (state.failed)
                        return retval;
                    if (state.backtracking == 0)
                        stream_RPAREN.add(char_literal129);
                    // wildcard labels:
                    if (state.backtracking == 0) {
                        retval.tree = root_0;
                        RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
                        root_0 = (Object) adaptor.nil();
                        // 193:5: -> ^( T_AGGREGATE_EXPR[] 'COUNT' '(' ( 'DISTINCT' )? count_argument ')' )
                        {
                            // JPA2.g:193:8: ^( T_AGGREGATE_EXPR[] 'COUNT' '(' ( 'DISTINCT' )? count_argument ')' )
                            {
                                Object root_1 = (Object) adaptor.nil();
                                root_1 = (Object) adaptor.becomeRoot(new AggregateExpressionNode(T_AGGREGATE_EXPR), root_1);
                                adaptor.addChild(root_1, stream_COUNT.nextNode());
                                adaptor.addChild(root_1, stream_LPAREN.nextNode());
                                // JPA2.g:193:66: ( 'DISTINCT' )?
                                if (stream_DISTINCT.hasNext()) {
                                    adaptor.addChild(root_1, (Object) adaptor.create(DISTINCT, "DISTINCT"));
                                }
                                stream_DISTINCT.reset();
                                adaptor.addChild(root_1, stream_count_argument.nextTree());
                                adaptor.addChild(root_1, stream_RPAREN.nextNode());
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
            case 3:
                // JPA2.g:194:7: function_invocation
                {
                    root_0 = (Object) adaptor.nil();
                    pushFollow(FOLLOW_function_invocation_in_aggregate_expression1656);
                    function_invocation130 = function_invocation();
                    state._fsp--;
                    if (state.failed)
                        return retval;
                    if (state.backtracking == 0)
                        adaptor.addChild(root_0, function_invocation130.getTree());
                }
                break;
        }
        retval.stop = input.LT(-1);
        if (state.backtracking == 0) {
            retval.tree = (Object) adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
        }
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
    // do for sure before leaving
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream)

Example 82 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project cuba by cuba-platform.

the class JPA2Parser method where_clause.

// $ANTLR start "where_clause"
// JPA2.g:199:1: where_clause : wh= 'WHERE' conditional_expression -> ^( T_CONDITION[$wh] conditional_expression ) ;
public final JPA2Parser.where_clause_return where_clause() throws RecognitionException {
    JPA2Parser.where_clause_return retval = new JPA2Parser.where_clause_return();
    retval.start = input.LT(1);
    Object root_0 = null;
    Token wh = null;
    ParserRuleReturnScope conditional_expression134 = null;
    Object wh_tree = null;
    RewriteRuleTokenStream stream_143 = new RewriteRuleTokenStream(adaptor, "token 143");
    RewriteRuleSubtreeStream stream_conditional_expression = new RewriteRuleSubtreeStream(adaptor, "rule conditional_expression");
    try {
        // JPA2.g:200:5: (wh= 'WHERE' conditional_expression -> ^( T_CONDITION[$wh] conditional_expression ) )
        // JPA2.g:200:7: wh= 'WHERE' conditional_expression
        {
            wh = (Token) match(input, 143, FOLLOW_143_in_where_clause1710);
            if (state.failed)
                return retval;
            if (state.backtracking == 0)
                stream_143.add(wh);
            pushFollow(FOLLOW_conditional_expression_in_where_clause1712);
            conditional_expression134 = conditional_expression();
            state._fsp--;
            if (state.failed)
                return retval;
            if (state.backtracking == 0)
                stream_conditional_expression.add(conditional_expression134.getTree());
            // wildcard labels:
            if (state.backtracking == 0) {
                retval.tree = root_0;
                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
                root_0 = (Object) adaptor.nil();
                // 200:40: -> ^( T_CONDITION[$wh] conditional_expression )
                {
                    // JPA2.g:200:43: ^( T_CONDITION[$wh] conditional_expression )
                    {
                        Object root_1 = (Object) adaptor.nil();
                        root_1 = (Object) adaptor.becomeRoot(new WhereNode(T_CONDITION, wh), root_1);
                        adaptor.addChild(root_1, stream_conditional_expression.nextTree());
                        adaptor.addChild(root_0, root_1);
                    }
                }
                retval.tree = root_0;
            }
        }
        retval.stop = input.LT(-1);
        if (state.backtracking == 0) {
            retval.tree = (Object) adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
        }
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
    // do for sure before leaving
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream)

Example 83 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project cuba by cuba-platform.

the class JPA2Parser method input_parameter.

// $ANTLR start "input_parameter"
// JPA2.g:492:1: input_parameter : ( '?' numeric_literal -> ^( T_PARAMETER[] '?' numeric_literal ) | NAMED_PARAMETER -> ^( T_PARAMETER[] NAMED_PARAMETER ) | '${' WORD '}' -> ^( T_PARAMETER[] '${' WORD '}' ) );
public final JPA2Parser.input_parameter_return input_parameter() throws RecognitionException {
    JPA2Parser.input_parameter_return retval = new JPA2Parser.input_parameter_return();
    retval.start = input.LT(1);
    Object root_0 = null;
    Token char_literal581 = null;
    Token NAMED_PARAMETER583 = null;
    Token string_literal584 = null;
    Token WORD585 = null;
    Token char_literal586 = null;
    ParserRuleReturnScope numeric_literal582 = null;
    Object char_literal581_tree = null;
    Object NAMED_PARAMETER583_tree = null;
    Object string_literal584_tree = null;
    Object WORD585_tree = null;
    Object char_literal586_tree = null;
    RewriteRuleTokenStream stream_77 = new RewriteRuleTokenStream(adaptor, "token 77");
    RewriteRuleTokenStream stream_WORD = new RewriteRuleTokenStream(adaptor, "token WORD");
    RewriteRuleTokenStream stream_147 = new RewriteRuleTokenStream(adaptor, "token 147");
    RewriteRuleTokenStream stream_63 = new RewriteRuleTokenStream(adaptor, "token 63");
    RewriteRuleTokenStream stream_NAMED_PARAMETER = new RewriteRuleTokenStream(adaptor, "token NAMED_PARAMETER");
    RewriteRuleSubtreeStream stream_numeric_literal = new RewriteRuleSubtreeStream(adaptor, "rule numeric_literal");
    try {
        // JPA2.g:493:5: ( '?' numeric_literal -> ^( T_PARAMETER[] '?' numeric_literal ) | NAMED_PARAMETER -> ^( T_PARAMETER[] NAMED_PARAMETER ) | '${' WORD '}' -> ^( T_PARAMETER[] '${' WORD '}' ) )
        int alt143 = 3;
        switch(input.LA(1)) {
            case 77:
                {
                    alt143 = 1;
                }
                break;
            case NAMED_PARAMETER:
                {
                    alt143 = 2;
                }
                break;
            case 63:
                {
                    alt143 = 3;
                }
                break;
            default:
                if (state.backtracking > 0) {
                    state.failed = true;
                    return retval;
                }
                NoViableAltException nvae = new NoViableAltException("", 143, 0, input);
                throw nvae;
        }
        switch(alt143) {
            case 1:
                // JPA2.g:493:7: '?' numeric_literal
                {
                    char_literal581 = (Token) match(input, 77, FOLLOW_77_in_input_parameter4585);
                    if (state.failed)
                        return retval;
                    if (state.backtracking == 0)
                        stream_77.add(char_literal581);
                    pushFollow(FOLLOW_numeric_literal_in_input_parameter4587);
                    numeric_literal582 = numeric_literal();
                    state._fsp--;
                    if (state.failed)
                        return retval;
                    if (state.backtracking == 0)
                        stream_numeric_literal.add(numeric_literal582.getTree());
                    // wildcard labels:
                    if (state.backtracking == 0) {
                        retval.tree = root_0;
                        RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
                        root_0 = (Object) adaptor.nil();
                        // 493:27: -> ^( T_PARAMETER[] '?' numeric_literal )
                        {
                            // JPA2.g:493:30: ^( T_PARAMETER[] '?' numeric_literal )
                            {
                                Object root_1 = (Object) adaptor.nil();
                                root_1 = (Object) adaptor.becomeRoot(new ParameterNode(T_PARAMETER), root_1);
                                adaptor.addChild(root_1, stream_77.nextNode());
                                adaptor.addChild(root_1, stream_numeric_literal.nextTree());
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
            case 2:
                // JPA2.g:494:7: NAMED_PARAMETER
                {
                    NAMED_PARAMETER583 = (Token) match(input, NAMED_PARAMETER, FOLLOW_NAMED_PARAMETER_in_input_parameter4610);
                    if (state.failed)
                        return retval;
                    if (state.backtracking == 0)
                        stream_NAMED_PARAMETER.add(NAMED_PARAMETER583);
                    // wildcard labels:
                    if (state.backtracking == 0) {
                        retval.tree = root_0;
                        RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
                        root_0 = (Object) adaptor.nil();
                        // 494:23: -> ^( T_PARAMETER[] NAMED_PARAMETER )
                        {
                            // JPA2.g:494:26: ^( T_PARAMETER[] NAMED_PARAMETER )
                            {
                                Object root_1 = (Object) adaptor.nil();
                                root_1 = (Object) adaptor.becomeRoot(new ParameterNode(T_PARAMETER), root_1);
                                adaptor.addChild(root_1, stream_NAMED_PARAMETER.nextNode());
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
            case 3:
                // JPA2.g:495:7: '${' WORD '}'
                {
                    string_literal584 = (Token) match(input, 63, FOLLOW_63_in_input_parameter4631);
                    if (state.failed)
                        return retval;
                    if (state.backtracking == 0)
                        stream_63.add(string_literal584);
                    WORD585 = (Token) match(input, WORD, FOLLOW_WORD_in_input_parameter4633);
                    if (state.failed)
                        return retval;
                    if (state.backtracking == 0)
                        stream_WORD.add(WORD585);
                    char_literal586 = (Token) match(input, 147, FOLLOW_147_in_input_parameter4635);
                    if (state.failed)
                        return retval;
                    if (state.backtracking == 0)
                        stream_147.add(char_literal586);
                    // wildcard labels:
                    if (state.backtracking == 0) {
                        retval.tree = root_0;
                        RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
                        root_0 = (Object) adaptor.nil();
                        // 495:21: -> ^( T_PARAMETER[] '${' WORD '}' )
                        {
                            // JPA2.g:495:24: ^( T_PARAMETER[] '${' WORD '}' )
                            {
                                Object root_1 = (Object) adaptor.nil();
                                root_1 = (Object) adaptor.becomeRoot(new ParameterNode(T_PARAMETER), root_1);
                                adaptor.addChild(root_1, stream_63.nextNode());
                                adaptor.addChild(root_1, stream_WORD.nextNode());
                                adaptor.addChild(root_1, stream_147.nextNode());
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
        }
        retval.stop = input.LT(-1);
        if (state.backtracking == 0) {
            retval.tree = (Object) adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
        }
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
    // do for sure before leaving
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream)

Example 84 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project cuba by cuba-platform.

the class JPA2Parser method select_statement.

// $ANTLR start "select_statement"
// JPA2.g:91:1: select_statement : sl= 'SELECT' select_clause from_clause ( where_clause )? ( groupby_clause )? ( having_clause )? ( orderby_clause )? EOF -> ^( T_QUERY[$sl] ( select_clause )? from_clause ( where_clause )? ( groupby_clause )? ( having_clause )? ( orderby_clause )? ) ;
public final JPA2Parser.select_statement_return select_statement() throws RecognitionException {
    JPA2Parser.select_statement_return retval = new JPA2Parser.select_statement_return();
    retval.start = input.LT(1);
    Object root_0 = null;
    Token sl = null;
    Token EOF10 = null;
    ParserRuleReturnScope select_clause4 = null;
    ParserRuleReturnScope from_clause5 = null;
    ParserRuleReturnScope where_clause6 = null;
    ParserRuleReturnScope groupby_clause7 = null;
    ParserRuleReturnScope having_clause8 = null;
    ParserRuleReturnScope orderby_clause9 = null;
    Object sl_tree = null;
    Object EOF10_tree = null;
    RewriteRuleTokenStream stream_129 = new RewriteRuleTokenStream(adaptor, "token 129");
    RewriteRuleTokenStream stream_EOF = new RewriteRuleTokenStream(adaptor, "token EOF");
    RewriteRuleSubtreeStream stream_where_clause = new RewriteRuleSubtreeStream(adaptor, "rule where_clause");
    RewriteRuleSubtreeStream stream_select_clause = new RewriteRuleSubtreeStream(adaptor, "rule select_clause");
    RewriteRuleSubtreeStream stream_from_clause = new RewriteRuleSubtreeStream(adaptor, "rule from_clause");
    RewriteRuleSubtreeStream stream_groupby_clause = new RewriteRuleSubtreeStream(adaptor, "rule groupby_clause");
    RewriteRuleSubtreeStream stream_having_clause = new RewriteRuleSubtreeStream(adaptor, "rule having_clause");
    RewriteRuleSubtreeStream stream_orderby_clause = new RewriteRuleSubtreeStream(adaptor, "rule orderby_clause");
    try {
        // JPA2.g:92:6: (sl= 'SELECT' select_clause from_clause ( where_clause )? ( groupby_clause )? ( having_clause )? ( orderby_clause )? EOF -> ^( T_QUERY[$sl] ( select_clause )? from_clause ( where_clause )? ( groupby_clause )? ( having_clause )? ( orderby_clause )? ) )
        // JPA2.g:92:8: sl= 'SELECT' select_clause from_clause ( where_clause )? ( groupby_clause )? ( having_clause )? ( orderby_clause )? EOF
        {
            sl = (Token) match(input, 129, FOLLOW_129_in_select_statement534);
            if (state.failed)
                return retval;
            if (state.backtracking == 0)
                stream_129.add(sl);
            pushFollow(FOLLOW_select_clause_in_select_statement536);
            select_clause4 = select_clause();
            state._fsp--;
            if (state.failed)
                return retval;
            if (state.backtracking == 0)
                stream_select_clause.add(select_clause4.getTree());
            pushFollow(FOLLOW_from_clause_in_select_statement538);
            from_clause5 = from_clause();
            state._fsp--;
            if (state.failed)
                return retval;
            if (state.backtracking == 0)
                stream_from_clause.add(from_clause5.getTree());
            // JPA2.g:92:46: ( where_clause )?
            int alt2 = 2;
            int LA2_0 = input.LA(1);
            if ((LA2_0 == 143)) {
                alt2 = 1;
            }
            switch(alt2) {
                case 1:
                    // JPA2.g:92:47: where_clause
                    {
                        pushFollow(FOLLOW_where_clause_in_select_statement541);
                        where_clause6 = where_clause();
                        state._fsp--;
                        if (state.failed)
                            return retval;
                        if (state.backtracking == 0)
                            stream_where_clause.add(where_clause6.getTree());
                    }
                    break;
            }
            // JPA2.g:92:62: ( groupby_clause )?
            int alt3 = 2;
            int LA3_0 = input.LA(1);
            if ((LA3_0 == GROUP)) {
                alt3 = 1;
            }
            switch(alt3) {
                case 1:
                    // JPA2.g:92:63: groupby_clause
                    {
                        pushFollow(FOLLOW_groupby_clause_in_select_statement546);
                        groupby_clause7 = groupby_clause();
                        state._fsp--;
                        if (state.failed)
                            return retval;
                        if (state.backtracking == 0)
                            stream_groupby_clause.add(groupby_clause7.getTree());
                    }
                    break;
            }
            // JPA2.g:92:80: ( having_clause )?
            int alt4 = 2;
            int LA4_0 = input.LA(1);
            if ((LA4_0 == HAVING)) {
                alt4 = 1;
            }
            switch(alt4) {
                case 1:
                    // JPA2.g:92:81: having_clause
                    {
                        pushFollow(FOLLOW_having_clause_in_select_statement551);
                        having_clause8 = having_clause();
                        state._fsp--;
                        if (state.failed)
                            return retval;
                        if (state.backtracking == 0)
                            stream_having_clause.add(having_clause8.getTree());
                    }
                    break;
            }
            // JPA2.g:92:97: ( orderby_clause )?
            int alt5 = 2;
            int LA5_0 = input.LA(1);
            if ((LA5_0 == ORDER)) {
                alt5 = 1;
            }
            switch(alt5) {
                case 1:
                    // JPA2.g:92:98: orderby_clause
                    {
                        pushFollow(FOLLOW_orderby_clause_in_select_statement556);
                        orderby_clause9 = orderby_clause();
                        state._fsp--;
                        if (state.failed)
                            return retval;
                        if (state.backtracking == 0)
                            stream_orderby_clause.add(orderby_clause9.getTree());
                    }
                    break;
            }
            EOF10 = (Token) match(input, EOF, FOLLOW_EOF_in_select_statement560);
            if (state.failed)
                return retval;
            if (state.backtracking == 0)
                stream_EOF.add(EOF10);
            // wildcard labels:
            if (state.backtracking == 0) {
                retval.tree = root_0;
                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
                root_0 = (Object) adaptor.nil();
                // 93:6: -> ^( T_QUERY[$sl] ( select_clause )? from_clause ( where_clause )? ( groupby_clause )? ( having_clause )? ( orderby_clause )? )
                {
                    // JPA2.g:93:9: ^( T_QUERY[$sl] ( select_clause )? from_clause ( where_clause )? ( groupby_clause )? ( having_clause )? ( orderby_clause )? )
                    {
                        Object root_1 = (Object) adaptor.nil();
                        root_1 = (Object) adaptor.becomeRoot(new QueryNode(T_QUERY, sl), root_1);
                        // JPA2.g:93:35: ( select_clause )?
                        if (stream_select_clause.hasNext()) {
                            adaptor.addChild(root_1, stream_select_clause.nextTree());
                        }
                        stream_select_clause.reset();
                        adaptor.addChild(root_1, stream_from_clause.nextTree());
                        // JPA2.g:93:64: ( where_clause )?
                        if (stream_where_clause.hasNext()) {
                            adaptor.addChild(root_1, stream_where_clause.nextTree());
                        }
                        stream_where_clause.reset();
                        // JPA2.g:93:80: ( groupby_clause )?
                        if (stream_groupby_clause.hasNext()) {
                            adaptor.addChild(root_1, stream_groupby_clause.nextTree());
                        }
                        stream_groupby_clause.reset();
                        // JPA2.g:93:98: ( having_clause )?
                        if (stream_having_clause.hasNext()) {
                            adaptor.addChild(root_1, stream_having_clause.nextTree());
                        }
                        stream_having_clause.reset();
                        // JPA2.g:93:115: ( orderby_clause )?
                        if (stream_orderby_clause.hasNext()) {
                            adaptor.addChild(root_1, stream_orderby_clause.nextTree());
                        }
                        stream_orderby_clause.reset();
                        adaptor.addChild(root_0, root_1);
                    }
                }
                retval.tree = root_0;
            }
        }
        retval.stop = input.LT(-1);
        if (state.backtracking == 0) {
            retval.tree = (Object) adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
        }
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
    // do for sure before leaving
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream)

Example 85 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project cuba by cuba-platform.

the class JPA2Parser method path_expression.

// $ANTLR start "path_expression"
// JPA2.g:145:1: path_expression : identification_variable '.' ( field '.' )* ( field )? -> ^( T_SELECTED_FIELD[$identification_variable.text] ( field )* ) ;
public final JPA2Parser.path_expression_return path_expression() throws RecognitionException {
    JPA2Parser.path_expression_return retval = new JPA2Parser.path_expression_return();
    retval.start = input.LT(1);
    Object root_0 = null;
    Token char_literal73 = null;
    Token char_literal75 = null;
    ParserRuleReturnScope identification_variable72 = null;
    ParserRuleReturnScope field74 = null;
    ParserRuleReturnScope field76 = null;
    Object char_literal73_tree = null;
    Object char_literal75_tree = null;
    RewriteRuleTokenStream stream_68 = new RewriteRuleTokenStream(adaptor, "token 68");
    RewriteRuleSubtreeStream stream_field = new RewriteRuleSubtreeStream(adaptor, "rule field");
    RewriteRuleSubtreeStream stream_identification_variable = new RewriteRuleSubtreeStream(adaptor, "rule identification_variable");
    try {
        // JPA2.g:146:5: ( identification_variable '.' ( field '.' )* ( field )? -> ^( T_SELECTED_FIELD[$identification_variable.text] ( field )* ) )
        // JPA2.g:146:8: identification_variable '.' ( field '.' )* ( field )?
        {
            pushFollow(FOLLOW_identification_variable_in_path_expression1152);
            identification_variable72 = identification_variable();
            state._fsp--;
            if (state.failed)
                return retval;
            if (state.backtracking == 0)
                stream_identification_variable.add(identification_variable72.getTree());
            char_literal73 = (Token) match(input, 68, FOLLOW_68_in_path_expression1154);
            if (state.failed)
                return retval;
            if (state.backtracking == 0)
                stream_68.add(char_literal73);
            // JPA2.g:146:36: ( field '.' )*
            loop26: while (true) {
                int alt26 = 2;
                switch(input.LA(1)) {
                    case WORD:
                        {
                            int LA26_1 = input.LA(2);
                            if ((LA26_1 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case 129:
                        {
                            int LA26_2 = input.LA(2);
                            if ((LA26_2 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case 103:
                        {
                            int LA26_3 = input.LA(2);
                            if ((LA26_3 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case GROUP:
                        {
                            int LA26_4 = input.LA(2);
                            if ((LA26_4 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case ORDER:
                        {
                            int LA26_5 = input.LA(2);
                            if ((LA26_5 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case MAX:
                        {
                            int LA26_6 = input.LA(2);
                            if ((LA26_6 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case MIN:
                        {
                            int LA26_7 = input.LA(2);
                            if ((LA26_7 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case SUM:
                        {
                            int LA26_8 = input.LA(2);
                            if ((LA26_8 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case AVG:
                        {
                            int LA26_9 = input.LA(2);
                            if ((LA26_9 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case COUNT:
                        {
                            int LA26_10 = input.LA(2);
                            if ((LA26_10 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case AS:
                        {
                            int LA26_11 = input.LA(2);
                            if ((LA26_11 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case 113:
                        {
                            int LA26_12 = input.LA(2);
                            if ((LA26_12 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case CASE:
                        {
                            int LA26_13 = input.LA(2);
                            if ((LA26_13 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case 123:
                        {
                            int LA26_14 = input.LA(2);
                            if ((LA26_14 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case SET:
                        {
                            int LA26_15 = input.LA(2);
                            if ((LA26_15 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case DESC:
                        {
                            int LA26_16 = input.LA(2);
                            if ((LA26_16 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case ASC:
                        {
                            int LA26_17 = input.LA(2);
                            if ((LA26_17 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                    case 95:
                    case 99:
                    case 105:
                    case 114:
                    case 116:
                    case 126:
                    case 128:
                    case 142:
                    case 144:
                        {
                            int LA26_18 = input.LA(2);
                            if ((LA26_18 == 68)) {
                                alt26 = 1;
                            }
                        }
                        break;
                }
                switch(alt26) {
                    case 1:
                        // JPA2.g:146:37: field '.'
                        {
                            pushFollow(FOLLOW_field_in_path_expression1157);
                            field74 = field();
                            state._fsp--;
                            if (state.failed)
                                return retval;
                            if (state.backtracking == 0)
                                stream_field.add(field74.getTree());
                            char_literal75 = (Token) match(input, 68, FOLLOW_68_in_path_expression1158);
                            if (state.failed)
                                return retval;
                            if (state.backtracking == 0)
                                stream_68.add(char_literal75);
                        }
                        break;
                    default:
                        break loop26;
                }
            }
            // JPA2.g:146:48: ( field )?
            int alt27 = 2;
            switch(input.LA(1)) {
                case WORD:
                    {
                        int LA27_1 = input.LA(2);
                        if ((synpred30_JPA2())) {
                            alt27 = 1;
                        }
                    }
                    break;
                case AVG:
                case CASE:
                case COUNT:
                case MAX:
                case MIN:
                case SUM:
                case 95:
                case 99:
                case 105:
                case 114:
                case 116:
                case 123:
                case 126:
                case 128:
                case 129:
                case 142:
                case 144:
                    {
                        alt27 = 1;
                    }
                    break;
                case 103:
                    {
                        switch(input.LA(2)) {
                            case EOF:
                            case AND:
                            case AS:
                            case ASC:
                            case DESC:
                            case ELSE:
                            case END:
                            case GROUP:
                            case HAVING:
                            case INNER:
                            case JOIN:
                            case LEFT:
                            case NOT:
                            case OR:
                            case ORDER:
                            case RPAREN:
                            case SET:
                            case THEN:
                            case WHEN:
                            case 64:
                            case 65:
                            case 66:
                            case 67:
                            case 69:
                            case 71:
                            case 72:
                            case 73:
                            case 74:
                            case 75:
                            case 76:
                            case 87:
                            case 100:
                            case 103:
                            case 107:
                            case 111:
                            case 113:
                            case 121:
                            case 122:
                            case 127:
                            case 143:
                                {
                                    alt27 = 1;
                                }
                                break;
                            case WORD:
                                {
                                    int LA27_12 = input.LA(3);
                                    if ((LA27_12 == EOF || LA27_12 == LPAREN || LA27_12 == RPAREN || LA27_12 == 66 || LA27_12 == 103)) {
                                        alt27 = 1;
                                    }
                                }
                                break;
                            case IN:
                                {
                                    int LA27_13 = input.LA(3);
                                    if ((LA27_13 == LPAREN || LA27_13 == NAMED_PARAMETER || LA27_13 == 63 || LA27_13 == 77)) {
                                        alt27 = 1;
                                    }
                                }
                                break;
                        }
                    }
                    break;
                case GROUP:
                    {
                        int LA27_4 = input.LA(2);
                        if ((LA27_4 == EOF || (LA27_4 >= AND && LA27_4 <= ASC) || LA27_4 == DESC || (LA27_4 >= ELSE && LA27_4 <= END) || (LA27_4 >= GROUP && LA27_4 <= INNER) || (LA27_4 >= JOIN && LA27_4 <= LEFT) || (LA27_4 >= NOT && LA27_4 <= ORDER) || LA27_4 == RPAREN || LA27_4 == SET || LA27_4 == THEN || (LA27_4 >= WHEN && LA27_4 <= WORD) || (LA27_4 >= 64 && LA27_4 <= 67) || LA27_4 == 69 || (LA27_4 >= 71 && LA27_4 <= 76) || LA27_4 == 87 || LA27_4 == 100 || LA27_4 == 103 || LA27_4 == 107 || LA27_4 == 111 || LA27_4 == 113 || (LA27_4 >= 121 && LA27_4 <= 122) || LA27_4 == 127 || LA27_4 == 143)) {
                            alt27 = 1;
                        }
                    }
                    break;
                case ORDER:
                    {
                        int LA27_5 = input.LA(2);
                        if ((LA27_5 == EOF || (LA27_5 >= AND && LA27_5 <= ASC) || LA27_5 == DESC || (LA27_5 >= ELSE && LA27_5 <= END) || (LA27_5 >= GROUP && LA27_5 <= INNER) || (LA27_5 >= JOIN && LA27_5 <= LEFT) || (LA27_5 >= NOT && LA27_5 <= ORDER) || LA27_5 == RPAREN || LA27_5 == SET || LA27_5 == THEN || (LA27_5 >= WHEN && LA27_5 <= WORD) || (LA27_5 >= 64 && LA27_5 <= 67) || LA27_5 == 69 || (LA27_5 >= 71 && LA27_5 <= 76) || LA27_5 == 87 || LA27_5 == 100 || LA27_5 == 103 || LA27_5 == 107 || LA27_5 == 111 || LA27_5 == 113 || (LA27_5 >= 121 && LA27_5 <= 122) || LA27_5 == 127 || LA27_5 == 143)) {
                            alt27 = 1;
                        }
                    }
                    break;
                case AS:
                    {
                        int LA27_6 = input.LA(2);
                        if ((synpred30_JPA2())) {
                            alt27 = 1;
                        }
                    }
                    break;
                case 113:
                    {
                        switch(input.LA(2)) {
                            case EOF:
                            case AND:
                            case AS:
                            case ASC:
                            case DESC:
                            case ELSE:
                            case END:
                            case HAVING:
                            case IN:
                            case INNER:
                            case JOIN:
                            case LEFT:
                            case NOT:
                            case OR:
                            case ORDER:
                            case RPAREN:
                            case SET:
                            case THEN:
                            case WHEN:
                            case 64:
                            case 65:
                            case 66:
                            case 67:
                            case 69:
                            case 71:
                            case 72:
                            case 73:
                            case 74:
                            case 75:
                            case 76:
                            case 87:
                            case 100:
                            case 103:
                            case 107:
                            case 111:
                            case 113:
                            case 121:
                            case 122:
                            case 127:
                            case 143:
                                {
                                    alt27 = 1;
                                }
                                break;
                            case WORD:
                                {
                                    int LA27_14 = input.LA(3);
                                    if ((LA27_14 == EOF || LA27_14 == LPAREN || LA27_14 == RPAREN || LA27_14 == 66 || LA27_14 == 103)) {
                                        alt27 = 1;
                                    }
                                }
                                break;
                            case GROUP:
                                {
                                    int LA27_15 = input.LA(3);
                                    if ((LA27_15 == BY)) {
                                        alt27 = 1;
                                    }
                                }
                                break;
                        }
                    }
                    break;
                case SET:
                    {
                        switch(input.LA(2)) {
                            case EOF:
                            case AND:
                            case AS:
                            case ASC:
                            case DESC:
                            case ELSE:
                            case END:
                            case HAVING:
                            case IN:
                            case INNER:
                            case JOIN:
                            case LEFT:
                            case NOT:
                            case OR:
                            case ORDER:
                            case RPAREN:
                            case SET:
                            case THEN:
                            case WHEN:
                            case 64:
                            case 65:
                            case 66:
                            case 67:
                            case 69:
                            case 71:
                            case 72:
                            case 73:
                            case 74:
                            case 75:
                            case 76:
                            case 87:
                            case 100:
                            case 103:
                            case 107:
                            case 111:
                            case 113:
                            case 121:
                            case 122:
                            case 127:
                            case 143:
                                {
                                    alt27 = 1;
                                }
                                break;
                            case WORD:
                                {
                                    int LA27_16 = input.LA(3);
                                    if ((LA27_16 == EOF || LA27_16 == LPAREN || LA27_16 == RPAREN || LA27_16 == 66 || LA27_16 == 103)) {
                                        alt27 = 1;
                                    }
                                }
                                break;
                            case GROUP:
                                {
                                    int LA27_17 = input.LA(3);
                                    if ((LA27_17 == BY)) {
                                        alt27 = 1;
                                    }
                                }
                                break;
                        }
                    }
                    break;
                case DESC:
                    {
                        int LA27_9 = input.LA(2);
                        if ((synpred30_JPA2())) {
                            alt27 = 1;
                        }
                    }
                    break;
                case ASC:
                    {
                        int LA27_10 = input.LA(2);
                        if ((synpred30_JPA2())) {
                            alt27 = 1;
                        }
                    }
                    break;
            }
            switch(alt27) {
                case 1:
                    // JPA2.g:146:48: field
                    {
                        pushFollow(FOLLOW_field_in_path_expression1162);
                        field76 = field();
                        state._fsp--;
                        if (state.failed)
                            return retval;
                        if (state.backtracking == 0)
                            stream_field.add(field76.getTree());
                    }
                    break;
            }
            // wildcard labels:
            if (state.backtracking == 0) {
                retval.tree = root_0;
                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
                root_0 = (Object) adaptor.nil();
                // 147:5: -> ^( T_SELECTED_FIELD[$identification_variable.text] ( field )* )
                {
                    // JPA2.g:147:8: ^( T_SELECTED_FIELD[$identification_variable.text] ( field )* )
                    {
                        Object root_1 = (Object) adaptor.nil();
                        root_1 = (Object) adaptor.becomeRoot(new PathNode(T_SELECTED_FIELD, (identification_variable72 != null ? input.toString(identification_variable72.start, identification_variable72.stop) : null)), root_1);
                        // JPA2.g:147:68: ( field )*
                        while (stream_field.hasNext()) {
                            adaptor.addChild(root_1, stream_field.nextTree());
                        }
                        stream_field.reset();
                        adaptor.addChild(root_0, root_1);
                    }
                }
                retval.tree = root_0;
            }
        }
        retval.stop = input.LT(-1);
        if (state.backtracking == 0) {
            retval.tree = (Object) adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
        }
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
    // do for sure before leaving
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream)

Aggregations

RewriteRuleSubtreeStream (org.antlr.runtime.tree.RewriteRuleSubtreeStream)123 RewriteRuleTokenStream (org.antlr.runtime.tree.RewriteRuleTokenStream)123 RecognitionException (org.antlr.runtime.RecognitionException)83 Token (org.antlr.runtime.Token)83 CommonTree (org.antlr.runtime.tree.CommonTree)62 NoViableAltException (org.antlr.runtime.NoViableAltException)24 CommonToken (org.antlr.runtime.CommonToken)18 RewriteEarlyExitException (org.antlr.runtime.tree.RewriteEarlyExitException)12 FailedPredicateException (org.antlr.runtime.FailedPredicateException)8 ParserRuleReturnScope (org.antlr.runtime.ParserRuleReturnScope)8 RewriteEmptyStreamException (org.antlr.runtime.tree.RewriteEmptyStreamException)2 EarlyExitException (org.antlr.runtime.EarlyExitException)1