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/polydiff/PolyDifferentiator.g
5 *     -                            On : 2012-02-16 18:10:53
6 *     -           for the tree parser : PolyDifferentiatorTreeParser
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/polydiff/PolyDifferentiator.g 2012-02-16 18:10:53
15
16
17/* -----------------------------------------
18 * Include the ANTLR3 generated header file.
19 */
20#import "PolyDifferentiator.h"
21/* ----------------------------------------- */
22
23
24/* ============================================================================= */
25/* =============================================================================
26 * Start of recognizer
27 */
28
29#pragma mark Bitsets
30static ANTLRBitSet *FOLLOW_8_in_poly44;
31static const unsigned long long FOLLOW_8_in_poly44_data[] = { 0x0000000000000004LL};
32static ANTLRBitSet *FOLLOW_poly_in_poly46;
33static const unsigned long long FOLLOW_poly_in_poly46_data[] = { 0x0000000000000370LL};
34static ANTLRBitSet *FOLLOW_poly_in_poly48;
35static const unsigned long long FOLLOW_poly_in_poly48_data[] = { 0x0000000000000008LL};
36static ANTLRBitSet *FOLLOW_MULT_in_poly55;
37static const unsigned long long FOLLOW_MULT_in_poly55_data[] = { 0x0000000000000004LL};
38static ANTLRBitSet *FOLLOW_INT_in_poly57;
39static const unsigned long long FOLLOW_INT_in_poly57_data[] = { 0x0000000000000010LL};
40static ANTLRBitSet *FOLLOW_ID_in_poly59;
41static const unsigned long long FOLLOW_ID_in_poly59_data[] = { 0x0000000000000008LL};
42static ANTLRBitSet *FOLLOW_MULT_in_poly71;
43static const unsigned long long FOLLOW_MULT_in_poly71_data[] = { 0x0000000000000004LL};
44static ANTLRBitSet *FOLLOW_INT_in_poly75;
45static const unsigned long long FOLLOW_INT_in_poly75_data[] = { 0x0000000000000200LL};
46static ANTLRBitSet *FOLLOW_9_in_poly78;
47static const unsigned long long FOLLOW_9_in_poly78_data[] = { 0x0000000000000004LL};
48static ANTLRBitSet *FOLLOW_ID_in_poly80;
49static const unsigned long long FOLLOW_ID_in_poly80_data[] = { 0x0000000000000020LL};
50static ANTLRBitSet *FOLLOW_INT_in_poly84;
51static const unsigned long long FOLLOW_INT_in_poly84_data[] = { 0x0000000000000008LL};
52static ANTLRBitSet *FOLLOW_9_in_poly122;
53static const unsigned long long FOLLOW_9_in_poly122_data[] = { 0x0000000000000004LL};
54static ANTLRBitSet *FOLLOW_ID_in_poly124;
55static const unsigned long long FOLLOW_ID_in_poly124_data[] = { 0x0000000000000020LL};
56static ANTLRBitSet *FOLLOW_INT_in_poly128;
57static const unsigned long long FOLLOW_INT_in_poly128_data[] = { 0x0000000000000008LL};
58static ANTLRBitSet *FOLLOW_INT_in_poly164;
59static const unsigned long long FOLLOW_INT_in_poly164_data[] = { 0x0000000000000002LL};
60static ANTLRBitSet *FOLLOW_ID_in_poly178;
61static const unsigned long long FOLLOW_ID_in_poly178_data[] = { 0x0000000000000002LL};
62
63
64#pragma mark Dynamic Global globalAttributeScopeImplementation
65
66#pragma mark Dynamic Rule Scopes ruleAttributeScopeImplementation
67
68#pragma mark Rule Return Scopes returnScopeImplementation
69@implementation PolyDifferentiator_poly_return /* returnScopeImplementation */
70/* AST returnScope.synthesize */
71@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
72+ (PolyDifferentiator_poly_return *)newPolyDifferentiator_poly_return
73{
74return [[[PolyDifferentiator_poly_return alloc] init] retain];
75}
76
77- (id) init
78{
79self = [super init];
80return self;
81}
82
83/* AST returnScope.methods */
84- (CommonTree *)getTree
85{
86    return tree;
87}
88
89- (void) setTree:(CommonTree *)aTree
90{
91    if (tree != aTree) {
92        if (tree != nil) [tree release];
93        if (aTree != nil) [aTree retain];
94        tree = aTree;
95    }
96}
97
98- (void) dealloc
99{
100    self.tree = nil;
101    [super dealloc];
102}
103
104
105@end /* end of returnScope implementation */
106
107
108
109@implementation PolyDifferentiator  // line 637
110
111/* ObjC start of ruleAttributeScope */
112#pragma mark Dynamic Rule Scopes ruleAttributeScope
113/* ObjC end of ruleAttributeScope */
114#pragma mark global Attribute Scopes globalAttributeScope
115/* ObjC start globalAttributeScope */
116/* ObjC end globalAttributeScope */
117/* ObjC start actions.(actionScope).synthesize */
118/* ObjC start synthesize() */
119/* AST genericParser.synthesize */
120/* AST parserProperties */
121@synthesize treeAdaptor;
122
123+ (void) initialize
124{
125    #pragma mark Bitsets
126    FOLLOW_8_in_poly44 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_poly44_data Count:(NSUInteger)1] retain];
127    FOLLOW_poly_in_poly46 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_poly_in_poly46_data Count:(NSUInteger)1] retain];
128    FOLLOW_poly_in_poly48 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_poly_in_poly48_data Count:(NSUInteger)1] retain];
129    FOLLOW_MULT_in_poly55 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_MULT_in_poly55_data Count:(NSUInteger)1] retain];
130    FOLLOW_INT_in_poly57 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_poly57_data Count:(NSUInteger)1] retain];
131    FOLLOW_ID_in_poly59 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_poly59_data Count:(NSUInteger)1] retain];
132    FOLLOW_MULT_in_poly71 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_MULT_in_poly71_data Count:(NSUInteger)1] retain];
133    FOLLOW_INT_in_poly75 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_poly75_data Count:(NSUInteger)1] retain];
134    FOLLOW_9_in_poly78 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_9_in_poly78_data Count:(NSUInteger)1] retain];
135    FOLLOW_ID_in_poly80 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_poly80_data Count:(NSUInteger)1] retain];
136    FOLLOW_INT_in_poly84 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_poly84_data Count:(NSUInteger)1] retain];
137    FOLLOW_9_in_poly122 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_9_in_poly122_data Count:(NSUInteger)1] retain];
138    FOLLOW_ID_in_poly124 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_poly124_data Count:(NSUInteger)1] retain];
139    FOLLOW_INT_in_poly128 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_poly128_data Count:(NSUInteger)1] retain];
140    FOLLOW_INT_in_poly164 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_poly164_data Count:(NSUInteger)1] retain];
141    FOLLOW_ID_in_poly178 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_poly178_data Count:(NSUInteger)1] retain];
142
143    [BaseRecognizer setTokenNames:[[AMutableArray arrayWithObjects:@"<invalid>", @"<EOR>", @"<DOWN>", @"<UP>",
144 @"ID", @"INT", @"MULT", @"WS", @"'+'", @"'^'", nil] retain]];
145    [BaseRecognizer setGrammarFileName:@"/Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/PolyDifferentiator.g"];
146}
147
148+ (PolyDifferentiator *)newPolyDifferentiator:(id<TreeNodeStream>)aStream
149{
150    return [[PolyDifferentiator alloc] initWithStream:aStream];
151}
152
153- (id) initWithStream:(id<TreeNodeStream>)aStream
154{
155    self = [super initWithStream:aStream State:[[RecognizerSharedState newRecognizerSharedStateWithRuleLen:1+1] retain]];
156    if ( self != nil ) {
157        /* start of actions-actionScope-init */
158        /* start of init */
159        /* AST genericParser.init */
160        [self setTreeAdaptor:[[CommonTreeAdaptor newTreeAdaptor] retain]];
161    }
162    return self;
163}
164
165- (void) dealloc
166{
167    /* AST genericParser.dealloc */
168    [self setTreeAdaptor:nil];
169
170    [super dealloc];
171}
172
173/* ObjC start actions.(actionScope).methods */
174/* ObjC end actions.(actionScope).methods */
175/* ObjC start methods() */
176/* AST genericParser.methods */
177/* AST parserMethods */
178- (id<TreeAdaptor>) getTreeAdaptor
179{
180	return treeAdaptor;
181}
182
183- (void) setTreeAdaptor:(id<TreeAdaptor>)aTreeAdaptor
184{
185	if (aTreeAdaptor != treeAdaptor) {
186		treeAdaptor = aTreeAdaptor;
187	}
188}
189/* ObjC end methods() */
190/* ObjC start rules */
191/*
192 * $ANTLR start poly
193 * /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/PolyDifferentiator.g:10:1: poly : ( ^( '+' poly poly ) | ^( MULT INT ID ) -> INT | ^( MULT c= INT ^( '^' ID e= INT ) ) -> ^( MULT[@\"*\"] INT[c2] ^( '^' ID INT[e2] ) ) | ^( '^' ID e= INT ) -> ^( MULT[@\"*\"] INT[c2] ^( '^' ID INT[e2] ) ) | INT -> INT[@\"0\"] | ID -> INT[@\"1\"] );
194 */
195- (PolyDifferentiator_poly_return *) poly
196{
197    /* ruleScopeSetUp */
198
199    /* ASTTreeParser ruleDeclarations */
200    /* AST ruleDeclarations */
201    /* ruleDeclarations */
202    PolyDifferentiator_poly_return * retval = [PolyDifferentiator_poly_return newPolyDifferentiator_poly_return];
203    [retval setStart:[input LT:1]];
204
205
206    CommonTree *root_0 = nil;
207
208    CommonTree *_first_0 = nil;
209    CommonTree *_last = nil;
210
211    @try {
212        /* AST ruleLabelDefs */
213        /* ruleLabelDefs entry */
214        CommonTree *c = nil;
215        CommonTree *e = nil;
216        CommonTree *char_literal1 = nil;
217        CommonTree *MULT4 = nil;
218        CommonTree *INT5 = nil;
219        CommonTree *ID6 = nil;
220        CommonTree *MULT7 = nil;
221        CommonTree *char_literal8 = nil;
222        CommonTree *ID9 = nil;
223        CommonTree *char_literal10 = nil;
224        CommonTree *ID11 = nil;
225        CommonTree *INT12 = nil;
226        CommonTree *ID13 = nil;PolyDifferentiator_poly_return * poly2 = nil ;
227
228        PolyDifferentiator_poly_return * poly3 = nil ;
229
230
231        CommonTree *c_tree=nil;
232        CommonTree *e_tree=nil;
233        CommonTree *char_literal1_tree=nil;
234        CommonTree *MULT4_tree=nil;
235        CommonTree *INT5_tree=nil;
236        CommonTree *ID6_tree=nil;
237        CommonTree *MULT7_tree=nil;
238        CommonTree *char_literal8_tree=nil;
239        CommonTree *ID9_tree=nil;
240        CommonTree *char_literal10_tree=nil;
241        CommonTree *ID11_tree=nil;
242        CommonTree *INT12_tree=nil;
243        CommonTree *ID13_tree=nil;
244        RewriteRuleTokenStream *stream_INT =
245            [[RewriteRuleNodeStream newRewriteRuleNodeStream:treeAdaptor
246                                                             description:@"token INT"] retain];
247        RewriteRuleTokenStream *stream_MULT =
248            [[RewriteRuleNodeStream newRewriteRuleNodeStream:treeAdaptor
249                                                             description:@"token MULT"] retain];
250        RewriteRuleTokenStream *stream_ID =
251            [[RewriteRuleNodeStream newRewriteRuleNodeStream:treeAdaptor
252                                                             description:@"token ID"] retain];
253        RewriteRuleTokenStream *stream_9 =
254            [[RewriteRuleNodeStream newRewriteRuleNodeStream:treeAdaptor
255                                                             description:@"token 9"] retain];
256
257        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/PolyDifferentiator.g:10:5: ( ^( '+' poly poly ) | ^( MULT INT ID ) -> INT | ^( MULT c= INT ^( '^' ID e= INT ) ) -> ^( MULT[@\"*\"] INT[c2] ^( '^' ID INT[e2] ) ) | ^( '^' ID e= INT ) -> ^( MULT[@\"*\"] INT[c2] ^( '^' ID INT[e2] ) ) | INT -> INT[@\"0\"] | ID -> INT[@\"1\"] ) //ruleblock
258        NSInteger alt1=6;
259        unichar charLA1 = [input LA:1];
260        switch (charLA1) {
261            case 8: ;
262                {
263                alt1=1;
264                }
265                break;
266            case MULT: ;
267                {
268                NSInteger LA1_2 = [input LA:2];
269
270                if ( (LA1_2==DOWN) ) {
271                    NSInteger LA1_6 = [input LA:3];
272
273                    if ( (LA1_6==INT) ) {
274                        NSInteger LA1_7 = [input LA:4];
275
276                        if ( (LA1_7==ID) ) {
277                            alt1=2;
278                        }
279                        else if ( (LA1_7==9) ) {
280                            alt1=3;
281                        }
282                        else {
283                            NoViableAltException *nvae = [NoViableAltException newException:1 state:7 stream:input];
284                            nvae.c = LA1_7;
285                            @throw nvae;
286
287                        }
288                    }
289                    else {
290                        NoViableAltException *nvae = [NoViableAltException newException:1 state:6 stream:input];
291                        nvae.c = LA1_6;
292                        @throw nvae;
293
294                    }
295                }
296                else {
297                    NoViableAltException *nvae = [NoViableAltException newException:1 state:2 stream:input];
298                    nvae.c = LA1_2;
299                    @throw nvae;
300
301                }
302                }
303                break;
304            case 9: ;
305                {
306                alt1=4;
307                }
308                break;
309            case INT: ;
310                {
311                alt1=5;
312                }
313                break;
314            case ID: ;
315                {
316                alt1=6;
317                }
318                break;
319
320        default: ;
321            NoViableAltException *nvae = [NoViableAltException newException:1 state:0 stream:input];
322            nvae.c = charLA1;
323            @throw nvae;
324
325        }
326
327        switch (alt1) {
328            case 1 : ;
329                // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/PolyDifferentiator.g:10:7: ^( '+' poly poly ) // alt
330                {
331                root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
332
333
334
335                /* ASTTreeParser tree */
336                _last = (CommonTree *)[input LT:1];
337                {
338                CommonTree *_save_last_1 = _last;
339                CommonTree *_first_1 = nil;
340                CommonTree *root_1 = [[[treeAdaptor class] newEmptyTree] retain];
341
342                /* ASTTreeParser tokenRefRuleRoot */
343                _last = (CommonTree *)[input LT:1];
344                char_literal1=(CommonTree *)[self match:input TokenType:8 Follow:FOLLOW_8_in_poly44];
345                char_literal1_tree = (CommonTree *)[treeAdaptor dupNode:char_literal1];
346
347
348                root_1 = (CommonTree *)[treeAdaptor becomeRoot:char_literal1_tree old:root_1];
349
350
351                [self match:input TokenType:TokenTypeDOWN Follow:nil];
352
353                /* ASTTreeParser ruleRef */
354                _last = (CommonTree *)[input LT:1];
355                /* ruleRef */
356                [self pushFollow:FOLLOW_poly_in_poly46];
357                poly2 = [self poly];
358
359                [self popFollow];
360
361
362                    [treeAdaptor addChild:poly2.tree toTree:root_1];
363
364
365                /* ASTTreeParser ruleRef */
366                _last = (CommonTree *)[input LT:1];
367                /* ruleRef */
368                [self pushFollow:FOLLOW_poly_in_poly48];
369                poly3 = [self poly];
370
371                [self popFollow];
372
373
374                    [treeAdaptor addChild:poly3.tree toTree:root_1];
375
376
377                [self match:input TokenType:TokenTypeUP Follow:nil];
378                [treeAdaptor addChild:root_1 toTree:root_0];
379                _last = _save_last_1;
380                }
381
382
383                /* ASTTreeParser noRewrite */
384
385                }
386                break;
387            case 2 : ;
388                // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/PolyDifferentiator.g:11:4: ^( MULT INT ID ) // alt
389                {
390
391                /* ASTTreeParser tree */
392                _last = (CommonTree *)[input LT:1];
393                {
394                CommonTree *_save_last_1 = _last;
395                CommonTree *_first_1 = nil;
396                CommonTree *root_1 = [[[treeAdaptor class] newEmptyTree] retain];
397
398                /* ASTTreeParser tokenRefBang */
399                _last = (CommonTree *)[input LT:1];
400                MULT4=(CommonTree *)[self match:input TokenType:MULT Follow:FOLLOW_MULT_in_poly55];
401                    [stream_MULT addElement:MULT4];
402
403
404                [self match:input TokenType:TokenTypeDOWN Follow:nil];
405
406                /* ASTTreeParser tokenRefBang */
407                _last = (CommonTree *)[input LT:1];
408                INT5=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_poly57];
409                    [stream_INT addElement:INT5];
410
411
412                /* ASTTreeParser tokenRefBang */
413                _last = (CommonTree *)[input LT:1];
414                ID6=(CommonTree *)[self match:input TokenType:ID Follow:FOLLOW_ID_in_poly59];
415                    [stream_ID addElement:ID6];
416
417
418                [self match:input TokenType:TokenTypeUP Follow:nil];
419                [treeAdaptor addChild:root_1 toTree:root_0];
420                _last = _save_last_1;
421                }
422
423
424                // AST REWRITE
425                // elements: INT
426                // token labels:
427                // rule labels: retval
428                // token list labels:
429                // rule list labels:
430                // wildcard labels:
431                retval.tree = root_0;
432
433                RewriteRuleSubtreeStream *stream_retval =
434                    [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
435                        description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
436
437                root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
438
439                // 11:20: -> INT
440                {
441                     // TODO: args:
442                    [treeAdaptor addChild:/* ASTTreeParser createRewriteNodeFromElement */
443                    [stream_INT nextNode]
444                     toTree:root_0];
445
446                }
447
448
449                retval.tree = root_0;
450
451
452                }
453                break;
454            case 3 : ;
455                // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/PolyDifferentiator.g:12:4: ^( MULT c= INT ^( '^' ID e= INT ) ) // alt
456                {
457
458                /* ASTTreeParser tree */
459                _last = (CommonTree *)[input LT:1];
460                {
461                CommonTree *_save_last_1 = _last;
462                CommonTree *_first_1 = nil;
463                CommonTree *root_1 = [[[treeAdaptor class] newEmptyTree] retain];
464
465                /* ASTTreeParser tokenRefBang */
466                _last = (CommonTree *)[input LT:1];
467                MULT7=(CommonTree *)[self match:input TokenType:MULT Follow:FOLLOW_MULT_in_poly71];
468                    [stream_MULT addElement:MULT7];
469
470
471                [self match:input TokenType:TokenTypeDOWN Follow:nil];
472
473                /* ASTTreeParser tokenRefBang */
474                _last = (CommonTree *)[input LT:1];
475                c=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_poly75];
476                    [stream_INT addElement:c];
477
478
479                /* ASTTreeParser tree */
480                _last = (CommonTree *)[input LT:1];
481                {
482                CommonTree *_save_last_2 = _last;
483                CommonTree *_first_2 = nil;
484                CommonTree *root_2 = [[[treeAdaptor class] newEmptyTree] retain];
485
486                /* ASTTreeParser tokenRefBang */
487                _last = (CommonTree *)[input LT:1];
488                char_literal8=(CommonTree *)[self match:input TokenType:9 Follow:FOLLOW_9_in_poly78];
489                    [stream_9 addElement:char_literal8];
490
491
492                [self match:input TokenType:TokenTypeDOWN Follow:nil];
493
494                /* ASTTreeParser tokenRefBang */
495                _last = (CommonTree *)[input LT:1];
496                ID9=(CommonTree *)[self match:input TokenType:ID Follow:FOLLOW_ID_in_poly80];
497                    [stream_ID addElement:ID9];
498
499
500                /* ASTTreeParser tokenRefBang */
501                _last = (CommonTree *)[input LT:1];
502                e=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_poly84];
503                    [stream_INT addElement:e];
504
505
506                [self match:input TokenType:TokenTypeUP Follow:nil];
507                [treeAdaptor addChild:root_2 toTree:root_1];
508                _last = _save_last_2;
509                }
510
511
512                [self match:input TokenType:TokenTypeUP Follow:nil];
513                [treeAdaptor addChild:root_1 toTree:root_0];
514                _last = _save_last_1;
515                }
516
517
518
519
520                		NSString *c2 = [NSString stringWithFormat:@"%d", (c!=nil?[c.text integerValue]:0)*(e!=nil?[e.text integerValue]:0)];
521                		NSString *e2 = [NSString stringWithFormat:@"%d", (e!=nil?[e.text integerValue]:0)-1];
522
523
524
525                // AST REWRITE
526                // elements: INT, 9, INT, ID, MULT
527                // token labels:
528                // rule labels: retval
529                // token list labels:
530                // rule list labels:
531                // wildcard labels:
532                retval.tree = root_0;
533
534                RewriteRuleSubtreeStream *stream_retval =
535                    [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
536                        description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
537
538                root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
539
540                // 17:8: -> ^( MULT[@\"*\"] INT[c2] ^( '^' ID INT[e2] ) )
541                {
542                    // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/PolyDifferentiator.g:17:11: ^( MULT[@\"*\"] INT[c2] ^( '^' ID INT[e2] ) )
543                    {
544                        CommonTree *root_1 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
545                        root_1 = (CommonTree *)[treeAdaptor becomeRoot:
546                                [[treeAdaptor createTree:MULT FromToken:@"*" Text:@"MULT"] retain]
547                         old:root_1];
548
549                        [treeAdaptor addChild:
550                                [[treeAdaptor createTree:INT FromToken:c2 Text:@"INT"] retain]
551                         toTree:root_1];
552
553                        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/PolyDifferentiator.g:17:32: ^( '^' ID INT[e2] )
554                        {
555                            CommonTree *root_2 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
556                            root_2 = (CommonTree *)[treeAdaptor becomeRoot:/* ASTTreeParser createRewriteNodeFromElement */
557                            [stream_9 nextNode]
558                             old:root_2];
559
560                             // TODO: args:
561                            [treeAdaptor addChild:/* ASTTreeParser createRewriteNodeFromElement */
562                            [stream_ID nextNode]
563                             toTree:root_2];
564
565                            [treeAdaptor addChild:
566                                    [[treeAdaptor createTree:INT FromToken:e2 Text:@"INT"] retain]
567                             toTree:root_2];
568
569                            [treeAdaptor addChild:root_2 toTree:root_1];
570                        }
571
572                        [treeAdaptor addChild:root_1 toTree:root_0];
573                    }
574
575                }
576
577
578                retval.tree = root_0;
579
580
581                }
582                break;
583            case 4 : ;
584                // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/PolyDifferentiator.g:18:4: ^( '^' ID e= INT ) // alt
585                {
586
587                /* ASTTreeParser tree */
588                _last = (CommonTree *)[input LT:1];
589                {
590                CommonTree *_save_last_1 = _last;
591                CommonTree *_first_1 = nil;
592                CommonTree *root_1 = [[[treeAdaptor class] newEmptyTree] retain];
593
594                /* ASTTreeParser tokenRefBang */
595                _last = (CommonTree *)[input LT:1];
596                char_literal10=(CommonTree *)[self match:input TokenType:9 Follow:FOLLOW_9_in_poly122];
597                    [stream_9 addElement:char_literal10];
598
599
600                [self match:input TokenType:TokenTypeDOWN Follow:nil];
601
602                /* ASTTreeParser tokenRefBang */
603                _last = (CommonTree *)[input LT:1];
604                ID11=(CommonTree *)[self match:input TokenType:ID Follow:FOLLOW_ID_in_poly124];
605                    [stream_ID addElement:ID11];
606
607
608                /* ASTTreeParser tokenRefBang */
609                _last = (CommonTree *)[input LT:1];
610                e=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_poly128];
611                    [stream_INT addElement:e];
612
613
614                [self match:input TokenType:TokenTypeUP Follow:nil];
615                [treeAdaptor addChild:root_1 toTree:root_0];
616                _last = _save_last_1;
617                }
618
619
620
621
622                		NSString *c2 = [NSString stringWithFormat:@"%d", (e!=nil?[e.text integerValue]:0)];
623                		NSString *e2 = [NSString stringWithFormat:@"%d", (e!=nil?[e.text integerValue]:0)-1];
624
625
626
627                // AST REWRITE
628                // elements: INT, 9, INT, ID
629                // token labels:
630                // rule labels: retval
631                // token list labels:
632                // rule list labels:
633                // wildcard labels:
634                retval.tree = root_0;
635
636                RewriteRuleSubtreeStream *stream_retval =
637                    [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
638                        description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
639
640                root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
641
642                // 23:8: -> ^( MULT[@\"*\"] INT[c2] ^( '^' ID INT[e2] ) )
643                {
644                    // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/PolyDifferentiator.g:23:11: ^( MULT[@\"*\"] INT[c2] ^( '^' ID INT[e2] ) )
645                    {
646                        CommonTree *root_1 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
647                        root_1 = (CommonTree *)[treeAdaptor becomeRoot:
648                                [[treeAdaptor createTree:MULT FromToken:@"*" Text:@"MULT"] retain]
649                         old:root_1];
650
651                        [treeAdaptor addChild:
652                                [[treeAdaptor createTree:INT FromToken:c2 Text:@"INT"] retain]
653                         toTree:root_1];
654
655                        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/PolyDifferentiator.g:23:32: ^( '^' ID INT[e2] )
656                        {
657                            CommonTree *root_2 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
658                            root_2 = (CommonTree *)[treeAdaptor becomeRoot:/* ASTTreeParser createRewriteNodeFromElement */
659                            [stream_9 nextNode]
660                             old:root_2];
661
662                             // TODO: args:
663                            [treeAdaptor addChild:/* ASTTreeParser createRewriteNodeFromElement */
664                            [stream_ID nextNode]
665                             toTree:root_2];
666
667                            [treeAdaptor addChild:
668                                    [[treeAdaptor createTree:INT FromToken:e2 Text:@"INT"] retain]
669                             toTree:root_2];
670
671                            [treeAdaptor addChild:root_2 toTree:root_1];
672                        }
673
674                        [treeAdaptor addChild:root_1 toTree:root_0];
675                    }
676
677                }
678
679
680                retval.tree = root_0;
681
682
683                }
684                break;
685            case 5 : ;
686                // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/PolyDifferentiator.g:24:4: INT // alt
687                {
688
689                /* ASTTreeParser tokenRefBang */
690                _last = (CommonTree *)[input LT:1];
691                INT12=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_poly164];
692                    [stream_INT addElement:INT12];
693
694
695                // AST REWRITE
696                // elements: INT
697                // token labels:
698                // rule labels: retval
699                // token list labels:
700                // rule list labels:
701                // wildcard labels:
702                retval.tree = root_0;
703
704                RewriteRuleSubtreeStream *stream_retval =
705                    [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
706                        description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
707
708                root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
709
710                // 24:12: -> INT[@\"0\"]
711                {
712                    [treeAdaptor addChild:
713                            [[treeAdaptor createTree:INT FromToken:@"0" Text:@"INT"] retain]
714                     toTree:root_0];
715
716                }
717
718
719                retval.tree = root_0;
720
721
722                }
723                break;
724            case 6 : ;
725                // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/PolyDifferentiator.g:25:4: ID // alt
726                {
727
728                /* ASTTreeParser tokenRefBang */
729                _last = (CommonTree *)[input LT:1];
730                ID13=(CommonTree *)[self match:input TokenType:ID Follow:FOLLOW_ID_in_poly178];
731                    [stream_ID addElement:ID13];
732
733
734                // AST REWRITE
735                // elements:
736                // token labels:
737                // rule labels: retval
738                // token list labels:
739                // rule list labels:
740                // wildcard labels:
741                retval.tree = root_0;
742
743                RewriteRuleSubtreeStream *stream_retval =
744                    [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
745                        description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
746
747                root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
748
749                // 25:11: -> INT[@\"1\"]
750                {
751                    [treeAdaptor addChild:
752                            [[treeAdaptor createTree:INT FromToken:@"1" Text:@"INT"] retain]
753                     toTree:root_0];
754
755                }
756
757
758                retval.tree = root_0;
759
760
761                }
762                break;
763
764        }
765        /* ASTTreeParser ruleCleanUp */
766        /* AST ruleCleanUp */
767        /* token+rule list labels */
768
769        [stream_INT release];
770        [stream_MULT release];
771        [stream_ID release];
772        [stream_9 release];
773
774        retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
775
776    }
777    @catch (RecognitionException *re) {
778        [self reportError:re];
779        [self recover:input Exception:re];
780    }
781
782    @finally {
783        /* ruleScopeCleanUp */
784
785    }
786    return retval;
787}
788/* $ANTLR end poly */
789/* ObjC end rules */
790
791@end /* end of PolyDifferentiator implementation line 692 */
792