📄 simplecparser.m
字号:
// rule labels [_functionHeader1 release]; [_functionHeader2 release]; // rule refs in alts with rewrites } return ;}// $ANTLR end declaration// $ANTLR start variable// SimpleC.g:28:1: variable : type declarator ';' ;- (void) variable{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { // SimpleC.g:29:9: ( type declarator ';' ) // ruleBlockSingleAlt // SimpleC.g:29:9: type declarator ';' // alt { [following addObject:FOLLOW_type_in_variable98]; [self type]; [following removeLastObject]; [following addObject:FOLLOW_declarator_in_variable100]; [self declarator]; [following removeLastObject]; [self match:input tokenType:7 follow:FOLLOW_7_in_variable102]; } } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input exception:re]; } @finally { // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return ;}// $ANTLR end variable// $ANTLR start declarator// SimpleC.g:32:1: declarator : ID ;- (void) declarator{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { // SimpleC.g:33:9: ( ID ) // ruleBlockSingleAlt // SimpleC.g:33:9: ID // alt { [self match:input tokenType:SimpleCParser_ID follow:FOLLOW_SimpleCParser_ID_in_declarator121]; } } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input exception:re]; } @finally { // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return ;}// $ANTLR end declarator// $ANTLR start functionHeader// SimpleC.g:36:1: functionHeader returns [NSString* name] : type ID '(' ( formalParameter ( ',' formalParameter )* )? ')' ;- (NSString*) functionHeader{ NSString* _name; // token labels ANTLRToken * _ID3 = nil; // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites _name =nil; // double check this after beta release! [_name retain]; // for now you must init here rather than in 'returns' @try { // SimpleC.g:40:9: ( type ID '(' ( formalParameter ( ',' formalParameter )* )? ')' ) // ruleBlockSingleAlt // SimpleC.g:40:9: type ID '(' ( formalParameter ( ',' formalParameter )* )? ')' // alt { [following addObject:FOLLOW_type_in_functionHeader150]; [self type]; [following removeLastObject]; _ID3=(ANTLRToken *)[input LT:1]; [_ID3 retain]; [self match:input tokenType:SimpleCParser_ID follow:FOLLOW_SimpleCParser_ID_in_functionHeader152]; [self match:input tokenType:8 follow:FOLLOW_8_in_functionHeader154]; // SimpleC.g:40:21: ( formalParameter ( ',' formalParameter )* )? // block int alt4=2; { int LA4_0 = [input LA:1]; if ( LA4_0==SimpleCParser_ID||(LA4_0>=11 && LA4_0<=13) ) { alt4 = 1; } } switch (alt4) { case 1 : // SimpleC.g:40:23: formalParameter ( ',' formalParameter )* // alt { [following addObject:FOLLOW_formalParameter_in_functionHeader158]; [self formalParameter]; [following removeLastObject]; do { int alt3=2; { int LA3_0 = [input LA:1]; if ( LA3_0==9 ) { alt3 = 1; } } switch (alt3) { case 1 : // SimpleC.g:40:41: ',' formalParameter // alt { [self match:input tokenType:9 follow:FOLLOW_9_in_functionHeader162]; [following addObject:FOLLOW_formalParameter_in_functionHeader164]; [self formalParameter]; [following removeLastObject]; } break; default : goto loop3; } } while (YES); loop3: ; } break; } [self match:input tokenType:10 follow:FOLLOW_10_in_functionHeader172]; _name = [_ID3 text]; // double check this after beta release! [_name retain]; } } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input exception:re]; } @finally { // token labels [_ID3 release]; // token+rule list labels // rule labels // rule refs in alts with rewrites } return _name;}// $ANTLR end functionHeader// $ANTLR start formalParameter// SimpleC.g:44:1: formalParameter : type declarator ;- (void) formalParameter{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { // SimpleC.g:45:9: ( type declarator ) // ruleBlockSingleAlt // SimpleC.g:45:9: type declarator // alt { [following addObject:FOLLOW_type_in_formalParameter194]; [self type]; [following removeLastObject]; [following addObject:FOLLOW_declarator_in_formalParameter196]; [self declarator]; [following removeLastObject]; } } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input exception:re]; } @finally { // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return ;}// $ANTLR end formalParameter// $ANTLR start type// SimpleC.g:48:1: type : ('int'|'char'|'void'|ID);- (void) type{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { // SimpleC.g:49:5: ( ('int'|'char'|'void'|ID)) // ruleBlockSingleAlt // SimpleC.g:49:9: ('int'|'char'|'void'|ID) // alt { if ([input LA:1]==SimpleCParser_ID||([input LA:1]>=11 && [input LA:1]<=13)) { [input consume]; errorRecovery = NO; } else { ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException exceptionWithSet:nil stream:input]; [self recoverFromMismatchedSet:input exception:mse follow:FOLLOW_set_in_type223]; @throw mse; } } } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input exception:re]; } @finally { // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return ;}// $ANTLR end type// $ANTLR start block// SimpleC.g:55:1: block : '{' ( variable )* ( stat )* '}' ;- (void) block{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { // SimpleC.g:56:9: ( '{' ( variable )* ( stat )* '}' ) // ruleBlockSingleAlt // SimpleC.g:56:9: '{' ( variable )* ( stat )* '}' // alt { [self match:input tokenType:14 follow:FOLLOW_14_in_block285]; do { int alt5=2; { int LA5_0 = [input LA:1]; if ( LA5_0==SimpleCParser_ID ) { { int LA5_2 = [input LA:2]; if ( LA5_2==SimpleCParser_ID ) { alt5 = 1; } } } else if ( (LA5_0>=11 && LA5_0<=13) ) { alt5 = 1; } } switch (alt5) { case 1 : // SimpleC.g:57:13: variable // alt { [following addObject:FOLLOW_variable_in_block299]; [self variable]; [following removeLastObject]; } break; default : goto loop5; } } while (YES); loop5: ; do { int alt6=2; { int LA6_0 = [input LA:1]; if ( (LA6_0>=SimpleCParser_ID && LA6_0<=SimpleCParser_INT)||(LA6_0>=7 && LA6_0<=8)||LA6_0==14||LA6_0==16 ) { alt6 = 1; } } switch (alt6) { case 1 : // SimpleC.g:58:13: stat // alt { [following addObject:FOLLOW_stat_in_block314]; [self stat]; [following removeLastObject]; } break; default : goto loop6; } } while (YES); loop6: ; [self match:input tokenType:15 follow:FOLLOW_15_in_block325]; } } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input exception:re]; } @finally { // token labels // token+rule list labels // rule labels // rule refs in alts with rewrites } return ;}// $ANTLR end block// $ANTLR start stat// SimpleC.g:62:1: stat : ( forStat | expr ';' | block | assignStat ';' | ';' );- (void) stat{ // token labels // token+rule list labels // rule labels // rule list labels // rule refs in alts with rewrites @try { // SimpleC.g:62:7: ( forStat | expr ';' | block | assignStat ';' | ';' ) //ruleblock int alt7=5; switch ([input LA:1]) { case 16: alt7 = 1; break; case SimpleCParser_ID: { int LA7_2 = [input LA:2]; if ( LA7_2==17 ) { alt7 = 4; } else if ( LA7_2==7||(LA7_2>=18 && LA7_2<=20) ) { alt7 = 2; } else { ANTLRNoViableAltException *nvae = [ANTLRNoViableAltException exceptionWithDecision:7 state:2 stream:input]; @throw nvae; } } break; case SimpleCParser_INT: case 8: alt7 = 2; break; case 14: alt7 = 3; break; case 7: alt7 = 5; break; default: { ANTLRNoViableAltException *nvae = [ANTLRNoViableAltException exceptionWithDecision:7 state:0 stream:input]; @throw nvae; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -