📄 simpleclexer.m
字号:
// $ANTLR 3.0b6 SimpleC.g 2007-02-01 01:28:02#import "SimpleCLexer.h"#pragma mark Cyclic DFAs/** As per Terence: No returns for lexer rules!#pragma mark Rule return scopes start#pragma mark Rule return scopes end*/@implementation SimpleCLexer- (id) initWithCharStream:(id<ANTLRCharStream>)anInput{ if (nil!=(self = [super initWithCharStream:anInput])) { } return self;}- (void) dealloc{ [super dealloc];}- (NSString *) grammarFileName{ return @"SimpleC.g";}- (void) mT21{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { ruleNestingLevel++; int _type = SimpleCLexer_T21; int _start = [self charIndex]; int _line = [self line]; int _charPosition = [self charPositionInLine]; int _channel = [ANTLRToken defaultChannel]; // SimpleC.g:7:7: ( ';' ) // ruleBlockSingleAlt // SimpleC.g:7:7: ';' // alt { [self matchChar:';']; } if ( token == nil && ruleNestingLevel == 1) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];} } @finally { ruleNestingLevel--; // rule cleanup // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return;}// $ANTLR end T21- (void) mT22{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { ruleNestingLevel++; int _type = SimpleCLexer_T22; int _start = [self charIndex]; int _line = [self line]; int _charPosition = [self charPositionInLine]; int _channel = [ANTLRToken defaultChannel]; // SimpleC.g:8:7: ( '(' ) // ruleBlockSingleAlt // SimpleC.g:8:7: '(' // alt { [self matchChar:'(']; } if ( token == nil && ruleNestingLevel == 1) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];} } @finally { ruleNestingLevel--; // rule cleanup // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return;}// $ANTLR end T22- (void) mT23{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { ruleNestingLevel++; int _type = SimpleCLexer_T23; int _start = [self charIndex]; int _line = [self line]; int _charPosition = [self charPositionInLine]; int _channel = [ANTLRToken defaultChannel]; // SimpleC.g:9:7: ( ',' ) // ruleBlockSingleAlt // SimpleC.g:9:7: ',' // alt { [self matchChar:',']; } if ( token == nil && ruleNestingLevel == 1) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];} } @finally { ruleNestingLevel--; // rule cleanup // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return;}// $ANTLR end T23- (void) mT24{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { ruleNestingLevel++; int _type = SimpleCLexer_T24; int _start = [self charIndex]; int _line = [self line]; int _charPosition = [self charPositionInLine]; int _channel = [ANTLRToken defaultChannel]; // SimpleC.g:10:7: ( ')' ) // ruleBlockSingleAlt // SimpleC.g:10:7: ')' // alt { [self matchChar:')']; } if ( token == nil && ruleNestingLevel == 1) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];} } @finally { ruleNestingLevel--; // rule cleanup // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return;}// $ANTLR end T24- (void) mT25{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { ruleNestingLevel++; int _type = SimpleCLexer_T25; int _start = [self charIndex]; int _line = [self line]; int _charPosition = [self charPositionInLine]; int _channel = [ANTLRToken defaultChannel]; // SimpleC.g:11:7: ( '{' ) // ruleBlockSingleAlt // SimpleC.g:11:7: '{' // alt { [self matchChar:'{']; } if ( token == nil && ruleNestingLevel == 1) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];} } @finally { ruleNestingLevel--; // rule cleanup // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return;}// $ANTLR end T25- (void) mT26{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { ruleNestingLevel++; int _type = SimpleCLexer_T26; int _start = [self charIndex]; int _line = [self line]; int _charPosition = [self charPositionInLine]; int _channel = [ANTLRToken defaultChannel]; // SimpleC.g:12:7: ( '}' ) // ruleBlockSingleAlt // SimpleC.g:12:7: '}' // alt { [self matchChar:'}']; } if ( token == nil && ruleNestingLevel == 1) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];} } @finally { ruleNestingLevel--; // rule cleanup // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return;}// $ANTLR end T26- (void) mFOR{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { ruleNestingLevel++; int _type = SimpleCLexer_FOR; int _start = [self charIndex]; int _line = [self line]; int _charPosition = [self charPositionInLine]; int _channel = [ANTLRToken defaultChannel]; // SimpleC.g:91:7: ( 'for' ) // ruleBlockSingleAlt // SimpleC.g:91:7: 'for' // alt { [self matchString:@"for"]; } if ( token == nil && ruleNestingLevel == 1) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];} } @finally { ruleNestingLevel--; // rule cleanup // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return;}// $ANTLR end FOR- (void) mINT_TYPE{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { ruleNestingLevel++; int _type = SimpleCLexer_INT_TYPE; int _start = [self charIndex]; int _line = [self line]; int _charPosition = [self charPositionInLine]; int _channel = [ANTLRToken defaultChannel]; // SimpleC.g:92:12: ( 'int' ) // ruleBlockSingleAlt // SimpleC.g:92:12: 'int' // alt { [self matchString:@"int"]; } if ( token == nil && ruleNestingLevel == 1) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];} } @finally { ruleNestingLevel--; // rule cleanup // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return;}// $ANTLR end INT_TYPE- (void) mCHAR{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { ruleNestingLevel++; int _type = SimpleCLexer_CHAR; int _start = [self charIndex]; int _line = [self line]; int _charPosition = [self charPositionInLine]; int _channel = [ANTLRToken defaultChannel]; // SimpleC.g:93:7: ( 'char' ) // ruleBlockSingleAlt // SimpleC.g:93:7: 'char' // alt { [self matchString:@"char"]; } if ( token == nil && ruleNestingLevel == 1) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];} } @finally { ruleNestingLevel--; // rule cleanup // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return;}// $ANTLR end CHAR- (void) mVOID{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { ruleNestingLevel++; int _type = SimpleCLexer_VOID; int _start = [self charIndex]; int _line = [self line]; int _charPosition = [self charPositionInLine]; int _channel = [ANTLRToken defaultChannel]; // SimpleC.g:94:7: ( 'void' ) // ruleBlockSingleAlt // SimpleC.g:94:7: 'void' // alt { [self matchString:@"void"]; } if ( token == nil && ruleNestingLevel == 1) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];} } @finally { ruleNestingLevel--; // rule cleanup // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return;}// $ANTLR end VOID- (void) mID{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { ruleNestingLevel++; int _type = SimpleCLexer_ID; int _start = [self charIndex]; int _line = [self line]; int _charPosition = [self charPositionInLine]; int _channel = [ANTLRToken defaultChannel]; // SimpleC.g:96:9: ( ('a'..'z'|'A'..'Z'|'_') ( ('a'..'z'|'A'..'Z'|'0'..'9'|'_'))* ) // ruleBlockSingleAlt // SimpleC.g:96:9: ('a'..'z'|'A'..'Z'|'_') ( ('a'..'z'|'A'..'Z'|'0'..'9'|'_'))* // alt { if (([input LA:1]>='A' && [input LA:1]<='Z')||[input LA:1]=='_'||([input LA:1]>='a' && [input LA:1]<='z')) { [input consume]; } else { ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException exceptionWithSet:nil stream:input]; [self recover:mse]; @throw mse; } do { int alt1=2; { int LA1_0 = [input LA:1]; if ( (LA1_0>='0' && LA1_0<='9')||(LA1_0>='A' && LA1_0<='Z')||LA1_0=='_'||(LA1_0>='a' && LA1_0<='z') ) { alt1 = 1; } } switch (alt1) { case 1 : // SimpleC.g:96:34: ('a'..'z'|'A'..'Z'|'0'..'9'|'_') // alt { 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')) { [input consume]; } else { ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException exceptionWithSet:nil stream:input]; [self recover:mse]; @throw mse; } } break; default : goto loop1; } } while (YES); loop1: ; } if ( token == nil && ruleNestingLevel == 1) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];} } @finally { ruleNestingLevel--; // rule cleanup // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return;}// $ANTLR end ID- (void) mINT{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { ruleNestingLevel++; int _type = SimpleCLexer_INT; int _start = [self charIndex]; int _line = [self line]; int _charPosition = [self charPositionInLine]; int _channel = [ANTLRToken defaultChannel]; // SimpleC.g:99:7: ( ( '0' .. '9' )+ ) // ruleBlockSingleAlt // SimpleC.g:99:7: ( '0' .. '9' )+ // alt { // SimpleC.g:99:7: ( '0' .. '9' )+ // positiveClosureBlock int cnt2=0; do { int alt2=2; { int LA2_0 = [input LA:1]; if ( (LA2_0>='0' && LA2_0<='9') ) { alt2 = 1; } } switch (alt2) { case 1 : // SimpleC.g:99:8: '0' .. '9' // alt { [self matchRangeFromChar:'0' to:'9']; } break; default : if ( cnt2 >= 1 ) goto loop2; ANTLREarlyExitException *eee = [ANTLREarlyExitException exceptionWithStream:input decisionNumber:2]; @throw eee; } cnt2++; } while (YES); loop2: ; } if ( token == nil && ruleNestingLevel == 1) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];} } @finally { ruleNestingLevel--; // rule cleanup // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return;}// $ANTLR end INT- (void) mEQ{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { ruleNestingLevel++; int _type = SimpleCLexer_EQ; int _start = [self charIndex]; int _line = [self line]; int _charPosition = [self charPositionInLine]; int _channel = [ANTLRToken defaultChannel]; // SimpleC.g:102:8: ( '=' ) // ruleBlockSingleAlt // SimpleC.g:102:8: '=' // alt { [self matchChar:'=']; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -