/** \file * This OBJC source file was generated by $ANTLR version 3.4 * * - From the grammar source file : /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g * - On : 2012-02-16 17:50:30 * - for the parser : SymbolTableParserParser * * Editing it, at least manually, is not wise. * * ObjC language generator and runtime by Alan Condit, acondit|hereisanat|ipns|dotgoeshere|com. * * */ // $ANTLR 3.4 /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g 2012-02-16 17:50:30 /* ----------------------------------------- * Include the ANTLR3 generated header file. */ #import "SymbolTableParser.h" /* ----------------------------------------- */ /* ============================================================================= */ /* ============================================================================= * Start of recognizer */ #pragma mark Bitsets static ANTLRBitSet *FOLLOW_globals_in_prog50; static const unsigned long long FOLLOW_globals_in_prog50_data[] = { 0x0000000000001002LL}; static ANTLRBitSet *FOLLOW_method_in_prog53; static const unsigned long long FOLLOW_method_in_prog53_data[] = { 0x0000000000001002LL}; static ANTLRBitSet *FOLLOW_decl_in_globals85; static const unsigned long long FOLLOW_decl_in_globals85_data[] = { 0x0000000000000802LL}; static ANTLRBitSet *FOLLOW_12_in_method116; static const unsigned long long FOLLOW_12_in_method116_data[] = { 0x0000000000000010LL}; static ANTLRBitSet *FOLLOW_ID_in_method118; static const unsigned long long FOLLOW_ID_in_method118_data[] = { 0x0000000000000080LL}; static ANTLRBitSet *FOLLOW_7_in_method120; static const unsigned long long FOLLOW_7_in_method120_data[] = { 0x0000000000000100LL}; static ANTLRBitSet *FOLLOW_8_in_method122; static const unsigned long long FOLLOW_8_in_method122_data[] = { 0x0000000000002000LL}; static ANTLRBitSet *FOLLOW_block_in_method124; static const unsigned long long FOLLOW_block_in_method124_data[] = { 0x0000000000000002LL}; static ANTLRBitSet *FOLLOW_13_in_block153; static const unsigned long long FOLLOW_13_in_block153_data[] = { 0x0000000000006810LL}; static ANTLRBitSet *FOLLOW_decl_in_block156; static const unsigned long long FOLLOW_decl_in_block156_data[] = { 0x0000000000006810LL}; static ANTLRBitSet *FOLLOW_stat_in_block161; static const unsigned long long FOLLOW_stat_in_block161_data[] = { 0x0000000000006010LL}; static ANTLRBitSet *FOLLOW_14_in_block165; static const unsigned long long FOLLOW_14_in_block165_data[] = { 0x0000000000000002LL}; static ANTLRBitSet *FOLLOW_ID_in_stat189; static const unsigned long long FOLLOW_ID_in_stat189_data[] = { 0x0000000000000400LL}; static ANTLRBitSet *FOLLOW_10_in_stat191; static const unsigned long long FOLLOW_10_in_stat191_data[] = { 0x0000000000000020LL}; static ANTLRBitSet *FOLLOW_INT_in_stat193; static const unsigned long long FOLLOW_INT_in_stat193_data[] = { 0x0000000000000200LL}; static ANTLRBitSet *FOLLOW_9_in_stat195; static const unsigned long long FOLLOW_9_in_stat195_data[] = { 0x0000000000000002LL}; static ANTLRBitSet *FOLLOW_block_in_stat205; static const unsigned long long FOLLOW_block_in_stat205_data[] = { 0x0000000000000002LL}; static ANTLRBitSet *FOLLOW_11_in_decl219; static const unsigned long long FOLLOW_11_in_decl219_data[] = { 0x0000000000000010LL}; static ANTLRBitSet *FOLLOW_ID_in_decl221; static const unsigned long long FOLLOW_ID_in_decl221_data[] = { 0x0000000000000200LL}; static ANTLRBitSet *FOLLOW_9_in_decl223; static const unsigned long long FOLLOW_9_in_decl223_data[] = { 0x0000000000000002LL}; #pragma mark Dynamic Global globalAttributeScopeImplementation @implementation Symbols_Scope /* globalAttributeScopeImplementation */ /* start of synthesize -- OBJC-Line 1750 */ @synthesize names; + (Symbols_Scope *)newSymbols_Scope { return [[Symbols_Scope alloc] init]; } - (id) init { self = [super init]; return self; } /* start of iterate get and set functions */ - (PtrBuffer *)getnames { return( names ); } - (void)setnames:(PtrBuffer *)aVal { names = aVal; } /* End of iterate get and set functions */ @end /* end of Symbols_Scope implementation */ #pragma mark Dynamic Rule Scopes ruleAttributeScopeImplementation #pragma mark Rule Return Scopes returnScopeImplementation @implementation SymbolTableParser // line 637 /* ObjC start of ruleAttributeScope */ #pragma mark Dynamic Rule Scopes ruleAttributeScope /* ObjC end of ruleAttributeScope */ #pragma mark global Attribute Scopes globalAttributeScope /* ObjC start globalAttributeScope */ static SymbolStack *Symbols_stack; /* ObjC end globalAttributeScope */ /* ObjC start actions.(actionScope).synthesize */ /* ObjC start synthesize() */ + (void) initialize { #pragma mark Bitsets FOLLOW_globals_in_prog50 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_globals_in_prog50_data Count:(NSUInteger)1] retain]; FOLLOW_method_in_prog53 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_method_in_prog53_data Count:(NSUInteger)1] retain]; FOLLOW_decl_in_globals85 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_decl_in_globals85_data Count:(NSUInteger)1] retain]; FOLLOW_12_in_method116 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_12_in_method116_data Count:(NSUInteger)1] retain]; FOLLOW_ID_in_method118 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_method118_data Count:(NSUInteger)1] retain]; FOLLOW_7_in_method120 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_7_in_method120_data Count:(NSUInteger)1] retain]; FOLLOW_8_in_method122 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_method122_data Count:(NSUInteger)1] retain]; FOLLOW_block_in_method124 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_method124_data Count:(NSUInteger)1] retain]; FOLLOW_13_in_block153 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_13_in_block153_data Count:(NSUInteger)1] retain]; FOLLOW_decl_in_block156 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_decl_in_block156_data Count:(NSUInteger)1] retain]; FOLLOW_stat_in_block161 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_stat_in_block161_data Count:(NSUInteger)1] retain]; FOLLOW_14_in_block165 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_14_in_block165_data Count:(NSUInteger)1] retain]; FOLLOW_ID_in_stat189 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_stat189_data Count:(NSUInteger)1] retain]; FOLLOW_10_in_stat191 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_10_in_stat191_data Count:(NSUInteger)1] retain]; FOLLOW_INT_in_stat193 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_stat193_data Count:(NSUInteger)1] retain]; FOLLOW_9_in_stat195 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_9_in_stat195_data Count:(NSUInteger)1] retain]; FOLLOW_block_in_stat205 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_stat205_data Count:(NSUInteger)1] retain]; FOLLOW_11_in_decl219 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_11_in_decl219_data Count:(NSUInteger)1] retain]; FOLLOW_ID_in_decl221 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_decl221_data Count:(NSUInteger)1] retain]; FOLLOW_9_in_decl223 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_9_in_decl223_data Count:(NSUInteger)1] retain]; [BaseRecognizer setTokenNames:[[AMutableArray arrayWithObjects:@"", @"", @"", @"", @"ID", @"INT", @"WS", @"'('", @"')'", @"';'", @"'='", @"'int'", @"'method'", @"'{'", @"'}'", nil] retain]]; [BaseRecognizer setGrammarFileName:@"/Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g"]; } + (SymbolTableParser *)newSymbolTableParser:(id)aStream { return [[SymbolTableParser alloc] initWithTokenStream:aStream]; } - (id) initWithTokenStream:(id)aStream { self = [super initWithTokenStream:aStream State:[[RecognizerSharedState newRecognizerSharedStateWithRuleLen:6+1] retain]]; if ( self != nil ) { /* globalAttributeScopeInit */ Symbols_scope = [Symbols_Scope newSymbols_Scope]; Symbols_stack = [SymbolStack newSymbolStackWithLen:30]; /* start of actions-actionScope-init */ level = 0; /* start of init */ } return self; } - (void) dealloc { [Symbols_stack release]; [super dealloc]; } /* ObjC start actions.(actionScope).methods */ /* ObjC end actions.(actionScope).methods */ /* ObjC start methods() */ /* ObjC end methods() */ /* ObjC start rules */ /* * $ANTLR start prog * /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:25:1: prog : globals ( method )* ; */ - (void) prog { /* ruleScopeSetUp */ /* ruleDeclarations */ @try { /* ruleLabelDefs entry */ // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:27:5: ( globals ( method )* ) // ruleBlockSingleAlt // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:27:9: globals ( method )* // alt { /* ruleRef */ [self pushFollow:FOLLOW_globals_in_prog50]; [self globals]; [self popFollow]; do { NSInteger alt1=2; NSInteger LA1_0 = [input LA:1]; if ( (LA1_0==12) ) { alt1=1; } switch (alt1) { case 1 : ; // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:27:18: method // alt { /* ruleRef */ [self pushFollow:FOLLOW_method_in_prog53]; [self method]; [self popFollow]; } break; default : goto loop1; } } while (YES); loop1: ; } /* token+rule list labels */ } @catch (RecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { /* ruleScopeCleanUp */ } return ; } /* $ANTLR end prog */ /* * $ANTLR start globals * /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:30:1: globals : ( decl )* ; */ - (void) globals { /* ruleScopeSetUp */ [Symbols_stack push:[Symbols_Scope newSymbols_Scope]]; /* ruleDeclarations */ level++; /* scopeSetAttributeRef */((Symbols_Scope *)[Symbols_stack peek]).names = [PtrBuffer newPtrBufferWithLen:10]; @try { /* ruleLabelDefs entry */ // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:36:5: ( ( decl )* ) // ruleBlockSingleAlt // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:36:9: ( decl )* // alt { do { NSInteger alt2=2; NSInteger LA2_0 = [input LA:1]; if ( (LA2_0==11) ) { alt2=1; } switch (alt2) { case 1 : ; // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:36:10: decl // alt { /* ruleRef */ [self pushFollow:FOLLOW_decl_in_globals85]; [self decl]; [self popFollow]; } break; default : goto loop2; } } while (YES); loop2: ; NSLog( @"globals: %@", [((Symbols_Scope *)[Symbols_stack peek]).names toString] ); level--; } /* token+rule list labels */ } @catch (RecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { /* ruleScopeCleanUp */ [Symbols_stack pop]; } return ; } /* $ANTLR end globals */ /* * $ANTLR start method * /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:43:1: method : 'method' ID '(' ')' block ; */ - (void) method { /* ruleScopeSetUp */ /* ruleDeclarations */ @try { /* ruleLabelDefs entry */ // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:44:5: ( 'method' ID '(' ')' block ) // ruleBlockSingleAlt // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:44:9: 'method' ID '(' ')' block // alt { [self match:input TokenType:12 Follow:FOLLOW_12_in_method116]; [self match:input TokenType:ID Follow:FOLLOW_ID_in_method118]; [self match:input TokenType:7 Follow:FOLLOW_7_in_method120]; [self match:input TokenType:8 Follow:FOLLOW_8_in_method122]; /* ruleRef */ [self pushFollow:FOLLOW_block_in_method124]; [self block]; [self popFollow]; } /* token+rule list labels */ } @catch (RecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { /* ruleScopeCleanUp */ } return ; } /* $ANTLR end method */ /* * $ANTLR start block * /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:47:1: block : '{' ( decl )* ( stat )* '}' ; */ - (void) block { /* ruleScopeSetUp */ [Symbols_stack push:[Symbols_Scope newSymbols_Scope]]; /* ruleDeclarations */ level++; /* scopeSetAttributeRef */((Symbols_Scope *)[Symbols_stack peek]).names = [PtrBuffer newPtrBufferWithLen:10]; @try { /* ruleLabelDefs entry */ // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:53:5: ( '{' ( decl )* ( stat )* '}' ) // ruleBlockSingleAlt // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:53:9: '{' ( decl )* ( stat )* '}' // alt { [self match:input TokenType:13 Follow:FOLLOW_13_in_block153]; do { NSInteger alt3=2; NSInteger LA3_0 = [input LA:1]; if ( (LA3_0==11) ) { alt3=1; } switch (alt3) { case 1 : ; // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:53:14: decl // alt { /* ruleRef */ [self pushFollow:FOLLOW_decl_in_block156]; [self decl]; [self popFollow]; } break; default : goto loop3; } } while (YES); loop3: ; do { NSInteger alt4=2; NSInteger LA4_0 = [input LA:1]; if ( (LA4_0==ID||LA4_0==13) ) { alt4=1; } switch (alt4) { case 1 : ; // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:53:22: stat // alt { /* ruleRef */ [self pushFollow:FOLLOW_stat_in_block161]; [self stat]; [self popFollow]; } break; default : goto loop4; } } while (YES); loop4: ; [self match:input TokenType:14 Follow:FOLLOW_14_in_block165]; NSLog( @"level %d symbols: %@", level, [((Symbols_Scope *)[Symbols_stack peek]).names toString] ); level--; } /* token+rule list labels */ } @catch (RecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { /* ruleScopeCleanUp */ [Symbols_stack pop]; } return ; } /* $ANTLR end block */ /* * $ANTLR start stat * /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:60:1: stat : ( ID '=' INT ';' | block ); */ - (void) stat { /* ruleScopeSetUp */ /* ruleDeclarations */ @try { /* ruleLabelDefs entry */ // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:60:5: ( ID '=' INT ';' | block ) //ruleblock NSInteger alt5=2; NSInteger LA5_0 = [input LA:1]; if ( (LA5_0==ID) ) { alt5=1; } else if ( (LA5_0==13) ) { alt5=2; } else { NoViableAltException *nvae = [NoViableAltException newException:5 state:0 stream:input]; nvae.c = LA5_0; @throw nvae; } switch (alt5) { case 1 : ; // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:60:9: ID '=' INT ';' // alt { [self match:input TokenType:ID Follow:FOLLOW_ID_in_stat189]; [self match:input TokenType:10 Follow:FOLLOW_10_in_stat191]; [self match:input TokenType:INT Follow:FOLLOW_INT_in_stat193]; [self match:input TokenType:9 Follow:FOLLOW_9_in_stat195]; } break; case 2 : ; // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:61:9: block // alt { /* ruleRef */ [self pushFollow:FOLLOW_block_in_stat205]; [self block]; [self popFollow]; } break; } /* token+rule list labels */ } @catch (RecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { /* ruleScopeCleanUp */ } return ; } /* $ANTLR end stat */ /* * $ANTLR start decl * /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:64:1: decl : 'int' ID ';' ; */ - (void) decl { /* ruleScopeSetUp */ /* ruleDeclarations */ @try { /* ruleLabelDefs entry */ CommonToken *ID1 = nil; // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:64:5: ( 'int' ID ';' ) // ruleBlockSingleAlt // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:64:9: 'int' ID ';' // alt { [self match:input TokenType:11 Follow:FOLLOW_11_in_decl219]; ID1=(CommonToken *)[self match:input TokenType:ID Follow:FOLLOW_ID_in_decl221]; [self match:input TokenType:9 Follow:FOLLOW_9_in_decl223]; [((Symbols_Scope *)[Symbols_stack peek]).names addObject:ID1]; } /* token+rule list labels */ } @catch (RecognitionException *re) { [self reportError:re]; [self recover:input Exception:re]; } @finally { /* ruleScopeCleanUp */ } return ; } /* $ANTLR end decl */ /* ObjC end rules */ @end /* end of SymbolTableParser implementation line 692 */