1/** \file 2 * This OBJC source file was generated by $ANTLR version ${project.version} ${buildNumber} 3 * 4 * - From the grammar source file : T.g 5 * - On : 2011-05-06 19:14:23 6 * - for the lexer : TLexerLexer 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} T.g 2011-05-06 19:14:23 15 16 17/* ----------------------------------------- 18 * Include the ANTLR3 generated header file. 19 */ 20#import "TLexer.h" 21/* ----------------------------------------- */ 22 23 24/* ============================================================================= */ 25/* ============================================================================= 26 * Start of recognizer 27 */ 28 29/** As per Terence: No returns for lexer rules! */ 30@implementation TLexer // line 330 31 32+ (void) initialize 33{ 34 [ANTLRBaseRecognizer setGrammarFileName:@"T.g"]; 35} 36 37+ (NSString *) tokenNameForType:(NSInteger)aTokenType 38{ 39 return [[self getTokenNames] objectAtIndex:aTokenType]; 40} 41 42+ (TLexer *)newTLexerWithCharStream:(id<ANTLRCharStream>)anInput 43{ 44 return [[TLexer alloc] initWithCharStream:anInput]; 45} 46 47- (id) initWithCharStream:(id<ANTLRCharStream>)anInput 48{ 49 self = [super initWithCharStream:anInput State:[[ANTLRRecognizerSharedState newANTLRRecognizerSharedStateWithRuleLen:5+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__7" 67- (void) mT__7 68{ 69 // 70 /* my ruleScopeSetUp */ 71 /* Terence's stuff */ 72 73 @try { 74 NSInteger _type = T__7; 75 NSInteger _channel = ANTLRTokenChannelDefault; 76 // T.g:7:6: ( 'enum' ) // ruleBlockSingleAlt 77 // T.g:7:8: 'enum' // alt 78 { 79 [self matchString:@"enum"]; 80 81 82 83 } 84 85 // token+rule list labels 86 87 state.type = _type; 88 state.channel = _channel; 89 } 90 @finally { 91 // 92 /* Terence's stuff */ 93 94 } 95 return; 96} 97/* $ANTLR end "T__7" */ 98 99// $ANTLR start "ID" 100- (void) mID 101{ 102 // 103 /* my ruleScopeSetUp */ 104 /* Terence's stuff */ 105 106 @try { 107 NSInteger _type = ID; 108 NSInteger _channel = ANTLRTokenChannelDefault; 109 // T.g:37:5: ( ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' )* ) // ruleBlockSingleAlt 110 // T.g:37:9: ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' )* // alt 111 { 112 if ((([input LA:1] >= 'A') && ([input LA:1] <= 'Z'))||[input LA:1] == '_'||(([input LA:1] >= 'a') && ([input LA:1] <= 'z'))) { 113 [input consume]; 114 } else { 115 ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException newException:nil stream:input]; 116 [self recover:mse]; 117 @throw mse; 118 } 119 120 121 do { 122 NSInteger alt1=2; 123 NSInteger LA1_0 = [input LA:1]; 124 if ( ((LA1_0 >= '0' && LA1_0 <= '9')||(LA1_0 >= 'A' && LA1_0 <= 'Z')||LA1_0=='_'||(LA1_0 >= 'a' && LA1_0 <= 'z')) ) { 125 alt1=1; 126 } 127 128 129 switch (alt1) { 130 case 1 : ; 131 // T.g: // alt 132 { 133 if ((([input LA:1] >= '0') && ([input LA:1] <= '9'))||(([input LA:1] >= 'A') && ([input LA:1] <= 'Z'))||[input LA:1] == '_'||(([input LA:1] >= 'a') && ([input LA:1] <= 'z'))) { 134 [input consume]; 135 } else { 136 ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException newException:nil stream:input]; 137 [self recover:mse]; 138 @throw mse; 139 } 140 141 142 } 143 break; 144 145 default : 146 goto loop1; 147 } 148 } while (YES); 149 loop1: ; 150 151 152 } 153 154 // token+rule list labels 155 156 state.type = _type; 157 state.channel = _channel; 158 } 159 @finally { 160 // 161 /* Terence's stuff */ 162 163 } 164 return; 165} 166/* $ANTLR end "ID" */ 167 168// $ANTLR start "INT" 169- (void) mINT 170{ 171 // 172 /* my ruleScopeSetUp */ 173 /* Terence's stuff */ 174 175 @try { 176 NSInteger _type = INT; 177 NSInteger _channel = ANTLRTokenChannelDefault; 178 // T.g:40:5: ( ( '0' .. '9' )+ ) // ruleBlockSingleAlt 179 // T.g:40:7: ( '0' .. '9' )+ // alt 180 { 181 // T.g:40:7: ( '0' .. '9' )+ // positiveClosureBlock 182 NSInteger cnt2 = 0; 183 do { 184 NSInteger alt2 = 2; 185 NSInteger LA2_0 = [input LA:1]; 186 if ( ((LA2_0 >= '0' && LA2_0 <= '9')) ) { 187 alt2=1; 188 } 189 190 191 switch (alt2) { 192 case 1 : ; 193 // T.g: // alt 194 { 195 if ((([input LA:1] >= '0') && ([input LA:1] <= '9'))) { 196 [input consume]; 197 } else { 198 ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException newException:nil stream:input]; 199 [self recover:mse]; 200 @throw mse; 201 } 202 203 204 } 205 break; 206 207 default : 208 if ( cnt2 >= 1 ) 209 goto loop2; 210 ANTLREarlyExitException *eee = 211 [ANTLREarlyExitException newException:input decisionNumber:2]; 212 @throw eee; 213 } 214 cnt2++; 215 } while (YES); 216 loop2: ; 217 218 219 } 220 221 // token+rule list labels 222 223 state.type = _type; 224 state.channel = _channel; 225 } 226 @finally { 227 // 228 /* Terence's stuff */ 229 230 } 231 return; 232} 233/* $ANTLR end "INT" */ 234 235// $ANTLR start "WS" 236- (void) mWS 237{ 238 // 239 /* my ruleScopeSetUp */ 240 /* Terence's stuff */ 241 242 @try { 243 NSInteger _type = WS; 244 NSInteger _channel = ANTLRTokenChannelDefault; 245 // T.g:43:5: ( ( ' ' | '\\t' | '\\r' | '\\n' )+ ) // ruleBlockSingleAlt 246 // T.g:43:9: ( ' ' | '\\t' | '\\r' | '\\n' )+ // alt 247 { 248 // T.g:43:9: ( ' ' | '\\t' | '\\r' | '\\n' )+ // positiveClosureBlock 249 NSInteger cnt3 = 0; 250 do { 251 NSInteger alt3 = 2; 252 NSInteger LA3_0 = [input LA:1]; 253 if ( ((LA3_0 >= '\t' && LA3_0 <= '\n')||LA3_0=='\r'||LA3_0==' ') ) { 254 alt3=1; 255 } 256 257 258 switch (alt3) { 259 case 1 : ; 260 // T.g: // alt 261 { 262 if ((([input LA:1] >= '\t') && ([input LA:1] <= '\n'))||[input LA:1] == '\r'||[input LA:1] == ' ') { 263 [input consume]; 264 } else { 265 ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException newException:nil stream:input]; 266 [self recover:mse]; 267 @throw mse; 268 } 269 270 271 } 272 break; 273 274 default : 275 if ( cnt3 >= 1 ) 276 goto loop3; 277 ANTLREarlyExitException *eee = 278 [ANTLREarlyExitException newException:input decisionNumber:3]; 279 @throw eee; 280 } 281 cnt3++; 282 } while (YES); 283 loop3: ; 284 285 286 _channel=99; 287 288 289 } 290 291 // token+rule list labels 292 293 state.type = _type; 294 state.channel = _channel; 295 } 296 @finally { 297 // 298 /* Terence's stuff */ 299 300 } 301 return; 302} 303/* $ANTLR end "WS" */ 304 305- (void) mTokens 306{ 307 // T.g:1:8: ( T__7 | ID | INT | WS ) //ruleblock 308 NSInteger alt4=4; 309 unichar charLA4 = [input LA:1]; 310 switch (charLA4) { 311 case 'e': ; 312 { 313 NSInteger LA4_1 = [input LA:2]; 314 315 if ( (LA4_1=='n') ) { 316 NSInteger LA4_5 = [input LA:3]; 317 318 if ( (LA4_5=='u') ) { 319 NSInteger LA4_6 = [input LA:4]; 320 321 if ( (LA4_6=='m') ) { 322 NSInteger LA4_7 = [input LA:5]; 323 324 if ( ((LA4_7 >= '0' && LA4_7 <= '9')||(LA4_7 >= 'A' && LA4_7 <= 'Z')||LA4_7=='_'||(LA4_7 >= 'a' && LA4_7 <= 'z')) ) { 325 alt4=2; 326 } 327 else { 328 alt4 = 1; 329 } 330 } 331 else { 332 alt4 = 2; 333 } 334 } 335 else { 336 alt4 = 2; 337 } 338 } 339 else { 340 alt4 = 2; 341 } 342 } 343 break; 344 case 'A': ; 345 case 'B': ; 346 case 'C': ; 347 case 'D': ; 348 case 'E': ; 349 case 'F': ; 350 case 'G': ; 351 case 'H': ; 352 case 'I': ; 353 case 'J': ; 354 case 'K': ; 355 case 'L': ; 356 case 'M': ; 357 case 'N': ; 358 case 'O': ; 359 case 'P': ; 360 case 'Q': ; 361 case 'R': ; 362 case 'S': ; 363 case 'T': ; 364 case 'U': ; 365 case 'V': ; 366 case 'W': ; 367 case 'X': ; 368 case 'Y': ; 369 case 'Z': ; 370 case '_': ; 371 case 'a': ; 372 case 'b': ; 373 case 'c': ; 374 case 'd': ; 375 case 'f': ; 376 case 'g': ; 377 case 'h': ; 378 case 'i': ; 379 case 'j': ; 380 case 'k': ; 381 case 'l': ; 382 case 'm': ; 383 case 'n': ; 384 case 'o': ; 385 case 'p': ; 386 case 'q': ; 387 case 'r': ; 388 case 's': ; 389 case 't': ; 390 case 'u': ; 391 case 'v': ; 392 case 'w': ; 393 case 'x': ; 394 case 'y': ; 395 case 'z': ; 396 { 397 alt4=2; 398 } 399 break; 400 case '0': ; 401 case '1': ; 402 case '2': ; 403 case '3': ; 404 case '4': ; 405 case '5': ; 406 case '6': ; 407 case '7': ; 408 case '8': ; 409 case '9': ; 410 { 411 alt4=3; 412 } 413 break; 414 case '\t': ; 415 case '\n': ; 416 case '\r': ; 417 case ' ': ; 418 { 419 alt4=4; 420 } 421 break; 422 423 default: ; 424 ANTLRNoViableAltException *nvae = [ANTLRNoViableAltException newException:4 state:0 stream:input]; 425 nvae.c = charLA4; 426 @throw nvae; 427 428 } 429 430 switch (alt4) { 431 case 1 : ; 432 // T.g:1:10: T__7 // alt 433 { 434 [self mT__7]; 435 436 437 438 } 439 break; 440 case 2 : ; 441 // T.g:1:15: ID // alt 442 { 443 [self mID]; 444 445 446 447 } 448 break; 449 case 3 : ; 450 // T.g:1:18: INT // alt 451 { 452 [self mINT]; 453 454 455 456 } 457 break; 458 case 4 : ; 459 // T.g:1:22: WS // alt 460 { 461 [self mWS]; 462 463 464 465 } 466 break; 467 468 } 469 470} 471 472@end /* end of TLexer implementation line 397 */