Search in sources :

Example 1 with RecognitionException

use of org.antlr.runtime.RecognitionException in project Apktool by iBotPeaches.

the class SmaliBuilder method buildFile.

private void buildFile(String fileName, DexBuilder dexBuilder) throws AndrolibException, IOException {
    File inFile = new File(mSmaliDir, fileName);
    InputStream inStream = new FileInputStream(inFile);
    if (fileName.endsWith(".smali")) {
        try {
            if (!SmaliMod.assembleSmaliFile(inFile, dexBuilder, false, false)) {
                throw new AndrolibException("Could not smali file: " + fileName);
            }
        } catch (IOException | RecognitionException ex) {
            throw new AndrolibException(ex);
        }
    } else {
        LOGGER.warning("Unknown file type, ignoring: " + inFile);
    }
    inStream.close();
}
Also used : AndrolibException(brut.androlib.AndrolibException) ExtFile(brut.directory.ExtFile) RecognitionException(org.antlr.runtime.RecognitionException)

Example 2 with RecognitionException

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

the class JavaParser method postfixedExpression.

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

Example 3 with RecognitionException

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

the class JavaParser method compilationUnit.

// $ANTLR start "compilationUnit"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:415:1: compilationUnit : annotationList ( packageDeclaration )? ( importDeclaration )* ( typeDecls )* ;
public final JavaParser.compilationUnit_return compilationUnit() throws RecognitionException {
    JavaParser.compilationUnit_return retval = new JavaParser.compilationUnit_return();
    retval.start = input.LT(1);
    int compilationUnit_StartIndex = input.index();
    CommonTree root_0 = null;
    JavaParser.annotationList_return annotationList2 = null;
    JavaParser.packageDeclaration_return packageDeclaration3 = null;
    JavaParser.importDeclaration_return importDeclaration4 = null;
    JavaParser.typeDecls_return typeDecls5 = null;
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 2)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:416:5: ( annotationList ( packageDeclaration )? ( importDeclaration )* ( typeDecls )* )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:416:9: annotationList ( packageDeclaration )? ( importDeclaration )* ( typeDecls )*
        {
            root_0 = (CommonTree) adaptor.nil();
            pushFollow(FOLLOW_annotationList_in_compilationUnit4526);
            annotationList2 = annotationList();
            state._fsp--;
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                adaptor.addChild(root_0, annotationList2.getTree());
            }
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:417:9: ( packageDeclaration )?
            int alt1 = 2;
            int LA1_0 = input.LA(1);
            if ((LA1_0 == PACKAGE)) {
                alt1 = 1;
            }
            switch(alt1) {
                case 1:
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: packageDeclaration
                    {
                        pushFollow(FOLLOW_packageDeclaration_in_compilationUnit4536);
                        packageDeclaration3 = packageDeclaration();
                        state._fsp--;
                        if (state.failed) {
                            return retval;
                        }
                        if (state.backtracking == 0) {
                            adaptor.addChild(root_0, packageDeclaration3.getTree());
                        }
                    }
                    break;
            }
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:418:9: ( importDeclaration )*
            loop2: do {
                int alt2 = 2;
                int LA2_0 = input.LA(1);
                if ((LA2_0 == IMPORT)) {
                    alt2 = 1;
                }
                switch(alt2) {
                    case 1:
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: importDeclaration
                        {
                            pushFollow(FOLLOW_importDeclaration_in_compilationUnit4547);
                            importDeclaration4 = importDeclaration();
                            state._fsp--;
                            if (state.failed) {
                                return retval;
                            }
                            if (state.backtracking == 0) {
                                adaptor.addChild(root_0, importDeclaration4.getTree());
                            }
                        }
                        break;
                    default:
                        break loop2;
                }
            } while (true);
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:419:9: ( typeDecls )*
            loop3: do {
                int alt3 = 2;
                int LA3_0 = input.LA(1);
                if ((LA3_0 == AT || LA3_0 == LESS_THAN || LA3_0 == SEMI || LA3_0 == ABSTRACT || LA3_0 == BOOLEAN || LA3_0 == BYTE || (LA3_0 >= CHAR && LA3_0 <= CLASS) || LA3_0 == DOUBLE || LA3_0 == ENUM || LA3_0 == FINAL || LA3_0 == FLOAT || LA3_0 == INTERFACE || (LA3_0 >= INT && LA3_0 <= NATIVE) || (LA3_0 >= PRIVATE && LA3_0 <= PUBLIC) || (LA3_0 >= SHORT && LA3_0 <= STRICTFP) || LA3_0 == SYNCHRONIZED || LA3_0 == TRANSIENT || (LA3_0 >= VOID && LA3_0 <= VOLATILE) || LA3_0 == IDENT)) {
                    alt3 = 1;
                }
                switch(alt3) {
                    case 1:
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: typeDecls
                        {
                            pushFollow(FOLLOW_typeDecls_in_compilationUnit4558);
                            typeDecls5 = typeDecls();
                            state._fsp--;
                            if (state.failed) {
                                return retval;
                            }
                            if (state.backtracking == 0) {
                                adaptor.addChild(root_0, typeDecls5.getTree());
                            }
                        }
                        break;
                    default:
                        break loop3;
                }
            } while (true);
        }
        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, 2, compilationUnit_StartIndex);
        }
    }
    return retval;
}
Also used : CommonTree(org.antlr.runtime.tree.CommonTree) RecognitionException(org.antlr.runtime.RecognitionException)

