From: Akim Demaille Date: Thu, 31 Jul 2008 10:50:42 +0000 (+0200) Subject: Rely on the state stack to display reduction traces. X-Git-Tag: v2.7.90~1126 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/33c195cc37a2d4e20c5437a0334953ea87637c20?ds=inline Rely on the state stack to display reduction traces. To display rhs symbols before a reduction, we used information about the rule reduced, which required the tables yyrhs and yyprhs. Now use rely only on the state stack to get the same information. * data/lalr1.cc (b4_rhs_data, b4_rhs_state): New. Use them. (parser::yyrhs_, parser::yyprhs_): Remove. (parser::yy_reduce_print_): Use the state stack. --- diff --git a/ChangeLog b/ChangeLog index e5e9e9f3..43dca2de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-11-09 Akim Demaille + + Rely on the state stack to display reduction traces. + To display rhs symbols before a reduction, we used information about the rule + reduced, which required the tables yyrhs and yyprhs. Now use rely only on the + state stack to get the same information. + + * data/lalr1.cc (b4_rhs_data, b4_rhs_state): New. + Use them. + (parser::yyrhs_, parser::yyprhs_): Remove. + (parser::yy_reduce_print_): Use the state stack. + 2008-11-09 Akim Demaille Fuse yyval and yyloc into yylhs. diff --git a/data/lalr1.cc b/data/lalr1.cc index 1f4aa252..34bcc278 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -60,19 +60,36 @@ m4_define([b4_lhs_location], [yylhs.location]) +# b4_rhs_data(RULE-LENGTH, NUM) +# ----------------------------- +# Return the data corresponding to the symbol #NUM, where the current +# rule has RULE-LENGTH symbols on RHS. +m4_define([b4_rhs_data], + [yystack_@{($1) - ($2)@}]) + + +# b4_rhs_state(RULE-LENGTH, NUM) +# ----------------------------- +# The state corresponding to the symbol #NUM, where the current +# rule has RULE-LENGTH symbols on RHS. +m4_define([b4_rhs_state], + [b4_rhs_data([$1], [$2]).state]) + + # b4_rhs_value(RULE-LENGTH, NUM, [TYPE]) # -------------------------------------- # Expansion of $NUM, where the current rule has RULE-LENGTH # symbols on RHS. m4_define([b4_rhs_value], - [b4_symbol_value([yystack_@{($1) - ($2)@}.value], [$3])]) + [b4_symbol_value([b4_rhs_data([$1], [$2]).value], [$3])]) + # b4_rhs_location(RULE-LENGTH, NUM) # --------------------------------- # Expansion of @NUM, where the current rule has RULE-LENGTH symbols # on RHS. m4_define([b4_rhs_location], -[yystack_@{($1) - ($2)@}.location]) + [b4_rhs_data([$1], [$2]).location]) # b4_symbol_actions(FILENAME, LINENO, @@ -441,10 +458,6 @@ m4_ifdef([b4_stype], #endif #if YYDEBUG - /// A `-1'-separated list of the rules' RHS. - static const ]b4_int_type_for([b4_rhs])[ yyrhs_[]; - /// For each rule, the index of the first RHS symbol in \a yyrhs_. - static const ]b4_int_type_for([b4_prhs])[ yyprhs_[]; /// For each rule, its source line number. static const ]b4_int_type_for([b4_rline])[ yyrline_[]; /// For each scanner token number, its symbol number. @@ -1210,13 +1223,6 @@ b4_error_verbose_if([ tok])[) #endif #if YYDEBUG - /* YYRHS -- A `-1'-separated list of the rules' RHS. */ - ]b4_table_define([rhs], [b4_rhs])[; - - /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ - ]b4_table_define([prhs], [b4_prhs])[; - /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ ]b4_table_define([rline], [b4_rline])[; @@ -1245,7 +1251,7 @@ b4_error_verbose_if([ tok])[) /* The symbols being reduced. */ for (int yyi = 0; yyi < yynrhs; yyi++) YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", - yyrhs_[yyprhs_[yyrule] + yyi], + ]yystos_@{b4_rhs_state(yynrhs, yyi + 1)@}[, ]b4_rhs_value(yynrhs, yyi + 1)[, ]b4_rhs_location(yynrhs, yyi + 1)[); }