Search in sources :

Example 46 with CommonTree

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

the class JavaParser method statement.

// $ANTLR start "statement"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:842:1: statement : ( block | ASSERT expr1= expression ( COLON expr2= expression SEMI -> ^( ASSERT $expr1 $expr2) | SEMI -> ^( ASSERT $expr1) ) | IF parenthesizedExpression ifStat= statement ( ELSE elseStat= statement -> ^( IF parenthesizedExpression $ifStat $elseStat) | -> ^( IF parenthesizedExpression $ifStat) ) | FOR LPAREN ( forInit SEMI forCondition SEMI forUpdater RPAREN statement -> ^( FOR forInit forCondition forUpdater statement ) | localModifierList type IDENT COLON expression RPAREN statement -> ^( FOR_EACH[$FOR, \"FOR_EACH\"] localModifierList type IDENT expression statement ) ) | WHILE parenthesizedExpression statement -> ^( WHILE parenthesizedExpression statement ) | DO statement WHILE parenthesizedExpression SEMI -> ^( DO statement parenthesizedExpression ) | TRY block ( catches ( finallyClause )? | finallyClause ) -> ^( TRY block ( catches )? ( finallyClause )? ) | SWITCH parenthesizedExpression LCURLY switchBlockLabels RCURLY -> ^( SWITCH parenthesizedExpression switchBlockLabels ) | SYNCHRONIZED parenthesizedExpression block -> ^( SYNCHRONIZED parenthesizedExpression block ) | RETURN ( expression )? SEMI -> ^( RETURN ( expression )? ) | THROW expression SEMI -> ^( THROW expression ) | BREAK ( IDENT )? SEMI -> ^( BREAK ( IDENT )? ) | CONTINUE ( IDENT )? SEMI -> ^( CONTINUE ( IDENT )? ) | IDENT COLON statement -> ^( LABELED_STATEMENT IDENT statement ) | expression SEMI | SEMI );
public final JavaParser.statement_return statement() throws RecognitionException {
    JavaParser.statement_return retval = new JavaParser.statement_return();
    retval.start = input.LT(1);
    int statement_StartIndex = input.index();
    CommonTree root_0 = null;
    Token ASSERT276 = null;
    Token COLON277 = null;
    Token SEMI278 = null;
    Token SEMI279 = null;
    Token IF280 = null;
    Token ELSE282 = null;
    Token FOR283 = null;
    Token LPAREN284 = null;
    Token SEMI286 = null;
    Token SEMI288 = null;
    Token RPAREN290 = null;
    Token IDENT294 = null;
    Token COLON295 = null;
    Token RPAREN297 = null;
    Token WHILE299 = null;
    Token DO302 = null;
    Token WHILE304 = null;
    Token SEMI306 = null;
    Token TRY307 = null;
    Token SWITCH312 = null;
    Token LCURLY314 = null;
    Token RCURLY316 = null;
    Token SYNCHRONIZED317 = null;
    Token RETURN320 = null;
    Token SEMI322 = null;
    Token THROW323 = null;
    Token SEMI325 = null;
    Token BREAK326 = null;
    Token IDENT327 = null;
    Token SEMI328 = null;
    Token CONTINUE329 = null;
    Token IDENT330 = null;
    Token SEMI331 = null;
    Token IDENT332 = null;
    Token COLON333 = null;
    Token SEMI336 = null;
    Token SEMI337 = null;
    JavaParser.expression_return expr1 = null;
    JavaParser.expression_return expr2 = null;
    JavaParser.statement_return ifStat = null;
    JavaParser.statement_return elseStat = null;
    JavaParser.block_return block275 = null;
    JavaParser.parenthesizedExpression_return parenthesizedExpression281 = null;
    JavaParser.forInit_return forInit285 = null;
    JavaParser.forCondition_return forCondition287 = null;
    JavaParser.forUpdater_return forUpdater289 = null;
    JavaParser.statement_return statement291 = null;
    JavaParser.localModifierList_return localModifierList292 = null;
    JavaParser.type_return type293 = null;
    JavaParser.expression_return expression296 = null;
    JavaParser.statement_return statement298 = null;
    JavaParser.parenthesizedExpression_return parenthesizedExpression300 = null;
    JavaParser.statement_return statement301 = null;
    JavaParser.statement_return statement303 = null;
    JavaParser.parenthesizedExpression_return parenthesizedExpression305 = null;
    JavaParser.block_return block308 = null;
    JavaParser.catches_return catches309 = null;
    JavaParser.finallyClause_return finallyClause310 = null;
    JavaParser.finallyClause_return finallyClause311 = null;
    JavaParser.parenthesizedExpression_return parenthesizedExpression313 = null;
    JavaParser.switchBlockLabels_return switchBlockLabels315 = null;
    JavaParser.parenthesizedExpression_return parenthesizedExpression318 = null;
    JavaParser.block_return block319 = null;
    JavaParser.expression_return expression321 = null;
    JavaParser.expression_return expression324 = null;
    JavaParser.statement_return statement334 = null;
    JavaParser.expression_return expression335 = null;
    CommonTree ASSERT276_tree = null;
    CommonTree COLON277_tree = null;
    CommonTree SEMI278_tree = null;
    CommonTree SEMI279_tree = null;
    CommonTree IF280_tree = null;
    CommonTree ELSE282_tree = null;
    CommonTree FOR283_tree = null;
    CommonTree LPAREN284_tree = null;
    CommonTree SEMI286_tree = null;
    CommonTree SEMI288_tree = null;
    CommonTree RPAREN290_tree = null;
    CommonTree IDENT294_tree = null;
    CommonTree COLON295_tree = null;
    CommonTree RPAREN297_tree = null;
    CommonTree WHILE299_tree = null;
    CommonTree DO302_tree = null;
    CommonTree WHILE304_tree = null;
    CommonTree SEMI306_tree = null;
    CommonTree TRY307_tree = null;
    CommonTree SWITCH312_tree = null;
    CommonTree LCURLY314_tree = null;
    CommonTree RCURLY316_tree = null;
    CommonTree SYNCHRONIZED317_tree = null;
    CommonTree RETURN320_tree = null;
    CommonTree SEMI322_tree = null;
    CommonTree THROW323_tree = null;
    CommonTree SEMI325_tree = null;
    CommonTree BREAK326_tree = null;
    CommonTree IDENT327_tree = null;
    CommonTree SEMI328_tree = null;
    CommonTree CONTINUE329_tree = null;
    CommonTree IDENT330_tree = null;
    CommonTree SEMI331_tree = null;
    CommonTree IDENT332_tree = null;
    CommonTree COLON333_tree = null;
    CommonTree SEMI336_tree = null;
    CommonTree SEMI337_tree = null;
    RewriteRuleTokenStream stream_COLON = new RewriteRuleTokenStream(adaptor, "token COLON");
    RewriteRuleTokenStream stream_RPAREN = new RewriteRuleTokenStream(adaptor, "token RPAREN");
    RewriteRuleTokenStream stream_SYNCHRONIZED = new RewriteRuleTokenStream(adaptor, "token SYNCHRONIZED");
    RewriteRuleTokenStream stream_WHILE = new RewriteRuleTokenStream(adaptor, "token WHILE");
    RewriteRuleTokenStream stream_CONTINUE = new RewriteRuleTokenStream(adaptor, "token CONTINUE");
    RewriteRuleTokenStream stream_SWITCH = new RewriteRuleTokenStream(adaptor, "token SWITCH");
    RewriteRuleTokenStream stream_RCURLY = new RewriteRuleTokenStream(adaptor, "token RCURLY");
    RewriteRuleTokenStream stream_ELSE = new RewriteRuleTokenStream(adaptor, "token ELSE");
    RewriteRuleTokenStream stream_RETURN = new RewriteRuleTokenStream(adaptor, "token RETURN");
    RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
    RewriteRuleTokenStream stream_FOR = new RewriteRuleTokenStream(adaptor, "token FOR");
    RewriteRuleTokenStream stream_DO = new RewriteRuleTokenStream(adaptor, "token DO");
    RewriteRuleTokenStream stream_LCURLY = new RewriteRuleTokenStream(adaptor, "token LCURLY");
    RewriteRuleTokenStream stream_SEMI = new RewriteRuleTokenStream(adaptor, "token SEMI");
    RewriteRuleTokenStream stream_ASSERT = new RewriteRuleTokenStream(adaptor, "token ASSERT");
    RewriteRuleTokenStream stream_BREAK = new RewriteRuleTokenStream(adaptor, "token BREAK");
    RewriteRuleTokenStream stream_THROW = new RewriteRuleTokenStream(adaptor, "token THROW");
    RewriteRuleTokenStream stream_TRY = new RewriteRuleTokenStream(adaptor, "token TRY");
    RewriteRuleTokenStream stream_LPAREN = new RewriteRuleTokenStream(adaptor, "token LPAREN");
    RewriteRuleTokenStream stream_IF = new RewriteRuleTokenStream(adaptor, "token IF");
    RewriteRuleSubtreeStream stream_statement = new RewriteRuleSubtreeStream(adaptor, "rule statement");
    RewriteRuleSubtreeStream stream_expression = new RewriteRuleSubtreeStream(adaptor, "rule expression");
    RewriteRuleSubtreeStream stream_finallyClause = new RewriteRuleSubtreeStream(adaptor, "rule finallyClause");
    RewriteRuleSubtreeStream stream_catches = new RewriteRuleSubtreeStream(adaptor, "rule catches");
    RewriteRuleSubtreeStream stream_forUpdater = new RewriteRuleSubtreeStream(adaptor, "rule forUpdater");
    RewriteRuleSubtreeStream stream_block = new RewriteRuleSubtreeStream(adaptor, "rule block");
    RewriteRuleSubtreeStream stream_forCondition = new RewriteRuleSubtreeStream(adaptor, "rule forCondition");
    RewriteRuleSubtreeStream stream_localModifierList = new RewriteRuleSubtreeStream(adaptor, "rule localModifierList");
    RewriteRuleSubtreeStream stream_forInit = new RewriteRuleSubtreeStream(adaptor, "rule forInit");
    RewriteRuleSubtreeStream stream_type = new RewriteRuleSubtreeStream(adaptor, "rule type");
    RewriteRuleSubtreeStream stream_switchBlockLabels = new RewriteRuleSubtreeStream(adaptor, "rule switchBlockLabels");
    RewriteRuleSubtreeStream stream_parenthesizedExpression = new RewriteRuleSubtreeStream(adaptor, "rule parenthesizedExpression");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 75)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:843:5: ( block | ASSERT expr1= expression ( COLON expr2= expression SEMI -> ^( ASSERT $expr1 $expr2) | SEMI -> ^( ASSERT $expr1) ) | IF parenthesizedExpression ifStat= statement ( ELSE elseStat= statement -> ^( IF parenthesizedExpression $ifStat $elseStat) | -> ^( IF parenthesizedExpression $ifStat) ) | FOR LPAREN ( forInit SEMI forCondition SEMI forUpdater RPAREN statement -> ^( FOR forInit forCondition forUpdater statement ) | localModifierList type IDENT COLON expression RPAREN statement -> ^( FOR_EACH[$FOR, \"FOR_EACH\"] localModifierList type IDENT expression statement ) ) | WHILE parenthesizedExpression statement -> ^( WHILE parenthesizedExpression statement ) | DO statement WHILE parenthesizedExpression SEMI -> ^( DO statement parenthesizedExpression ) | TRY block ( catches ( finallyClause )? | finallyClause ) -> ^( TRY block ( catches )? ( finallyClause )? ) | SWITCH parenthesizedExpression LCURLY switchBlockLabels RCURLY -> ^( SWITCH parenthesizedExpression switchBlockLabels ) | SYNCHRONIZED parenthesizedExpression block -> ^( SYNCHRONIZED parenthesizedExpression block ) | RETURN ( expression )? SEMI -> ^( RETURN ( expression )? ) | THROW expression SEMI -> ^( THROW expression ) | BREAK ( IDENT )? SEMI -> ^( BREAK ( IDENT )? ) | CONTINUE ( IDENT )? SEMI -> ^( CONTINUE ( IDENT )? ) | IDENT COLON statement -> ^( LABELED_STATEMENT IDENT statement ) | expression SEMI | SEMI )
        int alt98 = 16;
        alt98 = dfa98.predict(input);
        switch(alt98) {
            case 1:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:843:9: block
                {
                    root_0 = (CommonTree) adaptor.nil();
                    pushFollow(FOLLOW_block_in_statement8543);
                    block275 = block();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        adaptor.addChild(root_0, block275.getTree());
                    }
                }
                break;
            case 2:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:844:9: ASSERT expr1= expression ( COLON expr2= expression SEMI -> ^( ASSERT $expr1 $expr2) | SEMI -> ^( ASSERT $expr1) )
                {
                    ASSERT276 = (Token) match(input, ASSERT, FOLLOW_ASSERT_in_statement8553);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_ASSERT.add(ASSERT276);
                    }
                    pushFollow(FOLLOW_expression_in_statement8557);
                    expr1 = expression();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_expression.add(expr1.getTree());
                    }
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:845:9: ( COLON expr2= expression SEMI -> ^( ASSERT $expr1 $expr2) | SEMI -> ^( ASSERT $expr1) )
                    int alt90 = 2;
                    int LA90_0 = input.LA(1);
                    if ((LA90_0 == COLON)) {
                        alt90 = 1;
                    } else if ((LA90_0 == SEMI)) {
                        alt90 = 2;
                    } else {
                        if (state.backtracking > 0) {
                            state.failed = true;
                            return retval;
                        }
                        NoViableAltException nvae = new NoViableAltException("", 90, 0, input);
                        throw nvae;
                    }
                    switch(alt90) {
                        case 1:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:845:13: COLON expr2= expression SEMI
                            {
                                COLON277 = (Token) match(input, COLON, FOLLOW_COLON_in_statement8571);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_COLON.add(COLON277);
                                }
                                pushFollow(FOLLOW_expression_in_statement8575);
                                expr2 = expression();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_expression.add(expr2.getTree());
                                }
                                SEMI278 = (Token) match(input, SEMI, FOLLOW_SEMI_in_statement8577);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_SEMI.add(SEMI278);
                                }
                                // wildcard labels:
                                if (state.backtracking == 0) {
                                    retval.tree = root_0;
                                    RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                                    RewriteRuleSubtreeStream stream_expr1 = new RewriteRuleSubtreeStream(adaptor, "rule expr1", expr1 != null ? expr1.tree : null);
                                    RewriteRuleSubtreeStream stream_expr2 = new RewriteRuleSubtreeStream(adaptor, "rule expr2", expr2 != null ? expr2.tree : null);
                                    root_0 = (CommonTree) adaptor.nil();
                                    // 845:77: -> ^( ASSERT $expr1 $expr2)
                                    {
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:845:81: ^( ASSERT $expr1 $expr2)
                                        {
                                            CommonTree root_1 = (CommonTree) adaptor.nil();
                                            root_1 = (CommonTree) adaptor.becomeRoot(stream_ASSERT.nextNode(), root_1);
                                            adaptor.addChild(root_1, stream_expr1.nextTree());
                                            adaptor.addChild(root_1, stream_expr2.nextTree());
                                            adaptor.addChild(root_0, root_1);
                                        }
                                    }
                                    retval.tree = root_0;
                                }
                            }
                            break;
                        case 2:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:846:13: SEMI
                            {
                                SEMI279 = (Token) match(input, SEMI, FOLLOW_SEMI_in_statement8640);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_SEMI.add(SEMI279);
                                }
                                // wildcard labels:
                                if (state.backtracking == 0) {
                                    retval.tree = root_0;
                                    RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                                    RewriteRuleSubtreeStream stream_expr1 = new RewriteRuleSubtreeStream(adaptor, "rule expr1", expr1 != null ? expr1.tree : null);
                                    root_0 = (CommonTree) adaptor.nil();
                                    // 846:77: -> ^( ASSERT $expr1)
                                    {
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:846:81: ^( ASSERT $expr1)
                                        {
                                            CommonTree root_1 = (CommonTree) adaptor.nil();
                                            root_1 = (CommonTree) adaptor.becomeRoot(stream_ASSERT.nextNode(), root_1);
                                            adaptor.addChild(root_1, stream_expr1.nextTree());
                                            adaptor.addChild(root_0, root_1);
                                        }
                                    }
                                    retval.tree = root_0;
                                }
                            }
                            break;
                    }
                }
                break;
            case 3:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:848:9: IF parenthesizedExpression ifStat= statement ( ELSE elseStat= statement -> ^( IF parenthesizedExpression $ifStat $elseStat) | -> ^( IF parenthesizedExpression $ifStat) )
                {
                    IF280 = (Token) match(input, IF, FOLLOW_IF_in_statement8729);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_IF.add(IF280);
                    }
                    pushFollow(FOLLOW_parenthesizedExpression_in_statement8731);
                    parenthesizedExpression281 = parenthesizedExpression();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_parenthesizedExpression.add(parenthesizedExpression281.getTree());
                    }
                    pushFollow(FOLLOW_statement_in_statement8735);
                    ifStat = statement();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_statement.add(ifStat.getTree());
                    }
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:849:9: ( ELSE elseStat= statement -> ^( IF parenthesizedExpression $ifStat $elseStat) | -> ^( IF parenthesizedExpression $ifStat) )
                    int alt91 = 2;
                    int LA91_0 = input.LA(1);
                    if ((LA91_0 == ELSE)) {
                        int LA91_1 = input.LA(2);
                        if ((synpred122_Java())) {
                            alt91 = 1;
                        } else if ((true)) {
                            alt91 = 2;
                        } else {
                            if (state.backtracking > 0) {
                                state.failed = true;
                                return retval;
                            }
                            NoViableAltException nvae = new NoViableAltException("", 91, 1, input);
                            throw nvae;
                        }
                    } else if ((LA91_0 == EOF || LA91_0 == AT || LA91_0 == DEC || LA91_0 == INC || LA91_0 == LCURLY || LA91_0 == LESS_THAN || LA91_0 == LOGICAL_NOT || (LA91_0 >= LPAREN && LA91_0 <= MINUS) || LA91_0 == NOT || LA91_0 == PLUS || LA91_0 == RCURLY || LA91_0 == SEMI || (LA91_0 >= ABSTRACT && LA91_0 <= CASE) || (LA91_0 >= CHAR && LA91_0 <= DOUBLE) || LA91_0 == ENUM || (LA91_0 >= FALSE && LA91_0 <= FINAL) || (LA91_0 >= FLOAT && LA91_0 <= IF) || LA91_0 == INTERFACE || (LA91_0 >= INT && LA91_0 <= NULL) || (LA91_0 >= PRIVATE && LA91_0 <= THROW) || (LA91_0 >= TRANSIENT && LA91_0 <= WHILE) || (LA91_0 >= IDENT && LA91_0 <= STRING_LITERAL))) {
                        alt91 = 2;
                    } else {
                        if (state.backtracking > 0) {
                            state.failed = true;
                            return retval;
                        }
                        NoViableAltException nvae = new NoViableAltException("", 91, 0, input);
                        throw nvae;
                    }
                    switch(alt91) {
                        case 1:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:849:13: ELSE elseStat= statement
                            {
                                ELSE282 = (Token) match(input, ELSE, FOLLOW_ELSE_in_statement8749);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_ELSE.add(ELSE282);
                                }
                                pushFollow(FOLLOW_statement_in_statement8753);
                                elseStat = statement();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_statement.add(elseStat.getTree());
                                }
                                // wildcard labels:
                                if (state.backtracking == 0) {
                                    retval.tree = root_0;
                                    RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                                    RewriteRuleSubtreeStream stream_ifStat = new RewriteRuleSubtreeStream(adaptor, "rule ifStat", ifStat != null ? ifStat.tree : null);
                                    RewriteRuleSubtreeStream stream_elseStat = new RewriteRuleSubtreeStream(adaptor, "rule elseStat", elseStat != null ? elseStat.tree : null);
                                    root_0 = (CommonTree) adaptor.nil();
                                    // 849:77: -> ^( IF parenthesizedExpression $ifStat $elseStat)
                                    {
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:849:81: ^( IF parenthesizedExpression $ifStat $elseStat)
                                        {
                                            CommonTree root_1 = (CommonTree) adaptor.nil();
                                            root_1 = (CommonTree) adaptor.becomeRoot(stream_IF.nextNode(), root_1);
                                            adaptor.addChild(root_1, stream_parenthesizedExpression.nextTree());
                                            adaptor.addChild(root_1, stream_ifStat.nextTree());
                                            adaptor.addChild(root_1, stream_elseStat.nextTree());
                                            adaptor.addChild(root_0, root_1);
                                        }
                                    }
                                    retval.tree = root_0;
                                }
                            }
                            break;
                        case 2:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:850:77:
                            {
                                // wildcard labels:
                                if (state.backtracking == 0) {
                                    retval.tree = root_0;
                                    RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                                    RewriteRuleSubtreeStream stream_ifStat = new RewriteRuleSubtreeStream(adaptor, "rule ifStat", ifStat != null ? ifStat.tree : null);
                                    root_0 = (CommonTree) adaptor.nil();
                                    // 850:77: -> ^( IF parenthesizedExpression $ifStat)
                                    {
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:850:81: ^( IF parenthesizedExpression $ifStat)
                                        {
                                            CommonTree root_1 = (CommonTree) adaptor.nil();
                                            root_1 = (CommonTree) adaptor.becomeRoot(stream_IF.nextNode(), root_1);
                                            adaptor.addChild(root_1, stream_parenthesizedExpression.nextTree());
                                            adaptor.addChild(root_1, stream_ifStat.nextTree());
                                            adaptor.addChild(root_0, root_1);
                                        }
                                    }
                                    retval.tree = root_0;
                                }
                            }
                            break;
                    }
                }
                break;
            case 4:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:852:9: FOR LPAREN ( forInit SEMI forCondition SEMI forUpdater RPAREN statement -> ^( FOR forInit forCondition forUpdater statement ) | localModifierList type IDENT COLON expression RPAREN statement -> ^( FOR_EACH[$FOR, \"FOR_EACH\"] localModifierList type IDENT expression statement ) )
                {
                    FOR283 = (Token) match(input, FOR, FOLLOW_FOR_in_statement8916);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_FOR.add(FOR283);
                    }
                    LPAREN284 = (Token) match(input, LPAREN, FOLLOW_LPAREN_in_statement8918);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_LPAREN.add(LPAREN284);
                    }
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:853:9: ( forInit SEMI forCondition SEMI forUpdater RPAREN statement -> ^( FOR forInit forCondition forUpdater statement ) | localModifierList type IDENT COLON expression RPAREN statement -> ^( FOR_EACH[$FOR, \"FOR_EACH\"] localModifierList type IDENT expression statement ) )
                    int alt92 = 2;
                    alt92 = dfa92.predict(input);
                    switch(alt92) {
                        case 1:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:853:13: forInit SEMI forCondition SEMI forUpdater RPAREN statement
                            {
                                pushFollow(FOLLOW_forInit_in_statement8932);
                                forInit285 = forInit();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_forInit.add(forInit285.getTree());
                                }
                                SEMI286 = (Token) match(input, SEMI, FOLLOW_SEMI_in_statement8934);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_SEMI.add(SEMI286);
                                }
                                pushFollow(FOLLOW_forCondition_in_statement8936);
                                forCondition287 = forCondition();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_forCondition.add(forCondition287.getTree());
                                }
                                SEMI288 = (Token) match(input, SEMI, FOLLOW_SEMI_in_statement8938);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_SEMI.add(SEMI288);
                                }
                                pushFollow(FOLLOW_forUpdater_in_statement8940);
                                forUpdater289 = forUpdater();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_forUpdater.add(forUpdater289.getTree());
                                }
                                RPAREN290 = (Token) match(input, RPAREN, FOLLOW_RPAREN_in_statement8942);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_RPAREN.add(RPAREN290);
                                }
                                pushFollow(FOLLOW_statement_in_statement8944);
                                statement291 = statement();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_statement.add(statement291.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();
                                    // 853:77: -> ^( FOR forInit forCondition forUpdater statement )
                                    {
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:853:81: ^( FOR forInit forCondition forUpdater statement )
                                        {
                                            CommonTree root_1 = (CommonTree) adaptor.nil();
                                            root_1 = (CommonTree) adaptor.becomeRoot(stream_FOR.nextNode(), root_1);
                                            adaptor.addChild(root_1, stream_forInit.nextTree());
                                            adaptor.addChild(root_1, stream_forCondition.nextTree());
                                            adaptor.addChild(root_1, stream_forUpdater.nextTree());
                                            adaptor.addChild(root_1, stream_statement.nextTree());
                                            adaptor.addChild(root_0, root_1);
                                        }
                                    }
                                    retval.tree = root_0;
                                }
                            }
                            break;
                        case 2:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:854:13: localModifierList type IDENT COLON expression RPAREN statement
                            {
                                pushFollow(FOLLOW_localModifierList_in_statement8978);
                                localModifierList292 = localModifierList();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_localModifierList.add(localModifierList292.getTree());
                                }
                                pushFollow(FOLLOW_type_in_statement8980);
                                type293 = type();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_type.add(type293.getTree());
                                }
                                IDENT294 = (Token) match(input, IDENT, FOLLOW_IDENT_in_statement8982);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_IDENT.add(IDENT294);
                                }
                                COLON295 = (Token) match(input, COLON, FOLLOW_COLON_in_statement8984);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_COLON.add(COLON295);
                                }
                                pushFollow(FOLLOW_expression_in_statement8986);
                                expression296 = expression();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_expression.add(expression296.getTree());
                                }
                                RPAREN297 = (Token) match(input, RPAREN, FOLLOW_RPAREN_in_statement8988);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_RPAREN.add(RPAREN297);
                                }
                                pushFollow(FOLLOW_statement_in_statement8990);
                                statement298 = statement();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_statement.add(statement298.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();
                                    // 855:77: -> ^( FOR_EACH[$FOR, \"FOR_EACH\"] localModifierList type IDENT expression statement )
                                    {
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:855:81: ^( FOR_EACH[$FOR, \"FOR_EACH\"] localModifierList type IDENT expression statement )
                                        {
                                            CommonTree root_1 = (CommonTree) adaptor.nil();
                                            root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(FOR_EACH, FOR283, "FOR_EACH"), root_1);
                                            adaptor.addChild(root_1, stream_localModifierList.nextTree());
                                            adaptor.addChild(root_1, stream_type.nextTree());
                                            adaptor.addChild(root_1, stream_IDENT.nextNode());
                                            adaptor.addChild(root_1, stream_expression.nextTree());
                                            adaptor.addChild(root_1, stream_statement.nextTree());
                                            adaptor.addChild(root_0, root_1);
                                        }
                                    }
                                    retval.tree = root_0;
                                }
                            }
                            break;
                    }
                }
                break;
            case 5:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:857:9: WHILE parenthesizedExpression statement
                {
                    WHILE299 = (Token) match(input, WHILE, FOLLOW_WHILE_in_statement9104);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_WHILE.add(WHILE299);
                    }
                    pushFollow(FOLLOW_parenthesizedExpression_in_statement9106);
                    parenthesizedExpression300 = parenthesizedExpression();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_parenthesizedExpression.add(parenthesizedExpression300.getTree());
                    }
                    pushFollow(FOLLOW_statement_in_statement9108);
                    statement301 = statement();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_statement.add(statement301.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();
                        // 857:77: -> ^( WHILE parenthesizedExpression statement )
                        {
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:857:81: ^( WHILE parenthesizedExpression statement )
                            {
                                CommonTree root_1 = (CommonTree) adaptor.nil();
                                root_1 = (CommonTree) adaptor.becomeRoot(stream_WHILE.nextNode(), root_1);
                                adaptor.addChild(root_1, stream_parenthesizedExpression.nextTree());
                                adaptor.addChild(root_1, stream_statement.nextTree());
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
            case 6:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:858:9: DO statement WHILE parenthesizedExpression SEMI
                {
                    DO302 = (Token) match(input, DO, FOLLOW_DO_in_statement9157);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_DO.add(DO302);
                    }
                    pushFollow(FOLLOW_statement_in_statement9159);
                    statement303 = statement();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_statement.add(statement303.getTree());
                    }
                    WHILE304 = (Token) match(input, WHILE, FOLLOW_WHILE_in_statement9161);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_WHILE.add(WHILE304);
                    }
                    pushFollow(FOLLOW_parenthesizedExpression_in_statement9163);
                    parenthesizedExpression305 = parenthesizedExpression();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_parenthesizedExpression.add(parenthesizedExpression305.getTree());
                    }
                    SEMI306 = (Token) match(input, SEMI, FOLLOW_SEMI_in_statement9165);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_SEMI.add(SEMI306);
                    }
                    // 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();
                        // 858:77: -> ^( DO statement parenthesizedExpression )
                        {
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:858:81: ^( DO statement parenthesizedExpression )
                            {
                                CommonTree root_1 = (CommonTree) adaptor.nil();
                                root_1 = (CommonTree) adaptor.becomeRoot(stream_DO.nextNode(), root_1);
                                adaptor.addChild(root_1, stream_statement.nextTree());
                                adaptor.addChild(root_1, stream_parenthesizedExpression.nextTree());
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
            case 7:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:859:9: TRY block ( catches ( finallyClause )? | finallyClause )
                {
                    TRY307 = (Token) match(input, TRY, FOLLOW_TRY_in_statement9206);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_TRY.add(TRY307);
                    }
                    pushFollow(FOLLOW_block_in_statement9208);
                    block308 = block();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_block.add(block308.getTree());
                    }
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:859:19: ( catches ( finallyClause )? | finallyClause )
                    int alt94 = 2;
                    int LA94_0 = input.LA(1);
                    if ((LA94_0 == CATCH)) {
                        alt94 = 1;
                    } else if ((LA94_0 == FINALLY)) {
                        alt94 = 2;
                    } else {
                        if (state.backtracking > 0) {
                            state.failed = true;
                            return retval;
                        }
                        NoViableAltException nvae = new NoViableAltException("", 94, 0, input);
                        throw nvae;
                    }
                    switch(alt94) {
                        case 1:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:859:20: catches ( finallyClause )?
                            {
                                pushFollow(FOLLOW_catches_in_statement9211);
                                catches309 = catches();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_catches.add(catches309.getTree());
                                }
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:859:28: ( finallyClause )?
                                int alt93 = 2;
                                int LA93_0 = input.LA(1);
                                if ((LA93_0 == FINALLY)) {
                                    alt93 = 1;
                                }
                                switch(alt93) {
                                    case 1:
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: finallyClause
                                        {
                                            pushFollow(FOLLOW_finallyClause_in_statement9213);
                                            finallyClause310 = finallyClause();
                                            state._fsp--;
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_finallyClause.add(finallyClause310.getTree());
                                            }
                                        }
                                        break;
                                }
                            }
                            break;
                        case 2:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:859:45: finallyClause
                            {
                                pushFollow(FOLLOW_finallyClause_in_statement9218);
                                finallyClause311 = finallyClause();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_finallyClause.add(finallyClause311.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();
                        // 859:77: -> ^( TRY block ( catches )? ( finallyClause )? )
                        {
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:859:81: ^( TRY block ( catches )? ( finallyClause )? )
                            {
                                CommonTree root_1 = (CommonTree) adaptor.nil();
                                root_1 = (CommonTree) adaptor.becomeRoot(stream_TRY.nextNode(), root_1);
                                adaptor.addChild(root_1, stream_block.nextTree());
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:859:93: ( catches )?
                                if (stream_catches.hasNext()) {
                                    adaptor.addChild(root_1, stream_catches.nextTree());
                                }
                                stream_catches.reset();
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:859:102: ( finallyClause )?
                                if (stream_finallyClause.hasNext()) {
                                    adaptor.addChild(root_1, stream_finallyClause.nextTree());
                                }
                                stream_finallyClause.reset();
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
            case 8:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:860:9: SWITCH parenthesizedExpression LCURLY switchBlockLabels RCURLY
                {
                    SWITCH312 = (Token) match(input, SWITCH, FOLLOW_SWITCH_in_statement9261);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_SWITCH.add(SWITCH312);
                    }
                    pushFollow(FOLLOW_parenthesizedExpression_in_statement9263);
                    parenthesizedExpression313 = parenthesizedExpression();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_parenthesizedExpression.add(parenthesizedExpression313.getTree());
                    }
                    LCURLY314 = (Token) match(input, LCURLY, FOLLOW_LCURLY_in_statement9265);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_LCURLY.add(LCURLY314);
                    }
                    pushFollow(FOLLOW_switchBlockLabels_in_statement9267);
                    switchBlockLabels315 = switchBlockLabels();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_switchBlockLabels.add(switchBlockLabels315.getTree());
                    }
                    RCURLY316 = (Token) match(input, RCURLY, FOLLOW_RCURLY_in_statement9269);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_RCURLY.add(RCURLY316);
                    }
                    // 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();
                        // 860:77: -> ^( SWITCH parenthesizedExpression switchBlockLabels )
                        {
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:860:81: ^( SWITCH parenthesizedExpression switchBlockLabels )
                            {
                                CommonTree root_1 = (CommonTree) adaptor.nil();
                                root_1 = (CommonTree) adaptor.becomeRoot(stream_SWITCH.nextNode(), root_1);
                                adaptor.addChild(root_1, stream_parenthesizedExpression.nextTree());
                                adaptor.addChild(root_1, stream_switchBlockLabels.nextTree());
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
            case 9:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:861:9: SYNCHRONIZED parenthesizedExpression block
                {
                    SYNCHRONIZED317 = (Token) match(input, SYNCHRONIZED, FOLLOW_SYNCHRONIZED_in_statement9295);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_SYNCHRONIZED.add(SYNCHRONIZED317);
                    }
                    pushFollow(FOLLOW_parenthesizedExpression_in_statement9297);
                    parenthesizedExpression318 = parenthesizedExpression();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_parenthesizedExpression.add(parenthesizedExpression318.getTree());
                    }
                    pushFollow(FOLLOW_block_in_statement9299);
                    block319 = block();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_block.add(block319.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();
                        // 861:77: -> ^( SYNCHRONIZED parenthesizedExpression block )
                        {
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:861:81: ^( SYNCHRONIZED parenthesizedExpression block )
                            {
                                CommonTree root_1 = (CommonTree) adaptor.nil();
                                root_1 = (CommonTree) adaptor.becomeRoot(stream_SYNCHRONIZED.nextNode(), root_1);
                                adaptor.addChild(root_1, stream_parenthesizedExpression.nextTree());
                                adaptor.addChild(root_1, stream_block.nextTree());
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
            case 10:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:862:9: RETURN ( expression )? SEMI
                {
                    RETURN320 = (Token) match(input, RETURN, FOLLOW_RETURN_in_statement9345);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_RETURN.add(RETURN320);
                    }
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:862:16: ( expression )?
                    int alt95 = 2;
                    int LA95_0 = input.LA(1);
                    if ((LA95_0 == DEC || LA95_0 == INC || LA95_0 == LESS_THAN || LA95_0 == LOGICAL_NOT || (LA95_0 >= LPAREN && LA95_0 <= MINUS) || LA95_0 == NOT || LA95_0 == PLUS || LA95_0 == BOOLEAN || LA95_0 == BYTE || LA95_0 == CHAR || LA95_0 == DOUBLE || LA95_0 == FALSE || LA95_0 == FLOAT || (LA95_0 >= INT && LA95_0 <= LONG) || (LA95_0 >= NEW && LA95_0 <= NULL) || LA95_0 == SHORT || LA95_0 == SUPER || LA95_0 == THIS || LA95_0 == TRUE || LA95_0 == VOID || (LA95_0 >= IDENT && LA95_0 <= STRING_LITERAL))) {
                        alt95 = 1;
                    }
                    switch(alt95) {
                        case 1:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: expression
                            {
                                pushFollow(FOLLOW_expression_in_statement9347);
                                expression321 = expression();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_expression.add(expression321.getTree());
                                }
                            }
                            break;
                    }
                    SEMI322 = (Token) match(input, SEMI, FOLLOW_SEMI_in_statement9350);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_SEMI.add(SEMI322);
                    }
                    // 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();
                        // 862:77: -> ^( RETURN ( expression )? )
                        {
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:862:81: ^( RETURN ( expression )? )
                            {
                                CommonTree root_1 = (CommonTree) adaptor.nil();
                                root_1 = (CommonTree) adaptor.becomeRoot(stream_RETURN.nextNode(), root_1);
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:862:90: ( expression )?
                                if (stream_expression.hasNext()) {
                                    adaptor.addChild(root_1, stream_expression.nextTree());
                                }
                                stream_expression.reset();
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
            case 11:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:863:9: THROW expression SEMI
                {
                    THROW323 = (Token) match(input, THROW, FOLLOW_THROW_in_statement9414);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_THROW.add(THROW323);
                    }
                    pushFollow(FOLLOW_expression_in_statement9416);
                    expression324 = expression();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_expression.add(expression324.getTree());
                    }
                    SEMI325 = (Token) match(input, SEMI, FOLLOW_SEMI_in_statement9418);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_SEMI.add(SEMI325);
                    }
                    // 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();
                        // 863:77: -> ^( THROW expression )
                        {
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:863:81: ^( THROW expression )
                            {
                                CommonTree root_1 = (CommonTree) adaptor.nil();
                                root_1 = (CommonTree) adaptor.becomeRoot(stream_THROW.nextNode(), root_1);
                                adaptor.addChild(root_1, stream_expression.nextTree());
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
            case 12:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:864:9: BREAK ( IDENT )? SEMI
                {
                    BREAK326 = (Token) match(input, BREAK, FOLLOW_BREAK_in_statement9483);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_BREAK.add(BREAK326);
                    }
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:864:15: ( IDENT )?
                    int alt96 = 2;
                    int LA96_0 = input.LA(1);
                    if ((LA96_0 == IDENT)) {
                        alt96 = 1;
                    }
                    switch(alt96) {
                        case 1:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: IDENT
                            {
                                IDENT327 = (Token) match(input, IDENT, FOLLOW_IDENT_in_statement9485);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_IDENT.add(IDENT327);
                                }
                            }
                            break;
                    }
                    SEMI328 = (Token) match(input, SEMI, FOLLOW_SEMI_in_statement9488);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_SEMI.add(SEMI328);
                    }
                    // 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();
                        // 864:77: -> ^( BREAK ( IDENT )? )
                        {
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:864:81: ^( BREAK ( IDENT )? )
                            {
                                CommonTree root_1 = (CommonTree) adaptor.nil();
                                root_1 = (CommonTree) adaptor.becomeRoot(stream_BREAK.nextNode(), root_1);
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:864:89: ( IDENT )?
                                if (stream_IDENT.hasNext()) {
                                    adaptor.addChild(root_1, stream_IDENT.nextNode());
                                }
                                stream_IDENT.reset();
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
            case 13:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:865:9: CONTINUE ( IDENT )? SEMI
                {
                    CONTINUE329 = (Token) match(input, CONTINUE, FOLLOW_CONTINUE_in_statement9558);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_CONTINUE.add(CONTINUE329);
                    }
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:865:18: ( IDENT )?
                    int alt97 = 2;
                    int LA97_0 = input.LA(1);
                    if ((LA97_0 == IDENT)) {
                        alt97 = 1;
                    }
                    switch(alt97) {
                        case 1:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: IDENT
                            {
                                IDENT330 = (Token) match(input, IDENT, FOLLOW_IDENT_in_statement9560);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_IDENT.add(IDENT330);
                                }
                            }
                            break;
                    }
                    SEMI331 = (Token) match(input, SEMI, FOLLOW_SEMI_in_statement9563);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_SEMI.add(SEMI331);
                    }
                    // 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();
                        // 865:77: -> ^( CONTINUE ( IDENT )? )
                        {
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:865:81: ^( CONTINUE ( IDENT )? )
                            {
                                CommonTree root_1 = (CommonTree) adaptor.nil();
                                root_1 = (CommonTree) adaptor.becomeRoot(stream_CONTINUE.nextNode(), root_1);
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:865:92: ( IDENT )?
                                if (stream_IDENT.hasNext()) {
                                    adaptor.addChild(root_1, stream_IDENT.nextNode());
                                }
                                stream_IDENT.reset();
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
            case 14:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:866:9: IDENT COLON statement
                {
                    IDENT332 = (Token) match(input, IDENT, FOLLOW_IDENT_in_statement9630);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_IDENT.add(IDENT332);
                    }
                    COLON333 = (Token) match(input, COLON, FOLLOW_COLON_in_statement9632);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_COLON.add(COLON333);
                    }
                    pushFollow(FOLLOW_statement_in_statement9634);
                    statement334 = statement();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_statement.add(statement334.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();
                        // 866:77: -> ^( LABELED_STATEMENT IDENT statement )
                        {
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:866:81: ^( LABELED_STATEMENT IDENT statement )
                            {
                                CommonTree root_1 = (CommonTree) adaptor.nil();
                                root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(LABELED_STATEMENT, "LABELED_STATEMENT"), root_1);
                                adaptor.addChild(root_1, stream_IDENT.nextNode());
                                adaptor.addChild(root_1, stream_statement.nextTree());
                                adaptor.addChild(root_0, root_1);
                            }
                        }
                        retval.tree = root_0;
                    }
                }
                break;
            case 15:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:867:9: expression SEMI
                {
                    root_0 = (CommonTree) adaptor.nil();
                    pushFollow(FOLLOW_expression_in_statement9701);
                    expression335 = expression();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        adaptor.addChild(root_0, expression335.getTree());
                    }
                    SEMI336 = (Token) match(input, SEMI, FOLLOW_SEMI_in_statement9703);
                    if (state.failed) {
                        return retval;
                    }
                }
                break;
            case 16:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:868:9: SEMI
                {
                    root_0 = (CommonTree) adaptor.nil();
                    SEMI337 = (Token) match(input, SEMI, FOLLOW_SEMI_in_statement9714);
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        SEMI337_tree = (CommonTree) adaptor.create(SEMI337);
                        adaptor.addChild(root_0, SEMI337_tree);
                    }
                }
                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, 75, statement_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 47 with CommonTree

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

