/** \file * This OBJC source file was generated by $ANTLR version 3.2 Aug 23, 2010 07:48:06 * * - From the grammar source file : /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g * - On : 2010-08-23 07:55:04 * - for the tree parser : SimpleCTPTreeParser * * Editing it, at least manually, is not wise. * * ObjC language generator and runtime by Alan Condit, acondit|hereisanat|ipns|dotgoeshere|com. * * */ // [The "BSD licence"] // Copyright (c) 2010 Alan Condit // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. The name of the author may not be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // $ANTLR 3.2 Aug 23, 2010 07:48:06 /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g 2010-08-23 07:55:04 /* ----------------------------------------- * Include the ANTLR3 generated header file. */ #import "SimpleCTP.h" /* ----------------------------------------- */ /* ============================================================================= */ /* ============================================================================= * Start of recognizer */ #pragma mark Bitsets static ANTLRBitSet *FOLLOW_declaration_in_program56; static const unsigned long long FOLLOW_declaration_in_program56_data[] = { 0x0000000000000192LL}; static ANTLRBitSet *FOLLOW_variable_in_declaration76; static const unsigned long long FOLLOW_variable_in_declaration76_data[] = { 0x0000000000000002LL}; static ANTLRBitSet *FOLLOW_FUNC_DECL_in_declaration87; static const unsigned long long FOLLOW_FUNC_DECL_in_declaration87_data[] = { 0x0000000000000004LL}; static ANTLRBitSet *FOLLOW_functionHeader_in_declaration89; static const unsigned long long FOLLOW_functionHeader_in_declaration89_data[] = { 0x0000000000000008LL}; static ANTLRBitSet *FOLLOW_FUNC_DEF_in_declaration101; static const unsigned long long FOLLOW_FUNC_DEF_in_declaration101_data[] = { 0x0000000000000004LL}; static ANTLRBitSet *FOLLOW_functionHeader_in_declaration103; static const unsigned long long FOLLOW_functionHeader_in_declaration103_data[] = { 0x0000000000000200LL}; static ANTLRBitSet *FOLLOW_block_in_declaration105; static const unsigned long long FOLLOW_block_in_declaration105_data[] = { 0x0000000000000008LL}; static ANTLRBitSet *FOLLOW_VAR_DEF_in_variable126; static const unsigned long long FOLLOW_VAR_DEF_in_variable126_data[] = { 0x0000000000000004LL}; static ANTLRBitSet *FOLLOW_type_in_variable128; static const unsigned long long FOLLOW_type_in_variable128_data[] = { 0x0000000000000400LL}; static ANTLRBitSet *FOLLOW_declarator_in_variable130; static const unsigned long long FOLLOW_declarator_in_variable130_data[] = { 0x0000000000000008LL}; static ANTLRBitSet *FOLLOW_K_ID_in_declarator150; static const unsigned long long FOLLOW_K_ID_in_declarator150_data[] = { 0x0000000000000002LL}; static ANTLRBitSet *FOLLOW_FUNC_HDR_in_functionHeader171; static const unsigned long long FOLLOW_FUNC_HDR_in_functionHeader171_data[] = { 0x0000000000000004LL}; static ANTLRBitSet *FOLLOW_type_in_functionHeader173; static const unsigned long long FOLLOW_type_in_functionHeader173_data[] = { 0x0000000000000400LL}; static ANTLRBitSet *FOLLOW_K_ID_in_functionHeader175; static const unsigned long long FOLLOW_K_ID_in_functionHeader175_data[] = { 0x0000000000000020LL}; static ANTLRBitSet *FOLLOW_formalParameter_in_functionHeader177; static const unsigned long long FOLLOW_formalParameter_in_functionHeader177_data[] = { 0x0000000000000028LL}; static ANTLRBitSet *FOLLOW_ARG_DEF_in_formalParameter199; static const unsigned long long FOLLOW_ARG_DEF_in_formalParameter199_data[] = { 0x0000000000000004LL}; static ANTLRBitSet *FOLLOW_type_in_formalParameter201; static const unsigned long long FOLLOW_type_in_formalParameter201_data[] = { 0x0000000000000400LL}; static ANTLRBitSet *FOLLOW_declarator_in_formalParameter203; static const unsigned long long FOLLOW_declarator_in_formalParameter203_data[] = { 0x0000000000000008LL}; static ANTLRBitSet *FOLLOW_set_in_type0; static const unsigned long long FOLLOW_set_in_type0_data[] = { 0x0000000000000002LL}; static ANTLRBitSet *FOLLOW_BLOCK_in_block286; static const unsigned long long FOLLOW_BLOCK_in_block286_data[] = { 0x0000000000000004LL}; static ANTLRBitSet *FOLLOW_variable_in_block288; static const unsigned long long FOLLOW_variable_in_block288_data[] = { 0x000000000007CE18LL}; static ANTLRBitSet *FOLLOW_stat_in_block291; static const unsigned long long FOLLOW_stat_in_block291_data[] = { 0x000000000007CE08LL}; static ANTLRBitSet *FOLLOW_forStat_in_stat305; static const unsigned long long FOLLOW_forStat_in_stat305_data[] = { 0x0000000000000002LL}; static ANTLRBitSet *FOLLOW_expr_in_stat313; static const unsigned long long FOLLOW_expr_in_stat313_data[] = { 0x0000000000000002LL}; static ANTLRBitSet *FOLLOW_block_in_stat321; static const unsigned long long FOLLOW_block_in_stat321_data[] = { 0x0000000000000002LL}; static ANTLRBitSet *FOLLOW_K_FOR_in_forStat341; static const unsigned long long FOLLOW_K_FOR_in_forStat341_data[] = { 0x0000000000000004LL}; static ANTLRBitSet *FOLLOW_expr_in_forStat343; static const unsigned long long FOLLOW_expr_in_forStat343_data[] = { 0x0000000000078C00LL}; static ANTLRBitSet *FOLLOW_expr_in_forStat345; static const unsigned long long FOLLOW_expr_in_forStat345_data[] = { 0x0000000000078C00LL}; static ANTLRBitSet *FOLLOW_expr_in_forStat347; static const unsigned long long FOLLOW_expr_in_forStat347_data[] = { 0x0000000000000200LL}; static ANTLRBitSet *FOLLOW_block_in_forStat349; static const unsigned long long FOLLOW_block_in_forStat349_data[] = { 0x0000000000000008LL}; static ANTLRBitSet *FOLLOW_K_EQEQ_in_expr365; static const unsigned long long FOLLOW_K_EQEQ_in_expr365_data[] = { 0x0000000000000004LL}; static ANTLRBitSet *FOLLOW_expr_in_expr367; static const unsigned long long FOLLOW_expr_in_expr367_data[] = { 0x0000000000078C00LL}; static ANTLRBitSet *FOLLOW_expr_in_expr369; static const unsigned long long FOLLOW_expr_in_expr369_data[] = { 0x0000000000000008LL}; static ANTLRBitSet *FOLLOW_K_LT_in_expr381; static const unsigned long long FOLLOW_K_LT_in_expr381_data[] = { 0x0000000000000004LL}; static ANTLRBitSet *FOLLOW_expr_in_expr383; static const unsigned long long FOLLOW_expr_in_expr383_data[] = { 0x0000000000078C00LL}; static ANTLRBitSet *FOLLOW_expr_in_expr385; static const unsigned long long FOLLOW_expr_in_expr385_data[] = { 0x0000000000000008LL}; static ANTLRBitSet *FOLLOW_K_PLUS_in_expr397; static const unsigned long long FOLLOW_K_PLUS_in_expr397_data[] = { 0x0000000000000004LL}; static ANTLRBitSet *FOLLOW_expr_in_expr399; static const unsigned long long FOLLOW_expr_in_expr399_data[] = { 0x0000000000078C00LL}; static ANTLRBitSet *FOLLOW_expr_in_expr401; static const unsigned long long FOLLOW_expr_in_expr401_data[] = { 0x0000000000000008LL}; static ANTLRBitSet *FOLLOW_K_EQ_in_expr413; static const unsigned long long FOLLOW_K_EQ_in_expr413_data[] = { 0x0000000000000004LL}; static ANTLRBitSet *FOLLOW_K_ID_in_expr415; static const unsigned long long FOLLOW_K_ID_in_expr415_data[] = { 0x0000000000078C00LL}; static ANTLRBitSet *FOLLOW_expr_in_expr419; static const unsigned long long FOLLOW_expr_in_expr419_data[] = { 0x0000000000000008LL}; static ANTLRBitSet *FOLLOW_atom_in_expr432; static const unsigned long long FOLLOW_atom_in_expr432_data[] = { 0x0000000000000002LL}; static ANTLRBitSet *FOLLOW_set_in_atom0; static const unsigned long long FOLLOW_set_in_atom0_data[] = { 0x0000000000000002LL}; #pragma mark Dynamic Global Scopes @implementation Symbols_Scope /* globalAttributeScopeImpl */ /* start of synthesize -- OBJC-Line 1750 */ @synthesize tree; + (Symbols_Scope *)newSymbols_Scope { return [[[Symbols_Scope alloc] init] retain]; } /* start of iterate get and set functions */ - (ANTLRCommonTree *)gettree { return( tree ); } - (void)settree:(ANTLRCommonTree *)aVal { tree = aVal; } /* End of iterate get and set functions */ @end /* end of Symbols_Scope implementation */ #pragma mark Dynamic Rule Scopes #pragma mark Rule return scopes start @implementation SimpleCTP_expr_return + (SimpleCTP_expr_return *)newSimpleCTP_expr_return { return [[[SimpleCTP_expr_return alloc] init] retain]; } @end /* end of returnScope implementation */ @implementation SimpleCTP // line 610 + (void) initialize { #pragma mark Bitsets FOLLOW_declaration_in_program56 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_declaration_in_program56_data Count:(NSUInteger)1] retain]; FOLLOW_variable_in_declaration76 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_variable_in_declaration76_data Count:(NSUInteger)1] retain]; FOLLOW_FUNC_DECL_in_declaration87 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_FUNC_DECL_in_declaration87_data Count:(NSUInteger)1] retain]; FOLLOW_functionHeader_in_declaration89 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_functionHeader_in_declaration89_data Count:(NSUInteger)1] retain]; FOLLOW_FUNC_DEF_in_declaration101 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_FUNC_DEF_in_declaration101_data Count:(NSUInteger)1] retain]; FOLLOW_functionHeader_in_declaration103 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_functionHeader_in_declaration103_data Count:(NSUInteger)1] retain]; FOLLOW_block_in_declaration105 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_declaration105_data Count:(NSUInteger)1] retain]; FOLLOW_VAR_DEF_in_variable126 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_VAR_DEF_in_variable126_data Count:(NSUInteger)1] retain]; FOLLOW_type_in_variable128 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_type_in_variable128_data Count:(NSUInteger)1] retain]; FOLLOW_declarator_in_variable130 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_declarator_in_variable130_data Count:(NSUInteger)1] retain]; FOLLOW_K_ID_in_declarator150 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_ID_in_declarator150_data Count:(NSUInteger)1] retain]; FOLLOW_FUNC_HDR_in_functionHeader171 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_FUNC_HDR_in_functionHeader171_data Count:(NSUInteger)1] retain]; FOLLOW_type_in_functionHeader173 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_type_in_functionHeader173_data Count:(NSUInteger)1] retain]; FOLLOW_K_ID_in_functionHeader175 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_ID_in_functionHeader175_data Count:(NSUInteger)1] retain]; FOLLOW_formalParameter_in_functionHeader177 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_formalParameter_in_functionHeader177_data Count:(NSUInteger)1] retain]; FOLLOW_ARG_DEF_in_formalParameter199 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_ARG_DEF_in_formalParameter199_data Count:(NSUInteger)1] retain]; FOLLOW_type_in_formalParameter201 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_type_in_formalParameter201_data Count:(NSUInteger)1] retain]; FOLLOW_declarator_in_formalParameter203 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_declarator_in_formalParameter203_data Count:(NSUInteger)1] retain]; FOLLOW_set_in_type0 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_set_in_type0_data Count:(NSUInteger)1] retain]; FOLLOW_BLOCK_in_block286 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_BLOCK_in_block286_data Count:(NSUInteger)1] retain]; FOLLOW_variable_in_block288 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_variable_in_block288_data Count:(NSUInteger)1] retain]; FOLLOW_stat_in_block291 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_stat_in_block291_data Count:(NSUInteger)1] retain]; FOLLOW_forStat_in_stat305 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_forStat_in_stat305_data Count:(NSUInteger)1] retain]; FOLLOW_expr_in_stat313 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_stat313_data Count:(NSUInteger)1] retain]; FOLLOW_block_in_stat321 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_stat321_data Count:(NSUInteger)1] retain]; FOLLOW_K_FOR_in_forStat341 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_FOR_in_forStat341_data Count:(NSUInteger)1] retain]; FOLLOW_expr_in_forStat343 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_forStat343_data Count:(NSUInteger)1] retain]; FOLLOW_expr_in_forStat345 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_forStat345_data Count:(NSUInteger)1] retain]; FOLLOW_expr_in_forStat347 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_forStat347_data Count:(NSUInteger)1] retain]; FOLLOW_block_in_forStat349 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_forStat349_data Count:(NSUInteger)1] retain]; FOLLOW_K_EQEQ_in_expr365 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_EQEQ_in_expr365_data Count:(NSUInteger)1] retain]; FOLLOW_expr_in_expr367 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_expr367_data Count:(NSUInteger)1] retain]; FOLLOW_expr_in_expr369 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_expr369_data Count:(NSUInteger)1] retain]; FOLLOW_K_LT_in_expr381 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_LT_in_expr381_data Count:(NSUInteger)1] retain]; FOLLOW_expr_in_expr383 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_expr383_data Count:(NSUInteger)1] retain]; FOLLOW_expr_in_expr385 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_expr385_data Count:(NSUInteger)1] retain]; FOLLOW_K_PLUS_in_expr397 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_PLUS_in_expr397_data Count:(NSUInteger)1] retain]; FOLLOW_expr_in_expr399 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_expr399_data Count:(NSUInteger)1] retain]; FOLLOW_expr_in_expr401 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_expr401_data Count:(NSUInteger)1] retain]; FOLLOW_K_EQ_in_expr413 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_EQ_in_expr413_data Count:(NSUInteger)1] retain]; FOLLOW_K_ID_in_expr415 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_ID_in_expr415_data Count:(NSUInteger)1] retain]; FOLLOW_expr_in_expr419 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_expr419_data Count:(NSUInteger)1] retain]; FOLLOW_atom_in_expr432 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_atom_in_expr432_data Count:(NSUInteger)1] retain]; FOLLOW_set_in_atom0 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_set_in_atom0_data Count:(NSUInteger)1] retain]; [ANTLRBaseRecognizer setTokenNames:[[[NSArray alloc] initWithObjects:@"", @"", @"", @"", @"VAR_DEF", @"ARG_DEF", @"FUNC_HDR", @"FUNC_DECL", @"FUNC_DEF", @"BLOCK", @"K_ID", @"K_INT", @"K_CHAR", @"K_VOID", @"K_FOR", @"K_EQ", @"K_EQEQ", @"K_LT", @"K_PLUS", @"K_INT_TYPE", @"WS", @"';'", @"'('", @"','", @"')'", @"'{'", @"'}'", nil] retain]]; } + (SimpleCTP *)newSimpleCTP:(id)aStream { return [[SimpleCTP alloc] initWithStream:aStream]; } - (id) initWithStream:(id)aStream { if ((self = [super initWithStream:aStream State:[[ANTLRRecognizerSharedState newANTLRRecognizerSharedStateWithRuleLen:12+1] retain]]) != nil) { /* start of actions-actionScope-init */ /* start of init */ } return self; } - (void) dealloc { [Symbols_scope release]; [super dealloc]; } // start actions.actionScope.methods // start methods() // start rules /* * $ANTLR start program * /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:13:1: program : ( declaration )+ ; */ - (void) program { /* ruleScopeSetUp */ @try { // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:14:5: ( ( declaration )+ ) // ruleBlockSingleAlt // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:14:9: ( declaration )+ // alt { // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:14:9: ( declaration )+ // positiveClosureBlock NSInteger cnt1=0; do { NSInteger alt1=2; NSInteger LA1_0 = [input LA:1]; if ( (LA1_0==VAR_DEF||(LA1_0>=FUNC_DECL && LA1_0<=FUNC_DEF)) ) { alt1=1; } switch (alt1) { case 1 : ; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:14:9: declaration // alt { [self pushFollow:FOLLOW_declaration_in_program56]; [self declaration]; [self popFollow]; /* element() */ /* elements */ } break; default : if ( cnt1 >= 1 ) goto loop1; ANTLREarlyExitException *eee = [ANTLREarlyExitException exceptionWithStream:input decisionNumber:1]; @throw eee; } cnt1++; } while (YES); loop1: ; /* element() */ /* elements */ } // token+rule list labels } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { } return ; } /* $ANTLR end program */ /* * $ANTLR start declaration * /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:17:1: declaration : ( variable | ^( FUNC_DECL functionHeader ) | ^( FUNC_DEF functionHeader block ) ); */ - (void) declaration { /* ruleScopeSetUp */ @try { // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:18:5: ( variable | ^( FUNC_DECL functionHeader ) | ^( FUNC_DEF functionHeader block ) ) //ruleblock NSInteger alt2=3; switch ([input LA:1]) { case VAR_DEF: ; { alt2=1; } break; case FUNC_DECL: ; { alt2=2; } break; case FUNC_DEF: ; { alt2=3; } break; default: ; ANTLRNoViableAltException *nvae = [ANTLRNoViableAltException newANTLRNoViableAltException:2 state:0 stream:input]; @throw nvae; } switch (alt2) { case 1 : ; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:18:9: variable // alt { [self pushFollow:FOLLOW_variable_in_declaration76]; [self variable]; [self popFollow]; /* element() */ /* elements */ } break; case 2 : ; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:19:9: ^( FUNC_DECL functionHeader ) // alt { [self match:input TokenType:FUNC_DECL Follow:FOLLOW_FUNC_DECL_in_declaration87]; /* element() */ [self match:input TokenType:ANTLRTokenTypeDOWN Follow:nil]; [self pushFollow:FOLLOW_functionHeader_in_declaration89]; [self functionHeader]; [self popFollow]; /* element() */ [self match:input TokenType:ANTLRTokenTypeUP Follow:nil]; /* element() */ /* elements */ } break; case 3 : ; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:20:9: ^( FUNC_DEF functionHeader block ) // alt { [self match:input TokenType:FUNC_DEF Follow:FOLLOW_FUNC_DEF_in_declaration101]; /* element() */ [self match:input TokenType:ANTLRTokenTypeDOWN Follow:nil]; [self pushFollow:FOLLOW_functionHeader_in_declaration103]; [self functionHeader]; [self popFollow]; /* element() */ [self pushFollow:FOLLOW_block_in_declaration105]; [self block]; [self popFollow]; /* element() */ [self match:input TokenType:ANTLRTokenTypeUP Follow:nil]; /* element() */ /* elements */ } break; } // token+rule list labels } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { } return ; } /* $ANTLR end declaration */ /* * $ANTLR start variable * /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:23:1: variable : ^( VAR_DEF type declarator ) ; */ - (void) variable { /* ruleScopeSetUp */ @try { // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:24:5: ( ^( VAR_DEF type declarator ) ) // ruleBlockSingleAlt // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:24:9: ^( VAR_DEF type declarator ) // alt { [self match:input TokenType:VAR_DEF Follow:FOLLOW_VAR_DEF_in_variable126]; /* element() */ [self match:input TokenType:ANTLRTokenTypeDOWN Follow:nil]; [self pushFollow:FOLLOW_type_in_variable128]; [self type]; [self popFollow]; /* element() */ [self pushFollow:FOLLOW_declarator_in_variable130]; [self declarator]; [self popFollow]; /* element() */ [self match:input TokenType:ANTLRTokenTypeUP Follow:nil]; /* element() */ /* elements */ } // token+rule list labels } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { } return ; } /* $ANTLR end variable */ /* * $ANTLR start declarator * /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:27:1: declarator : K_ID ; */ - (void) declarator { /* ruleScopeSetUp */ @try { // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:28:5: ( K_ID ) // ruleBlockSingleAlt // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:28:9: K_ID // alt { [self match:input TokenType:K_ID Follow:FOLLOW_K_ID_in_declarator150]; /* element() */ /* elements */ } // token+rule list labels } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { } return ; } /* $ANTLR end declarator */ /* * $ANTLR start functionHeader * /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:31:1: functionHeader : ^( FUNC_HDR type K_ID ( formalParameter )+ ) ; */ - (void) functionHeader { /* ruleScopeSetUp */ @try { // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:32:5: ( ^( FUNC_HDR type K_ID ( formalParameter )+ ) ) // ruleBlockSingleAlt // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:32:9: ^( FUNC_HDR type K_ID ( formalParameter )+ ) // alt { [self match:input TokenType:FUNC_HDR Follow:FOLLOW_FUNC_HDR_in_functionHeader171]; /* element() */ [self match:input TokenType:ANTLRTokenTypeDOWN Follow:nil]; [self pushFollow:FOLLOW_type_in_functionHeader173]; [self type]; [self popFollow]; /* element() */ [self match:input TokenType:K_ID Follow:FOLLOW_K_ID_in_functionHeader175]; /* element() */ // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:32:30: ( formalParameter )+ // positiveClosureBlock NSInteger cnt3=0; do { NSInteger alt3=2; NSInteger LA3_0 = [input LA:1]; if ( (LA3_0==ARG_DEF) ) { alt3=1; } switch (alt3) { case 1 : ; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:32:30: formalParameter // alt { [self pushFollow:FOLLOW_formalParameter_in_functionHeader177]; [self formalParameter]; [self popFollow]; /* element() */ /* elements */ } break; default : if ( cnt3 >= 1 ) goto loop3; ANTLREarlyExitException *eee = [ANTLREarlyExitException exceptionWithStream:input decisionNumber:3]; @throw eee; } cnt3++; } while (YES); loop3: ; /* element() */ [self match:input TokenType:ANTLRTokenTypeUP Follow:nil]; /* element() */ /* elements */ } // token+rule list labels } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { } return ; } /* $ANTLR end functionHeader */ /* * $ANTLR start formalParameter * /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:35:1: formalParameter : ^( ARG_DEF type declarator ) ; */ - (void) formalParameter { /* ruleScopeSetUp */ @try { // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:36:5: ( ^( ARG_DEF type declarator ) ) // ruleBlockSingleAlt // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:36:9: ^( ARG_DEF type declarator ) // alt { [self match:input TokenType:ARG_DEF Follow:FOLLOW_ARG_DEF_in_formalParameter199]; /* element() */ [self match:input TokenType:ANTLRTokenTypeDOWN Follow:nil]; [self pushFollow:FOLLOW_type_in_formalParameter201]; [self type]; [self popFollow]; /* element() */ [self pushFollow:FOLLOW_declarator_in_formalParameter203]; [self declarator]; [self popFollow]; /* element() */ [self match:input TokenType:ANTLRTokenTypeUP Follow:nil]; /* element() */ /* elements */ } // token+rule list labels } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { } return ; } /* $ANTLR end formalParameter */ /* * $ANTLR start type * /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:39:1: type : ( K_INT | K_CHAR | K_VOID | K_ID ); */ - (void) type { /* ruleScopeSetUp */ @try { // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:40:5: ( K_INT | K_CHAR | K_VOID | K_ID ) // ruleBlockSingleAlt // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g: // alt { if ((([input LA:1] >= K_ID) && ([input LA:1] <= K_VOID))) { [input consume]; [state setIsErrorRecovery:NO]; } else { ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException exceptionWithSet:nil stream:input]; @throw mse; } /* element() */ /* elements */ } // token+rule list labels } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { } return ; } /* $ANTLR end type */ /* * $ANTLR start block * /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:46:1: block : ^( BLOCK ( variable )* ( stat )* ) ; */ - (void) block { /* ruleScopeSetUp */ @try { // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:47:5: ( ^( BLOCK ( variable )* ( stat )* ) ) // ruleBlockSingleAlt // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:47:9: ^( BLOCK ( variable )* ( stat )* ) // alt { [self match:input TokenType:BLOCK Follow:FOLLOW_BLOCK_in_block286]; /* element() */ if ( [input LA:1] == ANTLRTokenTypeDOWN ) { [self match:input TokenType:ANTLRTokenTypeDOWN Follow:nil]; do { NSInteger alt4=2; NSInteger LA4_0 = [input LA:1]; if ( (LA4_0==VAR_DEF) ) { alt4=1; } switch (alt4) { case 1 : ; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:47:17: variable // alt { [self pushFollow:FOLLOW_variable_in_block288]; [self variable]; [self popFollow]; /* element() */ /* elements */ } break; default : goto loop4; } } while (YES); loop4: ; /* element() */ do { NSInteger alt5=2; NSInteger LA5_0 = [input LA:1]; if ( ((LA5_0>=BLOCK && LA5_0<=K_INT)||(LA5_0>=K_FOR && LA5_0<=K_PLUS)) ) { alt5=1; } switch (alt5) { case 1 : ; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:47:27: stat // alt { [self pushFollow:FOLLOW_stat_in_block291]; [self stat]; [self popFollow]; /* element() */ /* elements */ } break; default : goto loop5; } } while (YES); loop5: ; /* element() */ [self match:input TokenType:ANTLRTokenTypeUP Follow:nil]; } /* element() */ /* elements */ } // token+rule list labels } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { } return ; } /* $ANTLR end block */ /* * $ANTLR start stat * /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:50:1: stat : ( forStat | expr | block ); */ - (void) stat { /* ruleScopeSetUp */ @try { // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:50:5: ( forStat | expr | block ) //ruleblock NSInteger alt6=3; switch ([input LA:1]) { case K_FOR: ; { alt6=1; } break; case K_ID: ; case K_INT: ; case K_EQ: ; case K_EQEQ: ; case K_LT: ; case K_PLUS: ; { alt6=2; } break; case BLOCK: ; { alt6=3; } break; default: ; ANTLRNoViableAltException *nvae = [ANTLRNoViableAltException newANTLRNoViableAltException:6 state:0 stream:input]; @throw nvae; } switch (alt6) { case 1 : ; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:50:7: forStat // alt { [self pushFollow:FOLLOW_forStat_in_stat305]; [self forStat]; [self popFollow]; /* element() */ /* elements */ } break; case 2 : ; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:51:7: expr // alt { [self pushFollow:FOLLOW_expr_in_stat313]; [self expr]; [self popFollow]; /* element() */ /* elements */ } break; case 3 : ; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:52:7: block // alt { [self pushFollow:FOLLOW_block_in_stat321]; [self block]; [self popFollow]; /* element() */ /* elements */ } break; } // token+rule list labels } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { } return ; } /* $ANTLR end stat */ /* * $ANTLR start forStat * /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:55:1: forStat : ^( K_FOR expr expr expr block ) ; */ - (void) forStat { /* ruleScopeSetUp */ @try { // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:56:5: ( ^( K_FOR expr expr expr block ) ) // ruleBlockSingleAlt // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:56:9: ^( K_FOR expr expr expr block ) // alt { [self match:input TokenType:K_FOR Follow:FOLLOW_K_FOR_in_forStat341]; /* element() */ [self match:input TokenType:ANTLRTokenTypeDOWN Follow:nil]; [self pushFollow:FOLLOW_expr_in_forStat343]; [self expr]; [self popFollow]; /* element() */ [self pushFollow:FOLLOW_expr_in_forStat345]; [self expr]; [self popFollow]; /* element() */ [self pushFollow:FOLLOW_expr_in_forStat347]; [self expr]; [self popFollow]; /* element() */ [self pushFollow:FOLLOW_block_in_forStat349]; [self block]; [self popFollow]; /* element() */ [self match:input TokenType:ANTLRTokenTypeUP Follow:nil]; /* element() */ /* elements */ } // token+rule list labels } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { } return ; } /* $ANTLR end forStat */ /* * $ANTLR start expr * /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:59:1: expr : ( ^( K_EQEQ expr expr ) | ^( K_LT expr expr ) | ^( K_PLUS expr expr ) | ^( K_EQ K_ID e= expr ) | atom ); */ - (SimpleCTP_expr_return *) expr { /* ruleScopeSetUp */ SimpleCTP_expr_return * retval = [SimpleCTP_expr_return newSimpleCTP_expr_return]; [retval setStart:[input LT:1]]; @try { ANTLRCommonTree *K_ID1 = nil; SimpleCTP_expr_return * e = nil; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:59:5: ( ^( K_EQEQ expr expr ) | ^( K_LT expr expr ) | ^( K_PLUS expr expr ) | ^( K_EQ K_ID e= expr ) | atom ) //ruleblock NSInteger alt7=5; switch ([input LA:1]) { case K_EQEQ: ; { alt7=1; } break; case K_LT: ; { alt7=2; } break; case K_PLUS: ; { alt7=3; } break; case K_EQ: ; { alt7=4; } break; case K_ID: ; case K_INT: ; { alt7=5; } break; default: ; ANTLRNoViableAltException *nvae = [ANTLRNoViableAltException newANTLRNoViableAltException:7 state:0 stream:input]; @throw nvae; } switch (alt7) { case 1 : ; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:59:9: ^( K_EQEQ expr expr ) // alt { [self match:input TokenType:K_EQEQ Follow:FOLLOW_K_EQEQ_in_expr365]; /* element() */ [self match:input TokenType:ANTLRTokenTypeDOWN Follow:nil]; [self pushFollow:FOLLOW_expr_in_expr367]; [self expr]; [self popFollow]; /* element() */ [self pushFollow:FOLLOW_expr_in_expr369]; [self expr]; [self popFollow]; /* element() */ [self match:input TokenType:ANTLRTokenTypeUP Follow:nil]; /* element() */ /* elements */ } break; case 2 : ; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:60:9: ^( K_LT expr expr ) // alt { [self match:input TokenType:K_LT Follow:FOLLOW_K_LT_in_expr381]; /* element() */ [self match:input TokenType:ANTLRTokenTypeDOWN Follow:nil]; [self pushFollow:FOLLOW_expr_in_expr383]; [self expr]; [self popFollow]; /* element() */ [self pushFollow:FOLLOW_expr_in_expr385]; [self expr]; [self popFollow]; /* element() */ [self match:input TokenType:ANTLRTokenTypeUP Follow:nil]; /* element() */ /* elements */ } break; case 3 : ; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:61:9: ^( K_PLUS expr expr ) // alt { [self match:input TokenType:K_PLUS Follow:FOLLOW_K_PLUS_in_expr397]; /* element() */ [self match:input TokenType:ANTLRTokenTypeDOWN Follow:nil]; [self pushFollow:FOLLOW_expr_in_expr399]; [self expr]; [self popFollow]; /* element() */ [self pushFollow:FOLLOW_expr_in_expr401]; [self expr]; [self popFollow]; /* element() */ [self match:input TokenType:ANTLRTokenTypeUP Follow:nil]; /* element() */ /* elements */ } break; case 4 : ; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:62:9: ^( K_EQ K_ID e= expr ) // alt { [self match:input TokenType:K_EQ Follow:FOLLOW_K_EQ_in_expr413]; /* element() */ [self match:input TokenType:ANTLRTokenTypeDOWN Follow:nil]; K_ID1=(ANTLRCommonTree *)[self match:input TokenType:K_ID Follow:FOLLOW_K_ID_in_expr415]; /* element() */ [self pushFollow:FOLLOW_expr_in_expr419]; e = [self expr]; [self popFollow]; /* element() */ [self match:input TokenType:ANTLRTokenTypeUP Follow:nil]; /* element() */ NSLog(@"assigning %@ to variable %@", (e!=nil?[[input getTokenStream] toStringFromStart:[[input getTreeAdaptor] getTokenStartIndex:[e getStart]] ToEnd:[[input getTreeAdaptor] getTokenStopIndex:[e getStart]]]:nil), (K_ID1!=nil?[K_ID1 getText]:0)); /* element() */ /* elements */ } break; case 5 : ; // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:63:9: atom // alt { [self pushFollow:FOLLOW_atom_in_expr432]; [self atom]; [self popFollow]; /* element() */ /* elements */ } break; } // token+rule list labels } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { } return retval; } /* $ANTLR end expr */ /* * $ANTLR start atom * /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:66:1: atom : ( K_ID | K_INT ); */ - (void) atom { /* ruleScopeSetUp */ @try { // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g:67:5: ( K_ID | K_INT ) // ruleBlockSingleAlt // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/simplecTreeParser/SimpleCTP.g: // alt { if ((([input LA:1] >= K_ID) && ([input LA:1] <= K_INT))) { [input consume]; [state setIsErrorRecovery:NO]; } else { ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException exceptionWithSet:nil stream:input]; @throw mse; } /* element() */ /* elements */ } // token+rule list labels } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { } return ; } /* $ANTLR end atom */ @end /* end of SimpleCTP implementation line 669 */ /* End of code * ============================================================================= */