📄 calc++-parser.cc
字号:
{ (yyval.ival) = (yysemantic_stack_[0].ival); ;} break; default: break; }/* Line 676 of lalr1.cc. */#line 434 "./calc++-parser.cc" yypop_ (yylen_); YY_STACK_PRINT (); yysemantic_stack_.push (yyval); yylocation_stack_.push (yyloc); /* Shift the result of the reduction. */ yyn_ = yyr1_[yyn_]; yystate_ = yypgoto_[yyn_ - yyntokens_] + yystate_stack_[0]; if (0 <= yystate_ && yystate_ <= yylast_ && yycheck_[yystate_] == yystate_stack_[0]) 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_; error (yylloc, yysyntax_error_ (YYERROR_VERBOSE_IF (yyilooka))); } yyerror_range[0] = yylloc; if (yyerrstatus_ == 3) { /* If just tried and failed to reuse look-ahead token after an error, discard it. */ if (yylooka <= yyeof_) { /* Return failure if at end of input. */ if (yylooka == yyeof_) YYABORT; } else { yydestruct_ ("Error: discarding", yyilooka, &yylval, &yylloc); yylooka = 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 (false) goto yyerrorlab; yyerror_range[0] = yylocation_stack_[yylen_ - 1]; yypop_ (yylen_); yystate_ = yystate_stack_[0]; 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 (yystate_stack_.height () == 1) YYABORT; yyerror_range[0] = yylocation_stack_[0]; yydestruct_ ("Error: popping", yystos_[yystate_], &yysemantic_stack_[0], &yylocation_stack_[0]); yypop_ (); yystate_ = yystate_stack_[0]; YY_STACK_PRINT (); } if (yyn_ == yyfinal_) goto yyacceptlab; yyerror_range[1] = yylloc; // Using YYLLOC is tempting, but would change the location of // the look-ahead. YYLOC is available though. YYLLOC_DEFAULT (yyloc, yyerror_range - 1, 2); yysemantic_stack_.push (yylval); yylocation_stack_.push (yyloc); /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos_[yyn_], &yysemantic_stack_[0], &yylocation_stack_[0]); yystate_ = yyn_; goto yynewstate; /* Accept. */yyacceptlab: yyresult_ = 0; goto yyreturn; /* Abort. */yyabortlab: yyresult_ = 1; goto yyreturn;yyreturn: if (yylooka != yyeof_ && yylooka != yyempty_) yydestruct_ ("Cleanup: discarding lookahead", yyilooka, &yylval, &yylloc); while (yystate_stack_.height () != 1) { yydestruct_ ("Cleanup: popping", yystos_[yystate_stack_[0]], &yysemantic_stack_[0], &yylocation_stack_[0]); yypop_ (); } return yyresult_;}// Generate an error message.std::stringyy::calcxx_parser::yysyntax_error_ (YYERROR_VERBOSE_IF (int tok)){ std::string res;#if YYERROR_VERBOSE yyn_ = yypact_[yystate_]; if (yypact_ninf_ < yyn_ && yyn_ < yylast_) { /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ int yyxbegin = yyn_ < 0 ? -yyn_ : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = yylast_ - yyn_; int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; int count = 0; for (int x = yyxbegin; x < yyxend; ++x) if (yycheck_[x + yyn_] == x && x != yyterror_) ++count; // FIXME: This method of building the message is not compatible // with internationalization. It should work like yacc.c does it. // That is, first build a string that looks like this: // "syntax error, unexpected %s or %s or %s" // Then, invoke YY_ on this string. // Finally, use the string as a format to output // yytname_[tok], etc. // Until this gets fixed, this message appears in English only. res = "syntax error, unexpected "; res += yytnamerr_ (yytname_[tok]); if (count < 5) { count = 0; for (int x = yyxbegin; x < yyxend; ++x) if (yycheck_[x + yyn_] == x && x != yyterror_) { res += (!count++) ? ", expecting " : " or "; res += yytnamerr_ (yytname_[x]); } } } else#endif res = YY_("syntax error"); return res;}/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */const signed char yy::calcxx_parser::yypact_ninf_ = -9;const signed charyy::calcxx_parser::yypact_[] ={ -9, 15, 5, -9, 13, -9, -9, -2, 7, 7, 7, 7, 7, -9, -2, 4, 4, -9, -9};/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE doesn't specify something else to do. Zero means the default is an error. */const unsigned charyy::calcxx_parser::yydefact_[] ={ 4, 0, 0, 1, 10, 11, 3, 2, 0, 0, 0, 0, 0, 10, 5, 6, 7, 8, 9};/* YYPGOTO[NTERM-NUM]. */const signed charyy::calcxx_parser::yypgoto_[] ={ -9, -9, -9, -9, -8};/* YYDEFGOTO[NTERM-NUM]. */const signed charyy::calcxx_parser::yydefgoto_[] ={ -1, 1, 2, 6, 7};/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. */const signed char yy::calcxx_parser::yytable_ninf_ = -1;const unsigned charyy::calcxx_parser::yytable_[] ={ 14, 15, 16, 17, 18, 9, 10, 11, 12, 4, 5, 13, 5, 11, 12, 3, 8};/* YYCHECK. */const unsigned charyy::calcxx_parser::yycheck_[] ={ 8, 9, 10, 11, 12, 7, 8, 9, 10, 4, 5, 4, 5, 9, 10, 0, 3};/* STOS_[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */const unsigned charyy::calcxx_parser::yystos_[] ={ 0, 12, 13, 0, 4, 5, 14, 15, 3, 7, 8, 9, 10, 4, 15, 15, 15, 15, 15};#if YYDEBUG/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding to YYLEX-NUM. */const unsigned short intyy::calcxx_parser::yytoken_number_[] ={ 0, 256, 257, 258, 259, 260, 261, 43, 45, 42, 47};#endif/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */const unsigned charyy::calcxx_parser::yyr1_[] ={ 0, 11, 12, 13, 13, 14, 15, 15, 15, 15, 15, 15};/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */const unsigned charyy::calcxx_parser::yyr2_[] ={ 0, 2, 2, 2, 0, 3, 3, 3, 3, 3, 1, 1};#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at \a yyntokens_, nonterminals. */const char*const yy::calcxx_parser::yytname_[] ={ "\"end of file\"", "error", "$undefined", "\":=\"", "\"identifier\"", "\"number\"", "\"expression\"", "'+'", "'-'", "'*'", "'/'", "$accept", "unit", "assignments", "assignment", "exp", 0};#endif#if YYDEBUG/* YYRHS -- A `-1'-separated list of the rules' RHS. */const yy::calcxx_parser::rhs_number_typeyy::calcxx_parser::yyrhs_[] ={ 12, 0, -1, 13, 15, -1, 13, 14, -1, -1, 4, 3, 15, -1, 15, 7, 15, -1, 15, 8, 15, -1, 15, 9, 15, -1, 15, 10, 15, -1, 4, -1, 5, -1};/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */const unsigned charyy::calcxx_parser::yyprhs_[] ={ 0, 0, 3, 6, 9, 10, 14, 18, 22, 26, 30, 32};/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */const unsigned short intyy::calcxx_parser::yyrline_[] ={ 0, 7392, 7392, 7394, 7395, 7397, 7401, 7402, 7403, 7404, 7405, 7406};// Print the state stack on the debug stream.voidyy::calcxx_parser::yystack_print_ (){ *yycdebug_ << "Stack now"; for (state_stack_type::const_iterator i = yystate_stack_.begin (); i != yystate_stack_.end (); ++i) *yycdebug_ << ' ' << *i; *yycdebug_ << std::endl;}// Report on the debug stream that the rule \a yyrule is going to be reduced.voidyy::calcxx_parser::yyreduce_print_ (int yyrule){ unsigned int yylno = yyrline_[yyrule]; /* Print the symbols being reduced, and their result. */ *yycdebug_ << "Reducing stack by rule " << yyn_ - 1 << " (line " << yylno << "), "; for (unsigned char i = yyprhs_[yyn_]; 0 <= yyrhs_[i]; ++i) *yycdebug_ << yytname_[yyrhs_[i]] << ' '; *yycdebug_ << "-> " << yytname_[yyr1_[yyn_]] << std::endl;}#endif // YYDEBUG/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */yy::calcxx_parser::token_number_typeyy::calcxx_parser::yytranslate_ (int token){ static const token_number_type translate_table[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 7, 2, 8, 2, 10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6 }; if ((unsigned int) token <= yyuser_token_number_max_) return translate_table[token]; else return yyundef_token_;}const int yy::calcxx_parser::yyeof_ = 0;const int yy::calcxx_parser::yylast_ = 16;const int yy::calcxx_parser::yynnts_ = 5;const int yy::calcxx_parser::yyempty_ = -2;const int yy::calcxx_parser::yyfinal_ = 3;const int yy::calcxx_parser::yyterror_ = 1;const int yy::calcxx_parser::yyerrcode_ = 256;const int yy::calcxx_parser::yyntokens_ = 11;const unsigned int yy::calcxx_parser::yyuser_token_number_max_ = 261;const yy::calcxx_parser::token_number_type yy::calcxx_parser::yyundef_token_ = 2;#line 7407 "../../doc/bison.texinfo"#line 7416 "../../doc/bison.texinfo"voidyy::calcxx_parser::error (const yy::calcxx_parser::location_type& l, const std::string& m){ driver.error (l, m);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -