⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simpleclexer.m

📁 ANTLR(ANother Tool for Language Recognition)它是这样的一种工具
💻 M
📖 第 1 页 / 共 2 页
字号:
// $ANTLR 3.0b5 /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g 2006-11-12 21:48:44#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];}- (void) mT7{	@try {		int _type = SimpleCLexer_T7;		int _start = [self charIndex];		int _line = [self line];		int _charPosition = [self charPositionInLine];		int _channel = [ANTLRToken defaultChannel];		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:7:6: ( ';' ) // ruleBlockSingleAlt		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:7:6: ';' // alt		{		[self matchChar:';'];		}		if ( token == nil ) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];}	}	@finally {        // rule cleanup		// token labels		// token+rule list labels		// rule labels		// rule refs in alts with rewrites	}	return;}// $ANTLR end T7- (void) mT8{	@try {		int _type = SimpleCLexer_T8;		int _start = [self charIndex];		int _line = [self line];		int _charPosition = [self charPositionInLine];		int _channel = [ANTLRToken defaultChannel];		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:8:6: ( '(' ) // ruleBlockSingleAlt		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:8:6: '(' // alt		{		[self matchChar:'('];		}		if ( token == nil ) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];}	}	@finally {        // rule cleanup		// token labels		// token+rule list labels		// rule labels		// rule refs in alts with rewrites	}	return;}// $ANTLR end T8- (void) mT9{	@try {		int _type = SimpleCLexer_T9;		int _start = [self charIndex];		int _line = [self line];		int _charPosition = [self charPositionInLine];		int _channel = [ANTLRToken defaultChannel];		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:9:6: ( ',' ) // ruleBlockSingleAlt		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:9:6: ',' // alt		{		[self matchChar:','];		}		if ( token == nil ) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];}	}	@finally {        // rule cleanup		// token labels		// token+rule list labels		// rule labels		// rule refs in alts with rewrites	}	return;}// $ANTLR end T9- (void) mT10{	@try {		int _type = SimpleCLexer_T10;		int _start = [self charIndex];		int _line = [self line];		int _charPosition = [self charPositionInLine];		int _channel = [ANTLRToken defaultChannel];		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:10:7: ( ')' ) // ruleBlockSingleAlt		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:10:7: ')' // alt		{		[self matchChar:')'];		}		if ( token == nil ) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];}	}	@finally {        // rule cleanup		// token labels		// token+rule list labels		// rule labels		// rule refs in alts with rewrites	}	return;}// $ANTLR end T10- (void) mT11{	@try {		int _type = SimpleCLexer_T11;		int _start = [self charIndex];		int _line = [self line];		int _charPosition = [self charPositionInLine];		int _channel = [ANTLRToken defaultChannel];		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:11:7: ( 'int' ) // ruleBlockSingleAlt		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:11:7: 'int' // alt		{		[self matchString:@"int"];		}		if ( token == nil ) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];}	}	@finally {        // rule cleanup		// token labels		// token+rule list labels		// rule labels		// rule refs in alts with rewrites	}	return;}// $ANTLR end T11- (void) mT12{	@try {		int _type = SimpleCLexer_T12;		int _start = [self charIndex];		int _line = [self line];		int _charPosition = [self charPositionInLine];		int _channel = [ANTLRToken defaultChannel];		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:12:7: ( 'char' ) // ruleBlockSingleAlt		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:12:7: 'char' // alt		{		[self matchString:@"char"];		}		if ( token == nil ) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];}	}	@finally {        // rule cleanup		// token labels		// token+rule list labels		// rule labels		// rule refs in alts with rewrites	}	return;}// $ANTLR end T12- (void) mT13{	@try {		int _type = SimpleCLexer_T13;		int _start = [self charIndex];		int _line = [self line];		int _charPosition = [self charPositionInLine];		int _channel = [ANTLRToken defaultChannel];		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:13:7: ( 'void' ) // ruleBlockSingleAlt		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:13:7: 'void' // alt		{		[self matchString:@"void"];		}		if ( token == nil ) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];}	}	@finally {        // rule cleanup		// token labels		// token+rule list labels		// rule labels		// rule refs in alts with rewrites	}	return;}// $ANTLR end T13- (void) mT14{	@try {		int _type = SimpleCLexer_T14;		int _start = [self charIndex];		int _line = [self line];		int _charPosition = [self charPositionInLine];		int _channel = [ANTLRToken defaultChannel];		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:14:7: ( '{' ) // ruleBlockSingleAlt		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:14:7: '{' // alt		{		[self matchChar:'{'];		}		if ( token == nil ) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];}	}	@finally {        // rule cleanup		// token labels		// token+rule list labels		// rule labels		// rule refs in alts with rewrites	}	return;}// $ANTLR end T14- (void) mT15{	@try {		int _type = SimpleCLexer_T15;		int _start = [self charIndex];		int _line = [self line];		int _charPosition = [self charPositionInLine];		int _channel = [ANTLRToken defaultChannel];		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:15:7: ( '}' ) // ruleBlockSingleAlt		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:15:7: '}' // alt		{		[self matchChar:'}'];		}		if ( token == nil ) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];}	}	@finally {        // rule cleanup		// token labels		// token+rule list labels		// rule labels		// rule refs in alts with rewrites	}	return;}// $ANTLR end T15- (void) mT16{	@try {		int _type = SimpleCLexer_T16;		int _start = [self charIndex];		int _line = [self line];		int _charPosition = [self charPositionInLine];		int _channel = [ANTLRToken defaultChannel];		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:16:7: ( 'for' ) // ruleBlockSingleAlt		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:16:7: 'for' // alt		{		[self matchString:@"for"];		}		if ( token == nil ) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];}	}	@finally {        // rule cleanup		// token labels		// token+rule list labels		// rule labels		// rule refs in alts with rewrites	}	return;}// $ANTLR end T16- (void) mT17{	@try {		int _type = SimpleCLexer_T17;		int _start = [self charIndex];		int _line = [self line];		int _charPosition = [self charPositionInLine];		int _channel = [ANTLRToken defaultChannel];		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:17:7: ( '=' ) // ruleBlockSingleAlt		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:17:7: '=' // alt		{		[self matchChar:'='];		}		if ( token == nil ) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];}	}	@finally {        // rule cleanup		// token labels		// token+rule list labels		// rule labels		// rule refs in alts with rewrites	}	return;}// $ANTLR end T17- (void) mT18{	@try {		int _type = SimpleCLexer_T18;		int _start = [self charIndex];		int _line = [self line];		int _charPosition = [self charPositionInLine];		int _channel = [ANTLRToken defaultChannel];		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:18:7: ( '==' ) // ruleBlockSingleAlt		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:18:7: '==' // alt		{		[self matchString:@"=="];		}		if ( token == nil ) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];}	}	@finally {        // rule cleanup		// token labels		// token+rule list labels		// rule labels		// rule refs in alts with rewrites	}	return;}// $ANTLR end T18- (void) mT19{	@try {		int _type = SimpleCLexer_T19;		int _start = [self charIndex];		int _line = [self line];		int _charPosition = [self charPositionInLine];		int _channel = [ANTLRToken defaultChannel];		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:19:7: ( '<' ) // ruleBlockSingleAlt		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:19:7: '<' // alt		{		[self matchChar:'<'];		}		if ( token == nil ) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];}	}	@finally {        // rule cleanup		// token labels		// token+rule list labels		// rule labels		// rule refs in alts with rewrites	}	return;}// $ANTLR end T19- (void) mT20{	@try {		int _type = SimpleCLexer_T20;		int _start = [self charIndex];		int _line = [self line];		int _charPosition = [self charPositionInLine];		int _channel = [ANTLRToken defaultChannel];		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:20:7: ( '+' ) // ruleBlockSingleAlt		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:20:7: '+' // alt		{		[self matchChar:'+'];		}		if ( token == nil ) { [self emitTokenWithType:_type line:_line charPosition:_charPosition channel:_channel start:_start stop:[self charIndex]];}	}	@finally {        // rule cleanup		// token labels		// token+rule list labels		// rule labels		// rule refs in alts with rewrites	}	return;}// $ANTLR end T20- (void) mID{	@try {		int _type = SimpleCLexer_ID;		int _start = [self charIndex];		int _line = [self line];		int _charPosition = [self charPositionInLine];		int _channel = [ANTLRToken defaultChannel];		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:94:9: ( ('a'..'z'|'A'..'Z'|'_') ( ('a'..'z'|'A'..'Z'|'0'..'9'|'_'))* ) // ruleBlockSingleAlt		// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:94: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 :			    // /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/LL-star/SimpleC.g:94: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: ;		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -