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/Simplifier.g 5 * - On : 2012-02-16 18:11:30 6 * - for the tree parser : SimplifierTreeParser 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/Simplifier.g 2012-02-16 18:11:30 15 16 17/* ----------------------------------------- 18 * Include the ANTLR3 generated header file. 19 */ 20#import "Simplifier.h" 21/* ----------------------------------------- */ 22 23 24/* ============================================================================= */ 25/* ============================================================================= 26 * Start of recognizer 27 */ 28 29#pragma mark Bitsets 30static ANTLRBitSet *FOLLOW_8_in_poly52; 31static const unsigned long long FOLLOW_8_in_poly52_data[] = { 0x0000000000000004LL}; 32static ANTLRBitSet *FOLLOW_INT_in_poly56; 33static const unsigned long long FOLLOW_INT_in_poly56_data[] = { 0x0000000000000020LL}; 34static ANTLRBitSet *FOLLOW_INT_in_poly60; 35static const unsigned long long FOLLOW_INT_in_poly60_data[] = { 0x0000000000000008LL}; 36static ANTLRBitSet *FOLLOW_8_in_poly73; 37static const unsigned long long FOLLOW_8_in_poly73_data[] = { 0x0000000000000004LL}; 38static ANTLRBitSet *FOLLOW_8_in_poly76; 39static const unsigned long long FOLLOW_8_in_poly76_data[] = { 0x0000000000000004LL}; 40static ANTLRBitSet *FOLLOW_INT_in_poly80; 41static const unsigned long long FOLLOW_INT_in_poly80_data[] = { 0x0000000000000370LL}; 42static ANTLRBitSet *FOLLOW_poly_in_poly84; 43static const unsigned long long FOLLOW_poly_in_poly84_data[] = { 0x0000000000000008LL}; 44static ANTLRBitSet *FOLLOW_INT_in_poly89; 45static const unsigned long long FOLLOW_INT_in_poly89_data[] = { 0x0000000000000008LL}; 46static ANTLRBitSet *FOLLOW_8_in_poly117; 47static const unsigned long long FOLLOW_8_in_poly117_data[] = { 0x0000000000000004LL}; 48static ANTLRBitSet *FOLLOW_8_in_poly120; 49static const unsigned long long FOLLOW_8_in_poly120_data[] = { 0x0000000000000004LL}; 50static ANTLRBitSet *FOLLOW_poly_in_poly124; 51static const unsigned long long FOLLOW_poly_in_poly124_data[] = { 0x0000000000000020LL}; 52static ANTLRBitSet *FOLLOW_INT_in_poly128; 53static const unsigned long long FOLLOW_INT_in_poly128_data[] = { 0x0000000000000008LL}; 54static ANTLRBitSet *FOLLOW_INT_in_poly133; 55static const unsigned long long FOLLOW_INT_in_poly133_data[] = { 0x0000000000000008LL}; 56static ANTLRBitSet *FOLLOW_8_in_poly161; 57static const unsigned long long FOLLOW_8_in_poly161_data[] = { 0x0000000000000004LL}; 58static ANTLRBitSet *FOLLOW_poly_in_poly165; 59static const unsigned long long FOLLOW_poly_in_poly165_data[] = { 0x0000000000000370LL}; 60static ANTLRBitSet *FOLLOW_poly_in_poly169; 61static const unsigned long long FOLLOW_poly_in_poly169_data[] = { 0x0000000000000008LL}; 62static ANTLRBitSet *FOLLOW_MULT_in_poly216; 63static const unsigned long long FOLLOW_MULT_in_poly216_data[] = { 0x0000000000000004LL}; 64static ANTLRBitSet *FOLLOW_INT_in_poly218; 65static const unsigned long long FOLLOW_INT_in_poly218_data[] = { 0x0000000000000370LL}; 66static ANTLRBitSet *FOLLOW_poly_in_poly220; 67static const unsigned long long FOLLOW_poly_in_poly220_data[] = { 0x0000000000000008LL}; 68static ANTLRBitSet *FOLLOW_9_in_poly251; 69static const unsigned long long FOLLOW_9_in_poly251_data[] = { 0x0000000000000004LL}; 70static ANTLRBitSet *FOLLOW_ID_in_poly253; 71static const unsigned long long FOLLOW_ID_in_poly253_data[] = { 0x0000000000000020LL}; 72static ANTLRBitSet *FOLLOW_INT_in_poly257; 73static const unsigned long long FOLLOW_INT_in_poly257_data[] = { 0x0000000000000008LL}; 74static ANTLRBitSet *FOLLOW_INT_in_poly302; 75static const unsigned long long FOLLOW_INT_in_poly302_data[] = { 0x0000000000000002LL}; 76static ANTLRBitSet *FOLLOW_ID_in_poly307; 77static const unsigned long long FOLLOW_ID_in_poly307_data[] = { 0x0000000000000002LL}; 78static ANTLRBitSet *FOLLOW_8_in_synpred1_Simplifier52; 79static const unsigned long long FOLLOW_8_in_synpred1_Simplifier52_data[] = { 0x0000000000000004LL}; 80static ANTLRBitSet *FOLLOW_INT_in_synpred1_Simplifier56; 81static const unsigned long long FOLLOW_INT_in_synpred1_Simplifier56_data[] = { 0x0000000000000020LL}; 82static ANTLRBitSet *FOLLOW_INT_in_synpred1_Simplifier60; 83static const unsigned long long FOLLOW_INT_in_synpred1_Simplifier60_data[] = { 0x0000000000000008LL}; 84static ANTLRBitSet *FOLLOW_8_in_synpred2_Simplifier73; 85static const unsigned long long FOLLOW_8_in_synpred2_Simplifier73_data[] = { 0x0000000000000004LL}; 86static ANTLRBitSet *FOLLOW_8_in_synpred2_Simplifier76; 87static const unsigned long long FOLLOW_8_in_synpred2_Simplifier76_data[] = { 0x0000000000000004LL}; 88static ANTLRBitSet *FOLLOW_INT_in_synpred2_Simplifier80; 89static const unsigned long long FOLLOW_INT_in_synpred2_Simplifier80_data[] = { 0x0000000000000370LL}; 90static ANTLRBitSet *FOLLOW_poly_in_synpred2_Simplifier84; 91static const unsigned long long FOLLOW_poly_in_synpred2_Simplifier84_data[] = { 0x0000000000000008LL}; 92static ANTLRBitSet *FOLLOW_INT_in_synpred2_Simplifier89; 93static const unsigned long long FOLLOW_INT_in_synpred2_Simplifier89_data[] = { 0x0000000000000008LL}; 94static ANTLRBitSet *FOLLOW_8_in_synpred3_Simplifier117; 95static const unsigned long long FOLLOW_8_in_synpred3_Simplifier117_data[] = { 0x0000000000000004LL}; 96static ANTLRBitSet *FOLLOW_8_in_synpred3_Simplifier120; 97static const unsigned long long FOLLOW_8_in_synpred3_Simplifier120_data[] = { 0x0000000000000004LL}; 98static ANTLRBitSet *FOLLOW_poly_in_synpred3_Simplifier124; 99static const unsigned long long FOLLOW_poly_in_synpred3_Simplifier124_data[] = { 0x0000000000000020LL}; 100static ANTLRBitSet *FOLLOW_INT_in_synpred3_Simplifier128; 101static const unsigned long long FOLLOW_INT_in_synpred3_Simplifier128_data[] = { 0x0000000000000008LL}; 102static ANTLRBitSet *FOLLOW_INT_in_synpred3_Simplifier133; 103static const unsigned long long FOLLOW_INT_in_synpred3_Simplifier133_data[] = { 0x0000000000000008LL}; 104static ANTLRBitSet *FOLLOW_8_in_synpred4_Simplifier161; 105static const unsigned long long FOLLOW_8_in_synpred4_Simplifier161_data[] = { 0x0000000000000004LL}; 106static ANTLRBitSet *FOLLOW_poly_in_synpred4_Simplifier165; 107static const unsigned long long FOLLOW_poly_in_synpred4_Simplifier165_data[] = { 0x0000000000000370LL}; 108static ANTLRBitSet *FOLLOW_poly_in_synpred4_Simplifier169; 109static const unsigned long long FOLLOW_poly_in_synpred4_Simplifier169_data[] = { 0x0000000000000008LL}; 110 111 112#pragma mark Dynamic Global globalAttributeScopeImplementation 113 114#pragma mark Dynamic Rule Scopes ruleAttributeScopeImplementation 115 116#pragma mark Rule Return Scopes returnScopeImplementation 117@implementation Simplifier_poly_return /* returnScopeImplementation */ 118/* AST returnScope.synthesize */ 119@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */ 120+ (Simplifier_poly_return *)newSimplifier_poly_return 121{ 122return [[[Simplifier_poly_return alloc] init] retain]; 123} 124 125- (id) init 126{ 127self = [super init]; 128return self; 129} 130 131/* AST returnScope.methods */ 132- (CommonTree *)getTree 133{ 134 return tree; 135} 136 137- (void) setTree:(CommonTree *)aTree 138{ 139 if (tree != aTree) { 140 if (tree != nil) [tree release]; 141 if (aTree != nil) [aTree retain]; 142 tree = aTree; 143 } 144} 145 146- (void) dealloc 147{ 148 self.tree = nil; 149 [super dealloc]; 150} 151 152 153@end /* end of returnScope implementation */ 154 155@implementation Simplifier_synpred1_Simplifier_return /* returnScopeImplementation */ 156/* AST returnScope.synthesize */ 157@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */ 158+ (Simplifier_synpred1_Simplifier_return *)newSimplifier_synpred1_Simplifier_return 159{ 160return [[[Simplifier_synpred1_Simplifier_return alloc] init] retain]; 161} 162 163- (id) init 164{ 165self = [super init]; 166return self; 167} 168 169/* AST returnScope.methods */ 170- (CommonTree *)getTree 171{ 172 return tree; 173} 174 175- (void) setTree:(CommonTree *)aTree 176{ 177 if (tree != aTree) { 178 if (tree != nil) [tree release]; 179 if (aTree != nil) [aTree retain]; 180 tree = aTree; 181 } 182} 183 184- (void) dealloc 185{ 186 self.tree = nil; 187 [super dealloc]; 188} 189 190 191@end /* end of returnScope implementation */ 192 193@implementation Simplifier_synpred2_Simplifier_return /* returnScopeImplementation */ 194/* AST returnScope.synthesize */ 195@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */ 196+ (Simplifier_synpred2_Simplifier_return *)newSimplifier_synpred2_Simplifier_return 197{ 198return [[[Simplifier_synpred2_Simplifier_return alloc] init] retain]; 199} 200 201- (id) init 202{ 203self = [super init]; 204return self; 205} 206 207/* AST returnScope.methods */ 208- (CommonTree *)getTree 209{ 210 return tree; 211} 212 213- (void) setTree:(CommonTree *)aTree 214{ 215 if (tree != aTree) { 216 if (tree != nil) [tree release]; 217 if (aTree != nil) [aTree retain]; 218 tree = aTree; 219 } 220} 221 222- (void) dealloc 223{ 224 self.tree = nil; 225 [super dealloc]; 226} 227 228 229@end /* end of returnScope implementation */ 230 231@implementation Simplifier_synpred3_Simplifier_return /* returnScopeImplementation */ 232/* AST returnScope.synthesize */ 233@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */ 234+ (Simplifier_synpred3_Simplifier_return *)newSimplifier_synpred3_Simplifier_return 235{ 236return [[[Simplifier_synpred3_Simplifier_return alloc] init] retain]; 237} 238 239- (id) init 240{ 241self = [super init]; 242return self; 243} 244 245/* AST returnScope.methods */ 246- (CommonTree *)getTree 247{ 248 return tree; 249} 250 251- (void) setTree:(CommonTree *)aTree 252{ 253 if (tree != aTree) { 254 if (tree != nil) [tree release]; 255 if (aTree != nil) [aTree retain]; 256 tree = aTree; 257 } 258} 259 260- (void) dealloc 261{ 262 self.tree = nil; 263 [super dealloc]; 264} 265 266 267@end /* end of returnScope implementation */ 268 269@implementation Simplifier_synpred4_Simplifier_return /* returnScopeImplementation */ 270/* AST returnScope.synthesize */ 271@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */ 272+ (Simplifier_synpred4_Simplifier_return *)newSimplifier_synpred4_Simplifier_return 273{ 274return [[[Simplifier_synpred4_Simplifier_return alloc] init] retain]; 275} 276 277- (id) init 278{ 279self = [super init]; 280return self; 281} 282 283/* AST returnScope.methods */ 284- (CommonTree *)getTree 285{ 286 return tree; 287} 288 289- (void) setTree:(CommonTree *)aTree 290{ 291 if (tree != aTree) { 292 if (tree != nil) [tree release]; 293 if (aTree != nil) [aTree retain]; 294 tree = aTree; 295 } 296} 297 298- (void) dealloc 299{ 300 self.tree = nil; 301 [super dealloc]; 302} 303 304 305@end /* end of returnScope implementation */ 306 307 308 309@implementation Simplifier // line 637 310 311/* ObjC start of ruleAttributeScope */ 312#pragma mark Dynamic Rule Scopes ruleAttributeScope 313/* ObjC end of ruleAttributeScope */ 314#pragma mark global Attribute Scopes globalAttributeScope 315/* ObjC start globalAttributeScope */ 316/* ObjC end globalAttributeScope */ 317/* ObjC start actions.(actionScope).synthesize */ 318/* ObjC start synthesize() */ 319/* AST genericParser.synthesize */ 320/* AST parserProperties */ 321@synthesize treeAdaptor; 322 323+ (void) initialize 324{ 325 #pragma mark Bitsets 326 FOLLOW_8_in_poly52 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_poly52_data Count:(NSUInteger)1] retain]; 327 FOLLOW_INT_in_poly56 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_poly56_data Count:(NSUInteger)1] retain]; 328 FOLLOW_INT_in_poly60 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_poly60_data Count:(NSUInteger)1] retain]; 329 FOLLOW_8_in_poly73 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_poly73_data Count:(NSUInteger)1] retain]; 330 FOLLOW_8_in_poly76 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_poly76_data Count:(NSUInteger)1] retain]; 331 FOLLOW_INT_in_poly80 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_poly80_data Count:(NSUInteger)1] retain]; 332 FOLLOW_poly_in_poly84 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_poly_in_poly84_data Count:(NSUInteger)1] retain]; 333 FOLLOW_INT_in_poly89 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_poly89_data Count:(NSUInteger)1] retain]; 334 FOLLOW_8_in_poly117 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_poly117_data Count:(NSUInteger)1] retain]; 335 FOLLOW_8_in_poly120 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_poly120_data Count:(NSUInteger)1] retain]; 336 FOLLOW_poly_in_poly124 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_poly_in_poly124_data Count:(NSUInteger)1] retain]; 337 FOLLOW_INT_in_poly128 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_poly128_data Count:(NSUInteger)1] retain]; 338 FOLLOW_INT_in_poly133 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_poly133_data Count:(NSUInteger)1] retain]; 339 FOLLOW_8_in_poly161 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_poly161_data Count:(NSUInteger)1] retain]; 340 FOLLOW_poly_in_poly165 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_poly_in_poly165_data Count:(NSUInteger)1] retain]; 341 FOLLOW_poly_in_poly169 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_poly_in_poly169_data Count:(NSUInteger)1] retain]; 342 FOLLOW_MULT_in_poly216 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_MULT_in_poly216_data Count:(NSUInteger)1] retain]; 343 FOLLOW_INT_in_poly218 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_poly218_data Count:(NSUInteger)1] retain]; 344 FOLLOW_poly_in_poly220 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_poly_in_poly220_data Count:(NSUInteger)1] retain]; 345 FOLLOW_9_in_poly251 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_9_in_poly251_data Count:(NSUInteger)1] retain]; 346 FOLLOW_ID_in_poly253 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_poly253_data Count:(NSUInteger)1] retain]; 347 FOLLOW_INT_in_poly257 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_poly257_data Count:(NSUInteger)1] retain]; 348 FOLLOW_INT_in_poly302 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_poly302_data Count:(NSUInteger)1] retain]; 349 FOLLOW_ID_in_poly307 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_poly307_data Count:(NSUInteger)1] retain]; 350 FOLLOW_8_in_synpred1_Simplifier52 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_synpred1_Simplifier52_data Count:(NSUInteger)1] retain]; 351 FOLLOW_INT_in_synpred1_Simplifier56 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_synpred1_Simplifier56_data Count:(NSUInteger)1] retain]; 352 FOLLOW_INT_in_synpred1_Simplifier60 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_synpred1_Simplifier60_data Count:(NSUInteger)1] retain]; 353 FOLLOW_8_in_synpred2_Simplifier73 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_synpred2_Simplifier73_data Count:(NSUInteger)1] retain]; 354 FOLLOW_8_in_synpred2_Simplifier76 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_synpred2_Simplifier76_data Count:(NSUInteger)1] retain]; 355 FOLLOW_INT_in_synpred2_Simplifier80 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_synpred2_Simplifier80_data Count:(NSUInteger)1] retain]; 356 FOLLOW_poly_in_synpred2_Simplifier84 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_poly_in_synpred2_Simplifier84_data Count:(NSUInteger)1] retain]; 357 FOLLOW_INT_in_synpred2_Simplifier89 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_synpred2_Simplifier89_data Count:(NSUInteger)1] retain]; 358 FOLLOW_8_in_synpred3_Simplifier117 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_synpred3_Simplifier117_data Count:(NSUInteger)1] retain]; 359 FOLLOW_8_in_synpred3_Simplifier120 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_synpred3_Simplifier120_data Count:(NSUInteger)1] retain]; 360 FOLLOW_poly_in_synpred3_Simplifier124 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_poly_in_synpred3_Simplifier124_data Count:(NSUInteger)1] retain]; 361 FOLLOW_INT_in_synpred3_Simplifier128 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_synpred3_Simplifier128_data Count:(NSUInteger)1] retain]; 362 FOLLOW_INT_in_synpred3_Simplifier133 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_synpred3_Simplifier133_data Count:(NSUInteger)1] retain]; 363 FOLLOW_8_in_synpred4_Simplifier161 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_synpred4_Simplifier161_data Count:(NSUInteger)1] retain]; 364 FOLLOW_poly_in_synpred4_Simplifier165 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_poly_in_synpred4_Simplifier165_data Count:(NSUInteger)1] retain]; 365 FOLLOW_poly_in_synpred4_Simplifier169 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_poly_in_synpred4_Simplifier169_data Count:(NSUInteger)1] retain]; 366 367 [BaseRecognizer setTokenNames:[[AMutableArray arrayWithObjects:@"<invalid>", @"<EOR>", @"<DOWN>", @"<UP>", 368 @"ID", @"INT", @"MULT", @"WS", @"'+'", @"'^'", nil] retain]]; 369 [BaseRecognizer setGrammarFileName:@"/Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g"]; 370 SEL synpred2_SimplifierSelector = @selector(synpred2_Simplifier_fragment); 371 SEL synpred1_SimplifierSelector = @selector(synpred1_Simplifier_fragment); 372 SEL synpred4_SimplifierSelector = @selector(synpred4_Simplifier_fragment); 373 SEL synpred3_SimplifierSelector = @selector(synpred3_Simplifier_fragment); 374 375} 376 377+ (Simplifier *)newSimplifier:(id<TreeNodeStream>)aStream 378{ 379 return [[Simplifier alloc] initWithStream:aStream]; 380} 381 382- (id) initWithStream:(id<TreeNodeStream>)aStream 383{ 384 self = [super initWithStream:aStream State:[[RecognizerSharedState newRecognizerSharedStateWithRuleLen:8+1] retain]]; 385 if ( self != nil ) { 386 /* start of actions-actionScope-init */ 387 /* start of init */ 388 /* AST genericParser.init */ 389 [self setTreeAdaptor:[[CommonTreeAdaptor newTreeAdaptor] retain]]; 390 } 391 return self; 392} 393 394- (void) dealloc 395{ 396 /* AST genericParser.dealloc */ 397 [self setTreeAdaptor:nil]; 398 399 [super dealloc]; 400} 401 402/* ObjC start actions.(actionScope).methods */ 403/* ObjC end actions.(actionScope).methods */ 404/* ObjC start methods() */ 405/* AST genericParser.methods */ 406/* AST parserMethods */ 407- (id<TreeAdaptor>) getTreeAdaptor 408{ 409 return treeAdaptor; 410} 411 412- (void) setTreeAdaptor:(id<TreeAdaptor>)aTreeAdaptor 413{ 414 if (aTreeAdaptor != treeAdaptor) { 415 treeAdaptor = aTreeAdaptor; 416 } 417} 418/* ObjC end methods() */ 419/* ObjC start rules */ 420/* 421 * $ANTLR start poly 422 * /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:16:1: poly : ( ^( '+' a= INT b= INT ) -> INT[[NSString stringWithFormat:@\"\\%d\", ($a.int+$b.int)]] | ^( '+' ^( '+' a= INT p= poly ) b= INT ) -> ^( '+' $p INT[[NSString stringWithFormat:@\"\\%d\", ($a.int+$b.int)]] ) | ^( '+' ^( '+' p= poly a= INT ) b= INT ) -> ^( '+' $p INT[[NSString stringWithFormat:@\"\\%d\", ($a.int+$b.int)]] ) | ^( '+' p= poly q= poly ) -> { [[$p.tree toStringTree] isEqualToString:@\"0\"] }? $q -> { [[$q.tree toStringTree] isEqualToString:@\"0\"] }? $p -> ^( '+' $p $q) | ^( MULT INT poly ) -> {$INT.int==1}? poly -> ^( MULT INT poly ) | ^( '^' ID e= INT ) -> {$e.int==1}? ID -> {$e.int==0}? INT[@\"1\"] -> ^( '^' ID INT ) | INT | ID ); 423 */ 424- (Simplifier_poly_return *) poly 425{ 426 /* ruleScopeSetUp */ 427 428 /* ASTTreeParser ruleDeclarations */ 429 /* AST ruleDeclarations */ 430 /* ruleDeclarations */ 431 Simplifier_poly_return * retval = [Simplifier_poly_return newSimplifier_poly_return]; 432 [retval setStart:[input LT:1]]; 433 434 435 CommonTree *root_0 = nil; 436 437 CommonTree *_first_0 = nil; 438 CommonTree *_last = nil; 439 440 @try { 441 /* AST ruleLabelDefs */ 442 /* ruleLabelDefs entry */ 443 CommonTree *a = nil; 444 CommonTree *b = nil; 445 CommonTree *e = nil; 446 CommonTree *char_literal1 = nil; 447 CommonTree *char_literal2 = nil; 448 CommonTree *char_literal3 = nil; 449 CommonTree *char_literal4 = nil; 450 CommonTree *char_literal5 = nil; 451 CommonTree *char_literal6 = nil; 452 CommonTree *MULT7 = nil; 453 CommonTree *INT8 = nil; 454 CommonTree *char_literal10 = nil; 455 CommonTree *ID11 = nil; 456 CommonTree *INT12 = nil; 457 CommonTree *ID13 = nil;Simplifier_poly_return * p = nil ; 458 459 Simplifier_poly_return * q = nil ; 460 461 Simplifier_poly_return * poly9 = nil ; 462 463 464 CommonTree *a_tree=nil; 465 CommonTree *b_tree=nil; 466 CommonTree *e_tree=nil; 467 CommonTree *char_literal1_tree=nil; 468 CommonTree *char_literal2_tree=nil; 469 CommonTree *char_literal3_tree=nil; 470 CommonTree *char_literal4_tree=nil; 471 CommonTree *char_literal5_tree=nil; 472 CommonTree *char_literal6_tree=nil; 473 CommonTree *MULT7_tree=nil; 474 CommonTree *INT8_tree=nil; 475 CommonTree *char_literal10_tree=nil; 476 CommonTree *ID11_tree=nil; 477 CommonTree *INT12_tree=nil; 478 CommonTree *ID13_tree=nil; 479 RewriteRuleTokenStream *stream_INT = 480 [[RewriteRuleNodeStream newRewriteRuleNodeStream:treeAdaptor 481 description:@"token INT"] retain]; 482 RewriteRuleTokenStream *stream_MULT = 483 [[RewriteRuleNodeStream newRewriteRuleNodeStream:treeAdaptor 484 description:@"token MULT"] retain]; 485 RewriteRuleTokenStream *stream_ID = 486 [[RewriteRuleNodeStream newRewriteRuleNodeStream:treeAdaptor 487 description:@"token ID"] retain]; 488 RewriteRuleTokenStream *stream_9 = 489 [[RewriteRuleNodeStream newRewriteRuleNodeStream:treeAdaptor 490 description:@"token 9"] retain]; 491 RewriteRuleTokenStream *stream_8 = 492 [[RewriteRuleNodeStream newRewriteRuleNodeStream:treeAdaptor 493 description:@"token 8"] retain]; 494 RewriteRuleSubtreeStream *stream_poly = 495 [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor 496 description:@"rule poly"] retain]; 497 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:16:5: ( ^( '+' a= INT b= INT ) -> INT[[NSString stringWithFormat:@\"\\%d\", ($a.int+$b.int)]] | ^( '+' ^( '+' a= INT p= poly ) b= INT ) -> ^( '+' $p INT[[NSString stringWithFormat:@\"\\%d\", ($a.int+$b.int)]] ) | ^( '+' ^( '+' p= poly a= INT ) b= INT ) -> ^( '+' $p INT[[NSString stringWithFormat:@\"\\%d\", ($a.int+$b.int)]] ) | ^( '+' p= poly q= poly ) -> { [[$p.tree toStringTree] isEqualToString:@\"0\"] }? $q -> { [[$q.tree toStringTree] isEqualToString:@\"0\"] }? $p -> ^( '+' $p $q) | ^( MULT INT poly ) -> {$INT.int==1}? poly -> ^( MULT INT poly ) | ^( '^' ID e= INT ) -> {$e.int==1}? ID -> {$e.int==0}? INT[@\"1\"] -> ^( '^' ID INT ) | INT | ID ) //ruleblock 498 NSInteger alt1=8; 499 unichar charLA1 = [input LA:1]; 500 switch (charLA1) { 501 case 8: ; 502 { 503 NSInteger LA1_1 = [input LA:2]; 504 505 if ( ([self evaluateSyntacticPredicate:@selector(synpred1_Simplifier_fragment)]) ) { 506 alt1=1; 507 } 508 else if ( ([self evaluateSyntacticPredicate:@selector(synpred2_Simplifier_fragment)]) ) { 509 alt1=2; 510 } 511 else if ( ([self evaluateSyntacticPredicate:@selector(synpred3_Simplifier_fragment)]) ) { 512 alt1=3; 513 } 514 else if ( ([self evaluateSyntacticPredicate:@selector(synpred4_Simplifier_fragment)]) ) { 515 alt1=4; 516 } 517 else { 518 if ( state.backtracking > 0 ) { state.failed = YES; return retval; } 519 520 NoViableAltException *nvae = [NoViableAltException newException:1 state:1 stream:input]; 521 nvae.c = LA1_1; 522 @throw nvae; 523 524 } 525 } 526 break; 527 case MULT: ; 528 { 529 alt1=5; 530 } 531 break; 532 case 9: ; 533 { 534 alt1=6; 535 } 536 break; 537 case INT: ; 538 { 539 alt1=7; 540 } 541 break; 542 case ID: ; 543 { 544 alt1=8; 545 } 546 break; 547 548 default: ; 549 if ( state.backtracking > 0 ) { state.failed = YES; return retval; } 550 551 NoViableAltException *nvae = [NoViableAltException newException:1 state:0 stream:input]; 552 nvae.c = charLA1; 553 @throw nvae; 554 555 } 556 557 switch (alt1) { 558 case 1 : ; 559 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:16:7: ^( '+' a= INT b= INT ) // alt 560 { 561 562 /* ASTTreeParser tree */ 563 _last = (CommonTree *)[input LT:1]; 564 { 565 CommonTree *_save_last_1 = _last; 566 CommonTree *_first_1 = nil; 567 CommonTree *root_1 = [[[treeAdaptor class] newEmptyTree] retain]; 568 569 /* ASTTreeParser tokenRefBang */ 570 _last = (CommonTree *)[input LT:1]; 571 char_literal1=(CommonTree *)[self match:input TokenType:8 Follow:FOLLOW_8_in_poly52]; if ( state.failed ) return retval; 572 if ( state.backtracking == 0 ) [stream_8 addElement:char_literal1]; 573 574 575 [self match:input TokenType:TokenTypeDOWN Follow:nil]; if ( state.failed ) return retval; 576 577 /* ASTTreeParser tokenRefBang */ 578 _last = (CommonTree *)[input LT:1]; 579 a=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_poly56]; if ( state.failed ) return retval; 580 if ( state.backtracking == 0 ) [stream_INT addElement:a]; 581 582 583 /* ASTTreeParser tokenRefBang */ 584 _last = (CommonTree *)[input LT:1]; 585 b=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_poly60]; if ( state.failed ) return retval; 586 if ( state.backtracking == 0 ) [stream_INT addElement:b]; 587 588 589 [self match:input TokenType:TokenTypeUP Follow:nil]; if ( state.failed ) return retval; 590 [treeAdaptor addChild:root_1 toTree:root_0]; 591 _last = _save_last_1; 592 } 593 594 595 // AST REWRITE 596 // elements: INT 597 // token labels: 598 // rule labels: retval 599 // token list labels: 600 // rule list labels: 601 // wildcard labels: 602 if ( state.backtracking == 0 ) { 603 604 retval.tree = root_0; 605 606 RewriteRuleSubtreeStream *stream_retval = 607 [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor 608 description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain]; 609 610 root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 611 612 // 16:26: -> INT[[NSString stringWithFormat:@\"\\%d\", ($a.int+$b.int)]] 613 { 614 [treeAdaptor addChild: 615 [[treeAdaptor createTree:INT FromToken:[NSString stringWithFormat:@"%d", ((a!=nil?[a.text integerValue]:0)+(b!=nil?[b.text integerValue]:0))] Text:@"INT"] retain] 616 toTree:root_0]; 617 618 } 619 620 621 retval.tree = root_0; 622 623 } 624 625 } 626 break; 627 case 2 : ; 628 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:18:4: ^( '+' ^( '+' a= INT p= poly ) b= INT ) // alt 629 { 630 631 /* ASTTreeParser tree */ 632 _last = (CommonTree *)[input LT:1]; 633 { 634 CommonTree *_save_last_1 = _last; 635 CommonTree *_first_1 = nil; 636 CommonTree *root_1 = [[[treeAdaptor class] newEmptyTree] retain]; 637 638 /* ASTTreeParser tokenRefBang */ 639 _last = (CommonTree *)[input LT:1]; 640 char_literal2=(CommonTree *)[self match:input TokenType:8 Follow:FOLLOW_8_in_poly73]; if ( state.failed ) return retval; 641 if ( state.backtracking == 0 ) [stream_8 addElement:char_literal2]; 642 643 644 [self match:input TokenType:TokenTypeDOWN Follow:nil]; if ( state.failed ) return retval; 645 646 /* ASTTreeParser tree */ 647 _last = (CommonTree *)[input LT:1]; 648 { 649 CommonTree *_save_last_2 = _last; 650 CommonTree *_first_2 = nil; 651 CommonTree *root_2 = [[[treeAdaptor class] newEmptyTree] retain]; 652 653 /* ASTTreeParser tokenRefBang */ 654 _last = (CommonTree *)[input LT:1]; 655 char_literal3=(CommonTree *)[self match:input TokenType:8 Follow:FOLLOW_8_in_poly76]; if ( state.failed ) return retval; 656 if ( state.backtracking == 0 ) [stream_8 addElement:char_literal3]; 657 658 659 [self match:input TokenType:TokenTypeDOWN Follow:nil]; if ( state.failed ) return retval; 660 661 /* ASTTreeParser tokenRefBang */ 662 _last = (CommonTree *)[input LT:1]; 663 a=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_poly80]; if ( state.failed ) return retval; 664 if ( state.backtracking == 0 ) [stream_INT addElement:a]; 665 666 667 /* ASTTreeParser ruleRefTrack */ 668 _last = (CommonTree *)[input LT:1]; 669 /* ruleRef */ 670 [self pushFollow:FOLLOW_poly_in_poly84]; 671 p = [self poly]; 672 673 [self popFollow]; 674 if ( state.failed ) return retval; 675 676 if ( state.backtracking == 0 ) 677 [stream_poly addElement:[p getTree]]; 678 679 [self match:input TokenType:TokenTypeUP Follow:nil]; if ( state.failed ) return retval; 680 [treeAdaptor addChild:root_2 toTree:root_1]; 681 _last = _save_last_2; 682 } 683 684 685 /* ASTTreeParser tokenRefBang */ 686 _last = (CommonTree *)[input LT:1]; 687 b=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_poly89]; if ( state.failed ) return retval; 688 if ( state.backtracking == 0 ) [stream_INT addElement:b]; 689 690 691 [self match:input TokenType:TokenTypeUP Follow:nil]; if ( state.failed ) return retval; 692 [treeAdaptor addChild:root_1 toTree:root_0]; 693 _last = _save_last_1; 694 } 695 696 697 // AST REWRITE 698 // elements: INT, p, 8 699 // token labels: 700 // rule labels: retval, p 701 // token list labels: 702 // rule list labels: 703 // wildcard labels: 704 if ( state.backtracking == 0 ) { 705 706 retval.tree = root_0; 707 708 RewriteRuleSubtreeStream *stream_retval = 709 [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor 710 description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain]; 711 RewriteRuleSubtreeStream *stream_p = 712 [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor 713 description:@"token p" element:p!=nil?[p getTree]:nil] retain]; 714 715 root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 716 717 // 19:8: -> ^( '+' $p INT[[NSString stringWithFormat:@\"\\%d\", ($a.int+$b.int)]] ) 718 { 719 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:19:11: ^( '+' $p INT[[NSString stringWithFormat:@\"\\%d\", ($a.int+$b.int)]] ) 720 { 721 CommonTree *root_1 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 722 root_1 = (CommonTree *)[treeAdaptor becomeRoot:/* ASTTreeParser createRewriteNodeFromElement */ 723 [stream_8 nextNode] 724 old:root_1]; 725 726 [treeAdaptor addChild:[stream_p nextTree] toTree:root_1]; 727 728 [treeAdaptor addChild: 729 [[treeAdaptor createTree:INT FromToken:[NSString stringWithFormat:@"%d", ((a!=nil?[a.text integerValue]:0)+(b!=nil?[b.text integerValue]:0))] Text:@"INT"] retain] 730 toTree:root_1]; 731 732 [treeAdaptor addChild:root_1 toTree:root_0]; 733 } 734 735 } 736 737 738 retval.tree = root_0; 739 740 } 741 742 } 743 break; 744 case 3 : ; 745 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:21:4: ^( '+' ^( '+' p= poly a= INT ) b= INT ) // alt 746 { 747 748 /* ASTTreeParser tree */ 749 _last = (CommonTree *)[input LT:1]; 750 { 751 CommonTree *_save_last_1 = _last; 752 CommonTree *_first_1 = nil; 753 CommonTree *root_1 = [[[treeAdaptor class] newEmptyTree] retain]; 754 755 /* ASTTreeParser tokenRefBang */ 756 _last = (CommonTree *)[input LT:1]; 757 char_literal4=(CommonTree *)[self match:input TokenType:8 Follow:FOLLOW_8_in_poly117]; if ( state.failed ) return retval; 758 if ( state.backtracking == 0 ) [stream_8 addElement:char_literal4]; 759 760 761 [self match:input TokenType:TokenTypeDOWN Follow:nil]; if ( state.failed ) return retval; 762 763 /* ASTTreeParser tree */ 764 _last = (CommonTree *)[input LT:1]; 765 { 766 CommonTree *_save_last_2 = _last; 767 CommonTree *_first_2 = nil; 768 CommonTree *root_2 = [[[treeAdaptor class] newEmptyTree] retain]; 769 770 /* ASTTreeParser tokenRefBang */ 771 _last = (CommonTree *)[input LT:1]; 772 char_literal5=(CommonTree *)[self match:input TokenType:8 Follow:FOLLOW_8_in_poly120]; if ( state.failed ) return retval; 773 if ( state.backtracking == 0 ) [stream_8 addElement:char_literal5]; 774 775 776 [self match:input TokenType:TokenTypeDOWN Follow:nil]; if ( state.failed ) return retval; 777 778 /* ASTTreeParser ruleRefTrack */ 779 _last = (CommonTree *)[input LT:1]; 780 /* ruleRef */ 781 [self pushFollow:FOLLOW_poly_in_poly124]; 782 p = [self poly]; 783 784 [self popFollow]; 785 if ( state.failed ) return retval; 786 787 if ( state.backtracking == 0 ) 788 [stream_poly addElement:[p getTree]]; 789 790 /* ASTTreeParser tokenRefBang */ 791 _last = (CommonTree *)[input LT:1]; 792 a=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_poly128]; if ( state.failed ) return retval; 793 if ( state.backtracking == 0 ) [stream_INT addElement:a]; 794 795 796 [self match:input TokenType:TokenTypeUP Follow:nil]; if ( state.failed ) return retval; 797 [treeAdaptor addChild:root_2 toTree:root_1]; 798 _last = _save_last_2; 799 } 800 801 802 /* ASTTreeParser tokenRefBang */ 803 _last = (CommonTree *)[input LT:1]; 804 b=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_poly133]; if ( state.failed ) return retval; 805 if ( state.backtracking == 0 ) [stream_INT addElement:b]; 806 807 808 [self match:input TokenType:TokenTypeUP Follow:nil]; if ( state.failed ) return retval; 809 [treeAdaptor addChild:root_1 toTree:root_0]; 810 _last = _save_last_1; 811 } 812 813 814 // AST REWRITE 815 // elements: INT, 8, p 816 // token labels: 817 // rule labels: retval, p 818 // token list labels: 819 // rule list labels: 820 // wildcard labels: 821 if ( state.backtracking == 0 ) { 822 823 retval.tree = root_0; 824 825 RewriteRuleSubtreeStream *stream_retval = 826 [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor 827 description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain]; 828 RewriteRuleSubtreeStream *stream_p = 829 [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor 830 description:@"token p" element:p!=nil?[p getTree]:nil] retain]; 831 832 root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 833 834 // 22:8: -> ^( '+' $p INT[[NSString stringWithFormat:@\"\\%d\", ($a.int+$b.int)]] ) 835 { 836 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:22:11: ^( '+' $p INT[[NSString stringWithFormat:@\"\\%d\", ($a.int+$b.int)]] ) 837 { 838 CommonTree *root_1 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 839 root_1 = (CommonTree *)[treeAdaptor becomeRoot:/* ASTTreeParser createRewriteNodeFromElement */ 840 [stream_8 nextNode] 841 old:root_1]; 842 843 [treeAdaptor addChild:[stream_p nextTree] toTree:root_1]; 844 845 [treeAdaptor addChild: 846 [[treeAdaptor createTree:INT FromToken:[NSString stringWithFormat:@"%d", ((a!=nil?[a.text integerValue]:0)+(b!=nil?[b.text integerValue]:0))] Text:@"INT"] retain] 847 toTree:root_1]; 848 849 [treeAdaptor addChild:root_1 toTree:root_0]; 850 } 851 852 } 853 854 855 retval.tree = root_0; 856 857 } 858 859 } 860 break; 861 case 4 : ; 862 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:24:4: ^( '+' p= poly q= poly ) // alt 863 { 864 865 /* ASTTreeParser tree */ 866 _last = (CommonTree *)[input LT:1]; 867 { 868 CommonTree *_save_last_1 = _last; 869 CommonTree *_first_1 = nil; 870 CommonTree *root_1 = [[[treeAdaptor class] newEmptyTree] retain]; 871 872 /* ASTTreeParser tokenRefBang */ 873 _last = (CommonTree *)[input LT:1]; 874 char_literal6=(CommonTree *)[self match:input TokenType:8 Follow:FOLLOW_8_in_poly161]; if ( state.failed ) return retval; 875 if ( state.backtracking == 0 ) [stream_8 addElement:char_literal6]; 876 877 878 [self match:input TokenType:TokenTypeDOWN Follow:nil]; if ( state.failed ) return retval; 879 880 /* ASTTreeParser ruleRefTrack */ 881 _last = (CommonTree *)[input LT:1]; 882 /* ruleRef */ 883 [self pushFollow:FOLLOW_poly_in_poly165]; 884 p = [self poly]; 885 886 [self popFollow]; 887 if ( state.failed ) return retval; 888 889 if ( state.backtracking == 0 ) 890 [stream_poly addElement:[p getTree]]; 891 892 /* ASTTreeParser ruleRefTrack */ 893 _last = (CommonTree *)[input LT:1]; 894 /* ruleRef */ 895 [self pushFollow:FOLLOW_poly_in_poly169]; 896 q = [self poly]; 897 898 [self popFollow]; 899 if ( state.failed ) return retval; 900 901 if ( state.backtracking == 0 ) 902 [stream_poly addElement:[q getTree]]; 903 904 [self match:input TokenType:TokenTypeUP Follow:nil]; if ( state.failed ) return retval; 905 [treeAdaptor addChild:root_1 toTree:root_0]; 906 _last = _save_last_1; 907 } 908 909 910 // AST REWRITE 911 // elements: 8, p, q, p, q 912 // token labels: 913 // rule labels: retval, q, p 914 // token list labels: 915 // rule list labels: 916 // wildcard labels: 917 if ( state.backtracking == 0 ) { 918 919 retval.tree = root_0; 920 921 RewriteRuleSubtreeStream *stream_retval = 922 [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor 923 description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain]; 924 RewriteRuleSubtreeStream *stream_q = 925 [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor 926 description:@"token q" element:q!=nil?[q getTree]:nil] retain]; 927 RewriteRuleSubtreeStream *stream_p = 928 [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor 929 description:@"token p" element:p!=nil?[p getTree]:nil] retain]; 930 931 root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 932 933 // 24:24: -> { [[$p.tree toStringTree] isEqualToString:@\"0\"] }? $q 934 if ( [[(p!=nil?((CommonTree *)p.tree):nil) toStringTree] isEqualToString:@"0"] ) { 935 [treeAdaptor addChild:[stream_q nextTree] toTree:root_0]; 936 937 } 938 939 else // 25:8: -> { [[$q.tree toStringTree] isEqualToString:@\"0\"] }? $p 940 if ( [[(q!=nil?((CommonTree *)q.tree):nil) toStringTree] isEqualToString:@"0"] ) { 941 [treeAdaptor addChild:[stream_p nextTree] toTree:root_0]; 942 943 } 944 945 else // 26:8: -> ^( '+' $p $q) 946 { 947 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:26:11: ^( '+' $p $q) 948 { 949 CommonTree *root_1 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 950 root_1 = (CommonTree *)[treeAdaptor becomeRoot:/* ASTTreeParser createRewriteNodeFromElement */ 951 [stream_8 nextNode] 952 old:root_1]; 953 954 [treeAdaptor addChild:[stream_p nextTree] toTree:root_1]; 955 956 [treeAdaptor addChild:[stream_q nextTree] toTree:root_1]; 957 958 [treeAdaptor addChild:root_1 toTree:root_0]; 959 } 960 961 } 962 963 964 retval.tree = root_0; 965 966 } 967 968 } 969 break; 970 case 5 : ; 971 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:28:4: ^( MULT INT poly ) // alt 972 { 973 974 /* ASTTreeParser tree */ 975 _last = (CommonTree *)[input LT:1]; 976 { 977 CommonTree *_save_last_1 = _last; 978 CommonTree *_first_1 = nil; 979 CommonTree *root_1 = [[[treeAdaptor class] newEmptyTree] retain]; 980 981 /* ASTTreeParser tokenRefBang */ 982 _last = (CommonTree *)[input LT:1]; 983 MULT7=(CommonTree *)[self match:input TokenType:MULT Follow:FOLLOW_MULT_in_poly216]; if ( state.failed ) return retval; 984 if ( state.backtracking == 0 ) [stream_MULT addElement:MULT7]; 985 986 987 [self match:input TokenType:TokenTypeDOWN Follow:nil]; if ( state.failed ) return retval; 988 989 /* ASTTreeParser tokenRefBang */ 990 _last = (CommonTree *)[input LT:1]; 991 INT8=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_poly218]; if ( state.failed ) return retval; 992 if ( state.backtracking == 0 ) [stream_INT addElement:INT8]; 993 994 995 /* ASTTreeParser ruleRefTrack */ 996 _last = (CommonTree *)[input LT:1]; 997 /* ruleRef */ 998 [self pushFollow:FOLLOW_poly_in_poly220]; 999 poly9 = [self poly]; 1000 1001 [self popFollow]; 1002 if ( state.failed ) return retval; 1003 1004 if ( state.backtracking == 0 ) 1005 [stream_poly addElement:[poly9 getTree]]; 1006 1007 [self match:input TokenType:TokenTypeUP Follow:nil]; if ( state.failed ) return retval; 1008 [treeAdaptor addChild:root_1 toTree:root_0]; 1009 _last = _save_last_1; 1010 } 1011 1012 1013 // AST REWRITE 1014 // elements: INT, poly, poly, MULT 1015 // token labels: 1016 // rule labels: retval 1017 // token list labels: 1018 // rule list labels: 1019 // wildcard labels: 1020 if ( state.backtracking == 0 ) { 1021 1022 retval.tree = root_0; 1023 1024 RewriteRuleSubtreeStream *stream_retval = 1025 [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor 1026 description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain]; 1027 1028 root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 1029 1030 // 28:21: -> {$INT.int==1}? poly 1031 if ((INT8!=nil?[INT8.text integerValue]:0)==1) { 1032 [treeAdaptor addChild:[stream_poly nextTree] toTree:root_0]; 1033 1034 } 1035 1036 else // 29:8: -> ^( MULT INT poly ) 1037 { 1038 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:29:11: ^( MULT INT poly ) 1039 { 1040 CommonTree *root_1 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 1041 root_1 = (CommonTree *)[treeAdaptor becomeRoot:/* ASTTreeParser createRewriteNodeFromElement */ 1042 [stream_MULT nextNode] 1043 old:root_1]; 1044 1045 // TODO: args: 1046 [treeAdaptor addChild:/* ASTTreeParser createRewriteNodeFromElement */ 1047 [stream_INT nextNode] 1048 toTree:root_1]; 1049 1050 [treeAdaptor addChild:[stream_poly nextTree] toTree:root_1]; 1051 1052 [treeAdaptor addChild:root_1 toTree:root_0]; 1053 } 1054 1055 } 1056 1057 1058 retval.tree = root_0; 1059 1060 } 1061 1062 } 1063 break; 1064 case 6 : ; 1065 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:31:4: ^( '^' ID e= INT ) // alt 1066 { 1067 1068 /* ASTTreeParser tree */ 1069 _last = (CommonTree *)[input LT:1]; 1070 { 1071 CommonTree *_save_last_1 = _last; 1072 CommonTree *_first_1 = nil; 1073 CommonTree *root_1 = [[[treeAdaptor class] newEmptyTree] retain]; 1074 1075 /* ASTTreeParser tokenRefBang */ 1076 _last = (CommonTree *)[input LT:1]; 1077 char_literal10=(CommonTree *)[self match:input TokenType:9 Follow:FOLLOW_9_in_poly251]; if ( state.failed ) return retval; 1078 if ( state.backtracking == 0 ) [stream_9 addElement:char_literal10]; 1079 1080 1081 [self match:input TokenType:TokenTypeDOWN Follow:nil]; if ( state.failed ) return retval; 1082 1083 /* ASTTreeParser tokenRefBang */ 1084 _last = (CommonTree *)[input LT:1]; 1085 ID11=(CommonTree *)[self match:input TokenType:ID Follow:FOLLOW_ID_in_poly253]; if ( state.failed ) return retval; 1086 if ( state.backtracking == 0 ) [stream_ID addElement:ID11]; 1087 1088 1089 /* ASTTreeParser tokenRefBang */ 1090 _last = (CommonTree *)[input LT:1]; 1091 e=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_poly257]; if ( state.failed ) return retval; 1092 if ( state.backtracking == 0 ) [stream_INT addElement:e]; 1093 1094 1095 [self match:input TokenType:TokenTypeUP Follow:nil]; if ( state.failed ) return retval; 1096 [treeAdaptor addChild:root_1 toTree:root_0]; 1097 _last = _save_last_1; 1098 } 1099 1100 1101 // AST REWRITE 1102 // elements: INT, ID, INT, 9, ID 1103 // token labels: 1104 // rule labels: retval 1105 // token list labels: 1106 // rule list labels: 1107 // wildcard labels: 1108 if ( state.backtracking == 0 ) { 1109 1110 retval.tree = root_0; 1111 1112 RewriteRuleSubtreeStream *stream_retval = 1113 [[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor 1114 description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain]; 1115 1116 root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 1117 1118 // 31:21: -> {$e.int==1}? ID 1119 if ((e!=nil?[e.text integerValue]:0)==1) { 1120 // TODO: args: 1121 [treeAdaptor addChild:/* ASTTreeParser createRewriteNodeFromElement */ 1122 [stream_ID nextNode] 1123 toTree:root_0]; 1124 1125 } 1126 1127 else // 32:8: -> {$e.int==0}? INT[@\"1\"] 1128 if ((e!=nil?[e.text integerValue]:0)==0) { 1129 [treeAdaptor addChild: 1130 [[treeAdaptor createTree:INT FromToken:@"1" Text:@"INT"] retain] 1131 toTree:root_0]; 1132 1133 } 1134 1135 else // 33:8: -> ^( '^' ID INT ) 1136 { 1137 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:33:11: ^( '^' ID INT ) 1138 { 1139 CommonTree *root_1 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 1140 root_1 = (CommonTree *)[treeAdaptor becomeRoot:/* ASTTreeParser createRewriteNodeFromElement */ 1141 [stream_9 nextNode] 1142 old:root_1]; 1143 1144 // TODO: args: 1145 [treeAdaptor addChild:/* ASTTreeParser createRewriteNodeFromElement */ 1146 [stream_ID nextNode] 1147 toTree:root_1]; 1148 1149 // TODO: args: 1150 [treeAdaptor addChild:/* ASTTreeParser createRewriteNodeFromElement */ 1151 [stream_INT nextNode] 1152 toTree:root_1]; 1153 1154 [treeAdaptor addChild:root_1 toTree:root_0]; 1155 } 1156 1157 } 1158 1159 1160 retval.tree = root_0; 1161 1162 } 1163 1164 } 1165 break; 1166 case 7 : ; 1167 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:35:4: INT // alt 1168 { 1169 root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 1170 1171 1172 1173 /* ASTTreeParser tokenRef */ 1174 _last = (CommonTree *)[input LT:1]; 1175 INT12=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_poly302]; if ( state.failed ) return retval; 1176 if ( state.backtracking == 0 ) { 1177 INT12_tree = (CommonTree *)[treeAdaptor dupNode:INT12]; 1178 1179 1180 [treeAdaptor addChild:INT12_tree toTree:root_0]; 1181 } 1182 1183 1184 /* ASTTreeParser noRewrite */ 1185 if ( state.backtracking == 0 ) { 1186 } 1187 } 1188 break; 1189 case 8 : ; 1190 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:36:4: ID // alt 1191 { 1192 root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 1193 1194 1195 1196 /* ASTTreeParser tokenRef */ 1197 _last = (CommonTree *)[input LT:1]; 1198 ID13=(CommonTree *)[self match:input TokenType:ID Follow:FOLLOW_ID_in_poly307]; if ( state.failed ) return retval; 1199 if ( state.backtracking == 0 ) { 1200 ID13_tree = (CommonTree *)[treeAdaptor dupNode:ID13]; 1201 1202 1203 [treeAdaptor addChild:ID13_tree toTree:root_0]; 1204 } 1205 1206 1207 /* ASTTreeParser noRewrite */ 1208 if ( state.backtracking == 0 ) { 1209 } 1210 } 1211 break; 1212 1213 } 1214 /* ASTTreeParser ruleCleanUp */ 1215 /* AST ruleCleanUp */ 1216 /* token+rule list labels */ 1217 1218 [stream_INT release]; 1219 [stream_MULT release]; 1220 [stream_ID release]; 1221 [stream_9 release]; 1222 [stream_8 release]; 1223 [stream_poly release]; 1224 1225 if ( state.backtracking == 0 ) { 1226 1227 retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0]; 1228 } 1229 1230 } 1231 @catch (RecognitionException *re) { 1232 [self reportError:re]; 1233 [self recover:input Exception:re]; 1234 } 1235 1236 @finally { 1237 /* ruleScopeCleanUp */ 1238 1239 } 1240 return retval; 1241} 1242/* $ANTLR end poly */ 1243// $ANTLR start synpred1_Simplifier_fragment 1244- (void) synpred1_Simplifier_fragment 1245{ 1246 /* ruleLabelDefs entry */ 1247 CommonTree *a = nil; 1248 CommonTree *b = nil; 1249 1250 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:16:7: ( ^( '+' a= INT b= INT ) ) // ruleBlockSingleAlt 1251 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:16:7: ^( '+' a= INT b= INT ) // alt 1252 { 1253 1254 1255 [self match:input TokenType:8 Follow:FOLLOW_8_in_synpred1_Simplifier52]; if ( state.failed ) return ; 1256 1257 [self match:input TokenType:DOWN Follow:nil]; if ( state.failed ) return ; 1258 1259 a=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_synpred1_Simplifier56]; if ( state.failed ) return ; 1260 1261 b=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_synpred1_Simplifier60]; if ( state.failed ) return ; 1262 1263 [self match:input TokenType:UP Follow:nil]; if ( state.failed ) return ; 1264 1265 1266 } 1267 1268} // $ANTLR end synpred1_Simplifier_fragment 1269// $ANTLR start synpred2_Simplifier_fragment 1270- (void) synpred2_Simplifier_fragment 1271{ 1272 /* ruleLabelDefs entry */ 1273 CommonTree *a = nil; 1274 CommonTree *b = nil;Simplifier_poly_return * p = nil ; 1275 1276 1277 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:18:4: ( ^( '+' ^( '+' a= INT p= poly ) b= INT ) ) // ruleBlockSingleAlt 1278 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:18:4: ^( '+' ^( '+' a= INT p= poly ) b= INT ) // alt 1279 { 1280 1281 1282 [self match:input TokenType:8 Follow:FOLLOW_8_in_synpred2_Simplifier73]; if ( state.failed ) return ; 1283 1284 [self match:input TokenType:DOWN Follow:nil]; if ( state.failed ) return ; 1285 1286 1287 [self match:input TokenType:8 Follow:FOLLOW_8_in_synpred2_Simplifier76]; if ( state.failed ) return ; 1288 1289 [self match:input TokenType:DOWN Follow:nil]; if ( state.failed ) return ; 1290 1291 a=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_synpred2_Simplifier80]; if ( state.failed ) return ; 1292 1293 /* ruleRef */ 1294 [self pushFollow:FOLLOW_poly_in_synpred2_Simplifier84]; 1295 p = [self poly]; 1296 1297 [self popFollow]; 1298 if ( state.failed ) return ; 1299 1300 1301 [self match:input TokenType:UP Follow:nil]; if ( state.failed ) return ; 1302 1303 1304 b=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_synpred2_Simplifier89]; if ( state.failed ) return ; 1305 1306 [self match:input TokenType:UP Follow:nil]; if ( state.failed ) return ; 1307 1308 1309 } 1310 1311} // $ANTLR end synpred2_Simplifier_fragment 1312// $ANTLR start synpred3_Simplifier_fragment 1313- (void) synpred3_Simplifier_fragment 1314{ 1315 /* ruleLabelDefs entry */ 1316 CommonTree *a = nil; 1317 CommonTree *b = nil;Simplifier_poly_return * p = nil ; 1318 1319 1320 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:21:4: ( ^( '+' ^( '+' p= poly a= INT ) b= INT ) ) // ruleBlockSingleAlt 1321 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:21:4: ^( '+' ^( '+' p= poly a= INT ) b= INT ) // alt 1322 { 1323 1324 1325 [self match:input TokenType:8 Follow:FOLLOW_8_in_synpred3_Simplifier117]; if ( state.failed ) return ; 1326 1327 [self match:input TokenType:DOWN Follow:nil]; if ( state.failed ) return ; 1328 1329 1330 [self match:input TokenType:8 Follow:FOLLOW_8_in_synpred3_Simplifier120]; if ( state.failed ) return ; 1331 1332 [self match:input TokenType:DOWN Follow:nil]; if ( state.failed ) return ; 1333 1334 /* ruleRef */ 1335 [self pushFollow:FOLLOW_poly_in_synpred3_Simplifier124]; 1336 p = [self poly]; 1337 1338 [self popFollow]; 1339 if ( state.failed ) return ; 1340 1341 1342 a=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_synpred3_Simplifier128]; if ( state.failed ) return ; 1343 1344 [self match:input TokenType:UP Follow:nil]; if ( state.failed ) return ; 1345 1346 1347 b=(CommonTree *)[self match:input TokenType:INT Follow:FOLLOW_INT_in_synpred3_Simplifier133]; if ( state.failed ) return ; 1348 1349 [self match:input TokenType:UP Follow:nil]; if ( state.failed ) return ; 1350 1351 1352 } 1353 1354} // $ANTLR end synpred3_Simplifier_fragment 1355// $ANTLR start synpred4_Simplifier_fragment 1356- (void) synpred4_Simplifier_fragment 1357{ 1358 /* ruleLabelDefs entry */ 1359 Simplifier_poly_return * p = nil ; 1360 1361 Simplifier_poly_return * q = nil ; 1362 1363 1364 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:24:4: ( ^( '+' p= poly q= poly ) ) // ruleBlockSingleAlt 1365 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Simplifier.g:24:4: ^( '+' p= poly q= poly ) // alt 1366 { 1367 1368 1369 [self match:input TokenType:8 Follow:FOLLOW_8_in_synpred4_Simplifier161]; if ( state.failed ) return ; 1370 1371 [self match:input TokenType:DOWN Follow:nil]; if ( state.failed ) return ; 1372 1373 /* ruleRef */ 1374 [self pushFollow:FOLLOW_poly_in_synpred4_Simplifier165]; 1375 p = [self poly]; 1376 1377 [self popFollow]; 1378 if ( state.failed ) return ; 1379 1380 1381 /* ruleRef */ 1382 [self pushFollow:FOLLOW_poly_in_synpred4_Simplifier169]; 1383 q = [self poly]; 1384 1385 [self popFollow]; 1386 if ( state.failed ) return ; 1387 1388 1389 [self match:input TokenType:UP Follow:nil]; if ( state.failed ) return ; 1390 1391 1392 } 1393 1394} // $ANTLR end synpred4_Simplifier_fragment 1395/* ObjC end rules */ 1396 1397@end /* end of Simplifier implementation line 692 */ 1398