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/treeparser/Lang.g 5 * - On : 2012-02-16 17:58:54 6 * - for the lexer : LangLexerLexer 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/treeparser/Lang.g 2012-02-16 17:58:54 15 16 17/* ----------------------------------------- 18 * Include the ANTLR3 generated header file. 19 */ 20#import "LangLexer.h" 21/* ----------------------------------------- */ 22 23 24/* ============================================================================= */ 25/* ============================================================================= 26 * Start of recognizer 27 */ 28 29/** As per Terence: No returns for lexer rules! */ 30@implementation LangLexer // line 330 31 32+ (void) initialize 33{ 34 [BaseRecognizer setGrammarFileName:@"/Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g"]; 35} 36 37+ (NSString *) tokenNameForType:(NSInteger)aTokenType 38{ 39 return [[self getTokenNames] objectAtIndex:aTokenType]; 40} 41 42+ (LangLexer *)newLangLexerWithCharStream:(id<CharStream>)anInput 43{ 44 return [[LangLexer alloc] initWithCharStream:anInput]; 45} 46 47- (id) initWithCharStream:(id<CharStream>)anInput 48{ 49 self = [super initWithCharStream:anInput State:[RecognizerSharedState newRecognizerSharedStateWithRuleLen:7+1]]; 50 if ( self != nil ) { 51 } 52 return self; 53} 54 55- (void) dealloc 56{ 57 [super dealloc]; 58} 59 60/* ObjC Start of actions.lexer.methods */ 61/* ObjC end of actions.lexer.methods */ 62/* ObjC start methods() */ 63/* ObjC end methods() */ 64 65/* Start of Rules */ 66// $ANTLR start "T__10" 67- (void) mT__10 68{ 69 // 70 /* ruleScopeSetUp */ 71 72 /* ruleDeclarations */ 73 74 @try { 75 NSInteger _type = T__10; 76 NSInteger _channel = TokenChannelDefault; 77 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:7:7: ( ';' ) // ruleBlockSingleAlt 78 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:7:9: ';' // alt 79 { 80 81 82 [self matchChar:';']; 83 84 85 } 86 87 /* token+rule list labels */ 88 89 state.type = _type; 90 state.channel = _channel; 91 } 92 @finally { 93 // 94 /* ruleScopeCleanUp */ 95 96 } 97 return; 98} 99/* $ANTLR end "T__10" */ 100// $ANTLR start "INTTYPE" 101- (void) mINTTYPE 102{ 103 // 104 /* ruleScopeSetUp */ 105 106 /* ruleDeclarations */ 107 108 @try { 109 NSInteger _type = INTTYPE; 110 NSInteger _channel = TokenChannelDefault; 111 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:18:9: ( 'int' ) // ruleBlockSingleAlt 112 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:18:11: 'int' // alt 113 { 114 115 116 [self matchString:@"int"]; 117 118 119 120 } 121 122 /* token+rule list labels */ 123 124 state.type = _type; 125 state.channel = _channel; 126 } 127 @finally { 128 // 129 /* ruleScopeCleanUp */ 130 131 } 132 return; 133} 134/* $ANTLR end "INTTYPE" */ 135// $ANTLR start "FLOATTYPE" 136- (void) mFLOATTYPE 137{ 138 // 139 /* ruleScopeSetUp */ 140 141 /* ruleDeclarations */ 142 143 @try { 144 NSInteger _type = FLOATTYPE; 145 NSInteger _channel = TokenChannelDefault; 146 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:19:11: ( 'float' ) // ruleBlockSingleAlt 147 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:19:13: 'float' // alt 148 { 149 150 151 [self matchString:@"float"]; 152 153 154 155 } 156 157 /* token+rule list labels */ 158 159 state.type = _type; 160 state.channel = _channel; 161 } 162 @finally { 163 // 164 /* ruleScopeCleanUp */ 165 166 } 167 return; 168} 169/* $ANTLR end "FLOATTYPE" */ 170// $ANTLR start "ID" 171- (void) mID 172{ 173 // 174 /* ruleScopeSetUp */ 175 176 /* ruleDeclarations */ 177 178 @try { 179 NSInteger _type = ID; 180 NSInteger _channel = TokenChannelDefault; 181 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:20:4: ( ( 'a' .. 'z' )+ ) // ruleBlockSingleAlt 182 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:20:6: ( 'a' .. 'z' )+ // alt 183 { 184 185 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:20:6: ( 'a' .. 'z' )+ // positiveClosureBlock 186 NSInteger cnt1 = 0; 187 do { 188 NSInteger alt1 = 2; 189 NSInteger LA1_0 = [input LA:1]; 190 if ( ((LA1_0 >= 'a' && LA1_0 <= 'z')) ) { 191 alt1=1; 192 } 193 194 195 switch (alt1) { 196 case 1 : ; 197 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g: // alt 198 { 199 200 if ((([input LA:1] >= 'a') && ([input LA:1] <= 'z'))) { 201 [input consume]; 202 } else { 203 MismatchedSetException *mse = [MismatchedSetException newException:nil stream:input]; 204 [self recover:mse]; 205 @throw mse; 206 } 207 208 209 } 210 break; 211 212 default : 213 if ( cnt1 >= 1 ) 214 goto loop1; 215 EarlyExitException *eee = 216 [EarlyExitException newException:input decisionNumber:1]; 217 @throw eee; 218 } 219 cnt1++; 220 } while (YES); 221 loop1: ; 222 223 224 } 225 226 /* token+rule list labels */ 227 228 state.type = _type; 229 state.channel = _channel; 230 } 231 @finally { 232 // 233 /* ruleScopeCleanUp */ 234 235 } 236 return; 237} 238/* $ANTLR end "ID" */ 239// $ANTLR start "INT" 240- (void) mINT 241{ 242 // 243 /* ruleScopeSetUp */ 244 245 /* ruleDeclarations */ 246 247 @try { 248 NSInteger _type = INT; 249 NSInteger _channel = TokenChannelDefault; 250 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:21:5: ( ( '0' .. '9' )+ ) // ruleBlockSingleAlt 251 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:21:7: ( '0' .. '9' )+ // alt 252 { 253 254 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:21:7: ( '0' .. '9' )+ // positiveClosureBlock 255 NSInteger cnt2 = 0; 256 do { 257 NSInteger alt2 = 2; 258 NSInteger LA2_0 = [input LA:1]; 259 if ( ((LA2_0 >= '0' && LA2_0 <= '9')) ) { 260 alt2=1; 261 } 262 263 264 switch (alt2) { 265 case 1 : ; 266 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g: // alt 267 { 268 269 if ((([input LA:1] >= '0') && ([input LA:1] <= '9'))) { 270 [input consume]; 271 } else { 272 MismatchedSetException *mse = [MismatchedSetException newException:nil stream:input]; 273 [self recover:mse]; 274 @throw mse; 275 } 276 277 278 } 279 break; 280 281 default : 282 if ( cnt2 >= 1 ) 283 goto loop2; 284 EarlyExitException *eee = 285 [EarlyExitException newException:input decisionNumber:2]; 286 @throw eee; 287 } 288 cnt2++; 289 } while (YES); 290 loop2: ; 291 292 293 } 294 295 /* token+rule list labels */ 296 297 state.type = _type; 298 state.channel = _channel; 299 } 300 @finally { 301 // 302 /* ruleScopeCleanUp */ 303 304 } 305 return; 306} 307/* $ANTLR end "INT" */ 308// $ANTLR start "WS" 309- (void) mWS 310{ 311 // 312 /* ruleScopeSetUp */ 313 314 /* ruleDeclarations */ 315 316 @try { 317 NSInteger _type = WS; 318 NSInteger _channel = TokenChannelDefault; 319 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:22:4: ( ( ' ' | '\\n' ) ) // ruleBlockSingleAlt 320 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:22:6: ( ' ' | '\\n' ) // alt 321 { 322 323 if ([input LA:1] == '\n'||[input LA:1] == ' ') { 324 [input consume]; 325 } else { 326 MismatchedSetException *mse = [MismatchedSetException newException:nil stream:input]; 327 [self recover:mse]; 328 @throw mse; 329 } 330 331 332 333 _channel=HIDDEN; 334 335 336 } 337 338 /* token+rule list labels */ 339 340 state.type = _type; 341 state.channel = _channel; 342 } 343 @finally { 344 // 345 /* ruleScopeCleanUp */ 346 347 } 348 return; 349} 350/* $ANTLR end "WS" */ 351- (void) mTokens 352{ 353 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:1:8: ( T__10 | INTTYPE | FLOATTYPE | ID | INT | WS ) //ruleblock 354 NSInteger alt3=6; 355 unichar charLA3 = [input LA:1]; 356 switch (charLA3) { 357 case ';': ; 358 { 359 alt3=1; 360 } 361 break; 362 case 'i': ; 363 { 364 NSInteger LA3_2 = [input LA:2]; 365 366 if ( (LA3_2=='n') ) { 367 NSInteger LA3_7 = [input LA:3]; 368 369 if ( (LA3_7=='t') ) { 370 NSInteger LA3_9 = [input LA:4]; 371 372 if ( ((LA3_9 >= 'a' && LA3_9 <= 'z')) ) { 373 alt3=4; 374 } 375 else { 376 alt3 = 2; 377 } 378 } 379 else { 380 alt3 = 4; 381 } 382 } 383 else { 384 alt3 = 4; 385 } 386 } 387 break; 388 case 'f': ; 389 { 390 NSInteger LA3_3 = [input LA:2]; 391 392 if ( (LA3_3=='l') ) { 393 NSInteger LA3_8 = [input LA:3]; 394 395 if ( (LA3_8=='o') ) { 396 NSInteger LA3_10 = [input LA:4]; 397 398 if ( (LA3_10=='a') ) { 399 NSInteger LA3_12 = [input LA:5]; 400 401 if ( (LA3_12=='t') ) { 402 NSInteger LA3_13 = [input LA:6]; 403 404 if ( ((LA3_13 >= 'a' && LA3_13 <= 'z')) ) { 405 alt3=4; 406 } 407 else { 408 alt3 = 3; 409 } 410 } 411 else { 412 alt3 = 4; 413 } 414 } 415 else { 416 alt3 = 4; 417 } 418 } 419 else { 420 alt3 = 4; 421 } 422 } 423 else { 424 alt3 = 4; 425 } 426 } 427 break; 428 case 'a': ; 429 case 'b': ; 430 case 'c': ; 431 case 'd': ; 432 case 'e': ; 433 case 'g': ; 434 case 'h': ; 435 case 'j': ; 436 case 'k': ; 437 case 'l': ; 438 case 'm': ; 439 case 'n': ; 440 case 'o': ; 441 case 'p': ; 442 case 'q': ; 443 case 'r': ; 444 case 's': ; 445 case 't': ; 446 case 'u': ; 447 case 'v': ; 448 case 'w': ; 449 case 'x': ; 450 case 'y': ; 451 case 'z': ; 452 { 453 alt3=4; 454 } 455 break; 456 case '0': ; 457 case '1': ; 458 case '2': ; 459 case '3': ; 460 case '4': ; 461 case '5': ; 462 case '6': ; 463 case '7': ; 464 case '8': ; 465 case '9': ; 466 { 467 alt3=5; 468 } 469 break; 470 case '\n': ; 471 case ' ': ; 472 { 473 alt3=6; 474 } 475 break; 476 477 default: ; 478 NoViableAltException *nvae = [NoViableAltException newException:3 state:0 stream:input]; 479 nvae.c = charLA3; 480 @throw nvae; 481 482 } 483 484 switch (alt3) { 485 case 1 : ; 486 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:1:10: T__10 // alt 487 { 488 489 490 [self mT__10]; 491 492 493 494 } 495 break; 496 case 2 : ; 497 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:1:16: INTTYPE // alt 498 { 499 500 501 [self mINTTYPE]; 502 503 504 505 } 506 break; 507 case 3 : ; 508 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:1:24: FLOATTYPE // alt 509 { 510 511 512 [self mFLOATTYPE]; 513 514 515 516 } 517 break; 518 case 4 : ; 519 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:1:34: ID // alt 520 { 521 522 523 [self mID]; 524 525 526 527 } 528 break; 529 case 5 : ; 530 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:1:37: INT // alt 531 { 532 533 534 [self mINT]; 535 536 537 538 } 539 break; 540 case 6 : ; 541 // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/treeparser/Lang.g:1:41: WS // alt 542 { 543 544 545 [self mWS]; 546 547 548 549 } 550 break; 551 552 } 553 554} 555 556@end /* end of LangLexer implementation line 397 */