• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/** \file
2 *  This OBJC source file was generated by $ANTLR version 3.4
3 *
4 *     -  From the grammar source file : /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g
5 *     -                            On : 2012-02-16 17:50:30
6 *     -                for the parser : SymbolTableParserParser
7 *
8 * Editing it, at least manually, is not wise.
9 *
10 * ObjC language generator and runtime by Alan Condit, acondit|hereisanat|ipns|dotgoeshere|com.
11 *
12 *
13*/
14// $ANTLR 3.4 /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g 2012-02-16 17:50:30
15
16
17/* -----------------------------------------
18 * Include the ANTLR3 generated header file.
19 */
20#import "SymbolTableParser.h"
21/* ----------------------------------------- */
22
23
24/* ============================================================================= */
25/* =============================================================================
26 * Start of recognizer
27 */
28
29#pragma mark Bitsets
30static ANTLRBitSet *FOLLOW_globals_in_prog50;
31static const unsigned long long FOLLOW_globals_in_prog50_data[] = { 0x0000000000001002LL};
32static ANTLRBitSet *FOLLOW_method_in_prog53;
33static const unsigned long long FOLLOW_method_in_prog53_data[] = { 0x0000000000001002LL};
34static ANTLRBitSet *FOLLOW_decl_in_globals85;
35static const unsigned long long FOLLOW_decl_in_globals85_data[] = { 0x0000000000000802LL};
36static ANTLRBitSet *FOLLOW_12_in_method116;
37static const unsigned long long FOLLOW_12_in_method116_data[] = { 0x0000000000000010LL};
38static ANTLRBitSet *FOLLOW_ID_in_method118;
39static const unsigned long long FOLLOW_ID_in_method118_data[] = { 0x0000000000000080LL};
40static ANTLRBitSet *FOLLOW_7_in_method120;
41static const unsigned long long FOLLOW_7_in_method120_data[] = { 0x0000000000000100LL};
42static ANTLRBitSet *FOLLOW_8_in_method122;
43static const unsigned long long FOLLOW_8_in_method122_data[] = { 0x0000000000002000LL};
44static ANTLRBitSet *FOLLOW_block_in_method124;
45static const unsigned long long FOLLOW_block_in_method124_data[] = { 0x0000000000000002LL};
46static ANTLRBitSet *FOLLOW_13_in_block153;
47static const unsigned long long FOLLOW_13_in_block153_data[] = { 0x0000000000006810LL};
48static ANTLRBitSet *FOLLOW_decl_in_block156;
49static const unsigned long long FOLLOW_decl_in_block156_data[] = { 0x0000000000006810LL};
50static ANTLRBitSet *FOLLOW_stat_in_block161;
51static const unsigned long long FOLLOW_stat_in_block161_data[] = { 0x0000000000006010LL};
52static ANTLRBitSet *FOLLOW_14_in_block165;
53static const unsigned long long FOLLOW_14_in_block165_data[] = { 0x0000000000000002LL};
54static ANTLRBitSet *FOLLOW_ID_in_stat189;
55static const unsigned long long FOLLOW_ID_in_stat189_data[] = { 0x0000000000000400LL};
56static ANTLRBitSet *FOLLOW_10_in_stat191;
57static const unsigned long long FOLLOW_10_in_stat191_data[] = { 0x0000000000000020LL};
58static ANTLRBitSet *FOLLOW_INT_in_stat193;
59static const unsigned long long FOLLOW_INT_in_stat193_data[] = { 0x0000000000000200LL};
60static ANTLRBitSet *FOLLOW_9_in_stat195;
61static const unsigned long long FOLLOW_9_in_stat195_data[] = { 0x0000000000000002LL};
62static ANTLRBitSet *FOLLOW_block_in_stat205;
63static const unsigned long long FOLLOW_block_in_stat205_data[] = { 0x0000000000000002LL};
64static ANTLRBitSet *FOLLOW_11_in_decl219;
65static const unsigned long long FOLLOW_11_in_decl219_data[] = { 0x0000000000000010LL};
66static ANTLRBitSet *FOLLOW_ID_in_decl221;
67static const unsigned long long FOLLOW_ID_in_decl221_data[] = { 0x0000000000000200LL};
68static ANTLRBitSet *FOLLOW_9_in_decl223;
69static const unsigned long long FOLLOW_9_in_decl223_data[] = { 0x0000000000000002LL};
70
71
72#pragma mark Dynamic Global globalAttributeScopeImplementation
73@implementation Symbols_Scope  /* globalAttributeScopeImplementation */
74/* start of synthesize -- OBJC-Line 1750 */
75@synthesize names;
76
77+ (Symbols_Scope *)newSymbols_Scope
78{
79return [[Symbols_Scope alloc] init];
80}
81
82- (id) init
83{
84self = [super init];
85return self;
86}
87
88/* start of iterate get and set functions */
89- (PtrBuffer *)getnames { return( names ); }
90- (void)setnames:(PtrBuffer *)aVal { names = aVal; }
91
92/* End of iterate get and set functions */
93@end /* end of Symbols_Scope implementation */
94
95
96
97#pragma mark Dynamic Rule Scopes ruleAttributeScopeImplementation
98
99#pragma mark Rule Return Scopes returnScopeImplementation
100
101@implementation SymbolTableParser  // line 637
102
103/* ObjC start of ruleAttributeScope */
104#pragma mark Dynamic Rule Scopes ruleAttributeScope
105/* ObjC end of ruleAttributeScope */
106#pragma mark global Attribute Scopes globalAttributeScope
107/* ObjC start globalAttributeScope */
108static SymbolStack *Symbols_stack;
109
110/* ObjC end globalAttributeScope */
111/* ObjC start actions.(actionScope).synthesize */
112/* ObjC start synthesize() */
113
114+ (void) initialize
115{
116    #pragma mark Bitsets
117    FOLLOW_globals_in_prog50 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_globals_in_prog50_data Count:(NSUInteger)1] retain];
118    FOLLOW_method_in_prog53 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_method_in_prog53_data Count:(NSUInteger)1] retain];
119    FOLLOW_decl_in_globals85 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_decl_in_globals85_data Count:(NSUInteger)1] retain];
120    FOLLOW_12_in_method116 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_12_in_method116_data Count:(NSUInteger)1] retain];
121    FOLLOW_ID_in_method118 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_method118_data Count:(NSUInteger)1] retain];
122    FOLLOW_7_in_method120 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_7_in_method120_data Count:(NSUInteger)1] retain];
123    FOLLOW_8_in_method122 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_method122_data Count:(NSUInteger)1] retain];
124    FOLLOW_block_in_method124 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_method124_data Count:(NSUInteger)1] retain];
125    FOLLOW_13_in_block153 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_13_in_block153_data Count:(NSUInteger)1] retain];
126    FOLLOW_decl_in_block156 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_decl_in_block156_data Count:(NSUInteger)1] retain];
127    FOLLOW_stat_in_block161 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_stat_in_block161_data Count:(NSUInteger)1] retain];
128    FOLLOW_14_in_block165 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_14_in_block165_data Count:(NSUInteger)1] retain];
129    FOLLOW_ID_in_stat189 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_stat189_data Count:(NSUInteger)1] retain];
130    FOLLOW_10_in_stat191 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_10_in_stat191_data Count:(NSUInteger)1] retain];
131    FOLLOW_INT_in_stat193 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_stat193_data Count:(NSUInteger)1] retain];
132    FOLLOW_9_in_stat195 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_9_in_stat195_data Count:(NSUInteger)1] retain];
133    FOLLOW_block_in_stat205 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_stat205_data Count:(NSUInteger)1] retain];
134    FOLLOW_11_in_decl219 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_11_in_decl219_data Count:(NSUInteger)1] retain];
135    FOLLOW_ID_in_decl221 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_decl221_data Count:(NSUInteger)1] retain];
136    FOLLOW_9_in_decl223 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_9_in_decl223_data Count:(NSUInteger)1] retain];
137
138    [BaseRecognizer setTokenNames:[[AMutableArray arrayWithObjects:@"<invalid>", @"<EOR>", @"<DOWN>", @"<UP>",
139 @"ID", @"INT", @"WS", @"'('", @"')'", @"';'", @"'='", @"'int'", @"'method'",
140 @"'{'", @"'}'", nil] retain]];
141    [BaseRecognizer setGrammarFileName:@"/Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g"];
142}
143
144+ (SymbolTableParser *)newSymbolTableParser:(id<TokenStream>)aStream
145{
146    return [[SymbolTableParser alloc] initWithTokenStream:aStream];
147}
148
149- (id) initWithTokenStream:(id<TokenStream>)aStream
150{
151    self = [super initWithTokenStream:aStream State:[[RecognizerSharedState newRecognizerSharedStateWithRuleLen:6+1] retain]];
152    if ( self != nil ) {
153        /* globalAttributeScopeInit */
154
155        Symbols_scope = [Symbols_Scope newSymbols_Scope];
156
157        Symbols_stack = [SymbolStack newSymbolStackWithLen:30];
158
159        /* start of actions-actionScope-init */
160
161        level = 0;
162
163        /* start of init */
164    }
165    return self;
166}
167
168- (void) dealloc
169{
170    [Symbols_stack release];
171
172    [super dealloc];
173}
174
175/* ObjC start actions.(actionScope).methods */
176/* ObjC end actions.(actionScope).methods */
177/* ObjC start methods() */
178/* ObjC end methods() */
179/* ObjC start rules */
180/*
181 * $ANTLR start prog
182 * /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:25:1: prog : globals ( method )* ;
183 */
184- (void) prog
185{
186    /* ruleScopeSetUp */
187
188    /* ruleDeclarations */
189
190    @try {
191        /* ruleLabelDefs entry */
192
193
194        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:27:5: ( globals ( method )* ) // ruleBlockSingleAlt
195        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:27:9: globals ( method )* // alt
196        {
197
198        /* ruleRef */
199        [self pushFollow:FOLLOW_globals_in_prog50];
200        [self globals];
201
202        [self popFollow];
203
204
205
206
207        do {
208            NSInteger alt1=2;
209            NSInteger LA1_0 = [input LA:1];
210            if ( (LA1_0==12) ) {
211                alt1=1;
212            }
213
214
215            switch (alt1) {
216                case 1 : ;
217                    // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:27:18: method // alt
218                    {
219
220                    /* ruleRef */
221                    [self pushFollow:FOLLOW_method_in_prog53];
222                    [self method];
223
224                    [self popFollow];
225
226
227
228                    }
229                    break;
230
231                default :
232                    goto loop1;
233            }
234        } while (YES);
235        loop1: ;
236
237
238        }
239
240        /* token+rule list labels */
241
242    }
243    @catch (RecognitionException *re) {
244        [self reportError:re];
245        [self recover:input Exception:re];
246    }
247
248    @finally {
249        /* ruleScopeCleanUp */
250
251    }
252    return ;
253}
254/* $ANTLR end prog */
255
256/*
257 * $ANTLR start globals
258 * /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:30:1: globals : ( decl )* ;
259 */
260- (void) globals
261{
262    /* ruleScopeSetUp */
263    [Symbols_stack push:[Symbols_Scope newSymbols_Scope]];
264
265    /* ruleDeclarations */
266
267
268        level++;
269        /* scopeSetAttributeRef */((Symbols_Scope *)[Symbols_stack peek]).names =  [PtrBuffer newPtrBufferWithLen:10];
270
271    @try {
272        /* ruleLabelDefs entry */
273
274
275        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:36:5: ( ( decl )* ) // ruleBlockSingleAlt
276        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:36:9: ( decl )* // alt
277        {
278
279
280        do {
281            NSInteger alt2=2;
282            NSInteger LA2_0 = [input LA:1];
283            if ( (LA2_0==11) ) {
284                alt2=1;
285            }
286
287
288            switch (alt2) {
289                case 1 : ;
290                    // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:36:10: decl // alt
291                    {
292
293                    /* ruleRef */
294                    [self pushFollow:FOLLOW_decl_in_globals85];
295                    [self decl];
296
297                    [self popFollow];
298
299
300
301                    }
302                    break;
303
304                default :
305                    goto loop2;
306            }
307        } while (YES);
308        loop2: ;
309
310
311
312
313                    NSLog( @"globals: %@", [((Symbols_Scope *)[Symbols_stack peek]).names toString] );
314                    level--;
315
316
317
318        }
319
320        /* token+rule list labels */
321
322    }
323    @catch (RecognitionException *re) {
324        [self reportError:re];
325        [self recover:input Exception:re];
326    }
327
328    @finally {
329        /* ruleScopeCleanUp */
330        [Symbols_stack pop];
331
332    }
333    return ;
334}
335/* $ANTLR end globals */
336
337/*
338 * $ANTLR start method
339 * /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:43:1: method : 'method' ID '(' ')' block ;
340 */
341- (void) method
342{
343    /* ruleScopeSetUp */
344
345    /* ruleDeclarations */
346
347    @try {
348        /* ruleLabelDefs entry */
349
350
351        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:44:5: ( 'method' ID '(' ')' block ) // ruleBlockSingleAlt
352        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:44:9: 'method' ID '(' ')' block // alt
353        {
354
355        [self match:input TokenType:12 Follow:FOLLOW_12_in_method116];
356
357        [self match:input TokenType:ID Follow:FOLLOW_ID_in_method118];
358
359        [self match:input TokenType:7 Follow:FOLLOW_7_in_method120];
360
361        [self match:input TokenType:8 Follow:FOLLOW_8_in_method122];
362
363        /* ruleRef */
364        [self pushFollow:FOLLOW_block_in_method124];
365        [self block];
366
367        [self popFollow];
368
369
370
371        }
372
373        /* token+rule list labels */
374
375    }
376    @catch (RecognitionException *re) {
377        [self reportError:re];
378        [self recover:input Exception:re];
379    }
380
381    @finally {
382        /* ruleScopeCleanUp */
383
384    }
385    return ;
386}
387/* $ANTLR end method */
388
389/*
390 * $ANTLR start block
391 * /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:47:1: block : '{' ( decl )* ( stat )* '}' ;
392 */
393- (void) block
394{
395    /* ruleScopeSetUp */
396    [Symbols_stack push:[Symbols_Scope newSymbols_Scope]];
397
398    /* ruleDeclarations */
399
400
401        level++;
402        /* scopeSetAttributeRef */((Symbols_Scope *)[Symbols_stack peek]).names =  [PtrBuffer newPtrBufferWithLen:10];
403
404    @try {
405        /* ruleLabelDefs entry */
406
407
408        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:53:5: ( '{' ( decl )* ( stat )* '}' ) // ruleBlockSingleAlt
409        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:53:9: '{' ( decl )* ( stat )* '}' // alt
410        {
411
412        [self match:input TokenType:13 Follow:FOLLOW_13_in_block153];
413
414
415        do {
416            NSInteger alt3=2;
417            NSInteger LA3_0 = [input LA:1];
418            if ( (LA3_0==11) ) {
419                alt3=1;
420            }
421
422
423            switch (alt3) {
424                case 1 : ;
425                    // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:53:14: decl // alt
426                    {
427
428                    /* ruleRef */
429                    [self pushFollow:FOLLOW_decl_in_block156];
430                    [self decl];
431
432                    [self popFollow];
433
434
435
436                    }
437                    break;
438
439                default :
440                    goto loop3;
441            }
442        } while (YES);
443        loop3: ;
444
445
446
447        do {
448            NSInteger alt4=2;
449            NSInteger LA4_0 = [input LA:1];
450            if ( (LA4_0==ID||LA4_0==13) ) {
451                alt4=1;
452            }
453
454
455            switch (alt4) {
456                case 1 : ;
457                    // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:53:22: stat // alt
458                    {
459
460                    /* ruleRef */
461                    [self pushFollow:FOLLOW_stat_in_block161];
462                    [self stat];
463
464                    [self popFollow];
465
466
467
468                    }
469                    break;
470
471                default :
472                    goto loop4;
473            }
474        } while (YES);
475        loop4: ;
476
477
478        [self match:input TokenType:14 Follow:FOLLOW_14_in_block165];
479
480
481
482                    NSLog( @"level %d symbols: %@", level, [((Symbols_Scope *)[Symbols_stack peek]).names toString] );
483                    level--;
484
485
486
487        }
488
489        /* token+rule list labels */
490
491    }
492    @catch (RecognitionException *re) {
493        [self reportError:re];
494        [self recover:input Exception:re];
495    }
496
497    @finally {
498        /* ruleScopeCleanUp */
499        [Symbols_stack pop];
500
501    }
502    return ;
503}
504/* $ANTLR end block */
505
506/*
507 * $ANTLR start stat
508 * /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:60:1: stat : ( ID '=' INT ';' | block );
509 */
510- (void) stat
511{
512    /* ruleScopeSetUp */
513
514    /* ruleDeclarations */
515
516    @try {
517        /* ruleLabelDefs entry */
518
519
520        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:60:5: ( ID '=' INT ';' | block ) //ruleblock
521        NSInteger alt5=2;
522        NSInteger LA5_0 = [input LA:1];
523
524        if ( (LA5_0==ID) ) {
525            alt5=1;
526        }
527        else if ( (LA5_0==13) ) {
528            alt5=2;
529        }
530        else {
531            NoViableAltException *nvae = [NoViableAltException newException:5 state:0 stream:input];
532            nvae.c = LA5_0;
533            @throw nvae;
534
535        }
536        switch (alt5) {
537            case 1 : ;
538                // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:60:9: ID '=' INT ';' // alt
539                {
540
541                [self match:input TokenType:ID Follow:FOLLOW_ID_in_stat189];
542
543                [self match:input TokenType:10 Follow:FOLLOW_10_in_stat191];
544
545                [self match:input TokenType:INT Follow:FOLLOW_INT_in_stat193];
546
547                [self match:input TokenType:9 Follow:FOLLOW_9_in_stat195];
548
549                }
550                break;
551            case 2 : ;
552                // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:61:9: block // alt
553                {
554
555                /* ruleRef */
556                [self pushFollow:FOLLOW_block_in_stat205];
557                [self block];
558
559                [self popFollow];
560
561
562
563                }
564                break;
565
566        }
567        /* token+rule list labels */
568
569    }
570    @catch (RecognitionException *re) {
571        [self reportError:re];
572        [self recover:input Exception:re];
573    }
574
575    @finally {
576        /* ruleScopeCleanUp */
577
578    }
579    return ;
580}
581/* $ANTLR end stat */
582
583/*
584 * $ANTLR start decl
585 * /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:64:1: decl : 'int' ID ';' ;
586 */
587- (void) decl
588{
589    /* ruleScopeSetUp */
590
591    /* ruleDeclarations */
592
593    @try {
594        /* ruleLabelDefs entry */
595        CommonToken *ID1 = nil;
596
597        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:64:5: ( 'int' ID ';' ) // ruleBlockSingleAlt
598        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/scopes/SymbolTable.g:64:9: 'int' ID ';' // alt
599        {
600
601        [self match:input TokenType:11 Follow:FOLLOW_11_in_decl219];
602
603        ID1=(CommonToken *)[self match:input TokenType:ID Follow:FOLLOW_ID_in_decl221];
604
605        [self match:input TokenType:9 Follow:FOLLOW_9_in_decl223];
606
607
608        [((Symbols_Scope *)[Symbols_stack peek]).names addObject:ID1];
609
610
611        }
612
613        /* token+rule list labels */
614
615    }
616    @catch (RecognitionException *re) {
617        [self reportError:re];
618        [self recover:input Exception:re];
619    }
620
621    @finally {
622        /* ruleScopeCleanUp */
623
624    }
625    return ;
626}
627/* $ANTLR end decl */
628/* ObjC end rules */
629
630@end /* end of SymbolTableParser implementation line 692 */
631