/** \file * This OBJC source file was generated by $ANTLR version ${project.version} ${buildNumber} * * - From the grammar source file : Lang.g * - On : 2011-05-06 17:38:52 * - for the lexer : LangLexerLexer * * Editing it, at least manually, is not wise. * * ObjC language generator and runtime by Alan Condit, acondit|hereisanat|ipns|dotgoeshere|com. * * */ // $ANTLR ${project.version} ${buildNumber} Lang.g 2011-05-06 17:38:52 /* ----------------------------------------- * Include the ANTLR3 generated header file. */ #import "LangLexer.h" /* ----------------------------------------- */ /* ============================================================================= */ /* ============================================================================= * Start of recognizer */ /** As per Terence: No returns for lexer rules! */ @implementation LangLexer // line 330 + (void) initialize { [ANTLRBaseRecognizer setGrammarFileName:@"Lang.g"]; } + (NSString *) tokenNameForType:(NSInteger)aTokenType { return [[self getTokenNames] objectAtIndex:aTokenType]; } + (LangLexer *)newLangLexerWithCharStream:(id<ANTLRCharStream>)anInput { return [[LangLexer alloc] initWithCharStream:anInput]; } - (id) initWithCharStream:(id<ANTLRCharStream>)anInput { self = [super initWithCharStream:anInput State:[[ANTLRRecognizerSharedState newANTLRRecognizerSharedStateWithRuleLen:7+1] retain]]; if ( self != nil ) { } return self; } - (void) dealloc { [super dealloc]; } /* ObjC Start of actions.lexer.methods */ /* ObjC end of actions.lexer.methods */ /* ObjC start methods() */ /* ObjC end methods() */ /* Start of Rules */ // $ANTLR start "T__10" - (void) mT__10 { // /* my ruleScopeSetUp */ /* Terence's stuff */ @try { NSInteger _type = T__10; NSInteger _channel = ANTLRTokenChannelDefault; // Lang.g:7:7: ( ';' ) // ruleBlockSingleAlt // Lang.g:7:9: ';' // alt { [self matchChar:';']; } // token+rule list labels state.type = _type; state.channel = _channel; } @finally { // /* Terence's stuff */ } return; } /* $ANTLR end "T__10" */ // $ANTLR start "INTTYPE" - (void) mINTTYPE { // /* my ruleScopeSetUp */ /* Terence's stuff */ @try { NSInteger _type = INTTYPE; NSInteger _channel = ANTLRTokenChannelDefault; // Lang.g:18:9: ( 'int' ) // ruleBlockSingleAlt // Lang.g:18:11: 'int' // alt { [self matchString:@"int"]; } // token+rule list labels state.type = _type; state.channel = _channel; } @finally { // /* Terence's stuff */ } return; } /* $ANTLR end "INTTYPE" */ // $ANTLR start "FLOATTYPE" - (void) mFLOATTYPE { // /* my ruleScopeSetUp */ /* Terence's stuff */ @try { NSInteger _type = FLOATTYPE; NSInteger _channel = ANTLRTokenChannelDefault; // Lang.g:19:11: ( 'float' ) // ruleBlockSingleAlt // Lang.g:19:13: 'float' // alt { [self matchString:@"float"]; } // token+rule list labels state.type = _type; state.channel = _channel; } @finally { // /* Terence's stuff */ } return; } /* $ANTLR end "FLOATTYPE" */ // $ANTLR start "ID" - (void) mID { // /* my ruleScopeSetUp */ /* Terence's stuff */ @try { NSInteger _type = ID; NSInteger _channel = ANTLRTokenChannelDefault; // Lang.g:20:4: ( ( 'a' .. 'z' )+ ) // ruleBlockSingleAlt // Lang.g:20:6: ( 'a' .. 'z' )+ // alt { // Lang.g:20:6: ( 'a' .. 'z' )+ // positiveClosureBlock NSInteger cnt1 = 0; do { NSInteger alt1 = 2; NSInteger LA1_0 = [input LA:1]; if ( ((LA1_0 >= 'a' && LA1_0 <= 'z')) ) { alt1=1; } switch (alt1) { case 1 : ; // Lang.g: // alt { if ((([input LA:1] >= 'a') && ([input LA:1] <= 'z'))) { [input consume]; } else { ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException newException:nil stream:input]; [self recover:mse]; @throw mse; } } break; default : if ( cnt1 >= 1 ) goto loop1; ANTLREarlyExitException *eee = [ANTLREarlyExitException newException:input decisionNumber:1]; @throw eee; } cnt1++; } while (YES); loop1: ; } // token+rule list labels state.type = _type; state.channel = _channel; } @finally { // /* Terence's stuff */ } return; } /* $ANTLR end "ID" */ // $ANTLR start "INT" - (void) mINT { // /* my ruleScopeSetUp */ /* Terence's stuff */ @try { NSInteger _type = INT; NSInteger _channel = ANTLRTokenChannelDefault; // Lang.g:21:5: ( ( '0' .. '9' )+ ) // ruleBlockSingleAlt // Lang.g:21:7: ( '0' .. '9' )+ // alt { // Lang.g:21:7: ( '0' .. '9' )+ // positiveClosureBlock NSInteger cnt2 = 0; do { NSInteger alt2 = 2; NSInteger LA2_0 = [input LA:1]; if ( ((LA2_0 >= '0' && LA2_0 <= '9')) ) { alt2=1; } switch (alt2) { case 1 : ; // Lang.g: // alt { if ((([input LA:1] >= '0') && ([input LA:1] <= '9'))) { [input consume]; } else { ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException newException:nil stream:input]; [self recover:mse]; @throw mse; } } break; default : if ( cnt2 >= 1 ) goto loop2; ANTLREarlyExitException *eee = [ANTLREarlyExitException newException:input decisionNumber:2]; @throw eee; } cnt2++; } while (YES); loop2: ; } // token+rule list labels state.type = _type; state.channel = _channel; } @finally { // /* Terence's stuff */ } return; } /* $ANTLR end "INT" */ // $ANTLR start "WS" - (void) mWS { // /* my ruleScopeSetUp */ /* Terence's stuff */ @try { NSInteger _type = WS; NSInteger _channel = ANTLRTokenChannelDefault; // Lang.g:22:4: ( ( ' ' | '\\n' ) ) // ruleBlockSingleAlt // Lang.g:22:6: ( ' ' | '\\n' ) // alt { if ([input LA:1] == '\n'||[input LA:1] == ' ') { [input consume]; } else { ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException newException:nil stream:input]; [self recover:mse]; @throw mse; } _channel=HIDDEN; } // token+rule list labels state.type = _type; state.channel = _channel; } @finally { // /* Terence's stuff */ } return; } /* $ANTLR end "WS" */ - (void) mTokens { // Lang.g:1:8: ( T__10 | INTTYPE | FLOATTYPE | ID | INT | WS ) //ruleblock NSInteger alt3=6; unichar charLA3 = [input LA:1]; switch (charLA3) { case ';': ; { alt3=1; } break; case 'i': ; { NSInteger LA3_2 = [input LA:2]; if ( (LA3_2=='n') ) { NSInteger LA3_7 = [input LA:3]; if ( (LA3_7=='t') ) { NSInteger LA3_9 = [input LA:4]; if ( ((LA3_9 >= 'a' && LA3_9 <= 'z')) ) { alt3=4; } else { alt3 = 2; } } else { alt3 = 4; } } else { alt3 = 4; } } break; case 'f': ; { NSInteger LA3_3 = [input LA:2]; if ( (LA3_3=='l') ) { NSInteger LA3_8 = [input LA:3]; if ( (LA3_8=='o') ) { NSInteger LA3_10 = [input LA:4]; if ( (LA3_10=='a') ) { NSInteger LA3_12 = [input LA:5]; if ( (LA3_12=='t') ) { NSInteger LA3_13 = [input LA:6]; if ( ((LA3_13 >= 'a' && LA3_13 <= 'z')) ) { alt3=4; } else { alt3 = 3; } } else { alt3 = 4; } } else { alt3 = 4; } } else { alt3 = 4; } } else { alt3 = 4; } } break; case 'a': ; case 'b': ; case 'c': ; case 'd': ; case 'e': ; case 'g': ; case 'h': ; case 'j': ; case 'k': ; case 'l': ; case 'm': ; case 'n': ; case 'o': ; case 'p': ; case 'q': ; case 'r': ; case 's': ; case 't': ; case 'u': ; case 'v': ; case 'w': ; case 'x': ; case 'y': ; case 'z': ; { alt3=4; } break; case '0': ; case '1': ; case '2': ; case '3': ; case '4': ; case '5': ; case '6': ; case '7': ; case '8': ; case '9': ; { alt3=5; } break; case '\n': ; case ' ': ; { alt3=6; } break; default: ; ANTLRNoViableAltException *nvae = [ANTLRNoViableAltException newException:3 state:0 stream:input]; nvae.c = charLA3; @throw nvae; } switch (alt3) { case 1 : ; // Lang.g:1:10: T__10 // alt { [self mT__10]; } break; case 2 : ; // Lang.g:1:16: INTTYPE // alt { [self mINTTYPE]; } break; case 3 : ; // Lang.g:1:24: FLOATTYPE // alt { [self mFLOATTYPE]; } break; case 4 : ; // Lang.g:1:34: ID // alt { [self mID]; } break; case 5 : ; // Lang.g:1:37: INT // alt { [self mINT]; } break; case 6 : ; // Lang.g:1:41: WS // alt { [self mWS]; } break; } } @end /* end of LangLexer implementation line 397 */