Search in sources :

Example 6 with RewriteRuleTokenStream

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

the class JavaParser method interfaceTypeDeclaration.

// $ANTLR start "interfaceTypeDeclaration"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:516:1: interfaceTypeDeclaration[CommonTree modifiers] : INTERFACE IDENT ( genericTypeParameterList )? ( interfaceExtendsClause )? interfaceBody -> ^( INTERFACE IDENT ( genericTypeParameterList )? ( interfaceExtendsClause )? interfaceBody ) ;
public final JavaParser.interfaceTypeDeclaration_return interfaceTypeDeclaration(CommonTree modifiers) throws RecognitionException {
    JavaParser.interfaceTypeDeclaration_return retval = new JavaParser.interfaceTypeDeclaration_return();
    retval.start = input.LT(1);
    int interfaceTypeDeclaration_StartIndex = input.index();
    CommonTree root_0 = null;
    Token INTERFACE66 = null;
    Token IDENT67 = null;
    JavaParser.genericTypeParameterList_return genericTypeParameterList68 = null;
    JavaParser.interfaceExtendsClause_return interfaceExtendsClause69 = null;
    JavaParser.interfaceBody_return interfaceBody70 = null;
    CommonTree INTERFACE66_tree = null;
    CommonTree IDENT67_tree = null;
    RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
    RewriteRuleTokenStream stream_INTERFACE = new RewriteRuleTokenStream(adaptor, "token INTERFACE");
    RewriteRuleSubtreeStream stream_genericTypeParameterList = new RewriteRuleSubtreeStream(adaptor, "rule genericTypeParameterList");
    RewriteRuleSubtreeStream stream_interfaceBody = new RewriteRuleSubtreeStream(adaptor, "rule interfaceBody");
    RewriteRuleSubtreeStream stream_interfaceExtendsClause = new RewriteRuleSubtreeStream(adaptor, "rule interfaceExtendsClause");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 21)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:517:5: ( INTERFACE IDENT ( genericTypeParameterList )? ( interfaceExtendsClause )? interfaceBody -> ^( INTERFACE IDENT ( genericTypeParameterList )? ( interfaceExtendsClause )? interfaceBody ) )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:517:9: INTERFACE IDENT ( genericTypeParameterList )? ( interfaceExtendsClause )? interfaceBody
        {
            INTERFACE66 = (Token) match(input, INTERFACE, FOLLOW_INTERFACE_in_interfaceTypeDeclaration5413);
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_INTERFACE.add(INTERFACE66);
            }
            IDENT67 = (Token) match(input, IDENT, FOLLOW_IDENT_in_interfaceTypeDeclaration5415);
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_IDENT.add(IDENT67);
            }
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:517:25: ( genericTypeParameterList )?
            int alt23 = 2;
            int LA23_0 = input.LA(1);
            if ((LA23_0 == LESS_THAN)) {
                alt23 = 1;
            }
            switch(alt23) {
                case 1:
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: genericTypeParameterList
                    {
                        pushFollow(FOLLOW_genericTypeParameterList_in_interfaceTypeDeclaration5417);
                        genericTypeParameterList68 = genericTypeParameterList();
                        state._fsp--;
                        if (state.failed) {
                            return retval;
                        }
                        if (state.backtracking == 0) {
                            stream_genericTypeParameterList.add(genericTypeParameterList68.getTree());
                        }
                    }
                    break;
            }
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:517:51: ( interfaceExtendsClause )?
            int alt24 = 2;
            int LA24_0 = input.LA(1);
            if ((LA24_0 == EXTENDS)) {
                alt24 = 1;
            }
            switch(alt24) {
                case 1:
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: interfaceExtendsClause
                    {
                        pushFollow(FOLLOW_interfaceExtendsClause_in_interfaceTypeDeclaration5420);
                        interfaceExtendsClause69 = interfaceExtendsClause();
                        state._fsp--;
                        if (state.failed) {
                            return retval;
                        }
                        if (state.backtracking == 0) {
                            stream_interfaceExtendsClause.add(interfaceExtendsClause69.getTree());
                        }
                    }
                    break;
            }
            pushFollow(FOLLOW_interfaceBody_in_interfaceTypeDeclaration5423);
            interfaceBody70 = interfaceBody();
            state._fsp--;
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_interfaceBody.add(interfaceBody70.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();
                // 518:9: -> ^( INTERFACE IDENT ( genericTypeParameterList )? ( interfaceExtendsClause )? interfaceBody )
                {
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:518:13: ^( INTERFACE IDENT ( genericTypeParameterList )? ( interfaceExtendsClause )? interfaceBody )
                    {
                        CommonTree root_1 = (CommonTree) adaptor.nil();
                        root_1 = (CommonTree) adaptor.becomeRoot(stream_INTERFACE.nextNode(), root_1);
                        adaptor.addChild(root_1, modifiers);
                        adaptor.addChild(root_1, stream_IDENT.nextNode());
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:518:44: ( genericTypeParameterList )?
                        if (stream_genericTypeParameterList.hasNext()) {
                            adaptor.addChild(root_1, stream_genericTypeParameterList.nextTree());
                        }
                        stream_genericTypeParameterList.reset();
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:518:70: ( interfaceExtendsClause )?
                        if (stream_interfaceExtendsClause.hasNext()) {
                            adaptor.addChild(root_1, stream_interfaceExtendsClause.nextTree());
                        }
                        stream_interfaceExtendsClause.reset();
                        adaptor.addChild(root_1, stream_interfaceBody.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, 21, interfaceTypeDeclaration_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 7 with RewriteRuleTokenStream

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

the class JavaParser method interfaceScopeDeclarations.

// $ANTLR start "interfaceScopeDeclarations"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:554:1: interfaceScopeDeclarations : ( modifierList ( ( genericTypeParameterList )? ( type IDENT formalParameterList ( arrayDeclaratorList )? ( throwsClause )? SEMI -> ^( FUNCTION_METHOD_DECL modifierList ( genericTypeParameterList )? type IDENT formalParameterList ( arrayDeclaratorList )? ( throwsClause )? ) | VOID IDENT formalParameterList ( throwsClause )? SEMI -> ^( VOID_METHOD_DECL modifierList ( genericTypeParameterList )? IDENT formalParameterList ( throwsClause )? ) ) | type interfaceFieldDeclaratorList SEMI -> ^( VAR_DECLARATION modifierList type interfaceFieldDeclaratorList ) ) | typeDeclaration | SEMI );
public final JavaParser.interfaceScopeDeclarations_return interfaceScopeDeclarations() throws RecognitionException {
    JavaParser.interfaceScopeDeclarations_return retval = new JavaParser.interfaceScopeDeclarations_return();
    retval.start = input.LT(1);
    int interfaceScopeDeclarations_StartIndex = input.index();
    CommonTree root_0 = null;
    Token IDENT109 = null;
    Token SEMI113 = null;
    Token VOID114 = null;
    Token IDENT115 = null;
    Token SEMI118 = null;
    Token SEMI121 = null;
    Token SEMI123 = null;
    JavaParser.modifierList_return modifierList106 = null;
    JavaParser.genericTypeParameterList_return genericTypeParameterList107 = null;
    JavaParser.type_return type108 = null;
    JavaParser.formalParameterList_return formalParameterList110 = null;
    JavaParser.arrayDeclaratorList_return arrayDeclaratorList111 = null;
    JavaParser.throwsClause_return throwsClause112 = null;
    JavaParser.formalParameterList_return formalParameterList116 = null;
    JavaParser.throwsClause_return throwsClause117 = null;
    JavaParser.type_return type119 = null;
    JavaParser.interfaceFieldDeclaratorList_return interfaceFieldDeclaratorList120 = null;
    JavaParser.typeDeclaration_return typeDeclaration122 = null;
    CommonTree IDENT109_tree = null;
    CommonTree SEMI113_tree = null;
    CommonTree VOID114_tree = null;
    CommonTree IDENT115_tree = null;
    CommonTree SEMI118_tree = null;
    CommonTree SEMI121_tree = null;
    CommonTree SEMI123_tree = null;
    RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
    RewriteRuleTokenStream stream_VOID = new RewriteRuleTokenStream(adaptor, "token VOID");
    RewriteRuleTokenStream stream_SEMI = new RewriteRuleTokenStream(adaptor, "token SEMI");
    RewriteRuleSubtreeStream stream_arrayDeclaratorList = new RewriteRuleSubtreeStream(adaptor, "rule arrayDeclaratorList");
    RewriteRuleSubtreeStream stream_throwsClause = new RewriteRuleSubtreeStream(adaptor, "rule throwsClause");
    RewriteRuleSubtreeStream stream_modifierList = new RewriteRuleSubtreeStream(adaptor, "rule modifierList");
    RewriteRuleSubtreeStream stream_genericTypeParameterList = new RewriteRuleSubtreeStream(adaptor, "rule genericTypeParameterList");
    RewriteRuleSubtreeStream stream_interfaceFieldDeclaratorList = new RewriteRuleSubtreeStream(adaptor, "rule interfaceFieldDeclaratorList");
    RewriteRuleSubtreeStream stream_type = new RewriteRuleSubtreeStream(adaptor, "rule type");
    RewriteRuleSubtreeStream stream_formalParameterList = new RewriteRuleSubtreeStream(adaptor, "rule formalParameterList");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 26)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:555:5: ( modifierList ( ( genericTypeParameterList )? ( type IDENT formalParameterList ( arrayDeclaratorList )? ( throwsClause )? SEMI -> ^( FUNCTION_METHOD_DECL modifierList ( genericTypeParameterList )? type IDENT formalParameterList ( arrayDeclaratorList )? ( throwsClause )? ) | VOID IDENT formalParameterList ( throwsClause )? SEMI -> ^( VOID_METHOD_DECL modifierList ( genericTypeParameterList )? IDENT formalParameterList ( throwsClause )? ) ) | type interfaceFieldDeclaratorList SEMI -> ^( VAR_DECLARATION modifierList type interfaceFieldDeclaratorList ) ) | typeDeclaration | SEMI )
        int alt44 = 3;
        alt44 = dfa44.predict(input);
        switch(alt44) {
            case 1:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:555:9: modifierList ( ( genericTypeParameterList )? ( type IDENT formalParameterList ( arrayDeclaratorList )? ( throwsClause )? SEMI -> ^( FUNCTION_METHOD_DECL modifierList ( genericTypeParameterList )? type IDENT formalParameterList ( arrayDeclaratorList )? ( throwsClause )? ) | VOID IDENT formalParameterList ( throwsClause )? SEMI -> ^( VOID_METHOD_DECL modifierList ( genericTypeParameterList )? IDENT formalParameterList ( throwsClause )? ) ) | type interfaceFieldDeclaratorList SEMI -> ^( VAR_DECLARATION modifierList type interfaceFieldDeclaratorList ) )
                {
                    pushFollow(FOLLOW_modifierList_in_interfaceScopeDeclarations5971);
                    modifierList106 = modifierList();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_modifierList.add(modifierList106.getTree());
                    }
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:556:9: ( ( genericTypeParameterList )? ( type IDENT formalParameterList ( arrayDeclaratorList )? ( throwsClause )? SEMI -> ^( FUNCTION_METHOD_DECL modifierList ( genericTypeParameterList )? type IDENT formalParameterList ( arrayDeclaratorList )? ( throwsClause )? ) | VOID IDENT formalParameterList ( throwsClause )? SEMI -> ^( VOID_METHOD_DECL modifierList ( genericTypeParameterList )? IDENT formalParameterList ( throwsClause )? ) ) | type interfaceFieldDeclaratorList SEMI -> ^( VAR_DECLARATION modifierList type interfaceFieldDeclaratorList ) )
                    int alt43 = 2;
                    switch(input.LA(1)) {
                        case LESS_THAN:
                        case VOID:
                            {
                                alt43 = 1;
                            }
                            break;
                        case BOOLEAN:
                        case BYTE:
                        case CHAR:
                        case DOUBLE:
                        case FLOAT:
                        case INT:
                        case LONG:
                        case SHORT:
                            {
                                int LA43_2 = input.LA(2);
                                if ((synpred51_Java())) {
                                    alt43 = 1;
                                } else if ((true)) {
                                    alt43 = 2;
                                } else {
                                    if (state.backtracking > 0) {
                                        state.failed = true;
                                        return retval;
                                    }
                                    NoViableAltException nvae = new NoViableAltException("", 43, 2, input);
                                    throw nvae;
                                }
                            }
                            break;
                        case IDENT:
                            {
                                int LA43_3 = input.LA(2);
                                if ((synpred51_Java())) {
                                    alt43 = 1;
                                } else if ((true)) {
                                    alt43 = 2;
                                } else {
                                    if (state.backtracking > 0) {
                                        state.failed = true;
                                        return retval;
                                    }
                                    NoViableAltException nvae = new NoViableAltException("", 43, 3, input);
                                    throw nvae;
                                }
                            }
                            break;
                        default:
                            if (state.backtracking > 0) {
                                state.failed = true;
                                return retval;
                            }
                            NoViableAltException nvae = new NoViableAltException("", 43, 0, input);
                            throw nvae;
                    }
                    switch(alt43) {
                        case 1:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:556:13: ( genericTypeParameterList )? ( type IDENT formalParameterList ( arrayDeclaratorList )? ( throwsClause )? SEMI -> ^( FUNCTION_METHOD_DECL modifierList ( genericTypeParameterList )? type IDENT formalParameterList ( arrayDeclaratorList )? ( throwsClause )? ) | VOID IDENT formalParameterList ( throwsClause )? SEMI -> ^( VOID_METHOD_DECL modifierList ( genericTypeParameterList )? IDENT formalParameterList ( throwsClause )? ) )
                            {
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:556:13: ( genericTypeParameterList )?
                                int alt38 = 2;
                                int LA38_0 = input.LA(1);
                                if ((LA38_0 == LESS_THAN)) {
                                    alt38 = 1;
                                }
                                switch(alt38) {
                                    case 1:
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: genericTypeParameterList
                                        {
                                            pushFollow(FOLLOW_genericTypeParameterList_in_interfaceScopeDeclarations5985);
                                            genericTypeParameterList107 = genericTypeParameterList();
                                            state._fsp--;
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_genericTypeParameterList.add(genericTypeParameterList107.getTree());
                                            }
                                        }
                                        break;
                                }
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:557:13: ( type IDENT formalParameterList ( arrayDeclaratorList )? ( throwsClause )? SEMI -> ^( FUNCTION_METHOD_DECL modifierList ( genericTypeParameterList )? type IDENT formalParameterList ( arrayDeclaratorList )? ( throwsClause )? ) | VOID IDENT formalParameterList ( throwsClause )? SEMI -> ^( VOID_METHOD_DECL modifierList ( genericTypeParameterList )? IDENT formalParameterList ( throwsClause )? ) )
                                int alt42 = 2;
                                int LA42_0 = input.LA(1);
                                if ((LA42_0 == BOOLEAN || LA42_0 == BYTE || LA42_0 == CHAR || LA42_0 == DOUBLE || LA42_0 == FLOAT || (LA42_0 >= INT && LA42_0 <= LONG) || LA42_0 == SHORT || LA42_0 == IDENT)) {
                                    alt42 = 1;
                                } else if ((LA42_0 == VOID)) {
                                    alt42 = 2;
                                } else {
                                    if (state.backtracking > 0) {
                                        state.failed = true;
                                        return retval;
                                    }
                                    NoViableAltException nvae = new NoViableAltException("", 42, 0, input);
                                    throw nvae;
                                }
                                switch(alt42) {
                                    case 1:
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:557:17: type IDENT formalParameterList ( arrayDeclaratorList )? ( throwsClause )? SEMI
                                        {
                                            pushFollow(FOLLOW_type_in_interfaceScopeDeclarations6004);
                                            type108 = type();
                                            state._fsp--;
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_type.add(type108.getTree());
                                            }
                                            IDENT109 = (Token) match(input, IDENT, FOLLOW_IDENT_in_interfaceScopeDeclarations6006);
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_IDENT.add(IDENT109);
                                            }
                                            pushFollow(FOLLOW_formalParameterList_in_interfaceScopeDeclarations6008);
                                            formalParameterList110 = formalParameterList();
                                            state._fsp--;
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_formalParameterList.add(formalParameterList110.getTree());
                                            }
                                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:557:48: ( arrayDeclaratorList )?
                                            int alt39 = 2;
                                            int LA39_0 = input.LA(1);
                                            if ((LA39_0 == LBRACK)) {
                                                alt39 = 1;
                                            }
                                            switch(alt39) {
                                                case 1:
                                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: arrayDeclaratorList
                                                    {
                                                        pushFollow(FOLLOW_arrayDeclaratorList_in_interfaceScopeDeclarations6010);
                                                        arrayDeclaratorList111 = arrayDeclaratorList();
                                                        state._fsp--;
                                                        if (state.failed) {
                                                            return retval;
                                                        }
                                                        if (state.backtracking == 0) {
                                                            stream_arrayDeclaratorList.add(arrayDeclaratorList111.getTree());
                                                        }
                                                    }
                                                    break;
                                            }
                                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:557:69: ( throwsClause )?
                                            int alt40 = 2;
                                            int LA40_0 = input.LA(1);
                                            if ((LA40_0 == THROWS)) {
                                                alt40 = 1;
                                            }
                                            switch(alt40) {
                                                case 1:
                                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: throwsClause
                                                    {
                                                        pushFollow(FOLLOW_throwsClause_in_interfaceScopeDeclarations6013);
                                                        throwsClause112 = throwsClause();
                                                        state._fsp--;
                                                        if (state.failed) {
                                                            return retval;
                                                        }
                                                        if (state.backtracking == 0) {
                                                            stream_throwsClause.add(throwsClause112.getTree());
                                                        }
                                                    }
                                                    break;
                                            }
                                            SEMI113 = (Token) match(input, SEMI, FOLLOW_SEMI_in_interfaceScopeDeclarations6016);
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_SEMI.add(SEMI113);
                                            }
                                            // 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();
                                                // 558:17: -> ^( FUNCTION_METHOD_DECL modifierList ( genericTypeParameterList )? type IDENT formalParameterList ( arrayDeclaratorList )? ( throwsClause )? )
                                                {
                                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:558:21: ^( FUNCTION_METHOD_DECL modifierList ( genericTypeParameterList )? type IDENT formalParameterList ( arrayDeclaratorList )? ( throwsClause )? )
                                                    {
                                                        CommonTree root_1 = (CommonTree) adaptor.nil();
                                                        root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(FUNCTION_METHOD_DECL, "FUNCTION_METHOD_DECL"), root_1);
                                                        adaptor.addChild(root_1, stream_modifierList.nextTree());
                                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:558:57: ( genericTypeParameterList )?
                                                        if (stream_genericTypeParameterList.hasNext()) {
                                                            adaptor.addChild(root_1, stream_genericTypeParameterList.nextTree());
                                                        }
                                                        stream_genericTypeParameterList.reset();
                                                        adaptor.addChild(root_1, stream_type.nextTree());
                                                        adaptor.addChild(root_1, stream_IDENT.nextNode());
                                                        adaptor.addChild(root_1, stream_formalParameterList.nextTree());
                                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:558:114: ( arrayDeclaratorList )?
                                                        if (stream_arrayDeclaratorList.hasNext()) {
                                                            adaptor.addChild(root_1, stream_arrayDeclaratorList.nextTree());
                                                        }
                                                        stream_arrayDeclaratorList.reset();
                                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:558:135: ( throwsClause )?
                                                        if (stream_throwsClause.hasNext()) {
                                                            adaptor.addChild(root_1, stream_throwsClause.nextTree());
                                                        }
                                                        stream_throwsClause.reset();
                                                        adaptor.addChild(root_0, root_1);
                                                    }
                                                }
                                                retval.tree = root_0;
                                            }
                                        }
                                        break;
                                    case 2:
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:559:17: VOID IDENT formalParameterList ( throwsClause )? SEMI
                                        {
                                            VOID114 = (Token) match(input, VOID, FOLLOW_VOID_in_interfaceScopeDeclarations6074);
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_VOID.add(VOID114);
                                            }
                                            IDENT115 = (Token) match(input, IDENT, FOLLOW_IDENT_in_interfaceScopeDeclarations6076);
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_IDENT.add(IDENT115);
                                            }
                                            pushFollow(FOLLOW_formalParameterList_in_interfaceScopeDeclarations6078);
                                            formalParameterList116 = formalParameterList();
                                            state._fsp--;
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_formalParameterList.add(formalParameterList116.getTree());
                                            }
                                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:559:48: ( throwsClause )?
                                            int alt41 = 2;
                                            int LA41_0 = input.LA(1);
                                            if ((LA41_0 == THROWS)) {
                                                alt41 = 1;
                                            }
                                            switch(alt41) {
                                                case 1:
                                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: throwsClause
                                                    {
                                                        pushFollow(FOLLOW_throwsClause_in_interfaceScopeDeclarations6080);
                                                        throwsClause117 = throwsClause();
                                                        state._fsp--;
                                                        if (state.failed) {
                                                            return retval;
                                                        }
                                                        if (state.backtracking == 0) {
                                                            stream_throwsClause.add(throwsClause117.getTree());
                                                        }
                                                    }
                                                    break;
                                            }
                                            SEMI118 = (Token) match(input, SEMI, FOLLOW_SEMI_in_interfaceScopeDeclarations6083);
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_SEMI.add(SEMI118);
                                            }
                                            // 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();
                                                // 560:17: -> ^( VOID_METHOD_DECL modifierList ( genericTypeParameterList )? IDENT formalParameterList ( throwsClause )? )
                                                {
                                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:560:21: ^( VOID_METHOD_DECL modifierList ( genericTypeParameterList )? IDENT formalParameterList ( throwsClause )? )
                                                    {
                                                        CommonTree root_1 = (CommonTree) adaptor.nil();
                                                        root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(VOID_METHOD_DECL, "VOID_METHOD_DECL"), root_1);
                                                        adaptor.addChild(root_1, stream_modifierList.nextTree());
                                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:560:53: ( genericTypeParameterList )?
                                                        if (stream_genericTypeParameterList.hasNext()) {
                                                            adaptor.addChild(root_1, stream_genericTypeParameterList.nextTree());
                                                        }
                                                        stream_genericTypeParameterList.reset();
                                                        adaptor.addChild(root_1, stream_IDENT.nextNode());
                                                        adaptor.addChild(root_1, stream_formalParameterList.nextTree());
                                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:560:105: ( throwsClause )?
                                                        if (stream_throwsClause.hasNext()) {
                                                            adaptor.addChild(root_1, stream_throwsClause.nextTree());
                                                        }
                                                        stream_throwsClause.reset();
                                                        adaptor.addChild(root_0, root_1);
                                                    }
                                                }
                                                retval.tree = root_0;
                                            }
                                        }
                                        break;
                                }
                            }
                            break;
                        case 2:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:562:13: type interfaceFieldDeclaratorList SEMI
                            {
                                pushFollow(FOLLOW_type_in_interfaceScopeDeclarations6146);
                                type119 = type();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_type.add(type119.getTree());
                                }
                                pushFollow(FOLLOW_interfaceFieldDeclaratorList_in_interfaceScopeDeclarations6148);
                                interfaceFieldDeclaratorList120 = interfaceFieldDeclaratorList();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_interfaceFieldDeclaratorList.add(interfaceFieldDeclaratorList120.getTree());
                                }
                                SEMI121 = (Token) match(input, SEMI, FOLLOW_SEMI_in_interfaceScopeDeclarations6150);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_SEMI.add(SEMI121);
                                }
                                // 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();
                                    // 563:13: -> ^( VAR_DECLARATION modifierList type interfaceFieldDeclaratorList )
                                    {
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:563:17: ^( VAR_DECLARATION modifierList type interfaceFieldDeclaratorList )
                                        {
                                            CommonTree root_1 = (CommonTree) adaptor.nil();
                                            root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(VAR_DECLARATION, "VAR_DECLARATION"), root_1);
                                            adaptor.addChild(root_1, stream_modifierList.nextTree());
                                            adaptor.addChild(root_1, stream_type.nextTree());
                                            adaptor.addChild(root_1, stream_interfaceFieldDeclaratorList.nextTree());
                                            adaptor.addChild(root_0, root_1);
                                        }
                                    }
                                    retval.tree = root_0;
                                }
                            }
                            break;
                    }
                }
                break;
            case 2:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:565:9: typeDeclaration
                {
                    root_0 = (CommonTree) adaptor.nil();
                    pushFollow(FOLLOW_typeDeclaration_in_interfaceScopeDeclarations6195);
                    typeDeclaration122 = typeDeclaration();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        adaptor.addChild(root_0, typeDeclaration122.getTree());
                    }
                }
                break;
            case 3:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:566:9: SEMI
                {
                    root_0 = (CommonTree) adaptor.nil();
                    SEMI123 = (Token) match(input, SEMI, FOLLOW_SEMI_in_interfaceScopeDeclarations6205);
                    if (state.failed) {
                        return retval;
                    }
                }
                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, 26, interfaceScopeDeclarations_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 8 with RewriteRuleTokenStream

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

the class JavaParser method formalParameterList.

// $ANTLR start "formalParameterList"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:725:1: formalParameterList : LPAREN ( formalParameterStandardDecl ( COMMA formalParameterStandardDecl )* ( COMMA formalParameterVarArgDecl )? -> ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] ( formalParameterStandardDecl )+ ( formalParameterVarArgDecl )? ) | formalParameterVarArgDecl -> ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] formalParameterVarArgDecl ) | -> ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] ) ) RPAREN ;
public final JavaParser.formalParameterList_return formalParameterList() throws RecognitionException {
    JavaParser.formalParameterList_return retval = new JavaParser.formalParameterList_return();
    retval.start = input.LT(1);
    int formalParameterList_StartIndex = input.index();
    CommonTree root_0 = null;
    Token LPAREN205 = null;
    Token COMMA207 = null;
    Token COMMA209 = null;
    Token RPAREN212 = null;
    JavaParser.formalParameterStandardDecl_return formalParameterStandardDecl206 = null;
    JavaParser.formalParameterStandardDecl_return formalParameterStandardDecl208 = null;
    JavaParser.formalParameterVarArgDecl_return formalParameterVarArgDecl210 = null;
    JavaParser.formalParameterVarArgDecl_return formalParameterVarArgDecl211 = null;
    CommonTree LPAREN205_tree = null;
    CommonTree COMMA207_tree = null;
    CommonTree COMMA209_tree = null;
    CommonTree RPAREN212_tree = null;
    RewriteRuleTokenStream stream_RPAREN = new RewriteRuleTokenStream(adaptor, "token RPAREN");
    RewriteRuleTokenStream stream_COMMA = new RewriteRuleTokenStream(adaptor, "token COMMA");
    RewriteRuleTokenStream stream_LPAREN = new RewriteRuleTokenStream(adaptor, "token LPAREN");
    RewriteRuleSubtreeStream stream_formalParameterVarArgDecl = new RewriteRuleSubtreeStream(adaptor, "rule formalParameterVarArgDecl");
    RewriteRuleSubtreeStream stream_formalParameterStandardDecl = new RewriteRuleSubtreeStream(adaptor, "rule formalParameterStandardDecl");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 56)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:726:5: ( LPAREN ( formalParameterStandardDecl ( COMMA formalParameterStandardDecl )* ( COMMA formalParameterVarArgDecl )? -> ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] ( formalParameterStandardDecl )+ ( formalParameterVarArgDecl )? ) | formalParameterVarArgDecl -> ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] formalParameterVarArgDecl ) | -> ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] ) ) RPAREN )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:726:9: LPAREN ( formalParameterStandardDecl ( COMMA formalParameterStandardDecl )* ( COMMA formalParameterVarArgDecl )? -> ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] ( formalParameterStandardDecl )+ ( formalParameterVarArgDecl )? ) | formalParameterVarArgDecl -> ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] formalParameterVarArgDecl ) | -> ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] ) ) RPAREN
        {
            LPAREN205 = (Token) match(input, LPAREN, FOLLOW_LPAREN_in_formalParameterList7456);
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_LPAREN.add(LPAREN205);
            }
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:727:9: ( formalParameterStandardDecl ( COMMA formalParameterStandardDecl )* ( COMMA formalParameterVarArgDecl )? -> ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] ( formalParameterStandardDecl )+ ( formalParameterVarArgDecl )? ) | formalParameterVarArgDecl -> ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] formalParameterVarArgDecl ) | -> ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] ) )
            int alt74 = 3;
            switch(input.LA(1)) {
                case FINAL:
                    {
                        int LA74_1 = input.LA(2);
                        if ((synpred100_Java())) {
                            alt74 = 1;
                        } else if ((synpred101_Java())) {
                            alt74 = 2;
                        } else {
                            if (state.backtracking > 0) {
                                state.failed = true;
                                return retval;
                            }
                            NoViableAltException nvae = new NoViableAltException("", 74, 1, input);
                            throw nvae;
                        }
                    }
                    break;
                case AT:
                    {
                        int LA74_2 = input.LA(2);
                        if ((synpred100_Java())) {
                            alt74 = 1;
                        } else if ((synpred101_Java())) {
                            alt74 = 2;
                        } else {
                            if (state.backtracking > 0) {
                                state.failed = true;
                                return retval;
                            }
                            NoViableAltException nvae = new NoViableAltException("", 74, 2, input);
                            throw nvae;
                        }
                    }
                    break;
                case BOOLEAN:
                case BYTE:
                case CHAR:
                case DOUBLE:
                case FLOAT:
                case INT:
                case LONG:
                case SHORT:
                    {
                        int LA74_3 = input.LA(2);
                        if ((synpred100_Java())) {
                            alt74 = 1;
                        } else if ((synpred101_Java())) {
                            alt74 = 2;
                        } else {
                            if (state.backtracking > 0) {
                                state.failed = true;
                                return retval;
                            }
                            NoViableAltException nvae = new NoViableAltException("", 74, 3, input);
                            throw nvae;
                        }
                    }
                    break;
                case IDENT:
                    {
                        int LA74_4 = input.LA(2);
                        if ((synpred100_Java())) {
                            alt74 = 1;
                        } else if ((synpred101_Java())) {
                            alt74 = 2;
                        } else {
                            if (state.backtracking > 0) {
                                state.failed = true;
                                return retval;
                            }
                            NoViableAltException nvae = new NoViableAltException("", 74, 4, input);
                            throw nvae;
                        }
                    }
                    break;
                case RPAREN:
                    {
                        alt74 = 3;
                    }
                    break;
                default:
                    if (state.backtracking > 0) {
                        state.failed = true;
                        return retval;
                    }
                    NoViableAltException nvae = new NoViableAltException("", 74, 0, input);
                    throw nvae;
            }
            switch(alt74) {
                case 1:
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:728:13: formalParameterStandardDecl ( COMMA formalParameterStandardDecl )* ( COMMA formalParameterVarArgDecl )?
                    {
                        pushFollow(FOLLOW_formalParameterStandardDecl_in_formalParameterList7483);
                        formalParameterStandardDecl206 = formalParameterStandardDecl();
                        state._fsp--;
                        if (state.failed) {
                            return retval;
                        }
                        if (state.backtracking == 0) {
                            stream_formalParameterStandardDecl.add(formalParameterStandardDecl206.getTree());
                        }
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:728:41: ( COMMA formalParameterStandardDecl )*
                        loop72: do {
                            int alt72 = 2;
                            int LA72_0 = input.LA(1);
                            if ((LA72_0 == COMMA)) {
                                int LA72_1 = input.LA(2);
                                if ((synpred98_Java())) {
                                    alt72 = 1;
                                }
                            }
                            switch(alt72) {
                                case 1:
                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:728:42: COMMA formalParameterStandardDecl
                                    {
                                        COMMA207 = (Token) match(input, COMMA, FOLLOW_COMMA_in_formalParameterList7486);
                                        if (state.failed) {
                                            return retval;
                                        }
                                        if (state.backtracking == 0) {
                                            stream_COMMA.add(COMMA207);
                                        }
                                        pushFollow(FOLLOW_formalParameterStandardDecl_in_formalParameterList7488);
                                        formalParameterStandardDecl208 = formalParameterStandardDecl();
                                        state._fsp--;
                                        if (state.failed) {
                                            return retval;
                                        }
                                        if (state.backtracking == 0) {
                                            stream_formalParameterStandardDecl.add(formalParameterStandardDecl208.getTree());
                                        }
                                    }
                                    break;
                                default:
                                    break loop72;
                            }
                        } while (true);
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:728:78: ( COMMA formalParameterVarArgDecl )?
                        int alt73 = 2;
                        int LA73_0 = input.LA(1);
                        if ((LA73_0 == COMMA)) {
                            alt73 = 1;
                        }
                        switch(alt73) {
                            case 1:
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:728:79: COMMA formalParameterVarArgDecl
                                {
                                    COMMA209 = (Token) match(input, COMMA, FOLLOW_COMMA_in_formalParameterList7493);
                                    if (state.failed) {
                                        return retval;
                                    }
                                    if (state.backtracking == 0) {
                                        stream_COMMA.add(COMMA209);
                                    }
                                    pushFollow(FOLLOW_formalParameterVarArgDecl_in_formalParameterList7495);
                                    formalParameterVarArgDecl210 = formalParameterVarArgDecl();
                                    state._fsp--;
                                    if (state.failed) {
                                        return retval;
                                    }
                                    if (state.backtracking == 0) {
                                        stream_formalParameterVarArgDecl.add(formalParameterVarArgDecl210.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();
                            // 729:13: -> ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] ( formalParameterStandardDecl )+ ( formalParameterVarArgDecl )? )
                            {
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:729:17: ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] ( formalParameterStandardDecl )+ ( formalParameterVarArgDecl )? )
                                {
                                    CommonTree root_1 = (CommonTree) adaptor.nil();
                                    root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(FORMAL_PARAM_LIST, LPAREN205, "FORMAL_PARAM_LIST"), root_1);
                                    if (!(stream_formalParameterStandardDecl.hasNext())) {
                                        throw new RewriteEarlyExitException();
                                    }
                                    while (stream_formalParameterStandardDecl.hasNext()) {
                                        adaptor.addChild(root_1, stream_formalParameterStandardDecl.nextTree());
                                    }
                                    stream_formalParameterStandardDecl.reset();
                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:729:96: ( formalParameterVarArgDecl )?
                                    if (stream_formalParameterVarArgDecl.hasNext()) {
                                        adaptor.addChild(root_1, stream_formalParameterVarArgDecl.nextTree());
                                    }
                                    stream_formalParameterVarArgDecl.reset();
                                    adaptor.addChild(root_0, root_1);
                                }
                            }
                            retval.tree = root_0;
                        }
                    }
                    break;
                case 2:
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:731:13: formalParameterVarArgDecl
                    {
                        pushFollow(FOLLOW_formalParameterVarArgDecl_in_formalParameterList7550);
                        formalParameterVarArgDecl211 = formalParameterVarArgDecl();
                        state._fsp--;
                        if (state.failed) {
                            return retval;
                        }
                        if (state.backtracking == 0) {
                            stream_formalParameterVarArgDecl.add(formalParameterVarArgDecl211.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();
                            // 732:13: -> ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] formalParameterVarArgDecl )
                            {
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:732:17: ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] formalParameterVarArgDecl )
                                {
                                    CommonTree root_1 = (CommonTree) adaptor.nil();
                                    root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(FORMAL_PARAM_LIST, LPAREN205, "FORMAL_PARAM_LIST"), root_1);
                                    adaptor.addChild(root_1, stream_formalParameterVarArgDecl.nextTree());
                                    adaptor.addChild(root_0, root_1);
                                }
                            }
                            retval.tree = root_0;
                        }
                    }
                    break;
                case 3:
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:734:13:
                    {
                        // 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();
                            // 734:13: -> ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] )
                            {
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:734:17: ^( FORMAL_PARAM_LIST[$LPAREN, \"FORMAL_PARAM_LIST\"] )
                                {
                                    CommonTree root_1 = (CommonTree) adaptor.nil();
                                    root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(FORMAL_PARAM_LIST, LPAREN205, "FORMAL_PARAM_LIST"), root_1);
                                    adaptor.addChild(root_0, root_1);
                                }
                            }
                            retval.tree = root_0;
                        }
                    }
                    break;
            }
            RPAREN212 = (Token) match(input, RPAREN, FOLLOW_RPAREN_in_formalParameterList7625);
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_RPAREN.add(RPAREN212);
            }
        }
        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, 56, formalParameterList_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)

