📄 parser.cc
字号:
/* Shift the look-ahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; goto yynewstate;/*-----------------------------------------------------------.| yydefault -- do the default action for the current state. |`-----------------------------------------------------------*/yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce;/*-----------------------------.| yyreduce -- Do a reduction. |`-----------------------------*/yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 2:#line 84 "./parser.y" { accept = 0; spec = NULL; } break; case 3:#line 87 "./parser.y" { spec = spec? mkAlt(spec, (yyvsp[(2) - (2)].regexp)) : (yyvsp[(2) - (2)].regexp); } break; case 5:#line 92 "./parser.y" { if((yyvsp[(1) - (4)].symbol)->re) in->fatal("sym already defined"); (yyvsp[(1) - (4)].symbol)->re = (yyvsp[(3) - (4)].regexp); } break; case 6:#line 96 "./parser.y" { in->fatal("trailing contexts are not allowed in named definitions"); } break; case 7:#line 98 "./parser.y" { in->config(*(yyvsp[(1) - (4)].str), *(yyvsp[(3) - (4)].str)); delete (yyvsp[(1) - (4)].str); delete (yyvsp[(3) - (4)].str); } break; case 8:#line 100 "./parser.y" { in->config(*(yyvsp[(1) - (4)].str), (yyvsp[(3) - (4)].number)); delete (yyvsp[(1) - (4)].str); } break; case 9:#line 104 "./parser.y" { (yyval.regexp) = new RuleOp((yyvsp[(1) - (3)].regexp), (yyvsp[(2) - (3)].regexp), (yyvsp[(3) - (3)].token), accept++); } break; case 10:#line 108 "./parser.y" { (yyval.regexp) = new NullOp; } break; case 11:#line 110 "./parser.y" { (yyval.regexp) = (yyvsp[(2) - (2)].regexp); } break; case 12:#line 114 "./parser.y" { (yyval.regexp) = (yyvsp[(1) - (1)].regexp); } break; case 13:#line 116 "./parser.y" { (yyval.regexp) = mkAlt((yyvsp[(1) - (3)].regexp), (yyvsp[(3) - (3)].regexp)); } break; case 14:#line 120 "./parser.y" { (yyval.regexp) = (yyvsp[(1) - (1)].regexp); } break; case 15:#line 122 "./parser.y" { (yyval.regexp) = mkDiff((yyvsp[(1) - (3)].regexp), (yyvsp[(3) - (3)].regexp)); if(!(yyval.regexp)) in->fatal("can only difference char sets"); } break; case 16:#line 129 "./parser.y" { (yyval.regexp) = (yyvsp[(1) - (1)].regexp); } break; case 17:#line 131 "./parser.y" { (yyval.regexp) = new CatOp((yyvsp[(1) - (2)].regexp), (yyvsp[(2) - (2)].regexp)); } break; case 18:#line 135 "./parser.y" { (yyval.regexp) = (yyvsp[(1) - (1)].regexp); } break; case 19:#line 137 "./parser.y" { switch((yyvsp[(2) - (2)].op)){ case '*': (yyval.regexp) = mkAlt(new CloseOp((yyvsp[(1) - (2)].regexp)), new NullOp()); break; case '+': (yyval.regexp) = new CloseOp((yyvsp[(1) - (2)].regexp)); break; case '?': (yyval.regexp) = mkAlt((yyvsp[(1) - (2)].regexp), new NullOp()); break; } } break; case 20:#line 151 "./parser.y" { (yyval.regexp) = new CloseVOp((yyvsp[(1) - (2)].regexp), (yyvsp[(2) - (2)].extop).minsize, (yyvsp[(2) - (2)].extop).maxsize); } break; case 21:#line 157 "./parser.y" { (yyval.op) = (yyvsp[(1) - (1)].op); } break; case 22:#line 159 "./parser.y" { (yyval.op) = ((yyvsp[(1) - (2)].op) == (yyvsp[(2) - (2)].op)) ? (yyvsp[(1) - (2)].op) : '*'; } break; case 23:#line 163 "./parser.y" { if(!(yyvsp[(1) - (1)].symbol)->re) in->fatal("can't find symbol"); (yyval.regexp) = (yyvsp[(1) - (1)].symbol)->re; } break; case 24:#line 167 "./parser.y" { (yyval.regexp) = (yyvsp[(1) - (1)].regexp); } break; case 25:#line 169 "./parser.y" { (yyval.regexp) = (yyvsp[(1) - (1)].regexp); } break; case 26:#line 171 "./parser.y" { (yyval.regexp) = (yyvsp[(2) - (3)].regexp); } break;/* Line 1267 of yacc.c. */#line 1553 "parser.cc" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate;/*------------------------------------.| yyerrlab -- here on detecting error |`------------------------------------*/yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs;#if ! YYERROR_VERBOSE yyerror (YY_("syntax error"));#else { YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) { YYSIZE_T yyalloc = 2 * yysize; if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) yyalloc = YYSTACK_ALLOC_MAXIMUM; if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yyalloc); if (yymsg) yymsg_alloc = yyalloc; else { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; } } if (0 < yysize && yysize <= yymsg_alloc) { (void) yysyntax_error (yymsg, yystate, yychar); yyerror (yymsg); } else { yyerror (YY_("syntax error")); if (yysize != 0) goto yyexhaustedlab; } }#endif } if (yyerrstatus == 3) { /* If just tried and failed to reuse look-ahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval); yychar = YYEMPTY; } } /* Else will try to reuse look-ahead token after shifting the error token. */ goto yyerrlab1;/*---------------------------------------------------.| yyerrorlab -- error raised explicitly by YYERROR. |`---------------------------------------------------*/yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1;/*-------------------------------------------------------------.| yyerrlab1 -- common code for both syntax error and YYERROR. |`-------------------------------------------------------------*/yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yydestruct ("Error: popping", yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } if (yyn == YYFINAL) YYACCEPT; *++yyvsp = yylval; /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate;/*-------------------------------------.| yyacceptlab -- YYACCEPT comes here. |`-------------------------------------*/yyacceptlab: yyresult = 0; goto yyreturn;/*-----------------------------------.| yyabortlab -- YYABORT comes here. |`-----------------------------------*/yyabortlab: yyresult = 1; goto yyreturn;#ifndef yyoverflow/*-------------------------------------------------.| yyexhaustedlab -- memory exhaustion comes here. |`-------------------------------------------------*/yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */#endifyyreturn: if (yychar != YYEOF && yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp); YYPOPSTACK (1); }#ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss);#endif#if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg);#endif /* Make sure YYID is used. */ return YYID (yyresult);}#line 174 "./parser.y"extern "C" {void yyerror(const char* s){ in->fatal(s);}int yylex(){ return in ? in->scan() : 0;}} // end extern "C"namespace re2c{void parse(Scanner& i, std::ostream& o){ in = &i; o << "/* Generated by re2c " PACKAGE_VERSION; if (!bNoGenerationDate) { o << " on "; time_t now = time(&now); o.write(ctime(&now), 24); } o << " */\n"; o << sourceFileInfo; while(i.echo()) { yyparse(); if(spec) { genCode(o, topIndent, spec); } o << sourceFileInfo; } RegExp::vFreeList.clear(); Range::vFreeList.clear(); Symbol::ClearTable(); in = NULL;}} // end namespace re2c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -