1/** \file 2 * This OBJC source file was generated by $ANTLR version ${project.version} ${buildNumber} 3 * 4 * - From the grammar source file : Lang.g 5 * - On : 2011-05-06 17:38:52 6 * - for the parser : LangParserParser 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 ${project.version} ${buildNumber} Lang.g 2011-05-06 17:38:52 15 16 17/* ----------------------------------------- 18 * Include the ANTLR3 generated header file. 19 */ 20#import "LangParser.h" 21/* ----------------------------------------- */ 22 23 24/* ============================================================================= */ 25/* ============================================================================= 26 * Start of recognizer 27 */ 28 29#pragma mark Bitsets 30static ANTLRBitSet *FOLLOW_decl_in_start41; 31static const unsigned long long FOLLOW_decl_in_start41_data[] = { 0x0000000000000002LL}; 32static ANTLRBitSet *FOLLOW_type_in_decl50; 33static const unsigned long long FOLLOW_type_in_decl50_data[] = { 0x0000000000000040LL}; 34static ANTLRBitSet *FOLLOW_ID_in_decl52; 35static const unsigned long long FOLLOW_ID_in_decl52_data[] = { 0x0000000000000400LL}; 36static ANTLRBitSet *FOLLOW_10_in_decl54; 37static const unsigned long long FOLLOW_10_in_decl54_data[] = { 0x0000000000000002LL}; 38 39 40#pragma mark Dynamic Global Scopes 41 42#pragma mark Dynamic Rule Scopes 43 44#pragma mark Rule Return Scopes start 45@implementation LangParser_start_return /* returnScope */ 46/* AST returnScope.synthesize */ 47@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */ 48+ (LangParser_start_return *)newLangParser_start_return 49{ 50 return [[[LangParser_start_return alloc] init] retain]; 51} 52 53- (id) init 54{ 55 self = [super init]; 56 return self; 57} 58 59/* AST returnScope.methods */ 60- (ANTLRCommonTree *)getTree 61{ 62 return tree; 63} 64 65- (void) setTree:(ANTLRCommonTree *)aTree 66{ 67 if (tree != aTree) { 68 if (tree != nil) [tree release]; 69 if (aTree != nil) [aTree retain]; 70 tree = aTree; 71 } 72} 73 74- (void) dealloc 75{ 76 self.tree = nil; 77 [super dealloc]; 78} 79 80 81 82@end /* end of returnScope implementation */ 83 84 85@implementation LangParser_decl_return /* returnScope */ 86/* AST returnScope.synthesize */ 87@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */ 88+ (LangParser_decl_return *)newLangParser_decl_return 89{ 90 return [[[LangParser_decl_return alloc] init] retain]; 91} 92 93- (id) init 94{ 95 self = [super init]; 96 return self; 97} 98 99/* AST returnScope.methods */ 100- (ANTLRCommonTree *)getTree 101{ 102 return tree; 103} 104 105- (void) setTree:(ANTLRCommonTree *)aTree 106{ 107 if (tree != aTree) { 108 if (tree != nil) [tree release]; 109 if (aTree != nil) [aTree retain]; 110 tree = aTree; 111 } 112} 113 114- (void) dealloc 115{ 116 self.tree = nil; 117 [super dealloc]; 118} 119 120 121 122@end /* end of returnScope implementation */ 123 124 125@implementation LangParser_type_return /* returnScope */ 126/* AST returnScope.synthesize */ 127@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */ 128+ (LangParser_type_return *)newLangParser_type_return 129{ 130 return [[[LangParser_type_return alloc] init] retain]; 131} 132 133- (id) init 134{ 135 self = [super init]; 136 return self; 137} 138 139/* AST returnScope.methods */ 140- (ANTLRCommonTree *)getTree 141{ 142 return tree; 143} 144 145- (void) setTree:(ANTLRCommonTree *)aTree 146{ 147 if (tree != aTree) { 148 if (tree != nil) [tree release]; 149 if (aTree != nil) [aTree retain]; 150 tree = aTree; 151 } 152} 153 154- (void) dealloc 155{ 156 self.tree = nil; 157 [super dealloc]; 158} 159 160 161 162@end /* end of returnScope implementation */ 163 164 165//#pragma mark Rule return scopes start 166// 167 168#pragma mark Rule return scopes start 169 170@implementation LangParser // line 637 171 172/* ObjC start of ruleAttributeScope */ 173#pragma mark Dynamic Rule Scopes 174/* ObjC end of ruleAttributeScope */ 175#pragma mark global Attribute Scopes 176/* ObjC start globalAttributeScope */ 177/* ObjC end globalAttributeScope */ 178/* ObjC start actions.(actionScope).synthesize */ 179/* ObjC end actions.(actionScope).synthesize */ 180/* ObjC start synthesize() */ 181/* AST genericParser.synthesize */ 182/* AST parserProperties */ 183@synthesize treeAdaptor; 184/* ObjC end synthesize() */ 185 186+ (void) initialize 187{ 188 #pragma mark Bitsets 189 FOLLOW_decl_in_start41 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_decl_in_start41_data Count:(NSUInteger)1] retain]; 190 FOLLOW_type_in_decl50 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_type_in_decl50_data Count:(NSUInteger)1] retain]; 191 FOLLOW_ID_in_decl52 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_decl52_data Count:(NSUInteger)1] retain]; 192 FOLLOW_10_in_decl54 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_10_in_decl54_data Count:(NSUInteger)1] retain]; 193 194 [ANTLRBaseRecognizer setTokenNames:[[AMutableArray arrayWithObjects:@"<invalid>", @"<EOR>", @"<DOWN>", @"<UP>", 195 @"DECL", @"FLOATTYPE", @"ID", @"INT", @"INTTYPE", @"WS", @"';'", nil] retain]]; 196 [ANTLRBaseRecognizer setGrammarFileName:@"Lang.g"]; 197} 198 199+ (LangParser *)newLangParser:(id<ANTLRTokenStream>)aStream 200{ 201 return [[LangParser alloc] initWithTokenStream:aStream]; 202 203 204} 205 206- (id) initWithTokenStream:(id<ANTLRTokenStream>)aStream 207{ 208 self = [super initWithTokenStream:aStream State:[[ANTLRRecognizerSharedState newANTLRRecognizerSharedStateWithRuleLen:3+1] retain]]; 209 if ( self != nil ) { 210 211 212 /* start of actions-actionScope-init */ 213 /* start of init */ 214 /* AST genericParser.init */ 215 [self setTreeAdaptor:[[ANTLRCommonTreeAdaptor newTreeAdaptor] retain]]; 216 } 217 return self; 218} 219 220- (void) dealloc 221{ 222 /* AST genericParser.dealloc */ 223 [self setTreeAdaptor:nil]; 224 225 [super dealloc]; 226} 227 228/* ObjC start members */ 229/* ObjC end members */ 230/* ObjC start actions.(actionScope).methods */ 231/* ObjC end actions.(actionScope).methods */ 232/* ObjC start methods() */ 233/* AST genericParser.methods */ 234/* AST parserMethods */ 235- (id<ANTLRTreeAdaptor>) getTreeAdaptor 236{ 237 return treeAdaptor; 238} 239 240- (void) setTreeAdaptor:(id<ANTLRTreeAdaptor>)aTreeAdaptor 241{ 242 if (aTreeAdaptor != treeAdaptor) { 243 treeAdaptor = aTreeAdaptor; 244 } 245} 246/* ObjC end methods() */ 247/* ObjC start rules */ 248/* 249 * $ANTLR start start 250 * Lang.g:10:1: start : decl ; 251 */ 252- (LangParser_start_return *) start 253{ 254 /* my ruleScopeSetUp */ 255 /* Terence's stuff */ 256 257 /* AST ruleDeclarations */ 258 LangParser_start_return * retval = [LangParser_start_return newLangParser_start_return]; 259 [retval setStart:[input LT:1]]; 260 261 262 ANTLRCommonTree *root_0 = nil; 263 264 @try { 265 /* AST ruleLabelDefs */ 266 LangParser_decl_return * decl1 = nil ; 267 268 269 270 // Lang.g:10:7: ( decl ) // ruleBlockSingleAlt 271 // Lang.g:10:9: decl // alt 272 { 273 root_0 = (ANTLRCommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 274 275 276 /* ASTParser ruleRef */ 277 /* ruleRef */ 278 [self pushFollow:FOLLOW_decl_in_start41]; 279 decl1 = [self decl]; 280 281 [self popFollow]; 282 283 284 [treeAdaptor addChild:[decl1 getTree] toTree:root_0]; 285 286 } 287 288 /* ASTParser ruleCleanUp */ 289 /* AST ruleCleanUp */ 290 // token+rule list labels 291 [retval setStop:[input LT:-1]]; 292 293 294 295 retval.tree = (ANTLRCommonTree *)[treeAdaptor rulePostProcessing:root_0]; 296 [treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken]; 297 298 } 299 @catch (ANTLRRecognitionException *re) { 300 [self reportError:re]; 301 [self recover:input Exception:re]; 302 /* ASTParser rule.setErrorReturnValue */ 303 retval.tree = (ANTLRCommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re]; 304 305 } 306 307 @finally { 308 /* Terence's stuff */ 309 310 } 311 return retval; 312} 313/* $ANTLR end start */ 314 315/* 316 * $ANTLR start decl 317 * Lang.g:12:1: decl : type ID ';' -> ^( DECL type ID ) ; 318 */ 319- (LangParser_decl_return *) decl 320{ 321 /* my ruleScopeSetUp */ 322 /* Terence's stuff */ 323 324 /* AST ruleDeclarations */ 325 LangParser_decl_return * retval = [LangParser_decl_return newLangParser_decl_return]; 326 [retval setStart:[input LT:1]]; 327 328 329 ANTLRCommonTree *root_0 = nil; 330 331 @try { 332 /* AST ruleLabelDefs */ 333 ANTLRCommonToken *ID3 = nil; 334 ANTLRCommonToken *char_literal4 = nil; 335 LangParser_type_return * type2 = nil ; 336 337 338 ANTLRCommonTree *ID3_tree=nil; 339 ANTLRCommonTree *char_literal4_tree=nil; 340 ANTLRRewriteRuleTokenStream *stream_10 = 341 [[ANTLRRewriteRuleTokenStream newANTLRRewriteRuleTokenStream:treeAdaptor 342 description:@"token 10"] retain]; 343 ANTLRRewriteRuleTokenStream *stream_ID = 344 [[ANTLRRewriteRuleTokenStream newANTLRRewriteRuleTokenStream:treeAdaptor 345 description:@"token ID"] retain]; 346 ANTLRRewriteRuleSubtreeStream *stream_type = 347 [[ANTLRRewriteRuleSubtreeStream newANTLRRewriteRuleSubtreeStream:treeAdaptor 348 description:@"rule type"] retain]; 349 // Lang.g:12:6: ( type ID ';' -> ^( DECL type ID ) ) // ruleBlockSingleAlt 350 // Lang.g:12:8: type ID ';' // alt 351 { 352 /* ruleRef */ 353 [self pushFollow:FOLLOW_type_in_decl50]; 354 type2 = [self type]; 355 356 [self popFollow]; 357 358 359 [stream_type addElement:[type2 getTree]]; 360 361 ID3=(ANTLRCommonToken *)[self match:input TokenType:ID Follow:FOLLOW_ID_in_decl52]; 362 [stream_ID addElement:ID3]; 363 364 365 char_literal4=(ANTLRCommonToken *)[self match:input TokenType:10 Follow:FOLLOW_10_in_decl54]; 366 [stream_10 addElement:char_literal4]; 367 368 369 // AST REWRITE 370 // elements: ID, type 371 // token labels: 372 // rule labels: retval 373 // token list labels: 374 // rule list labels: 375 // wildcard labels: 376 retval.tree = root_0; 377 378 ANTLRRewriteRuleSubtreeStream *stream_retval = 379 [[ANTLRRewriteRuleSubtreeStream newANTLRRewriteRuleSubtreeStream:treeAdaptor 380 description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain]; 381 382 root_0 = (ANTLRCommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 383 384 // 12:20: -> ^( DECL type ID ) 385 { 386 // Lang.g:12:23: ^( DECL type ID ) 387 { 388 ANTLRCommonTree *root_1 = (ANTLRCommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 389 root_1 = (ANTLRCommonTree *)[treeAdaptor becomeRoot: 390 [treeAdaptor createTree:DECL Text:@"DECL"] 391 old:root_1]; 392 393 [treeAdaptor addChild:[stream_type nextTree] toTree:root_1]; 394 395 // TODO: args: 396 [treeAdaptor addChild: 397 [stream_ID nextNode] 398 toTree:root_1]; 399 400 [treeAdaptor addChild:root_1 toTree:root_0]; 401 } 402 403 } 404 405 406 retval.tree = root_0; 407 408 409 } 410 411 /* ASTParser ruleCleanUp */ 412 /* AST ruleCleanUp */ 413 // token+rule list labels 414 [retval setStop:[input LT:-1]]; 415 416 417 [stream_10 release]; 418 [stream_ID release]; 419 [stream_type release]; 420 421 retval.tree = (ANTLRCommonTree *)[treeAdaptor rulePostProcessing:root_0]; 422 [treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken]; 423 424 } 425 @catch (ANTLRRecognitionException *re) { 426 [self reportError:re]; 427 [self recover:input Exception:re]; 428 /* ASTParser rule.setErrorReturnValue */ 429 retval.tree = (ANTLRCommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re]; 430 431 } 432 433 @finally { 434 /* Terence's stuff */ 435 436 } 437 return retval; 438} 439/* $ANTLR end decl */ 440 441/* 442 * $ANTLR start type 443 * Lang.g:14:1: type : ( INTTYPE | FLOATTYPE ); 444 */ 445- (LangParser_type_return *) type 446{ 447 /* my ruleScopeSetUp */ 448 /* Terence's stuff */ 449 450 /* AST ruleDeclarations */ 451 LangParser_type_return * retval = [LangParser_type_return newLangParser_type_return]; 452 [retval setStart:[input LT:1]]; 453 454 455 ANTLRCommonTree *root_0 = nil; 456 457 @try { 458 /* AST ruleLabelDefs */ 459 ANTLRCommonToken *set5 = nil; 460 461 ANTLRCommonTree *set5_tree=nil; 462 463 // Lang.g:14:6: ( INTTYPE | FLOATTYPE ) // ruleBlockSingleAlt 464 // Lang.g: // alt 465 { 466 root_0 = (ANTLRCommonTree *)[[[treeAdaptor class] newEmptyTree] retain]; 467 468 469 /* ASTParser matchRuleBlockSet */ 470 /* ASTParser matchSet */ 471 set5 = (ANTLRCommonToken *)[input LT:1]; /* matchSet */ 472 473 if ([input LA:1] == FLOATTYPE||[input LA:1] == INTTYPE) { 474 [input consume]; 475 [treeAdaptor addChild:/* ASTParser createNodeFromToken */ 476 (ANTLRCommonTree *)[[treeAdaptor create:set5] retain] 477 toTree:root_0 ]; 478 [state setIsErrorRecovery:NO]; 479 } else { 480 ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException newException:nil stream:input]; 481 @throw mse; 482 } 483 484 485 } 486 487 /* ASTParser ruleCleanUp */ 488 /* AST ruleCleanUp */ 489 // token+rule list labels 490 [retval setStop:[input LT:-1]]; 491 492 493 494 retval.tree = (ANTLRCommonTree *)[treeAdaptor rulePostProcessing:root_0]; 495 [treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken]; 496 497 } 498 @catch (ANTLRRecognitionException *re) { 499 [self reportError:re]; 500 [self recover:input Exception:re]; 501 /* ASTParser rule.setErrorReturnValue */ 502 retval.tree = (ANTLRCommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re]; 503 504 } 505 506 @finally { 507 /* Terence's stuff */ 508 509 } 510 return retval; 511} 512/* $ANTLR end type */ 513/* ObjC end rules */ 514 515@end /* end of LangParser implementation line 692 */ 516