Search in sources :

Example 16 with CommonTree

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

the class JavaParser method throwsClause.

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

Example 17 with CommonTree

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

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

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

the class JavaParser method annotationDefaultValue.

// $ANTLR start "annotationDefaultValue"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:819:1: annotationDefaultValue : DEFAULT annotationElementValue ;
public final JavaParser.annotationDefaultValue_return annotationDefaultValue() throws RecognitionException {
    JavaParser.annotationDefaultValue_return retval = new JavaParser.annotationDefaultValue_return();
    retval.start = input.LT(1);
    int annotationDefaultValue_StartIndex = input.index();
    CommonTree root_0 = null;
    Token DEFAULT263 = null;
    JavaParser.annotationElementValue_return annotationElementValue264 = null;
    CommonTree DEFAULT263_tree = null;
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 71)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:820:5: ( DEFAULT annotationElementValue )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:820:9: DEFAULT annotationElementValue
        {
            root_0 = (CommonTree) adaptor.nil();
            DEFAULT263 = (Token) match(input, DEFAULT, FOLLOW_DEFAULT_in_annotationDefaultValue8389);
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                DEFAULT263_tree = (CommonTree) adaptor.create(DEFAULT263);
                root_0 = (CommonTree) adaptor.becomeRoot(DEFAULT263_tree, root_0);
            }
            pushFollow(FOLLOW_annotationElementValue_in_annotationDefaultValue8392);
            annotationElementValue264 = annotationElementValue();
            state._fsp--;
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                adaptor.addChild(root_0, annotationElementValue264.getTree());
            }
        }
        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, 71, annotationDefaultValue_StartIndex);
        }
    }
    return retval;
}
Also used : CommonTree(org.antlr.runtime.tree.CommonTree) Token(org.antlr.runtime.Token) RecognitionException(org.antlr.runtime.RecognitionException)

Example 20 with CommonTree

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

the class JavaParser method simpleType.

// $ANTLR start "simpleType"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:652:1: simpleType : primitiveType ( arrayDeclaratorList )? -> ^( TYPE primitiveType ( arrayDeclaratorList )? ) ;
public final JavaParser.simpleType_return simpleType() throws RecognitionException {
    JavaParser.simpleType_return retval = new JavaParser.simpleType_return();
    retval.start = input.LT(1);
    int simpleType_StartIndex = input.index();
    CommonTree root_0 = null;
    JavaParser.primitiveType_return primitiveType168 = null;
    JavaParser.arrayDeclaratorList_return arrayDeclaratorList169 = null;
    RewriteRuleSubtreeStream stream_arrayDeclaratorList = new RewriteRuleSubtreeStream(adaptor, "rule arrayDeclaratorList");
    RewriteRuleSubtreeStream stream_primitiveType = new RewriteRuleSubtreeStream(adaptor, "rule primitiveType");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 42)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:653:5: ( primitiveType ( arrayDeclaratorList )? -> ^( TYPE primitiveType ( arrayDeclaratorList )? ) )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:653:9: primitiveType ( arrayDeclaratorList )?
        {
            pushFollow(FOLLOW_primitiveType_in_simpleType6874);
            primitiveType168 = primitiveType();
            state._fsp--;
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_primitiveType.add(primitiveType168.getTree());
            }
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:653:23: ( arrayDeclaratorList )?
            int alt59 = 2;
            int LA59_0 = input.LA(1);
            if ((LA59_0 == LBRACK)) {
                int LA59_1 = input.LA(2);
                if ((LA59_1 == RBRACK)) {
                    int LA59_3 = input.LA(3);
                    if ((synpred77_Java())) {
                        alt59 = 1;
                    }
                }
            }
            switch(alt59) {
                case 1:
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: arrayDeclaratorList
                    {
                        pushFollow(FOLLOW_arrayDeclaratorList_in_simpleType6876);
                        arrayDeclaratorList169 = arrayDeclaratorList();
                        state._fsp--;
                        if (state.failed) {
                            return retval;
                        }
                        if (state.backtracking == 0) {
                            stream_arrayDeclaratorList.add(arrayDeclaratorList169.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();
                // 654:9: -> ^( TYPE primitiveType ( arrayDeclaratorList )? )
                {
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:654:13: ^( TYPE primitiveType ( arrayDeclaratorList )? )
                    {
                        CommonTree root_1 = (CommonTree) adaptor.nil();
                        root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(TYPE, "TYPE"), root_1);
                        adaptor.addChild(root_1, stream_primitiveType.nextTree());
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:654:34: ( arrayDeclaratorList )?
                        if (stream_arrayDeclaratorList.hasNext()) {
                            adaptor.addChild(root_1, stream_arrayDeclaratorList.nextTree());
                        }
                        stream_arrayDeclaratorList.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, 42, simpleType_StartIndex);
        }
    }
    return retval;
}
Also used : CommonTree(org.antlr.runtime.tree.CommonTree) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) RecognitionException(org.antlr.runtime.RecognitionException)

Aggregations

CommonTree (org.antlr.runtime.tree.CommonTree)155 RecognitionException (org.antlr.runtime.RecognitionException)132 Token (org.antlr.runtime.Token)106 RewriteRuleSubtreeStream (org.antlr.runtime.tree.RewriteRuleSubtreeStream)81 RewriteRuleTokenStream (org.antlr.runtime.tree.RewriteRuleTokenStream)62 NoViableAltException (org.antlr.runtime.NoViableAltException)33 RewriteEarlyExitException (org.antlr.runtime.tree.RewriteEarlyExitException)15 CommonTokenStream (org.antlr.runtime.CommonTokenStream)12 CommonTreeNodeStream (org.antlr.runtime.tree.CommonTreeNodeStream)8 ANTLRStringStream (org.antlr.runtime.ANTLRStringStream)6 EarlyExitException (org.antlr.runtime.EarlyExitException)4 MismatchedSetException (org.antlr.runtime.MismatchedSetException)4 WindowingException (com.sap.hadoop.windowing.WindowingException)3 FileInputStream (java.io.FileInputStream)3 InputStreamReader (java.io.InputStreamReader)3 CharStream (org.antlr.runtime.CharStream)3 Tree (org.antlr.runtime.tree.Tree)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 TokenSource (org.antlr.runtime.TokenSource)2