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