Search in sources :

Example 1 with RewriteEarlyExitException

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

the class JavaParser method classFieldDeclaratorList.

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

Example 2 with RewriteEarlyExitException

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

the class JavaParser method annotationInitializers.

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

Example 3 with RewriteEarlyExitException

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

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

the class CssParser method properties.

// $ANTLR start "properties"
// /home/langera/dev/freud/src/grammar/Css.g:77:1: properties : declaration ( ';' ( declaration )? )* -> ( declaration )+ ;
public final CssParser.properties_return properties() throws RecognitionException {
    CssParser.properties_return retval = new CssParser.properties_return();
    retval.start = input.LT(1);
    CommonTree root_0 = null;
    Token char_literal32 = null;
    CssParser.declaration_return declaration31 = null;
    CssParser.declaration_return declaration33 = null;
    CommonTree char_literal32_tree = null;
    RewriteRuleTokenStream stream_34 = new RewriteRuleTokenStream(adaptor, "token 34");
    RewriteRuleSubtreeStream stream_declaration = new RewriteRuleSubtreeStream(adaptor, "rule declaration");
    try {
        // /home/langera/dev/freud/src/grammar/Css.g:78:2: ( declaration ( ';' ( declaration )? )* -> ( declaration )+ )
        // /home/langera/dev/freud/src/grammar/Css.g:78:4: declaration ( ';' ( declaration )? )*
        {
            pushFollow(FOLLOW_declaration_in_properties395);
            declaration31 = declaration();
            state._fsp--;
            stream_declaration.add(declaration31.getTree());
            // /home/langera/dev/freud/src/grammar/Css.g:78:16: ( ';' ( declaration )? )*
            loop16: do {
                int alt16 = 2;
                int LA16_0 = input.LA(1);
                if ((LA16_0 == 34)) {
                    alt16 = 1;
                }
                switch(alt16) {
                    case 1:
                        // /home/langera/dev/freud/src/grammar/Css.g:78:17: ';' ( declaration )?
                        {
                            char_literal32 = (Token) match(input, 34, FOLLOW_34_in_properties398);
                            stream_34.add(char_literal32);
                            // /home/langera/dev/freud/src/grammar/Css.g:78:21: ( declaration )?
                            int alt15 = 2;
                            int LA15_0 = input.LA(1);
                            if ((LA15_0 == IDENT)) {
                                alt15 = 1;
                            }
                            switch(alt15) {
                                case 1:
                                    // /home/langera/dev/freud/src/grammar/Css.g:78:21: declaration
                                    {
                                        pushFollow(FOLLOW_declaration_in_properties400);
                                        declaration33 = declaration();
                                        state._fsp--;
                                        stream_declaration.add(declaration33.getTree());
                                    }
                                    break;
                            }
                        }
                        break;
                    default:
                        break loop16;
                }
            } while (true);
            // AST REWRITE
            // elements: declaration
            // token labels:
            // rule labels: retval
            // token list labels:
            // rule list labels:
            // wildcard labels:
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
            root_0 = (CommonTree) adaptor.nil();
            // 78:36: -> ( declaration )+
            {
                if (!(stream_declaration.hasNext())) {
                    throw new RewriteEarlyExitException();
                }
                while (stream_declaration.hasNext()) {
                    adaptor.addChild(root_0, stream_declaration.nextTree());
                }
                stream_declaration.reset();
            }
            retval.tree = root_0;
        }
        retval.stop = input.LT(-1);
        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 {
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) CommonTree(org.antlr.runtime.tree.CommonTree) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) RewriteEarlyExitException(org.antlr.runtime.tree.RewriteEarlyExitException) RecognitionException(org.antlr.runtime.RecognitionException)

Example 5 with RewriteEarlyExitException

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

the class JavaParser method qualifiedTypeIdent.

// $ANTLR start "qualifiedTypeIdent"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:667:1: qualifiedTypeIdent : typeIdent ( DOT typeIdent )* -> ^( QUALIFIED_TYPE_IDENT ( typeIdent )+ ) ;
public final JavaParser.qualifiedTypeIdent_return qualifiedTypeIdent() throws RecognitionException {
    JavaParser.qualifiedTypeIdent_return retval = new JavaParser.qualifiedTypeIdent_return();
    retval.start = input.LT(1);
    int qualifiedTypeIdent_StartIndex = input.index();
    CommonTree root_0 = null;
    Token DOT175 = null;
    JavaParser.typeIdent_return typeIdent174 = null;
    JavaParser.typeIdent_return typeIdent176 = null;
    CommonTree DOT175_tree = null;
    RewriteRuleTokenStream stream_DOT = new RewriteRuleTokenStream(adaptor, "token DOT");
    RewriteRuleSubtreeStream stream_typeIdent = new RewriteRuleSubtreeStream(adaptor, "rule typeIdent");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 45)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:668:5: ( typeIdent ( DOT typeIdent )* -> ^( QUALIFIED_TYPE_IDENT ( typeIdent )+ ) )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:668:9: typeIdent ( DOT typeIdent )*
        {
            pushFollow(FOLLOW_typeIdent_in_qualifiedTypeIdent7001);
            typeIdent174 = typeIdent();
            state._fsp--;
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_typeIdent.add(typeIdent174.getTree());
            }
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:668:19: ( DOT typeIdent )*
            loop62: do {
                int alt62 = 2;
                int LA62_0 = input.LA(1);
                if ((LA62_0 == DOT)) {
                    int LA62_2 = input.LA(2);
                    if ((synpred80_Java())) {
                        alt62 = 1;
                    }
                }
                switch(alt62) {
                    case 1:
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:668:20: DOT typeIdent
                        {
                            DOT175 = (Token) match(input, DOT, FOLLOW_DOT_in_qualifiedTypeIdent7004);
                            if (state.failed) {
                                return retval;
                            }
                            if (state.backtracking == 0) {
                                stream_DOT.add(DOT175);
                            }
                            pushFollow(FOLLOW_typeIdent_in_qualifiedTypeIdent7006);
                            typeIdent176 = typeIdent();
                            state._fsp--;
                            if (state.failed) {
                                return retval;
                            }
                            if (state.backtracking == 0) {
                                stream_typeIdent.add(typeIdent176.getTree());
                            }
                        }
                        break;
                    default:
                        break loop62;
                }
            } 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();
                // 669:9: -> ^( QUALIFIED_TYPE_IDENT ( typeIdent )+ )
                {
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:669:13: ^( QUALIFIED_TYPE_IDENT ( typeIdent )+ )
                    {
                        CommonTree root_1 = (CommonTree) adaptor.nil();
                        root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(QUALIFIED_TYPE_IDENT, "QUALIFIED_TYPE_IDENT"), root_1);
                        if (!(stream_typeIdent.hasNext())) {
                            throw new RewriteEarlyExitException();
                        }
                        while (stream_typeIdent.hasNext()) {
                            adaptor.addChild(root_1, stream_typeIdent.nextTree());
                        }
                        stream_typeIdent.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, 45, qualifiedTypeIdent_StartIndex);
        }
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) CommonTree(org.antlr.runtime.tree.CommonTree) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) RewriteEarlyExitException(org.antlr.runtime.tree.RewriteEarlyExitException) RecognitionException(org.antlr.runtime.RecognitionException)

Aggregations

RecognitionException (org.antlr.runtime.RecognitionException)13 CommonTree (org.antlr.runtime.tree.CommonTree)13 RewriteEarlyExitException (org.antlr.runtime.tree.RewriteEarlyExitException)13 RewriteRuleSubtreeStream (org.antlr.runtime.tree.RewriteRuleSubtreeStream)13 Token (org.antlr.runtime.Token)11 RewriteRuleTokenStream (org.antlr.runtime.tree.RewriteRuleTokenStream)11 EarlyExitException (org.antlr.runtime.EarlyExitException)2 NoViableAltException (org.antlr.runtime.NoViableAltException)2