Search in sources :

Example 11 with RewriteRuleSubtreeStream

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

the class JavaParser method localModifierList.

// $ANTLR start "localModifierList"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:637:1: localModifierList : ( localModifier )* -> ^( LOCAL_MODIFIER_LIST ( localModifier )* ) ;
public final JavaParser.localModifierList_return localModifierList() throws RecognitionException {
    JavaParser.localModifierList_return retval = new JavaParser.localModifierList_return();
    retval.start = input.LT(1);
    int localModifierList_StartIndex = input.index();
    CommonTree root_0 = null;
    JavaParser.localModifier_return localModifier163 = null;
    RewriteRuleSubtreeStream stream_localModifier = new RewriteRuleSubtreeStream(adaptor, "rule localModifier");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 39)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:638:5: ( ( localModifier )* -> ^( LOCAL_MODIFIER_LIST ( localModifier )* ) )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:638:9: ( localModifier )*
        {
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:638:9: ( localModifier )*
            loop56: do {
                int alt56 = 2;
                int LA56_0 = input.LA(1);
                if ((LA56_0 == AT || LA56_0 == FINAL)) {
                    alt56 = 1;
                }
                switch(alt56) {
                    case 1:
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: localModifier
                        {
                            pushFollow(FOLLOW_localModifier_in_localModifierList6778);
                            localModifier163 = localModifier();
                            state._fsp--;
                            if (state.failed) {
                                return retval;
                            }
                            if (state.backtracking == 0) {
                                stream_localModifier.add(localModifier163.getTree());
                            }
                        }
                        break;
                    default:
                        break loop56;
                }
            } 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();
                // 639:9: -> ^( LOCAL_MODIFIER_LIST ( localModifier )* )
                {
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:639:12: ^( LOCAL_MODIFIER_LIST ( localModifier )* )
                    {
                        CommonTree root_1 = (CommonTree) adaptor.nil();
                        root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(LOCAL_MODIFIER_LIST, "LOCAL_MODIFIER_LIST"), root_1);
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:639:34: ( localModifier )*
                        while (stream_localModifier.hasNext()) {
                            adaptor.addChild(root_1, stream_localModifier.nextTree());
                        }
                        stream_localModifier.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, 39, localModifierList_StartIndex);
        }
    }
    return retval;
}
Also used : CommonTree(org.antlr.runtime.tree.CommonTree) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) RecognitionException(org.antlr.runtime.RecognitionException)

Example 12 with RewriteRuleSubtreeStream

use of org.antlr.runtime.tree.RewriteRuleSubtreeStream 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 13 with RewriteRuleSubtreeStream

use of org.antlr.runtime.tree.RewriteRuleSubtreeStream 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)

Example 14 with RewriteRuleSubtreeStream

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

the class JavaParser method annotationScopeDeclarations.