Example 4 with RecognitionException

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

the class JavaParser method modifier.

// $ANTLR start "modifier"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:623:1: modifier : ( PUBLIC | PROTECTED | PRIVATE | STATIC | ABSTRACT | NATIVE | SYNCHRONIZED | TRANSIENT | VOLATILE | STRICTFP | localModifier );
public final JavaParser.modifier_return modifier() throws RecognitionException {
    JavaParser.modifier_return retval = new JavaParser.modifier_return();
    retval.start = input.LT(1);
    int modifier_StartIndex = input.index();
    CommonTree root_0 = null;
    Token PUBLIC152 = null;
    Token PROTECTED153 = null;
    Token PRIVATE154 = null;
    Token STATIC155 = null;
    Token ABSTRACT156 = null;
    Token NATIVE157 = null;
    Token SYNCHRONIZED158 = null;
    Token TRANSIENT159 = null;
    Token VOLATILE160 = null;
    Token STRICTFP161 = null;
    JavaParser.localModifier_return localModifier162 = null;
    CommonTree PUBLIC152_tree = null;
    CommonTree PROTECTED153_tree = null;
    CommonTree PRIVATE154_tree = null;
    CommonTree STATIC155_tree = null;
    CommonTree ABSTRACT156_tree = null;
    CommonTree NATIVE157_tree = null;
    CommonTree SYNCHRONIZED158_tree = null;
    CommonTree TRANSIENT159_tree = null;
    CommonTree VOLATILE160_tree = null;
    CommonTree STRICTFP161_tree = null;
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 38)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:624:5: ( PUBLIC | PROTECTED | PRIVATE | STATIC | ABSTRACT | NATIVE | SYNCHRONIZED | TRANSIENT | VOLATILE | STRICTFP | localModifier )
        int alt55 = 11;
        switch(input.LA(1)) {
            case PUBLIC:
                {
                    alt55 = 1;
                }
                break;
            case PROTECTED:
                {
                    alt55 = 2;
                }
                break;
            case PRIVATE:
                {
                    alt55 = 3;
                }
                break;
            case STATIC:
                {
                    alt55 = 4;
                }
                break;
            case ABSTRACT:
                {
                    alt55 = 5;
                }
                break;
            case NATIVE:
                {
                    alt55 = 6;
                }
                break;
            case SYNCHRONIZED:
                {
                    alt55 = 7;
                }
                break;
            case TRANSIENT:
                {
                    alt55 = 8;
                }
                break;
            case VOLATILE:
                {
                    alt55 = 9;
                }
                break;
            case STRICTFP:
                {
                    alt55 = 10;
                }
                break;
            case AT:
            case FINAL:
                {
                    alt55 = 11;
                }
                break;
            default:
                if (state.backtracking > 0) {
                    state.failed = true;
                    return retval;
                }
                NoViableAltException nvae = new NoViableAltException("", 55, 0, input);
                throw nvae;
        }
        switch(alt55) {
            case 1:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:624:9: PUBLIC
                {
                    root_0 = (CommonTree) adaptor.nil();
                    PUBLIC152 = (Token) match(input, PUBLIC, FOLLOW_PUBLIC_in_modifier6659);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        PUBLIC152_tree = (CommonTree) adaptor.create(PUBLIC152);
                        adaptor.addChild(root_0, PUBLIC152_tree);
                    }
                }
                break;
            case 2:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:625:9: PROTECTED
                {
                    root_0 = (CommonTree) adaptor.nil();
                    PROTECTED153 = (Token) match(input, PROTECTED, FOLLOW_PROTECTED_in_modifier6669);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        PROTECTED153_tree = (CommonTree) adaptor.create(PROTECTED153);
                        adaptor.addChild(root_0, PROTECTED153_tree);
                    }
                }
                break;
            case 3:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:626:9: PRIVATE
                {
                    root_0 = (CommonTree) adaptor.nil();
                    PRIVATE154 = (Token) match(input, PRIVATE, FOLLOW_PRIVATE_in_modifier6679);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        PRIVATE154_tree = (CommonTree) adaptor.create(PRIVATE154);
                        adaptor.addChild(root_0, PRIVATE154_tree);
                    }
                }
                break;
            case 4:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:627:9: STATIC
                {
                    root_0 = (CommonTree) adaptor.nil();
                    STATIC155 = (Token) match(input, STATIC, FOLLOW_STATIC_in_modifier6689);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        STATIC155_tree = (CommonTree) adaptor.create(STATIC155);
                        adaptor.addChild(root_0, STATIC155_tree);
                    }
                }
                break;
            case 5:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:628:9: ABSTRACT
                {
                    root_0 = (CommonTree) adaptor.nil();
                    ABSTRACT156 = (Token) match(input, ABSTRACT, FOLLOW_ABSTRACT_in_modifier6699);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        ABSTRACT156_tree = (CommonTree) adaptor.create(ABSTRACT156);
                        adaptor.addChild(root_0, ABSTRACT156_tree);
                    }
                }
                break;
            case 6:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:629:9: NATIVE
                {
                    root_0 = (CommonTree) adaptor.nil();
                    NATIVE157 = (Token) match(input, NATIVE, FOLLOW_NATIVE_in_modifier6709);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        NATIVE157_tree = (CommonTree) adaptor.create(NATIVE157);
                        adaptor.addChild(root_0, NATIVE157_tree);
                    }
                }
                break;
            case 7:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:630:9: SYNCHRONIZED
                {
                    root_0 = (CommonTree) adaptor.nil();
                    SYNCHRONIZED158 = (Token) match(input, SYNCHRONIZED, FOLLOW_SYNCHRONIZED_in_modifier6719);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        SYNCHRONIZED158_tree = (CommonTree) adaptor.create(SYNCHRONIZED158);
                        adaptor.addChild(root_0, SYNCHRONIZED158_tree);
                    }
                }
                break;
            case 8:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:631:9: TRANSIENT
                {
                    root_0 = (CommonTree) adaptor.nil();
                    TRANSIENT159 = (Token) match(input, TRANSIENT, FOLLOW_TRANSIENT_in_modifier6729);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        TRANSIENT159_tree = (CommonTree) adaptor.create(TRANSIENT159);
                        adaptor.addChild(root_0, TRANSIENT159_tree);
                    }
                }
                break;
            case 9:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:632:9: VOLATILE
                {
                    root_0 = (CommonTree) adaptor.nil();
                    VOLATILE160 = (Token) match(input, VOLATILE, FOLLOW_VOLATILE_in_modifier6739);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        VOLATILE160_tree = (CommonTree) adaptor.create(VOLATILE160);
                        adaptor.addChild(root_0, VOLATILE160_tree);
                    }
                }
                break;
            case 10:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:633:9: STRICTFP
                {
                    root_0 = (CommonTree) adaptor.nil();
                    STRICTFP161 = (Token) match(input, STRICTFP, FOLLOW_STRICTFP_in_modifier6749);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        STRICTFP161_tree = (CommonTree) adaptor.create(STRICTFP161);
                        adaptor.addChild(root_0, STRICTFP161_tree);
                    }
                }
                break;
            case 11:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:634:9: localModifier
                {
                    root_0 = (CommonTree) adaptor.nil();
                    pushFollow(FOLLOW_localModifier_in_modifier6759);
                    localModifier162 = localModifier();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        adaptor.addChild(root_0, localModifier162.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, 38, modifier_StartIndex);
        }
    }
    return retval;
}
Also used : CommonTree(org.antlr.runtime.tree.CommonTree) NoViableAltException(org.antlr.runtime.NoViableAltException) Token(org.antlr.runtime.Token) RecognitionException(org.antlr.runtime.RecognitionException)