Example 9 with RewriteRuleTokenStream

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

the class JavaParser method interfaceFieldDeclarator.

// $ANTLR start "interfaceFieldDeclarator"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:584:1: interfaceFieldDeclarator : variableDeclaratorId ASSIGN variableInitializer -> ^( VAR_DECLARATOR variableDeclaratorId variableInitializer ) ;
public final JavaParser.interfaceFieldDeclarator_return interfaceFieldDeclarator() throws RecognitionException {
    JavaParser.interfaceFieldDeclarator_return retval = new JavaParser.interfaceFieldDeclarator_return();
    retval.start = input.LT(1);
    int interfaceFieldDeclarator_StartIndex = input.index();
    CommonTree root_0 = null;
    Token ASSIGN134 = null;
    JavaParser.variableDeclaratorId_return variableDeclaratorId133 = null;
    JavaParser.variableInitializer_return variableInitializer135 = null;
    CommonTree ASSIGN134_tree = null;
    RewriteRuleTokenStream stream_ASSIGN = new RewriteRuleTokenStream(adaptor, "token ASSIGN");
    RewriteRuleSubtreeStream stream_variableDeclaratorId = new RewriteRuleSubtreeStream(adaptor, "rule variableDeclaratorId");
    RewriteRuleSubtreeStream stream_variableInitializer = new RewriteRuleSubtreeStream(adaptor, "rule variableInitializer");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 30)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:585:5: ( variableDeclaratorId ASSIGN variableInitializer -> ^( VAR_DECLARATOR variableDeclaratorId variableInitializer ) )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:585:9: variableDeclaratorId ASSIGN variableInitializer
        {
            pushFollow(FOLLOW_variableDeclaratorId_in_interfaceFieldDeclarator6359);
            variableDeclaratorId133 = variableDeclaratorId();
            state._fsp--;
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_variableDeclaratorId.add(variableDeclaratorId133.getTree());
            }
            ASSIGN134 = (Token) match(input, ASSIGN, FOLLOW_ASSIGN_in_interfaceFieldDeclarator6361);
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_ASSIGN.add(ASSIGN134);
            }
            pushFollow(FOLLOW_variableInitializer_in_interfaceFieldDeclarator6363);
            variableInitializer135 = variableInitializer();
            state._fsp--;
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_variableInitializer.add(variableInitializer135.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();
                // 586:9: -> ^( VAR_DECLARATOR variableDeclaratorId variableInitializer )
                {
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:586:13: ^( VAR_DECLARATOR variableDeclaratorId variableInitializer )
                    {
                        CommonTree root_1 = (CommonTree) adaptor.nil();
                        root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(VAR_DECLARATOR, "VAR_DECLARATOR"), root_1);
                        adaptor.addChild(root_1, stream_variableDeclaratorId.nextTree());
                        adaptor.addChild(root_1, stream_variableInitializer.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, 30, interfaceFieldDeclarator_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 10 with RewriteRuleTokenStream

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

the class JavaParser method formalParameterVarArgDecl.

// $ANTLR start "formalParameterVarArgDecl"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:744:1: formalParameterVarArgDecl : localModifierList type ELLIPSIS variableDeclaratorId -> ^( FORMAL_PARAM_VARARG_DECL localModifierList type variableDeclaratorId ) ;
public final JavaParser.formalParameterVarArgDecl_return formalParameterVarArgDecl() throws RecognitionException {
    JavaParser.formalParameterVarArgDecl_return retval = new JavaParser.formalParameterVarArgDecl_return();
    retval.start = input.LT(1);
    int formalParameterVarArgDecl_StartIndex = input.index();
    CommonTree root_0 = null;
    Token ELLIPSIS218 = null;
    JavaParser.localModifierList_return localModifierList216 = null;
    JavaParser.type_return type217 = null;
    JavaParser.variableDeclaratorId_return variableDeclaratorId219 = null;
    CommonTree ELLIPSIS218_tree = null;
    RewriteRuleTokenStream stream_ELLIPSIS = new RewriteRuleTokenStream(adaptor, "token ELLIPSIS");
    RewriteRuleSubtreeStream stream_variableDeclaratorId = new RewriteRuleSubtreeStream(adaptor, "rule variableDeclaratorId");
    RewriteRuleSubtreeStream stream_localModifierList = new RewriteRuleSubtreeStream(adaptor, "rule localModifierList");
    RewriteRuleSubtreeStream stream_type = new RewriteRuleSubtreeStream(adaptor, "rule type");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 58)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:745:5: ( localModifierList type ELLIPSIS variableDeclaratorId -> ^( FORMAL_PARAM_VARARG_DECL localModifierList type variableDeclaratorId ) )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:745:9: localModifierList type ELLIPSIS variableDeclaratorId
        {
            pushFollow(FOLLOW_localModifierList_in_formalParameterVarArgDecl7688);
            localModifierList216 = localModifierList();
            state._fsp--;
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_localModifierList.add(localModifierList216.getTree());
            }
            pushFollow(FOLLOW_type_in_formalParameterVarArgDecl7690);
            type217 = type();
            state._fsp--;
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_type.add(type217.getTree());
            }
            ELLIPSIS218 = (Token) match(input, ELLIPSIS, FOLLOW_ELLIPSIS_in_formalParameterVarArgDecl7692);
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_ELLIPSIS.add(ELLIPSIS218);
            }
            pushFollow(FOLLOW_variableDeclaratorId_in_formalParameterVarArgDecl7694);
            variableDeclaratorId219 = variableDeclaratorId();
            state._fsp--;
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_variableDeclaratorId.add(variableDeclaratorId219.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();
                // 746:9: -> ^( FORMAL_PARAM_VARARG_DECL localModifierList type variableDeclaratorId )
                {
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:746:13: ^( FORMAL_PARAM_VARARG_DECL localModifierList type variableDeclaratorId )
                    {
                        CommonTree root_1 = (CommonTree) adaptor.nil();
                        root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(FORMAL_PARAM_VARARG_DECL, "FORMAL_PARAM_VARARG_DECL"), root_1);
                        adaptor.addChild(root_1, stream_localModifierList.nextTree());
                        adaptor.addChild(root_1, stream_type.nextTree());
                        adaptor.addChild(root_1, stream_variableDeclaratorId.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, 58, formalParameterVarArgDecl_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)

Aggregations

RecognitionException (org.antlr.runtime.RecognitionException)74 Token (org.antlr.runtime.Token)74 RewriteRuleSubtreeStream (org.antlr.runtime.tree.RewriteRuleSubtreeStream)74 RewriteRuleTokenStream (org.antlr.runtime.tree.RewriteRuleTokenStream)74 CommonTree (org.antlr.runtime.tree.CommonTree)62 NoViableAltException (org.antlr.runtime.NoViableAltException)22 RewriteEarlyExitException (org.antlr.runtime.tree.RewriteEarlyExitException)12 CommonToken (org.antlr.runtime.CommonToken)9 FailedPredicateException (org.antlr.runtime.FailedPredicateException)4 ParserRuleReturnScope (org.antlr.runtime.ParserRuleReturnScope)4 EarlyExitException (org.antlr.runtime.EarlyExitException)1 RewriteEmptyStreamException (org.antlr.runtime.tree.RewriteEmptyStreamException)1