simplecparser.m
来自「ANTLR(ANother Tool for Language Recognit」· M 代码 · 共 1,753 行 · 第 1/5 页
M
1,753 行
id root_0 = nil; SimpleCParser_type_return * _type18 = nil; SimpleCParser_declarator_return * _declarator19 = nil; NSMutableArray *_list_type = [[NSMutableArray alloc] init]; NSMutableArray *_list_declarator = [[NSMutableArray alloc] init]; @try { // /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:40:9: ( type declarator -> ^( ARG_DEF type declarator ) ) // ruleBlockSingleAlt // /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:40:9: type declarator // alt { [following addObject:FOLLOW_type_in_formalParameter281]; _type18 = [self type]; [following removeLastObject]; [_list_type addObject:[_type18 tree]]; [following addObject:FOLLOW_declarator_in_formalParameter283]; _declarator19 = [self declarator]; [following removeLastObject]; [_list_declarator addObject:[_declarator19 tree]]; // AST REWRITE int i_0 = 0; [_retval setTree:root_0]; root_0 = (id)[adaptor emptyTree]; // 40:25: -> ^( ARG_DEF type declarator ) { // /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:40:28: ^( ARG_DEF type declarator ) { id root_1 = (id)[adaptor emptyTree]; root_1 = (id)[adaptor makeNode:[adaptor newTreeWithTokenType:SimpleCParser_ARG_DEF text:[tokenNames objectAtIndex:SimpleCParser_ARG_DEF]] parentOf:root_1]; [adaptor addChild:(id<ANTLRTree>)[_list_type objectAtIndex:i_0] toTree:root_1]; [adaptor addChild:(id<ANTLRTree>)[_list_declarator objectAtIndex:i_0] toTree:root_1]; [adaptor addChild:root_1 toTree:root_0]; } } } } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input exception:re]; } @finally { // token labels // token+rule list labels // rule labels [_type18 release]; [_declarator19 release]; // rule refs in alts with rewrites [_list_type release]; [_list_declarator release]; [_retval setStop:[input LT:-1]]; [_retval setTree:(id)[adaptor postProcessTree:root_0]]; [adaptor setBoundariesForTree:[_retval tree] fromToken:[_retval start] toToken:[_retval stop]]; } return _retval;}// $ANTLR end formalParameter// $ANTLR start type// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:43:1: type : ('int'|'char'|'void'|ID);- (SimpleCParser_type_return *) type{ SimpleCParser_type_return * _retval = [[SimpleCParser_type_return alloc] init]; [_retval setStart:[input LT:1]]; id root_0 = nil; ANTLRToken * _set20 = nil; id _set20_tree = nil; @try { // /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:44:5: ( ('int'|'char'|'void'|ID)) // ruleBlockSingleAlt // /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:44:9: ('int'|'char'|'void'|ID) // alt { root_0 = (id)[adaptor emptyTree]; _set20 = (ANTLRToken *)[input LT:1]; if ([input LA:1]==SimpleCParser_ID||([input LA:1]>=SimpleCParser_INT_TYPE && [input LA:1]<=SimpleCParser_VOID)) { [adaptor addChild:[adaptor newTreeWithToken:_set20] toTree:root_0]; [input consume]; errorRecovery = NO; } else { ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException exceptionWithSet:nil stream:input]; [self recoverFromMismatchedSet:input exception:mse follow:FOLLOW_set_in_type312]; @throw mse; } } } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input exception:re]; } @finally { // token labels [_set20 release]; // token+rule list labels // rule labels // rule refs in alts with rewrites [_retval setStop:[input LT:-1]]; [_retval setTree:(id)[adaptor postProcessTree:root_0]]; [adaptor setBoundariesForTree:[_retval tree] fromToken:[_retval start] toToken:[_retval stop]]; } return _retval;}// $ANTLR end type// $ANTLR start block// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:50:1: block : lc= '{' ( variable )* ( stat )* '}' -> ^( BLOCK[$lc,"BLOCK"] ( variable )* ( stat )* ) ;- (SimpleCParser_block_return *) block{ SimpleCParser_block_return * _retval = [[SimpleCParser_block_return alloc] init]; [_retval setStart:[input LT:1]]; id root_0 = nil; ANTLRToken * _lc = nil; ANTLRToken * _char_literal23 = nil; SimpleCParser_variable_return * _variable21 = nil; SimpleCParser_stat_return * _stat22 = nil; NSMutableArray *_list_stat = [[NSMutableArray alloc] init]; NSMutableArray *_list_variable = [[NSMutableArray alloc] init]; NSMutableArray *_list_26 = [[NSMutableArray alloc] init]; NSMutableArray *_list_25 = [[NSMutableArray alloc] init]; id _lc_tree = nil; id _char_literal23_tree = nil; @try { // /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:51:9: (lc= '{' ( variable )* ( stat )* '}' -> ^( BLOCK[$lc,\"BLOCK\"] ( variable )* ( stat )* ) ) // ruleBlockSingleAlt // /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:51:9: lc= '{' ( variable )* ( stat )* '}' // alt { _lc=(ANTLRToken *)[input LT:1]; [_lc retain]; [self match:input tokenType:25 follow:FOLLOW_25_in_block376]; [_list_25 addObject:_lc]; 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>=SimpleCParser_INT_TYPE && LA5_0<=SimpleCParser_VOID) ) { alt5 = 1; } } switch (alt5) { case 1 : // /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:52:13: variable // alt { [following addObject:FOLLOW_variable_in_block390]; _variable21 = [self variable]; [following removeLastObject]; [_list_variable addObject:[_variable21 tree]]; } 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<=SimpleCParser_FOR)||(LA6_0>=21 && LA6_0<=22)||LA6_0==25 ) { alt6 = 1; } } switch (alt6) { case 1 : // /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:53:13: stat // alt { [following addObject:FOLLOW_stat_in_block405]; _stat22 = [self stat]; [following removeLastObject]; [_list_stat addObject:[_stat22 tree]]; } break; default : goto loop6; } } while (YES); loop6: ; _char_literal23=(ANTLRToken *)[input LT:1]; [_char_literal23 retain]; [self match:input tokenType:26 follow:FOLLOW_26_in_block416]; [_list_26 addObject:_char_literal23]; // AST REWRITE int i_0 = 0; [_retval setTree:root_0]; root_0 = (id)[adaptor emptyTree]; // 55:9: -> ^( BLOCK[$lc,\"BLOCK\"] ( variable )* ( stat )* ) { // /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:55:12: ^( BLOCK[$lc,\"BLOCK\"] ( variable )* ( stat )* ) { id root_1 = (id)[adaptor emptyTree]; root_1 = (id)[adaptor makeNode:[adaptor newTreeWithTokenType:SimpleCParser_BLOCK text:[_lc text]] parentOf:root_1]; // /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:55:33: ( variable )* { int n_1 = _list_variable == nil ? 0 : [_list_variable count]; int i_1; for (i_1=0; i_1<n_1; i_1++) { [adaptor addChild:(id<ANTLRTree>)[_list_variable objectAtIndex:i_1] toTree:root_1]; } } // /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:55:43: ( stat )* { int n_1 = _list_stat == nil ? 0 : [_list_stat count]; int i_1; for (i_1=0; i_1<n_1; i_1++) { [adaptor addChild:(id<ANTLRTree>)[_list_stat objectAtIndex:i_1] toTree:root_1]; } } [adaptor addChild:root_1 toTree:root_0]; } } } } @catch (ANTLRRecognitionException *re) { [self reportError:re]; [self recover:input exception:re]; } @finally { // token labels [_lc release]; [_char_literal23 release]; // token+rule list labels // rule labels [_variable21 release]; [_stat22 release]; // rule refs in alts with rewrites [_list_stat release]; [_list_variable release]; [_list_26 release]; [_list_25 release]; [_retval setStop:[input LT:-1]]; [_retval setTree:(id)[adaptor postProcessTree:root_0]]; [adaptor setBoundariesForTree:[_retval tree] fromToken:[_retval start] toToken:[_retval stop]]; } return _retval;}// $ANTLR end block// $ANTLR start stat// /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:58:1: stat : ( forStat | expr ';'! | block | assignStat ';'! | ';'! );- (SimpleCParser_stat_return *) stat{ SimpleCParser_stat_return * _retval = [[SimpleCParser_stat_return alloc] init]; [_retval setStart:[input LT:1]]; id root_0 = nil; ANTLRToken * _char_literal26 = nil; ANTLRToken * _char_literal29 = nil; ANTLRToken * _char_literal30 = nil; SimpleCParser_forStat_return * _forStat24 = nil; SimpleCParser_expr_return * _expr25 = nil; SimpleCParser_block_return * _block27 = nil; SimpleCParser_assignStat_return * _assignStat28 = nil; id _char_literal26_tree = nil; id _char_literal29_tree = nil; id _char_literal30_tree = nil; @try { // /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:58:7: ( forStat | expr ';'! | block | assignStat ';'! | ';'! ) //ruleblock int alt7=5; switch ([input LA:1]) { case SimpleCParser_FOR: alt7 = 1; break; case SimpleCParser_ID: { int LA7_2 = [input LA:2]; if ( LA7_2==SimpleCParser_EQ ) { alt7 = 4; } else if ( (LA7_2>=SimpleCParser_EQEQ && LA7_2<=SimpleCParser_PLUS)||LA7_2==21 ) { alt7 = 2; } else { ANTLRNoViableAltException *nvae = [ANTLRNoViableAltException exceptionWithDecision:7 state:2 stream:input]; @throw nvae; } } break; case SimpleCParser_INT: case 22: alt7 = 2;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?