// $ANTLR start "annotationScopeDeclarations"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:809:1: annotationScopeDeclarations : ( modifierList type ( IDENT LPAREN RPAREN ( annotationDefaultValue )? SEMI -> ^( ANNOTATION_METHOD_DECL modifierList type IDENT ( annotationDefaultValue )? ) | classFieldDeclaratorList SEMI -> ^( VAR_DECLARATION modifierList type classFieldDeclaratorList ) ) | typeDeclaration );
public final JavaParser.annotationScopeDeclarations_return annotationScopeDeclarations() throws RecognitionException {
    JavaParser.annotationScopeDeclarations_return retval = new JavaParser.annotationScopeDeclarations_return();
    retval.start = input.LT(1);
    int annotationScopeDeclarations_StartIndex = input.index();
    CommonTree root_0 = null;
    Token IDENT255 = null;
    Token LPAREN256 = null;
    Token RPAREN257 = null;
    Token SEMI259 = null;
    Token SEMI261 = null;
    JavaParser.modifierList_return modifierList253 = null;
    JavaParser.type_return type254 = null;
    JavaParser.annotationDefaultValue_return annotationDefaultValue258 = null;
    JavaParser.classFieldDeclaratorList_return classFieldDeclaratorList260 = null;
    JavaParser.typeDeclaration_return typeDeclaration262 = null;
    CommonTree IDENT255_tree = null;
    CommonTree LPAREN256_tree = null;
    CommonTree RPAREN257_tree = null;
    CommonTree SEMI259_tree = null;
    CommonTree SEMI261_tree = null;
    RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
    RewriteRuleTokenStream stream_RPAREN = new RewriteRuleTokenStream(adaptor, "token RPAREN");
    RewriteRuleTokenStream stream_SEMI = new RewriteRuleTokenStream(adaptor, "token SEMI");
    RewriteRuleTokenStream stream_LPAREN = new RewriteRuleTokenStream(adaptor, "token LPAREN");
    RewriteRuleSubtreeStream stream_modifierList = new RewriteRuleSubtreeStream(adaptor, "rule modifierList");
    RewriteRuleSubtreeStream stream_annotationDefaultValue = new RewriteRuleSubtreeStream(adaptor, "rule annotationDefaultValue");
    RewriteRuleSubtreeStream stream_type = new RewriteRuleSubtreeStream(adaptor, "rule type");
    RewriteRuleSubtreeStream stream_classFieldDeclaratorList = new RewriteRuleSubtreeStream(adaptor, "rule classFieldDeclaratorList");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 70)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:810:5: ( modifierList type ( IDENT LPAREN RPAREN ( annotationDefaultValue )? SEMI -> ^( ANNOTATION_METHOD_DECL modifierList type IDENT ( annotationDefaultValue )? ) | classFieldDeclaratorList SEMI -> ^( VAR_DECLARATION modifierList type classFieldDeclaratorList ) ) | typeDeclaration )
        int alt87 = 2;
        alt87 = dfa87.predict(input);
        switch(alt87) {
            case 1:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:810:9: modifierList type ( IDENT LPAREN RPAREN ( annotationDefaultValue )? SEMI -> ^( ANNOTATION_METHOD_DECL modifierList type IDENT ( annotationDefaultValue )? ) | classFieldDeclaratorList SEMI -> ^( VAR_DECLARATION modifierList type classFieldDeclaratorList ) )
                {
                    pushFollow(FOLLOW_modifierList_in_annotationScopeDeclarations8256);
                    modifierList253 = modifierList();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_modifierList.add(modifierList253.getTree());
                    }
                    pushFollow(FOLLOW_type_in_annotationScopeDeclarations8258);
                    type254 = type();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_type.add(type254.getTree());
                    }
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:811:9: ( IDENT LPAREN RPAREN ( annotationDefaultValue )? SEMI -> ^( ANNOTATION_METHOD_DECL modifierList type IDENT ( annotationDefaultValue )? ) | classFieldDeclaratorList SEMI -> ^( VAR_DECLARATION modifierList type classFieldDeclaratorList ) )
                    int alt86 = 2;
                    int LA86_0 = input.LA(1);
                    if ((LA86_0 == IDENT)) {
                        int LA86_1 = input.LA(2);
                        if ((LA86_1 == LPAREN)) {
                            alt86 = 1;
                        } else if ((LA86_1 == ASSIGN || LA86_1 == COMMA || LA86_1 == LBRACK || LA86_1 == SEMI)) {
                            alt86 = 2;
                        } else {
                            if (state.backtracking > 0) {
                                state.failed = true;
                                return retval;
                            }
                            NoViableAltException nvae = new NoViableAltException("", 86, 1, input);
                            throw nvae;
                        }
                    } else {
                        if (state.backtracking > 0) {
                            state.failed = true;
                            return retval;
                        }
                        NoViableAltException nvae = new NoViableAltException("", 86, 0, input);
                        throw nvae;
                    }
                    switch(alt86) {
                        case 1:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:811:13: IDENT LPAREN RPAREN ( annotationDefaultValue )? SEMI
                            {
                                IDENT255 = (Token) match(input, IDENT, FOLLOW_IDENT_in_annotationScopeDeclarations8272);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_IDENT.add(IDENT255);
                                }
                                LPAREN256 = (Token) match(input, LPAREN, FOLLOW_LPAREN_in_annotationScopeDeclarations8274);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_LPAREN.add(LPAREN256);
                                }
                                RPAREN257 = (Token) match(input, RPAREN, FOLLOW_RPAREN_in_annotationScopeDeclarations8276);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_RPAREN.add(RPAREN257);
                                }
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:811:33: ( annotationDefaultValue )?
                                int alt85 = 2;
                                int LA85_0 = input.LA(1);
                                if ((LA85_0 == DEFAULT)) {
                                    alt85 = 1;
                                }
                                switch(alt85) {
                                    case 1:
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: annotationDefaultValue
                                        {
                                            pushFollow(FOLLOW_annotationDefaultValue_in_annotationScopeDeclarations8278);
                                            annotationDefaultValue258 = annotationDefaultValue();
                                            state._fsp--;
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_annotationDefaultValue.add(annotationDefaultValue258.getTree());
                                            }
                                        }
                                        break;
                                }
                                SEMI259 = (Token) match(input, SEMI, FOLLOW_SEMI_in_annotationScopeDeclarations8281);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_SEMI.add(SEMI259);
                                }
                                // 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();
                                    // 812:13: -> ^( ANNOTATION_METHOD_DECL modifierList type IDENT ( annotationDefaultValue )? )
                                    {
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:812:17: ^( ANNOTATION_METHOD_DECL modifierList type IDENT ( annotationDefaultValue )? )
                                        {
                                            CommonTree root_1 = (CommonTree) adaptor.nil();
                                            root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(ANNOTATION_METHOD_DECL, "ANNOTATION_METHOD_DECL"), root_1);
                                            adaptor.addChild(root_1, stream_modifierList.nextTree());
                                            adaptor.addChild(root_1, stream_type.nextTree());
                                            adaptor.addChild(root_1, stream_IDENT.nextNode());
                                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:812:66: ( annotationDefaultValue )?
                                            if (stream_annotationDefaultValue.hasNext()) {
                                                adaptor.addChild(root_1, stream_annotationDefaultValue.nextTree());
                                            }
                                            stream_annotationDefaultValue.reset();
                                            adaptor.addChild(root_0, root_1);
                                        }
                                    }
                                    retval.tree = root_0;
                                }
                            }
                            break;
                        case 2:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:813:13: classFieldDeclaratorList SEMI
                            {
                                pushFollow(FOLLOW_classFieldDeclaratorList_in_annotationScopeDeclarations8323);
                                classFieldDeclaratorList260 = classFieldDeclaratorList();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_classFieldDeclaratorList.add(classFieldDeclaratorList260.getTree());
                                }
                                SEMI261 = (Token) match(input, SEMI, FOLLOW_SEMI_in_annotationScopeDeclarations8325);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_SEMI.add(SEMI261);
                                }
                                // 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();
                                    // 814:13: -> ^( VAR_DECLARATION modifierList type classFieldDeclaratorList )
                                    {
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:814:17: ^( VAR_DECLARATION modifierList type classFieldDeclaratorList )
                                        {
                                            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_classFieldDeclaratorList.nextTree());
                                            adaptor.addChild(root_0, root_1);
                                        }
                                    }
                                    retval.tree = root_0;
                                }
                            }
                            break;
                    }
                }
                break;
            case 2:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:816:9: typeDeclaration
                {
                    root_0 = (CommonTree) adaptor.nil();
                    pushFollow(FOLLOW_typeDeclaration_in_annotationScopeDeclarations8370);
                    typeDeclaration262 = typeDeclaration();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        adaptor.addChild(root_0, typeDeclaration262.getTree());
                    }
                }
                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, 70, annotationScopeDeclarations_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 15 with RewriteRuleSubtreeStream

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