the class JavaParser method enumClassScopeDeclarations.

// $ANTLR start "enumClassScopeDeclarations"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:503:1: enumClassScopeDeclarations : SEMI ( classScopeDeclarations )* -> ^( CLASS_TOP_LEVEL_SCOPE[$SEMI, \"CLASS_TOP_LEVEL_SCOPE\"] ( classScopeDeclarations )* ) ;
public final JavaParser.enumClassScopeDeclarations_return enumClassScopeDeclarations() throws RecognitionException {
    JavaParser.enumClassScopeDeclarations_return retval = new JavaParser.enumClassScopeDeclarations_return();
    retval.start = input.LT(1);
    int enumClassScopeDeclarations_StartIndex = input.index();
    CommonTree root_0 = null;
    Token SEMI57 = null;
    JavaParser.classScopeDeclarations_return classScopeDeclarations58 = null;
    CommonTree SEMI57_tree = null;
    RewriteRuleTokenStream stream_SEMI = new RewriteRuleTokenStream(adaptor, "token SEMI");
    RewriteRuleSubtreeStream stream_classScopeDeclarations = new RewriteRuleSubtreeStream(adaptor, "rule classScopeDeclarations");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 18)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:504:5: ( SEMI ( classScopeDeclarations )* -> ^( CLASS_TOP_LEVEL_SCOPE[$SEMI, \"CLASS_TOP_LEVEL_SCOPE\"] ( classScopeDeclarations )* ) )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:504:9: SEMI ( classScopeDeclarations )*
        {
            SEMI57 = (Token) match(input, SEMI, FOLLOW_SEMI_in_enumClassScopeDeclarations5316);
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_SEMI.add(SEMI57);
            }
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:504:14: ( classScopeDeclarations )*
            loop19: do {
                int alt19 = 2;
                int LA19_0 = input.LA(1);
                if ((LA19_0 == AT || LA19_0 == LCURLY || LA19_0 == LESS_THAN || LA19_0 == SEMI || LA19_0 == ABSTRACT || LA19_0 == BOOLEAN || LA19_0 == BYTE || (LA19_0 >= CHAR && LA19_0 <= CLASS) || LA19_0 == DOUBLE || LA19_0 == ENUM || LA19_0 == FINAL || LA19_0 == FLOAT || LA19_0 == INTERFACE || (LA19_0 >= INT && LA19_0 <= NATIVE) || (LA19_0 >= PRIVATE && LA19_0 <= PUBLIC) || (LA19_0 >= SHORT && LA19_0 <= STRICTFP) || LA19_0 == SYNCHRONIZED || LA19_0 == TRANSIENT || (LA19_0 >= VOID && LA19_0 <= VOLATILE) || LA19_0 == IDENT)) {
                    alt19 = 1;
                }
                switch(alt19) {
                    case 1:
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: classScopeDeclarations
                        {
                            pushFollow(FOLLOW_classScopeDeclarations_in_enumClassScopeDeclarations5318);
                            classScopeDeclarations58 = classScopeDeclarations();
                            state._fsp--;
                            if (state.failed) {
                                return retval;
                            }
                            if (state.backtracking == 0) {
                                stream_classScopeDeclarations.add(classScopeDeclarations58.getTree());
                            }
                        }
                        break;
                    default:
                        break loop19;
                }
            } 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();
                // 505:9: -> ^( CLASS_TOP_LEVEL_SCOPE[$SEMI, \"CLASS_TOP_LEVEL_SCOPE\"] ( classScopeDeclarations )* )
                {
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:505:13: ^( CLASS_TOP_LEVEL_SCOPE[$SEMI, \"CLASS_TOP_LEVEL_SCOPE\"] ( classScopeDeclarations )* )
                    {
                        CommonTree root_1 = (CommonTree) adaptor.nil();
                        root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(CLASS_TOP_LEVEL_SCOPE, SEMI57, "CLASS_TOP_LEVEL_SCOPE"), root_1);
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:505:69: ( classScopeDeclarations )*
                        while (stream_classScopeDeclarations.hasNext()) {
                            adaptor.addChild(root_1, stream_classScopeDeclarations.nextTree());
                        }
                        stream_classScopeDeclarations.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, 18, enumClassScopeDeclarations_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 48 with CommonTree

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

the class JavaParser method relationalExpression.

// $ANTLR start "relationalExpression"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:989:1: relationalExpression : shiftExpression ( ( LESS_OR_EQUAL | GREATER_OR_EQUAL | LESS_THAN | GREATER_THAN ) shiftExpression )* ;
public final JavaParser.relationalExpression_return relationalExpression() throws RecognitionException {
    JavaParser.relationalExpression_return retval = new JavaParser.relationalExpression_return();
    retval.start = input.LT(1);
    int relationalExpression_StartIndex = input.index();
    CommonTree root_0 = null;
    Token LESS_OR_EQUAL408 = null;
    Token GREATER_OR_EQUAL409 = null;
    Token LESS_THAN410 = null;
    Token GREATER_THAN411 = null;
    JavaParser.shiftExpression_return shiftExpression407 = null;
    JavaParser.shiftExpression_return shiftExpression412 = null;
    CommonTree LESS_OR_EQUAL408_tree = null;
    CommonTree GREATER_OR_EQUAL409_tree = null;
    CommonTree LESS_THAN410_tree = null;
    CommonTree GREATER_THAN411_tree = null;
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 98)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:990:5: ( shiftExpression ( ( LESS_OR_EQUAL | GREATER_OR_EQUAL | LESS_THAN | GREATER_THAN ) shiftExpression )* )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:990:9: shiftExpression ( ( LESS_OR_EQUAL | GREATER_OR_EQUAL | LESS_THAN | GREATER_THAN ) shiftExpression )*
        {
            root_0 = (CommonTree) adaptor.nil();
            pushFollow(FOLLOW_shiftExpression_in_relationalExpression10811);
            shiftExpression407 = shiftExpression();
            state._fsp--;
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                adaptor.addChild(root_0, shiftExpression407.getTree());
            }
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:991:9: ( ( LESS_OR_EQUAL | GREATER_OR_EQUAL | LESS_THAN | GREATER_THAN ) shiftExpression )*
            loop120: do {
                int alt120 = 2;
                int LA120_0 = input.LA(1);
                if (((LA120_0 >= GREATER_OR_EQUAL && LA120_0 <= GREATER_THAN) || (LA120_0 >= LESS_OR_EQUAL && LA120_0 <= LESS_THAN))) {
                    alt120 = 1;
                }
                switch(alt120) {
                    case 1:
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:991:13: ( LESS_OR_EQUAL | GREATER_OR_EQUAL | LESS_THAN | GREATER_THAN ) shiftExpression
                        {
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:991:13: ( LESS_OR_EQUAL | GREATER_OR_EQUAL | LESS_THAN | GREATER_THAN )
                            int alt119 = 4;
                            switch(input.LA(1)) {
                                case LESS_OR_EQUAL:
                                    {
                                        alt119 = 1;
                                    }
                                    break;
                                case GREATER_OR_EQUAL:
                                    {
                                        alt119 = 2;
                                    }
                                    break;
                                case LESS_THAN:
                                    {
                                        alt119 = 3;
                                    }
                                    break;
                                case GREATER_THAN:
                                    {
                                        alt119 = 4;
                                    }
                                    break;
                                default:
                                    if (state.backtracking > 0) {
                                        state.failed = true;
                                        return retval;
                                    }
                                    NoViableAltException nvae = new NoViableAltException("", 119, 0, input);
                                    throw nvae;
                            }
                            switch(alt119) {
                                case 1:
                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:991:17: LESS_OR_EQUAL
                                    {
                                        LESS_OR_EQUAL408 = (Token) match(input, LESS_OR_EQUAL, FOLLOW_LESS_OR_EQUAL_in_relationalExpression10829);
                                        if (state.failed) {
                                            return retval;
                                        }
                                        if (state.backtracking == 0) {
                                            LESS_OR_EQUAL408_tree = (CommonTree) adaptor.create(LESS_OR_EQUAL408);
                                            root_0 = (CommonTree) adaptor.becomeRoot(LESS_OR_EQUAL408_tree, root_0);
                                        }
                                    }
                                    break;
                                case 2:
                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:992:17: GREATER_OR_EQUAL
                                    {
                                        GREATER_OR_EQUAL409 = (Token) match(input, GREATER_OR_EQUAL, FOLLOW_GREATER_OR_EQUAL_in_relationalExpression10848);
                                        if (state.failed) {
                                            return retval;
                                        }
                                        if (state.backtracking == 0) {
                                            GREATER_OR_EQUAL409_tree = (CommonTree) adaptor.create(GREATER_OR_EQUAL409);
                                            root_0 = (CommonTree) adaptor.becomeRoot(GREATER_OR_EQUAL409_tree, root_0);
                                        }
                                    }
                                    break;
                                case 3:
                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:993:17: LESS_THAN
                                    {
                                        LESS_THAN410 = (Token) match(input, LESS_THAN, FOLLOW_LESS_THAN_in_relationalExpression10867);
                                        if (state.failed) {
                                            return retval;
                                        }
                                        if (state.backtracking == 0) {
                                            LESS_THAN410_tree = (CommonTree) adaptor.create(LESS_THAN410);
                                            root_0 = (CommonTree) adaptor.becomeRoot(LESS_THAN410_tree, root_0);
                                        }
                                    }
                                    break;
                                case 4:
                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:994:17: GREATER_THAN
                                    {
                                        GREATER_THAN411 = (Token) match(input, GREATER_THAN, FOLLOW_GREATER_THAN_in_relationalExpression10886);
                                        if (state.failed) {
                                            return retval;
                                        }
                                        if (state.backtracking == 0) {
                                            GREATER_THAN411_tree = (CommonTree) adaptor.create(GREATER_THAN411);
                                            root_0 = (CommonTree) adaptor.becomeRoot(GREATER_THAN411_tree, root_0);
                                        }
                                    }
                                    break;
                            }
                            pushFollow(FOLLOW_shiftExpression_in_relationalExpression10915);
                            shiftExpression412 = shiftExpression();
                            state._fsp--;
                            if (state.failed) {
                                return retval;
                            }
                            if (state.backtracking == 0) {
                                adaptor.addChild(root_0, shiftExpression412.getTree());
                            }
                        }
                        break;
                    default:
                        break loop120;
                }
            } 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, 98, relationalExpression_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 49 with CommonTree

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

the class JavaParser method newArrayConstruction.

// $ANTLR start "newArrayConstruction"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1146:1: newArrayConstruction : ( arrayDeclaratorList arrayInitializer | LBRACK expression RBRACK ( LBRACK expression RBRACK )* ( arrayDeclaratorList )? );
public final JavaParser.newArrayConstruction_return newArrayConstruction() throws RecognitionException {
    JavaParser.newArrayConstruction_return retval = new JavaParser.newArrayConstruction_return();
    retval.start = input.LT(1);
    int newArrayConstruction_StartIndex = input.index();
    CommonTree root_0 = null;
    Token LBRACK524 = null;
    Token RBRACK526 = null;
    Token LBRACK527 = null;
    Token RBRACK529 = null;
    JavaParser.arrayDeclaratorList_return arrayDeclaratorList522 = null;
    JavaParser.arrayInitializer_return arrayInitializer523 = null;
    JavaParser.expression_return expression525 = null;
    JavaParser.expression_return expression528 = null;
    JavaParser.arrayDeclaratorList_return arrayDeclaratorList530 = null;
    CommonTree LBRACK524_tree = null;
    CommonTree RBRACK526_tree = null;
    CommonTree LBRACK527_tree = null;
    CommonTree RBRACK529_tree = null;
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 109)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:1147:5: ( arrayDeclaratorList arrayInitializer | LBRACK expression RBRACK ( LBRACK expression RBRACK )* ( arrayDeclaratorList )? )
        int alt153 = 2;
        int LA153_0 = input.LA(1);
        if ((LA153_0 == LBRACK)) {
            int LA153_1 = input.LA(2);
            if ((LA153_1 == RBRACK)) {
                alt153 = 1;
            } else if ((LA153_1 == DEC || LA153_1 == INC || LA153_1 == LESS_THAN || LA153_1 == LOGICAL_NOT || (LA153_1 >= LPAREN && LA153_1 <= MINUS) || LA153_1 == NOT || LA153_1 == PLUS || LA153_1 == BOOLEAN || LA153_1 == BYTE || LA153_1 == CHAR || LA153_1 == DOUBLE || LA153_1 == FALSE || LA153_1 == FLOAT || (LA153_1 >= INT && LA153_1 <= LONG) || (LA153_1 >= NEW && LA153_1 <= NULL) || LA153_1 == SHORT || LA153_1 == SUPER || LA153_1 == THIS || LA153_1 == TRUE || LA153_1 == VOID || (LA153_1 >= IDENT && LA153_1 <= STRING_LITERAL))) {
                alt153 = 2;
            } else {
                if (state.backtracking > 0) {
                    state.failed = true;
                    return retval;
                }
                NoViableAltException nvae = new NoViableAltException("", 153, 1, input);
                throw nvae;
            }
        } else {
            if (state.backtracking > 0) {
                state.failed = true;
                return retval;
            }
            NoViableAltException nvae = new NoViableAltException("", 153, 0, input);
            throw nvae;
        }
        switch(alt153) {
            case 1:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:1147:9: arrayDeclaratorList arrayInitializer
                {
                    root_0 = (CommonTree) adaptor.nil();
                    pushFollow(FOLLOW_arrayDeclaratorList_in_newArrayConstruction14338);
                    arrayDeclaratorList522 = arrayDeclaratorList();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        adaptor.addChild(root_0, arrayDeclaratorList522.getTree());
                    }
                    pushFollow(FOLLOW_arrayInitializer_in_newArrayConstruction14340);
                    arrayInitializer523 = arrayInitializer();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        adaptor.addChild(root_0, arrayInitializer523.getTree());
                    }
                }
                break;
            case 2:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:1148:9: LBRACK expression RBRACK ( LBRACK expression RBRACK )* ( arrayDeclaratorList )?
                {
                    root_0 = (CommonTree) adaptor.nil();
                    LBRACK524 = (Token) match(input, LBRACK, FOLLOW_LBRACK_in_newArrayConstruction14350);
                    if (state.failed) {
                        return retval;
                    }
                    pushFollow(FOLLOW_expression_in_newArrayConstruction14353);
                    expression525 = expression();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        adaptor.addChild(root_0, expression525.getTree());
                    }
                    RBRACK526 = (Token) match(input, RBRACK, FOLLOW_RBRACK_in_newArrayConstruction14355);
                    if (state.failed) {
                        return retval;
                    }
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1148:36: ( LBRACK expression RBRACK )*
                    loop151: do {
                        int alt151 = 2;
                        alt151 = dfa151.predict(input);
                        switch(alt151) {
                            case 1:
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:1148:37: LBRACK expression RBRACK
                                {
                                    LBRACK527 = (Token) match(input, LBRACK, FOLLOW_LBRACK_in_newArrayConstruction14359);
                                    if (state.failed) {
                                        return retval;
                                    }
                                    pushFollow(FOLLOW_expression_in_newArrayConstruction14362);
                                    expression528 = expression();
                                    state._fsp--;
                                    if (state.failed) {
                                        return retval;
                                    }
                                    if (state.backtracking == 0) {
                                        adaptor.addChild(root_0, expression528.getTree());
                                    }
                                    RBRACK529 = (Token) match(input, RBRACK, FOLLOW_RBRACK_in_newArrayConstruction14364);
                                    if (state.failed) {
                                        return retval;
                                    }
                                }
                                break;
                            default:
                                break loop151;
                        }
                    } while (true);
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1148:66: ( arrayDeclaratorList )?
                    int alt152 = 2;
                    int LA152_0 = input.LA(1);
                    if ((LA152_0 == LBRACK)) {
                        int LA152_1 = input.LA(2);
                        if ((LA152_1 == RBRACK)) {
                            alt152 = 1;
                        }
                    }
                    switch(alt152) {
                        case 1:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: arrayDeclaratorList
                            {
                                pushFollow(FOLLOW_arrayDeclaratorList_in_newArrayConstruction14369);
                                arrayDeclaratorList530 = arrayDeclaratorList();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    adaptor.addChild(root_0, arrayDeclaratorList530.getTree());
                                }
                            }
                            break;
                    }
                }
                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, 109, newArrayConstruction_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 50 with CommonTree

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

the class JavaParser method expression.

// $ANTLR start "expression"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:929:1: expression : assignmentExpression -> ^( EXPR assignmentExpression ) ;
public final JavaParser.expression_return expression() throws RecognitionException {
    JavaParser.expression_return retval = new JavaParser.expression_return();
    retval.start = input.LT(1);
    int expression_StartIndex = input.index();
    CommonTree root_0 = null;
    JavaParser.assignmentExpression_return assignmentExpression365 = null;
    RewriteRuleSubtreeStream stream_assignmentExpression = new RewriteRuleSubtreeStream(adaptor, "rule assignmentExpression");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 88)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:930:5: ( assignmentExpression -> ^( EXPR assignmentExpression ) )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:930:9: assignmentExpression
        {
            pushFollow(FOLLOW_assignmentExpression_in_expression10216);
            assignmentExpression365 = assignmentExpression();
            state._fsp--;
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_assignmentExpression.add(assignmentExpression365.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();
                // 931:9: -> ^( EXPR assignmentExpression )
                {
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:931:13: ^( EXPR assignmentExpression )
                    {
                        CommonTree root_1 = (CommonTree) adaptor.nil();
                        root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(EXPR, "EXPR"), root_1);
                        adaptor.addChild(root_1, stream_assignmentExpression.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, 88, expression_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