Example 5 with RecognitionException

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

Aggregations

RecognitionException (org.antlr.runtime.RecognitionException)376 Token (org.antlr.runtime.Token)215 CommonTree (org.antlr.runtime.tree.CommonTree)138 RewriteRuleSubtreeStream (org.antlr.runtime.tree.RewriteRuleSubtreeStream)112 CommonToken (org.antlr.runtime.CommonToken)95 RewriteRuleTokenStream (org.antlr.runtime.tree.RewriteRuleTokenStream)83 NoViableAltException (org.antlr.runtime.NoViableAltException)50 ParserRuleReturnScope (org.antlr.runtime.ParserRuleReturnScope)34 RewriteEarlyExitException (org.antlr.runtime.tree.RewriteEarlyExitException)27 CommonTokenStream (org.antlr.runtime.CommonTokenStream)23 ANTLRStringStream (org.antlr.runtime.ANTLRStringStream)16 EarlyExitException (org.antlr.runtime.EarlyExitException)16 MismatchedSetException (org.antlr.runtime.MismatchedSetException)14 MismatchedTokenException (org.antlr.runtime.MismatchedTokenException)12 Test (org.junit.Test)12 TokenRewriteStream (org.antlr.runtime.TokenRewriteStream)11 FailedPredicateException (org.antlr.runtime.FailedPredicateException)10 MissingTokenException (org.antlr.runtime.MissingTokenException)10 UnwantedTokenException (org.antlr.runtime.UnwantedTokenException)10 BoundIdentifiers (org.drools.compiler.compiler.BoundIdentifiers)8