public final ANTLRv3TreeFilter.rewrite_alternative_return rewrite_alternative() throws RecognitionException {
        ANTLRv3TreeFilter.rewrite_alternative_return retval = new ANTLRv3TreeFilter.rewrite_alternative_return();
        retval.start = input.LT(1);

        try {
            // back-end/koopa/trees/antlr/filter/generator/ANTLRv3TreeFilter.g:423:2: ( rewrite_template | rewrite_tree_alternative | ^( ALT EPSILON EOA ) )
            int alt43=3;
            int LA43_0 = input.LA(1);

            if ( (LA43_0==TEMPLATE||LA43_0==ACTION) ) {
                alt43=1;
            }
            else if ( (LA43_0==ALT) ) {
                int LA43_2 = input.LA(2);

                if ( (LA43_2==DOWN) ) {
                    int LA43_3 = input.LA(3);

                    if ( (LA43_3==EPSILON) ) {
                        alt43=3;
                    }
                    else if ( ((LA43_3>=BLOCK && LA43_3<=POSITIVE_CLOSURE)||LA43_3==LABEL||LA43_3==TREE_BEGIN||(LA43_3>=TOKEN_REF && LA43_3<=ACTION)||LA43_3==RULE_REF) ) {
                        alt43=2;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("", 43, 3, input);

                        throw nvae;
                    }
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("", 43, 2, input);

                    throw nvae;
                }
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 43, 0, input);

                throw nvae;
            }
            switch (alt43) {
                case 1 :
                    // back-end/koopa/trees/antlr/filter/generator/ANTLRv3TreeFilter.g:423:4: rewrite_template
                    {
                    pushFollow(FOLLOW_rewrite_template_in_rewrite_alternative2138);
                    rewrite_template();

                    state._fsp--;


                    }
                    break;
                case 2 :
                    // back-end/koopa/trees/antlr/filter/generator/ANTLRv3TreeFilter.g:424:4: rewrite_tree_alternative
                    {
                    pushFollow(FOLLOW_rewrite_tree_alternative_in_rewrite_alternative2143);
                    rewrite_tree_alternative();

                    state._fsp--;


                    }
                    break;
                case 3 :
                    // back-end/koopa/trees/antlr/filter/generator/ANTLRv3TreeFilter.g:425:9: ^( ALT EPSILON EOA )
                    {
                    match(input,ALT,FOLLOW_ALT_in_rewrite_alternative2154); 

                    match(input, Token.DOWN, null); 
                    match(input,EPSILON,FOLLOW_EPSILON_in_rewrite_alternative2156); 
                    match(input,EOA,FOLLOW_EOA_in_rewrite_alternative2158); 

                    match(input, Token.UP, null); 

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }