Factor the generation of the (integral) tables bw yacc.c and lalr1.cc.

* data/lalr1.cc (b4_tables_map): Move to...
	* data/bison.m4: here.
	Update the comment for yytable during the flight.
	(b4_tables_declare, b4_tables_define): New.
	* data/lalr1.cc: Use them.
	* data/c.m4 (b4_table_define): New.
	* data/yacc.c: Use b4_tables_define instead of output the tables
	by hand.
	* tests/regression.at (Web2c Actions): Adjust the expected output,
	the order of the tables changed.
This commit is contained in:
Akim Demaille
2008-11-25 21:25:48 +01:00
parent 3d3bc1fe30
commit 0991e29b75
6 changed files with 93 additions and 109 deletions

View File

@@ -39,41 +39,6 @@ m4_define([b4_table_define],
};dnl
])
# b4_tables_map(MACRO)
# --------------------
# Map MACRO on all the integral tables. MACRO is expected to have
# the signature MACRO(TABLE-NAME, CONTENT, COMMENT).
m4_define([b4_tables_map],
[$1([pact], [b4_pact],
[[YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM.]])
$1([defact], [b4_defact],
[[YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
does not specify something else to do. Zero means the default is an
error.]])
$1([pgoto], [b4_pgoto], [[YYPGOTO[NTERM-NUM].]])
$1([defgoto], [b4_defgoto], [[YYDEFGOTO[NTERM-NUM].]])
$1([table], [b4_table],
[[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.]])
$1([check], [b4_check])
$1([stos], [b4_stos],
[[STOS_[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM.]])
$1([r1], [b4_r1],
[[YYR1[YYN] -- Symbol number of symbol that rule YYN derives.]])
$1([r2], [b4_r2],
[[YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.]])
])
# b4_symbol_value_template(VAL, [TYPE])
# -------------------------------------
@@ -711,7 +676,7 @@ m4_ifdef([b4_stype],
static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
/* Tables. */
]b4_tables_map([b4_table_declare])[
]b4_tables_declare[
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
/// For a symbol, its name in clear.
@@ -1534,7 +1499,7 @@ b4_error_verbose_if([int yystate, int yytoken],
const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class_name::yytable_ninf_ = b4_table_ninf[;
]b4_tables_map([b4_table_define])[
]b4_tables_define[
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.