the class JavaParser method annotationList.

// $ANTLR start "annotationList"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:758:1: annotationList : ( annotation )* -> ^( ANNOTATION_LIST ( annotation )* ) ;
public final JavaParser.annotationList_return annotationList() throws RecognitionException {
    JavaParser.annotationList_return retval = new JavaParser.annotationList_return();
    retval.start = input.LT(1);
    int annotationList_StartIndex = input.index();
    CommonTree root_0 = null;
    JavaParser.annotation_return annotation222 = null;
    RewriteRuleSubtreeStream stream_annotation = new RewriteRuleSubtreeStream(adaptor, "rule annotation");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 60)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:759:5: ( ( annotation )* -> ^( ANNOTATION_LIST ( annotation )* ) )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:759:9: ( annotation )*
        {
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:759:9: ( annotation )*
            loop76: do {
                int alt76 = 2;
                int LA76_0 = input.LA(1);
                if ((LA76_0 == AT)) {
                    int LA76_2 = input.LA(2);
                    if ((LA76_2 == IDENT)) {
                        int LA76_3 = input.LA(3);
                        if ((synpred103_Java())) {
                            alt76 = 1;
                        }
                    }
                }
                switch(alt76) {
                    case 1:
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: annotation
                        {
                            pushFollow(FOLLOW_annotation_in_annotationList7834);
                            annotation222 = annotation();
                            state._fsp--;
                            if (state.failed) {
                                return retval;
                            }
                            if (state.backtracking == 0) {
                                stream_annotation.add(annotation222.getTree());
                            }
                        }
                        break;
                    default:
                        break loop76;
                }
            } 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();
                // 760:9: -> ^( ANNOTATION_LIST ( annotation )* )
                {
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:760:13: ^( ANNOTATION_LIST ( annotation )* )
                    {
                        CommonTree root_1 = (CommonTree) adaptor.nil();
                        root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(ANNOTATION_LIST, "ANNOTATION_LIST"), root_1);
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:760:31: ( annotation )*
                        while (stream_annotation.hasNext()) {
                            adaptor.addChild(root_1, stream_annotation.nextTree());
                        }
                        stream_annotation.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, 60, annotationList_StartIndex);
        }
    }
    return retval;
}
Also used : CommonTree(org.antlr.runtime.tree.CommonTree) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) RecognitionException(org.antlr.runtime.RecognitionException)

Aggregations

RecognitionException (org.antlr.runtime.RecognitionException)98 RewriteRuleSubtreeStream (org.antlr.runtime.tree.RewriteRuleSubtreeStream)98 CommonTree (org.antlr.runtime.tree.CommonTree)81 Token (org.antlr.runtime.Token)74 RewriteRuleTokenStream (org.antlr.runtime.tree.RewriteRuleTokenStream)74 NoViableAltException (org.antlr.runtime.NoViableAltException)24 RewriteEarlyExitException (org.antlr.runtime.tree.RewriteEarlyExitException)16 CommonToken (org.antlr.runtime.CommonToken)9 ParserRuleReturnScope (org.antlr.runtime.ParserRuleReturnScope)9 EarlyExitException (org.antlr.runtime.EarlyExitException)5 FailedPredicateException (org.antlr.runtime.FailedPredicateException)4 RewriteEmptyStreamException (org.antlr.runtime.tree.RewriteEmptyStreamException)1