Search in sources :

Example 1 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.

the class JavaParser method postfixedExpression.

// $ANTLR start "postfixedExpression"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1045:1: postfixedExpression : ( primaryExpression -> primaryExpression ) (outerDot= DOT ( ( ( genericTypeArgumentListSimplified )? IDENT -> ^( DOT $postfixedExpression IDENT ) ) ( arguments -> ^( METHOD_CALL $postfixedExpression ( genericTypeArgumentListSimplified )? arguments ) )? | THIS -> ^( DOT $postfixedExpression THIS ) | Super= SUPER arguments -> ^( SUPER_CONSTRUCTOR_CALL[$Super, \"SUPER_CONSTRUCTOR_CALL\"] $postfixedExpression arguments ) | ( SUPER innerDot= DOT IDENT -> ^( $innerDot ^( $outerDot $postfixedExpression SUPER ) IDENT ) ) ( arguments -> ^( METHOD_CALL $postfixedExpression arguments ) )? | innerNewExpression -> ^( DOT $postfixedExpression innerNewExpression ) ) | LBRACK expression RBRACK -> ^( ARRAY_ELEMENT_ACCESS $postfixedExpression expression ) )* ( INC -> ^( POST_INC[$INC, \"POST_INC\"] $postfixedExpression) | DEC -> ^( POST_DEC[$DEC, \"POST_DEC\"] $postfixedExpression) )? ;
public final JavaParser.postfixedExpression_return postfixedExpression() throws RecognitionException {
    JavaParser.postfixedExpression_return retval = new JavaParser.postfixedExpression_return();
    retval.start = input.LT(1);
    int postfixedExpression_StartIndex = input.index();
    CommonTree root_0 = null;
    Token outerDot = null;
    Token Super = null;
    Token innerDot = null;
    Token IDENT451 = null;
    Token THIS453 = null;
    Token SUPER455 = null;
    Token IDENT456 = null;
    Token LBRACK459 = null;
    Token RBRACK461 = null;
    Token INC462 = null;
    Token DEC463 = null;
    JavaParser.primaryExpression_return primaryExpression449 = null;
    JavaParser.genericTypeArgumentListSimplified_return genericTypeArgumentListSimplified450 = null;
    JavaParser.arguments_return arguments452 = null;
    JavaParser.arguments_return arguments454 = null;
    JavaParser.arguments_return arguments457 = null;
    JavaParser.innerNewExpression_return innerNewExpression458 = null;
    JavaParser.expression_return expression460 = null;
    CommonTree outerDot_tree = null;
    CommonTree Super_tree = null;
    CommonTree innerDot_tree = null;
    CommonTree IDENT451_tree = null;
    CommonTree THIS453_tree = null;
    CommonTree SUPER455_tree = null;
    CommonTree IDENT456_tree = null;
    CommonTree LBRACK459_tree = null;
    CommonTree RBRACK461_tree = null;
    CommonTree INC462_tree = null;
    CommonTree DEC463_tree = null;
    RewriteRuleTokenStream stream_RBRACK = new RewriteRuleTokenStream(adaptor, "token RBRACK");
    RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
    RewriteRuleTokenStream stream_INC = new RewriteRuleTokenStream(adaptor, "token INC");
    RewriteRuleTokenStream stream_DEC = new RewriteRuleTokenStream(adaptor, "token DEC");
    RewriteRuleTokenStream stream_LBRACK = new RewriteRuleTokenStream(adaptor, "token LBRACK");
    RewriteRuleTokenStream stream_SUPER = new RewriteRuleTokenStream(adaptor, "token SUPER");
    RewriteRuleTokenStream stream_DOT = new RewriteRuleTokenStream(adaptor, "token DOT");
    RewriteRuleTokenStream stream_THIS = new RewriteRuleTokenStream(adaptor, "token THIS");
    RewriteRuleSubtreeStream stream_expression = new RewriteRuleSubtreeStream(adaptor, "rule expression");
    RewriteRuleSubtreeStream stream_arguments = new RewriteRuleSubtreeStream(adaptor, "rule arguments");
    RewriteRuleSubtreeStream stream_primaryExpression = new RewriteRuleSubtreeStream(adaptor, "rule primaryExpression");
    RewriteRuleSubtreeStream stream_genericTypeArgumentListSimplified = new RewriteRuleSubtreeStream(adaptor, "rule genericTypeArgumentListSimplified");
    RewriteRuleSubtreeStream stream_innerNewExpression = new RewriteRuleSubtreeStream(adaptor, "rule innerNewExpression");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 104)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:1047:5: ( ( primaryExpression -> primaryExpression ) (outerDot= DOT ( ( ( genericTypeArgumentListSimplified )? IDENT -> ^( DOT $postfixedExpression IDENT ) ) ( arguments -> ^( METHOD_CALL $postfixedExpression ( genericTypeArgumentListSimplified )? arguments ) )? | THIS -> ^( DOT $postfixedExpression THIS ) | Super= SUPER arguments -> ^( SUPER_CONSTRUCTOR_CALL[$Super, \"SUPER_CONSTRUCTOR_CALL\"] $postfixedExpression arguments ) | ( SUPER innerDot= DOT IDENT -> ^( $innerDot ^( $outerDot $postfixedExpression SUPER ) IDENT ) ) ( arguments -> ^( METHOD_CALL $postfixedExpression arguments ) )? | innerNewExpression -> ^( DOT $postfixedExpression innerNewExpression ) ) | LBRACK expression RBRACK -> ^( ARRAY_ELEMENT_ACCESS $postfixedExpression expression ) )* ( INC -> ^( POST_INC[$INC, \"POST_INC\"] $postfixedExpression) | DEC -> ^( POST_DEC[$DEC, \"POST_DEC\"] $postfixedExpression) )? )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:1047:9: ( primaryExpression -> primaryExpression ) (outerDot= DOT ( ( ( genericTypeArgumentListSimplified )? IDENT -> ^( DOT $postfixedExpression IDENT ) ) ( arguments -> ^( METHOD_CALL $postfixedExpression ( genericTypeArgumentListSimplified )? arguments ) )? | THIS -> ^( DOT $postfixedExpression THIS ) | Super= SUPER arguments -> ^( SUPER_CONSTRUCTOR_CALL[$Super, \"SUPER_CONSTRUCTOR_CALL\"] $postfixedExpression arguments ) | ( SUPER innerDot= DOT IDENT -> ^( $innerDot ^( $outerDot $postfixedExpression SUPER ) IDENT ) ) ( arguments -> ^( METHOD_CALL $postfixedExpression arguments ) )? | innerNewExpression -> ^( DOT $postfixedExpression innerNewExpression ) ) | LBRACK expression RBRACK -> ^( ARRAY_ELEMENT_ACCESS $postfixedExpression expression ) )* ( INC -> ^( POST_INC[$INC, \"POST_INC\"] $postfixedExpression) | DEC -> ^( POST_DEC[$DEC, \"POST_DEC\"] $postfixedExpression) )?
        {
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:1047:9: ( primaryExpression -> primaryExpression )
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:1047:13: primaryExpression
            {
                pushFollow(FOLLOW_primaryExpression_in_postfixedExpression11572);
                primaryExpression449 = primaryExpression();
                state._fsp--;
                if (state.failed) {
                    return retval;
                }
                if (state.backtracking == 0) {
                    stream_primaryExpression.add(primaryExpression449.getTree());
                }
                // wildcard labels:
                if (state.backtracking == 0) {
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                    root_0 = (CommonTree) adaptor.nil();
                    // 1047:53: -> primaryExpression
                    {
                        adaptor.addChild(root_0, stream_primaryExpression.nextTree());
                    }
                    retval.tree = root_0;
                }
            }
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:1050:9: (outerDot= DOT ( ( ( genericTypeArgumentListSimplified )? IDENT -> ^( DOT $postfixedExpression IDENT ) ) ( arguments -> ^( METHOD_CALL $postfixedExpression ( genericTypeArgumentListSimplified )? arguments ) )? | THIS -> ^( DOT $postfixedExpression THIS ) | Super= SUPER arguments -> ^( SUPER_CONSTRUCTOR_CALL[$Super, \"SUPER_CONSTRUCTOR_CALL\"] $postfixedExpression arguments ) | ( SUPER innerDot= DOT IDENT -> ^( $innerDot ^( $outerDot $postfixedExpression SUPER ) IDENT ) ) ( arguments -> ^( METHOD_CALL $postfixedExpression arguments ) )? | innerNewExpression -> ^( DOT $postfixedExpression innerNewExpression ) ) | LBRACK expression RBRACK -> ^( ARRAY_ELEMENT_ACCESS $postfixedExpression expression ) )*
            loop133: do {
                int alt133 = 3;
                int LA133_0 = input.LA(1);
                if ((LA133_0 == DOT)) {
                    alt133 = 1;
                } else if ((LA133_0 == LBRACK)) {
                    alt133 = 2;
                }
                switch(alt133) {
                    case 1:
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:1050:13: outerDot= DOT ( ( ( genericTypeArgumentListSimplified )? IDENT -> ^( DOT $postfixedExpression IDENT ) ) ( arguments -> ^( METHOD_CALL $postfixedExpression ( genericTypeArgumentListSimplified )? arguments ) )? | THIS -> ^( DOT $postfixedExpression THIS ) | Super= SUPER arguments -> ^( SUPER_CONSTRUCTOR_CALL[$Super, \"SUPER_CONSTRUCTOR_CALL\"] $postfixedExpression arguments ) | ( SUPER innerDot= DOT IDENT -> ^( $innerDot ^( $outerDot $postfixedExpression SUPER ) IDENT ) ) ( arguments -> ^( METHOD_CALL $postfixedExpression arguments ) )? | innerNewExpression -> ^( DOT $postfixedExpression innerNewExpression ) )
                        {
                            outerDot = (Token) match(input, DOT, FOLLOW_DOT_in_postfixedExpression11634);
                            if (state.failed) {
                                return retval;
                            }
                            if (state.backtracking == 0) {
                                stream_DOT.add(outerDot);
                            }
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:1051:13: ( ( ( genericTypeArgumentListSimplified )? IDENT -> ^( DOT $postfixedExpression IDENT ) ) ( arguments -> ^( METHOD_CALL $postfixedExpression ( genericTypeArgumentListSimplified )? arguments ) )? | THIS -> ^( DOT $postfixedExpression THIS ) | Super= SUPER arguments -> ^( SUPER_CONSTRUCTOR_CALL[$Super, \"SUPER_CONSTRUCTOR_CALL\"] $postfixedExpression arguments ) | ( SUPER innerDot= DOT IDENT -> ^( $innerDot ^( $outerDot $postfixedExpression SUPER ) IDENT ) ) ( arguments -> ^( METHOD_CALL $postfixedExpression arguments ) )? | innerNewExpression -> ^( DOT $postfixedExpression innerNewExpression ) )
                            int alt132 = 5;
                            switch(input.LA(1)) {
                                case LESS_THAN:
                                case IDENT:
                                    {
                                        alt132 = 1;
                                    }
                                    break;
                                case THIS:
                                    {
                                        alt132 = 2;
                                    }
                                    break;
                                case SUPER:
                                    {
                                        int LA132_3 = input.LA(2);
                                        if ((LA132_3 == DOT)) {
                                            alt132 = 4;
                                        } else if ((LA132_3 == LPAREN)) {
                                            alt132 = 3;
                                        } else {
                                            if (state.backtracking > 0) {
                                                state.failed = true;
                                                return retval;
                                            }
                                            NoViableAltException nvae = new NoViableAltException("", 132, 3, input);
                                            throw nvae;
                                        }
                                    }
                                    break;
                                case NEW:
                                    {
                                        alt132 = 5;
                                    }
                                    break;
                                default:
                                    if (state.backtracking > 0) {
                                        state.failed = true;
                                        return retval;
                                    }
                                    NoViableAltException nvae = new NoViableAltException("", 132, 0, input);
                                    throw nvae;
                            }
                            switch(alt132) {
                                case 1:
                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1051:17: ( ( genericTypeArgumentListSimplified )? IDENT -> ^( DOT $postfixedExpression IDENT ) ) ( arguments -> ^( METHOD_CALL $postfixedExpression ( genericTypeArgumentListSimplified )? arguments ) )?
                                    {
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:1051:17: ( ( genericTypeArgumentListSimplified )? IDENT -> ^( DOT $postfixedExpression IDENT ) )
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:1051:21: ( genericTypeArgumentListSimplified )? IDENT
                                        {
                                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:1051:21: ( genericTypeArgumentListSimplified )?
                                            int alt129 = 2;
                                            int LA129_0 = input.LA(1);
                                            if ((LA129_0 == LESS_THAN)) {
                                                alt129 = 1;
                                            }
                                            switch(alt129) {
                                                case 1:
                                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: genericTypeArgumentListSimplified
                                                    {
                                                        pushFollow(FOLLOW_genericTypeArgumentListSimplified_in_postfixedExpression11656);
                                                        genericTypeArgumentListSimplified450 = genericTypeArgumentListSimplified();
                                                        state._fsp--;
                                                        if (state.failed) {
                                                            return retval;
                                                        }
                                                        if (state.backtracking == 0) {
                                                            stream_genericTypeArgumentListSimplified.add(genericTypeArgumentListSimplified450.getTree());
                                                        }
                                                    }
                                                    break;
                                            }
                                            IDENT451 = (Token) match(input, IDENT, FOLLOW_IDENT_in_postfixedExpression11738);
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_IDENT.add(IDENT451);
                                            }
                                            // wildcard labels:
                                            if (state.backtracking == 0) {
                                                retval.tree = root_0;
                                                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                                                root_0 = (CommonTree) adaptor.nil();
                                                // 1053:53: -> ^( DOT $postfixedExpression IDENT )
                                                {
                                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1053:57: ^( DOT $postfixedExpression IDENT )
                                                    {
                                                        CommonTree root_1 = (CommonTree) adaptor.nil();
                                                        root_1 = (CommonTree) adaptor.becomeRoot(stream_DOT.nextNode(), root_1);
                                                        adaptor.addChild(root_1, stream_retval.nextTree());
                                                        adaptor.addChild(root_1, stream_IDENT.nextNode());
                                                        adaptor.addChild(root_0, root_1);
                                                    }
                                                }
                                                retval.tree = root_0;
                                            }
                                        }
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:1055:17: ( arguments -> ^( METHOD_CALL $postfixedExpression ( genericTypeArgumentListSimplified )? arguments ) )?
                                        int alt130 = 2;
                                        int LA130_0 = input.LA(1);
                                        if ((LA130_0 == LPAREN)) {
                                            alt130 = 1;
                                        }
                                        switch(alt130) {
                                            case 1:
                                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:1055:21: arguments
                                                {
                                                    pushFollow(FOLLOW_arguments_in_postfixedExpression11816);
                                                    arguments452 = arguments();
                                                    state._fsp--;
                                                    if (state.failed) {
                                                        return retval;
                                                    }
                                                    if (state.backtracking == 0) {
                                                        stream_arguments.add(arguments452.getTree());
                                                    }
                                                    // wildcard labels:
                                                    if (state.backtracking == 0) {
                                                        retval.tree = root_0;
                                                        RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                                                        root_0 = (CommonTree) adaptor.nil();
                                                        // 1055:53: -> ^( METHOD_CALL $postfixedExpression ( genericTypeArgumentListSimplified )? arguments )
                                                        {
                                                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:1055:57: ^( METHOD_CALL $postfixedExpression ( genericTypeArgumentListSimplified )? arguments )
                                                            {
                                                                CommonTree root_1 = (CommonTree) adaptor.nil();
                                                                root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(METHOD_CALL, "METHOD_CALL"), root_1);
                                                                adaptor.addChild(root_1, stream_retval.nextTree());
                                                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:1055:92: ( genericTypeArgumentListSimplified )?
                                                                if (stream_genericTypeArgumentListSimplified.hasNext()) {
                                                                    adaptor.addChild(root_1, stream_genericTypeArgumentListSimplified.nextTree());
                                                                }
                                                                stream_genericTypeArgumentListSimplified.reset();
                                                                adaptor.addChild(root_1, stream_arguments.nextTree());
                                                                adaptor.addChild(root_0, root_1);
                                                            }
                                                        }
                                                        retval.tree = root_0;
                                                    }
                                                }
                                                break;
                                        }
                                    }
                                    break;
                                case 2:
                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1057:17: THIS
                                    {
                                        THIS453 = (Token) match(input, THIS, FOLLOW_THIS_in_postfixedExpression11890);
                                        if (state.failed) {
                                            return retval;
                                        }
                                        if (state.backtracking == 0) {
                                            stream_THIS.add(THIS453);
                                        }
                                        // wildcard labels:
                                        if (state.backtracking == 0) {
                                            retval.tree = root_0;
                                            RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                                            root_0 = (CommonTree) adaptor.nil();
                                            // 1057:53: -> ^( DOT $postfixedExpression THIS )
                                            {
                                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:1057:57: ^( DOT $postfixedExpression THIS )
                                                {
                                                    CommonTree root_1 = (CommonTree) adaptor.nil();
                                                    root_1 = (CommonTree) adaptor.becomeRoot(stream_DOT.nextNode(), root_1);
                                                    adaptor.addChild(root_1, stream_retval.nextTree());
                                                    adaptor.addChild(root_1, stream_THIS.nextNode());
                                                    adaptor.addChild(root_0, root_1);
                                                }
                                            }
                                            retval.tree = root_0;
                                        }
                                    }
                                    break;
                                case 3:
                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1058:17: Super= SUPER arguments
                                    {
                                        Super = (Token) match(input, SUPER, FOLLOW_SUPER_in_postfixedExpression11953);
                                        if (state.failed) {
                                            return retval;
                                        }
                                        if (state.backtracking == 0) {
                                            stream_SUPER.add(Super);
                                        }
                                        pushFollow(FOLLOW_arguments_in_postfixedExpression11955);
                                        arguments454 = arguments();
                                        state._fsp--;
                                        if (state.failed) {
                                            return retval;
                                        }
                                        if (state.backtracking == 0) {
                                            stream_arguments.add(arguments454.getTree());
                                        }
                                        // wildcard labels:
                                        if (state.backtracking == 0) {
                                            retval.tree = root_0;
                                            RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                                            root_0 = (CommonTree) adaptor.nil();
                                            // 1058:57: -> ^( SUPER_CONSTRUCTOR_CALL[$Super, \"SUPER_CONSTRUCTOR_CALL\"] $postfixedExpression arguments )
                                            {
                                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:1058:61: ^( SUPER_CONSTRUCTOR_CALL[$Super, \"SUPER_CONSTRUCTOR_CALL\"] $postfixedExpression arguments )
                                                {
                                                    CommonTree root_1 = (CommonTree) adaptor.nil();
                                                    root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(SUPER_CONSTRUCTOR_CALL, Super, "SUPER_CONSTRUCTOR_CALL"), root_1);
                                                    adaptor.addChild(root_1, stream_retval.nextTree());
                                                    adaptor.addChild(root_1, stream_arguments.nextTree());
                                                    adaptor.addChild(root_0, root_1);
                                                }
                                            }
                                            retval.tree = root_0;
                                        }
                                    }
                                    break;
                                case 4:
                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1059:17: ( SUPER innerDot= DOT IDENT -> ^( $innerDot ^( $outerDot $postfixedExpression SUPER ) IDENT ) ) ( arguments -> ^( METHOD_CALL $postfixedExpression arguments ) )?
                                    {
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:1059:17: ( SUPER innerDot= DOT IDENT -> ^( $innerDot ^( $outerDot $postfixedExpression SUPER ) IDENT ) )
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:1059:21: SUPER innerDot= DOT IDENT
                                        {
                                            SUPER455 = (Token) match(input, SUPER, FOLLOW_SUPER_in_postfixedExpression12008);
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_SUPER.add(SUPER455);
                                            }
                                            innerDot = (Token) match(input, DOT, FOLLOW_DOT_in_postfixedExpression12012);
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_DOT.add(innerDot);
                                            }
                                            IDENT456 = (Token) match(input, IDENT, FOLLOW_IDENT_in_postfixedExpression12014);
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_IDENT.add(IDENT456);
                                            }
                                            // wildcard labels:
                                            if (state.backtracking == 0) {
                                                retval.tree = root_0;
                                                RewriteRuleTokenStream stream_outerDot = new RewriteRuleTokenStream(adaptor, "token outerDot", outerDot);
                                                RewriteRuleTokenStream stream_innerDot = new RewriteRuleTokenStream(adaptor, "token innerDot", innerDot);
                                                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                                                root_0 = (CommonTree) adaptor.nil();
                                                // 1059:53: -> ^( $innerDot ^( $outerDot $postfixedExpression SUPER ) IDENT )
                                                {
                                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1059:57: ^( $innerDot ^( $outerDot $postfixedExpression SUPER ) IDENT )
                                                    {
                                                        CommonTree root_1 = (CommonTree) adaptor.nil();
                                                        root_1 = (CommonTree) adaptor.becomeRoot(stream_innerDot.nextNode(), root_1);
                                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:1059:69: ^( $outerDot $postfixedExpression SUPER )
                                                        {
                                                            CommonTree root_2 = (CommonTree) adaptor.nil();
                                                            root_2 = (CommonTree) adaptor.becomeRoot(stream_outerDot.nextNode(), root_2);
                                                            adaptor.addChild(root_2, stream_retval.nextTree());
                                                            adaptor.addChild(root_2, stream_SUPER.nextNode());
                                                            adaptor.addChild(root_1, root_2);
                                                        }
                                                        adaptor.addChild(root_1, stream_IDENT.nextNode());
                                                        adaptor.addChild(root_0, root_1);
                                                    }
                                                }
                                                retval.tree = root_0;
                                            }
                                        }
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:1061:17: ( arguments -> ^( METHOD_CALL $postfixedExpression arguments ) )?
                                        int alt131 = 2;
                                        int LA131_0 = input.LA(1);
                                        if ((LA131_0 == LPAREN)) {
                                            alt131 = 1;
                                        }
                                        switch(alt131) {
                                            case 1:
                                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:1061:21: arguments
                                                {
                                                    pushFollow(FOLLOW_arguments_in_postfixedExpression12081);
                                                    arguments457 = arguments();
                                                    state._fsp--;
                                                    if (state.failed) {
                                                        return retval;
                                                    }
                                                    if (state.backtracking == 0) {
                                                        stream_arguments.add(arguments457.getTree());
                                                    }
                                                    // wildcard labels:
                                                    if (state.backtracking == 0) {
                                                        retval.tree = root_0;
                                                        RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                                                        root_0 = (CommonTree) adaptor.nil();
                                                        // 1061:53: -> ^( METHOD_CALL $postfixedExpression arguments )
                                                        {
                                                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:1061:57: ^( METHOD_CALL $postfixedExpression arguments )
                                                            {
                                                                CommonTree root_1 = (CommonTree) adaptor.nil();
                                                                root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(METHOD_CALL, "METHOD_CALL"), root_1);
                                                                adaptor.addChild(root_1, stream_retval.nextTree());
                                                                adaptor.addChild(root_1, stream_arguments.nextTree());
                                                                adaptor.addChild(root_0, root_1);
                                                            }
                                                        }
                                                        retval.tree = root_0;
                                                    }
                                                }
                                                break;
                                        }
                                    }
                                    break;
                                case 5:
                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1063:17: innerNewExpression
                                    {
                                        pushFollow(FOLLOW_innerNewExpression_in_postfixedExpression12152);
                                        innerNewExpression458 = innerNewExpression();
                                        state._fsp--;
                                        if (state.failed) {
                                            return retval;
                                        }
                                        if (state.backtracking == 0) {
                                            stream_innerNewExpression.add(innerNewExpression458.getTree());
                                        }
                                        // wildcard labels:
                                        if (state.backtracking == 0) {
                                            retval.tree = root_0;
                                            RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                                            root_0 = (CommonTree) adaptor.nil();
                                            // 1063:53: -> ^( DOT $postfixedExpression innerNewExpression )
                                            {
                                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:1063:57: ^( DOT $postfixedExpression innerNewExpression )
                                                {
                                                    CommonTree root_1 = (CommonTree) adaptor.nil();
                                                    root_1 = (CommonTree) adaptor.becomeRoot(stream_DOT.nextNode(), root_1);
                                                    adaptor.addChild(root_1, stream_retval.nextTree());
                                                    adaptor.addChild(root_1, stream_innerNewExpression.nextTree());
                                                    adaptor.addChild(root_0, root_1);
                                                }
                                            }
                                            retval.tree = root_0;
                                        }
                                    }
                                    break;
                            }
                        }
                        break;
                    case 2:
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:1065:13: LBRACK expression RBRACK
                        {
                            LBRACK459 = (Token) match(input, LBRACK, FOLLOW_LBRACK_in_postfixedExpression12209);
                            if (state.failed) {
                                return retval;
                            }
                            if (state.backtracking == 0) {
                                stream_LBRACK.add(LBRACK459);
                            }
                            pushFollow(FOLLOW_expression_in_postfixedExpression12211);
                            expression460 = expression();
                            state._fsp--;
                            if (state.failed) {
                                return retval;
                            }
                            if (state.backtracking == 0) {
                                stream_expression.add(expression460.getTree());
                            }
                            RBRACK461 = (Token) match(input, RBRACK, FOLLOW_RBRACK_in_postfixedExpression12213);
                            if (state.failed) {
                                return retval;
                            }
                            if (state.backtracking == 0) {
                                stream_RBRACK.add(RBRACK461);
                            }
                            // wildcard labels:
                            if (state.backtracking == 0) {
                                retval.tree = root_0;
                                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                                root_0 = (CommonTree) adaptor.nil();
                                // 1065:53: -> ^( ARRAY_ELEMENT_ACCESS $postfixedExpression expression )
                                {
                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1065:57: ^( ARRAY_ELEMENT_ACCESS $postfixedExpression expression )
                                    {
                                        CommonTree root_1 = (CommonTree) adaptor.nil();
                                        root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(ARRAY_ELEMENT_ACCESS, "ARRAY_ELEMENT_ACCESS"), root_1);
                                        adaptor.addChild(root_1, stream_retval.nextTree());
                                        adaptor.addChild(root_1, stream_expression.nextTree());
                                        adaptor.addChild(root_0, root_1);
                                    }
                                }
                                retval.tree = root_0;
                            }
                        }
                        break;
                    default:
                        break loop133;
                }
            } while (true);
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:1068:9: ( INC -> ^( POST_INC[$INC, \"POST_INC\"] $postfixedExpression) | DEC -> ^( POST_DEC[$DEC, \"POST_DEC\"] $postfixedExpression) )?
            int alt134 = 3;
            int LA134_0 = input.LA(1);
            if ((LA134_0 == INC)) {
                alt134 = 1;
            } else if ((LA134_0 == DEC)) {
                alt134 = 2;
            }
            switch(alt134) {
                case 1:
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1068:13: INC
                    {
                        INC462 = (Token) match(input, INC, FOLLOW_INC_in_postfixedExpression12274);
                        if (state.failed) {
                            return retval;
                        }
                        if (state.backtracking == 0) {
                            stream_INC.add(INC462);
                        }
                        // wildcard labels:
                        if (state.backtracking == 0) {
                            retval.tree = root_0;
                            RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                            root_0 = (CommonTree) adaptor.nil();
                            // 1068:17: -> ^( POST_INC[$INC, \"POST_INC\"] $postfixedExpression)
                            {
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:1068:20: ^( POST_INC[$INC, \"POST_INC\"] $postfixedExpression)
                                {
                                    CommonTree root_1 = (CommonTree) adaptor.nil();
                                    root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(POST_INC, INC462, "POST_INC"), root_1);
                                    adaptor.addChild(root_1, stream_retval.nextTree());
                                    adaptor.addChild(root_0, root_1);
                                }
                            }
                            retval.tree = root_0;
                        }
                    }
                    break;
                case 2:
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1069:13: DEC
                    {
                        DEC463 = (Token) match(input, DEC, FOLLOW_DEC_in_postfixedExpression12298);
                        if (state.failed) {
                            return retval;
                        }
                        if (state.backtracking == 0) {
                            stream_DEC.add(DEC463);
                        }
                        // wildcard labels:
                        if (state.backtracking == 0) {
                            retval.tree = root_0;
                            RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                            root_0 = (CommonTree) adaptor.nil();
                            // 1069:17: -> ^( POST_DEC[$DEC, \"POST_DEC\"] $postfixedExpression)
                            {
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:1069:20: ^( POST_DEC[$DEC, \"POST_DEC\"] $postfixedExpression)
                                {
                                    CommonTree root_1 = (CommonTree) adaptor.nil();
                                    root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(POST_DEC, DEC463, "POST_DEC"), root_1);
                                    adaptor.addChild(root_1, stream_retval.nextTree());
                                    adaptor.addChild(root_0, root_1);
                                }
                            }
                            retval.tree = root_0;
                        }
                    }
                    break;
            }
        }
        retval.stop = input.LT(-1);
        if (state.backtracking == 0) {
            retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
        }
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
        if (state.backtracking > 0) {
            memoize(input, 104, postfixedExpression_StartIndex);
        }
    }
    return retval;
}
Also used : CommonTree(org.antlr.runtime.tree.CommonTree) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) NoViableAltException(org.antlr.runtime.NoViableAltException) RecognitionException(org.antlr.runtime.RecognitionException)

Example 2 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.

the class JavaParser method classFieldDeclaratorList.

// $ANTLR start "classFieldDeclaratorList"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:569:1: classFieldDeclaratorList : classFieldDeclarator ( COMMA classFieldDeclarator )* -> ^( VAR_DECLARATOR_LIST ( classFieldDeclarator )+ ) ;
public final JavaParser.classFieldDeclaratorList_return classFieldDeclaratorList() throws RecognitionException {
    JavaParser.classFieldDeclaratorList_return retval = new JavaParser.classFieldDeclaratorList_return();
    retval.start = input.LT(1);
    int classFieldDeclaratorList_StartIndex = input.index();
    CommonTree root_0 = null;
    Token COMMA125 = null;
    JavaParser.classFieldDeclarator_return classFieldDeclarator124 = null;
    JavaParser.classFieldDeclarator_return classFieldDeclarator126 = null;
    CommonTree COMMA125_tree = null;
    RewriteRuleTokenStream stream_COMMA = new RewriteRuleTokenStream(adaptor, "token COMMA");
    RewriteRuleSubtreeStream stream_classFieldDeclarator = new RewriteRuleSubtreeStream(adaptor, "rule classFieldDeclarator");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 27)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:570:5: ( classFieldDeclarator ( COMMA classFieldDeclarator )* -> ^( VAR_DECLARATOR_LIST ( classFieldDeclarator )+ ) )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:570:9: classFieldDeclarator ( COMMA classFieldDeclarator )*
        {
            pushFollow(FOLLOW_classFieldDeclarator_in_classFieldDeclaratorList6225);
            classFieldDeclarator124 = classFieldDeclarator();
            state._fsp--;
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_classFieldDeclarator.add(classFieldDeclarator124.getTree());
            }
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:570:30: ( COMMA classFieldDeclarator )*
            loop45: do {
                int alt45 = 2;
                int LA45_0 = input.LA(1);
                if ((LA45_0 == COMMA)) {
                    alt45 = 1;
                }
                switch(alt45) {
                    case 1:
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:570:31: COMMA classFieldDeclarator
                        {
                            COMMA125 = (Token) match(input, COMMA, FOLLOW_COMMA_in_classFieldDeclaratorList6228);
                            if (state.failed) {
                                return retval;
                            }
                            if (state.backtracking == 0) {
                                stream_COMMA.add(COMMA125);
                            }
                            pushFollow(FOLLOW_classFieldDeclarator_in_classFieldDeclaratorList6230);
                            classFieldDeclarator126 = classFieldDeclarator();
                            state._fsp--;
                            if (state.failed) {
                                return retval;
                            }
                            if (state.backtracking == 0) {
                                stream_classFieldDeclarator.add(classFieldDeclarator126.getTree());
                            }
                        }
                        break;
                    default:
                        break loop45;
                }
            } while (true);
            // wildcard labels:
            if (state.backtracking == 0) {
                retval.tree = root_0;
                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                root_0 = (CommonTree) adaptor.nil();
                // 571:9: -> ^( VAR_DECLARATOR_LIST ( classFieldDeclarator )+ )
                {
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:571:13: ^( VAR_DECLARATOR_LIST ( classFieldDeclarator )+ )
                    {
                        CommonTree root_1 = (CommonTree) adaptor.nil();
                        root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(VAR_DECLARATOR_LIST, "VAR_DECLARATOR_LIST"), root_1);
                        if (!(stream_classFieldDeclarator.hasNext())) {
                            throw new RewriteEarlyExitException();
                        }
                        while (stream_classFieldDeclarator.hasNext()) {
                            adaptor.addChild(root_1, stream_classFieldDeclarator.nextTree());
                        }
                        stream_classFieldDeclarator.reset();
                        adaptor.addChild(root_0, root_1);
                    }
                }
                retval.tree = root_0;
            }
        }
        retval.stop = input.LT(-1);
        if (state.backtracking == 0) {
            retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
        }
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
        if (state.backtracking > 0) {
            memoize(input, 27, classFieldDeclaratorList_StartIndex);
        }
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) CommonTree(org.antlr.runtime.tree.CommonTree) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) RewriteEarlyExitException(org.antlr.runtime.tree.RewriteEarlyExitException) RecognitionException(org.antlr.runtime.RecognitionException)

Example 3 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.

the class JavaParser method genericTypeArgument.

// $ANTLR start "genericTypeArgument"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:701:1: genericTypeArgument : ( type | QUESTION ( genericWildcardBoundType )? -> ^( QUESTION ( genericWildcardBoundType )? ) );
public final JavaParser.genericTypeArgument_return genericTypeArgument() throws RecognitionException {
    JavaParser.genericTypeArgument_return retval = new JavaParser.genericTypeArgument_return();
    retval.start = input.LT(1);
    int genericTypeArgument_StartIndex = input.index();
    CommonTree root_0 = null;
    Token QUESTION191 = null;
    JavaParser.type_return type190 = null;
    JavaParser.genericWildcardBoundType_return genericWildcardBoundType192 = null;
    CommonTree QUESTION191_tree = null;
    RewriteRuleTokenStream stream_QUESTION = new RewriteRuleTokenStream(adaptor, "token QUESTION");
    RewriteRuleSubtreeStream stream_genericWildcardBoundType = new RewriteRuleSubtreeStream(adaptor, "rule genericWildcardBoundType");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 51)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:702:5: ( type | QUESTION ( genericWildcardBoundType )? -> ^( QUESTION ( genericWildcardBoundType )? ) )
        int alt68 = 2;
        int LA68_0 = input.LA(1);
        if ((LA68_0 == BOOLEAN || LA68_0 == BYTE || LA68_0 == CHAR || LA68_0 == DOUBLE || LA68_0 == FLOAT || (LA68_0 >= INT && LA68_0 <= LONG) || LA68_0 == SHORT || LA68_0 == IDENT)) {
            alt68 = 1;
        } else if ((LA68_0 == QUESTION)) {
            alt68 = 2;
        } else {
            if (state.backtracking > 0) {
                state.failed = true;
                return retval;
            }
            NoViableAltException nvae = new NoViableAltException("", 68, 0, input);
            throw nvae;
        }
        switch(alt68) {
            case 1:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:702:9: type
                {
                    root_0 = (CommonTree) adaptor.nil();
                    pushFollow(FOLLOW_type_in_genericTypeArgument7273);
                    type190 = type();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        adaptor.addChild(root_0, type190.getTree());
                    }
                }
                break;
            case 2:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:703:9: QUESTION ( genericWildcardBoundType )?
                {
                    QUESTION191 = (Token) match(input, QUESTION, FOLLOW_QUESTION_in_genericTypeArgument7283);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_QUESTION.add(QUESTION191);
                    }
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:703:18: ( genericWildcardBoundType )?
                    int alt67 = 2;
                    int LA67_0 = input.LA(1);
                    if ((LA67_0 == EXTENDS)) {
                        int LA67_1 = input.LA(2);
                        if ((LA67_1 == BOOLEAN || LA67_1 == BYTE || LA67_1 == CHAR || LA67_1 == DOUBLE || LA67_1 == FLOAT || (LA67_1 >= INT && LA67_1 <= LONG) || LA67_1 == SHORT)) {
                            int LA67_4 = input.LA(3);
                            if ((synpred93_Java())) {
                                alt67 = 1;
                            }
                        } else if ((LA67_1 == IDENT)) {
                            int LA67_5 = input.LA(3);
                            if ((synpred93_Java())) {
                                alt67 = 1;
                            }
                        }
                    } else if ((LA67_0 == SUPER)) {
                        int LA67_3 = input.LA(2);
                        if ((LA67_3 == BOOLEAN || LA67_3 == BYTE || LA67_3 == CHAR || LA67_3 == DOUBLE || LA67_3 == FLOAT || (LA67_3 >= INT && LA67_3 <= LONG) || LA67_3 == SHORT || LA67_3 == IDENT)) {
                            alt67 = 1;
                        }
                    }
                    switch(alt67) {
                        case 1:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: genericWildcardBoundType
                            {
                                pushFollow(FOLLOW_genericWildcardBoundType_in_genericTypeArgument7285);
                                genericWildcardBoundType192 = genericWildcardBoundType();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_genericWildcardBoundType.add(genericWildcardBoundType192.getTree());
                                }
                            }
                            break;
                    }
                    // wildcard labels:
                    if (state.backtracking == 0) {
                        retval.tree = root_0;
                        RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                        root_0 = (CommonTree) adaptor.nil();
                        // 704:9: -> ^( QUESTION ( genericWildcardBoundType )? )
                        {
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:704:13: ^( QUESTION ( genericWildcardBoundType )? )
                            {
                                CommonTree root_1 = (CommonTree) adaptor.nil();
                                root_1 = (CommonTree) adaptor.becomeRoot(stream_QUESTION.nextNode(), root_1);
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:704:24: ( genericWildcardBoundType )?
                                if (stream_genericWildcardBoundType.hasNext()) {
                                    adaptor.addChild(root_1, stream_genericWildcardBoundType.nextTree());
                                }
                                stream_genericWildcardBoundType.reset();
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
        }
        retval.stop = input.LT(-1);
        if (state.backtracking == 0) {
            retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
        }
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
        if (state.backtracking > 0) {
            memoize(input, 51, genericTypeArgument_StartIndex);
        }
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) CommonTree(org.antlr.runtime.tree.CommonTree) NoViableAltException(org.antlr.runtime.NoViableAltException) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) RecognitionException(org.antlr.runtime.RecognitionException)

Example 4 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.

the class JavaParser method throwsClause.

// $ANTLR start "throwsClause"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:613:1: throwsClause : THROWS qualifiedIdentList -> ^( THROWS_CLAUSE[$THROWS, \"THROWS_CLAUSE\"] qualifiedIdentList ) ;
public final JavaParser.throwsClause_return throwsClause() throws RecognitionException {
    JavaParser.throwsClause_return retval = new JavaParser.throwsClause_return();
    retval.start = input.LT(1);
    int throwsClause_StartIndex = input.index();
    CommonTree root_0 = null;
    Token THROWS149 = null;
    JavaParser.qualifiedIdentList_return qualifiedIdentList150 = null;
    CommonTree THROWS149_tree = null;
    RewriteRuleTokenStream stream_THROWS = new RewriteRuleTokenStream(adaptor, "token THROWS");
    RewriteRuleSubtreeStream stream_qualifiedIdentList = new RewriteRuleSubtreeStream(adaptor, "rule qualifiedIdentList");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 36)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:614:5: ( THROWS qualifiedIdentList -> ^( THROWS_CLAUSE[$THROWS, \"THROWS_CLAUSE\"] qualifiedIdentList ) )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:614:9: THROWS qualifiedIdentList
        {
            THROWS149 = (Token) match(input, THROWS, FOLLOW_THROWS_in_throwsClause6582);
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_THROWS.add(THROWS149);
            }
            pushFollow(FOLLOW_qualifiedIdentList_in_throwsClause6584);
            qualifiedIdentList150 = qualifiedIdentList();
            state._fsp--;
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_qualifiedIdentList.add(qualifiedIdentList150.getTree());
            }
            // wildcard labels:
            if (state.backtracking == 0) {
                retval.tree = root_0;
                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                root_0 = (CommonTree) adaptor.nil();
                // 615:9: -> ^( THROWS_CLAUSE[$THROWS, \"THROWS_CLAUSE\"] qualifiedIdentList )
                {
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:615:13: ^( THROWS_CLAUSE[$THROWS, \"THROWS_CLAUSE\"] qualifiedIdentList )
                    {
                        CommonTree root_1 = (CommonTree) adaptor.nil();
                        root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(THROWS_CLAUSE, THROWS149, "THROWS_CLAUSE"), root_1);
                        adaptor.addChild(root_1, stream_qualifiedIdentList.nextTree());
                        adaptor.addChild(root_0, root_1);
                    }
                }
                retval.tree = root_0;
            }
        }
        retval.stop = input.LT(-1);
        if (state.backtracking == 0) {
            retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
        }
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
        if (state.backtracking > 0) {
            memoize(input, 36, throwsClause_StartIndex);
        }
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) CommonTree(org.antlr.runtime.tree.CommonTree) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) RecognitionException(org.antlr.runtime.RecognitionException)

Example 5 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.

the class JavaParser method annotationInitializers.

// $ANTLR start "annotationInitializers"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:772:1: annotationInitializers : ( annotationInitializer ( COMMA annotationInitializer )* -> ^( ANNOTATION_INIT_KEY_LIST ( annotationInitializer )+ ) | annotationElementValue -> ^( ANNOTATION_INIT_DEFAULT_KEY annotationElementValue ) );
public final JavaParser.annotationInitializers_return annotationInitializers() throws RecognitionException {
    JavaParser.annotationInitializers_return retval = new JavaParser.annotationInitializers_return();
    retval.start = input.LT(1);
    int annotationInitializers_StartIndex = input.index();
    CommonTree root_0 = null;
    Token COMMA230 = null;
    JavaParser.annotationInitializer_return annotationInitializer229 = null;
    JavaParser.annotationInitializer_return annotationInitializer231 = null;
    JavaParser.annotationElementValue_return annotationElementValue232 = null;
    CommonTree COMMA230_tree = null;
    RewriteRuleTokenStream stream_COMMA = new RewriteRuleTokenStream(adaptor, "token COMMA");
    RewriteRuleSubtreeStream stream_annotationElementValue = new RewriteRuleSubtreeStream(adaptor, "rule annotationElementValue");
    RewriteRuleSubtreeStream stream_annotationInitializer = new RewriteRuleSubtreeStream(adaptor, "rule annotationInitializer");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 63)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:773:5: ( annotationInitializer ( COMMA annotationInitializer )* -> ^( ANNOTATION_INIT_KEY_LIST ( annotationInitializer )+ ) | annotationElementValue -> ^( ANNOTATION_INIT_DEFAULT_KEY annotationElementValue ) )
        int alt79 = 2;
        int LA79_0 = input.LA(1);
        if ((LA79_0 == IDENT)) {
            int LA79_1 = input.LA(2);
            if ((LA79_1 == ASSIGN)) {
                alt79 = 1;
            } else if ((LA79_1 == AND || LA79_1 == BIT_SHIFT_RIGHT || (LA79_1 >= DEC && LA79_1 <= DIV) || LA79_1 == DOT || (LA79_1 >= EQUAL && LA79_1 <= LBRACK) || (LA79_1 >= LESS_OR_EQUAL && LA79_1 <= LOGICAL_AND) || (LA79_1 >= LOGICAL_OR && LA79_1 <= MINUS) || LA79_1 == MOD || (LA79_1 >= NOT_EQUAL && LA79_1 <= OR) || LA79_1 == PLUS || LA79_1 == QUESTION || LA79_1 == RPAREN || LA79_1 == SHIFT_LEFT || LA79_1 == SHIFT_RIGHT || LA79_1 == STAR || LA79_1 == XOR || LA79_1 == INSTANCEOF)) {
                alt79 = 2;
            } else {
                if (state.backtracking > 0) {
                    state.failed = true;
                    return retval;
                }
                NoViableAltException nvae = new NoViableAltException("", 79, 1, input);
                throw nvae;
            }
        } else if ((LA79_0 == AT || LA79_0 == DEC || LA79_0 == INC || LA79_0 == LCURLY || LA79_0 == LESS_THAN || LA79_0 == LOGICAL_NOT || (LA79_0 >= LPAREN && LA79_0 <= MINUS) || LA79_0 == NOT || LA79_0 == PLUS || LA79_0 == BOOLEAN || LA79_0 == BYTE || LA79_0 == CHAR || LA79_0 == DOUBLE || LA79_0 == FALSE || LA79_0 == FLOAT || (LA79_0 >= INT && LA79_0 <= LONG) || (LA79_0 >= NEW && LA79_0 <= NULL) || LA79_0 == SHORT || LA79_0 == SUPER || LA79_0 == THIS || LA79_0 == TRUE || LA79_0 == VOID || (LA79_0 >= HEX_LITERAL && LA79_0 <= STRING_LITERAL))) {
            alt79 = 2;
        } else {
            if (state.backtracking > 0) {
                state.failed = true;
                return retval;
            }
            NoViableAltException nvae = new NoViableAltException("", 79, 0, input);
            throw nvae;
        }
        switch(alt79) {
            case 1:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:773:9: annotationInitializer ( COMMA annotationInitializer )*
                {
                    pushFollow(FOLLOW_annotationInitializer_in_annotationInitializers7938);
                    annotationInitializer229 = annotationInitializer();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_annotationInitializer.add(annotationInitializer229.getTree());
                    }
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:773:31: ( COMMA annotationInitializer )*
                    loop78: do {
                        int alt78 = 2;
                        int LA78_0 = input.LA(1);
                        if ((LA78_0 == COMMA)) {
                            alt78 = 1;
                        }
                        switch(alt78) {
                            case 1:
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:773:32: COMMA annotationInitializer
                                {
                                    COMMA230 = (Token) match(input, COMMA, FOLLOW_COMMA_in_annotationInitializers7941);
                                    if (state.failed) {
                                        return retval;
                                    }
                                    if (state.backtracking == 0) {
                                        stream_COMMA.add(COMMA230);
                                    }
                                    pushFollow(FOLLOW_annotationInitializer_in_annotationInitializers7943);
                                    annotationInitializer231 = annotationInitializer();
                                    state._fsp--;
                                    if (state.failed) {
                                        return retval;
                                    }
                                    if (state.backtracking == 0) {
                                        stream_annotationInitializer.add(annotationInitializer231.getTree());
                                    }
                                }
                                break;
                            default:
                                break loop78;
                        }
                    } while (true);
                    // wildcard labels:
                    if (state.backtracking == 0) {
                        retval.tree = root_0;
                        RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                        root_0 = (CommonTree) adaptor.nil();
                        // 774:9: -> ^( ANNOTATION_INIT_KEY_LIST ( annotationInitializer )+ )
                        {
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:774:13: ^( ANNOTATION_INIT_KEY_LIST ( annotationInitializer )+ )
                            {
                                CommonTree root_1 = (CommonTree) adaptor.nil();
                                root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(ANNOTATION_INIT_KEY_LIST, "ANNOTATION_INIT_KEY_LIST"), root_1);
                                if (!(stream_annotationInitializer.hasNext())) {
                                    throw new RewriteEarlyExitException();
                                }
                                while (stream_annotationInitializer.hasNext()) {
                                    adaptor.addChild(root_1, stream_annotationInitializer.nextTree());
                                }
                                stream_annotationInitializer.reset();
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
            case 2:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:775:9: annotationElementValue
                {
                    pushFollow(FOLLOW_annotationElementValue_in_annotationInitializers7973);
                    annotationElementValue232 = annotationElementValue();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_annotationElementValue.add(annotationElementValue232.getTree());
                    }
                    // wildcard labels:
                    if (state.backtracking == 0) {
                        retval.tree = root_0;
                        RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                        root_0 = (CommonTree) adaptor.nil();
                        // 776:9: -> ^( ANNOTATION_INIT_DEFAULT_KEY annotationElementValue )
                        {
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:776:13: ^( ANNOTATION_INIT_DEFAULT_KEY annotationElementValue )
                            {
                                CommonTree root_1 = (CommonTree) adaptor.nil();
                                root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(ANNOTATION_INIT_DEFAULT_KEY, "ANNOTATION_INIT_DEFAULT_KEY"), root_1);
                                adaptor.addChild(root_1, stream_annotationElementValue.nextTree());
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
        }
        retval.stop = input.LT(-1);
        if (state.backtracking == 0) {
            retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
        }
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
        if (state.backtracking > 0) {
            memoize(input, 63, annotationInitializers_StartIndex);
        }
    }
    return retval;
}
Also used : CommonTree(org.antlr.runtime.tree.CommonTree) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) RewriteEarlyExitException(org.antlr.runtime.tree.RewriteEarlyExitException) RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) NoViableAltException(org.antlr.runtime.NoViableAltException) RecognitionException(org.antlr.runtime.RecognitionException)

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