* 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.
+2008-11-26 Akim Demaille <demaille@gostai.com>
+
+ 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.
+
2008-11-26 Akim Demaille <demaille@gostai.com>
Get rid of (yy)rhs and (yy)prhs.
+# 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.
+If YYTABLE_NINF, syntax error.]])
+
+$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_tables_declare
+# b4_tables_define
+# -----------------
+# Define/declare the (deterministic) parser tables.
+m4_define([b4_tables_declare],
+[b4_tables_map([b4_table_declare])])
+
+m4_define([b4_tables_define],
+[b4_tables_map([b4_table_define])])
+
+
+
## ------------------ ##
## Decoding options. ##
## ------------------ ##
m4_define([b4_null], [0])
+# b4_table_define(TABLE-NAME, CONTENT, COMMENT)
+# ---------------------------------------------
+# Define "yy<TABLE-NAME>" which contents is CONTENT.
+m4_define([b4_table_define],
+[m4_ifval([$3], [b4_c_comment([$3], [ ])
+])dnl
+static const b4_int_type_for([$2]) yy$1[[]] =
+{
+ $2
+};dnl
+])
## ------------------------- ##
};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])
# -------------------------------------
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.
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.
};
# endif
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const ]b4_int_type_for([b4_r1])[ yyr1[] =
-{
- ]b4_r1[
-};
-
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
-static const ]b4_int_type_for([b4_r2])[ yyr2[] =
-{
- ]b4_r2[
-};
-
-/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
- STATE-NUM when YYTABLE doesn't specify something else to do. Zero
- means the default is an error. */
-static const ]b4_int_type_for([b4_defact])[ yydefact[] =
-{
- ]b4_defact[
-};
-
-/* YYDEFGOTO[NTERM-NUM]. */
-static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
-{
- ]b4_defgoto[
-};
-
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
#define YYPACT_NINF ]b4_pact_ninf[
-static const ]b4_int_type_for([b4_pact])[ yypact[] =
-{
- ]b4_pact[
-};
-
-/* YYPGOTO[NTERM-NUM]. */
-static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] =
-{
- ]b4_pgoto[
-};
-/* 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.
- If YYTABLE_NINF, syntax error. */
#define YYTABLE_NINF ]b4_table_ninf[
-static const ]b4_int_type_for([b4_table])[ yytable[] =
-{
- ]b4_table[
-};
-
-static const ]b4_int_type_for([b4_check])[ yycheck[] =
-{
- ]b4_check[
-};
-/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
-static const ]b4_int_type_for([b4_stos])[ yystos[] =
-{
- ]b4_stos[
-};
+]b4_tables_define[
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
{
0, 256, 257, 258, 259, 260, 261
};
-static const yytype_uint8 yyr1[] =
-{
- 0, 7, 8, 9, 9, 10, 11
-};
-static const yytype_uint8 yyr2[] =
+static const yytype_int8 yypact[] =
{
- 0, 2, 1, 0, 2, 4, 2
+ -2, -1, 4, -8, 0, 2, -8, -2, -8, -2,
+ -8, -8
};
static const yytype_uint8 yydefact[] =
{
3, 0, 0, 2, 0, 0, 1, 3, 4, 3,
6, 5
};
-static const yytype_int8 yydefgoto[] =
-{
- -1, 2, 3, 4, 8
-};
-static const yytype_int8 yypact[] =
-{
- -2, -1, 4, -8, 0, 2, -8, -2, -8, -2,
- -8, -8
-};
static const yytype_int8 yypgoto[] =
{
-8, -7, -8, -8, -8
};
+static const yytype_int8 yydefgoto[] =
+{
+ -1, 2, 3, 4, 8
+};
static const yytype_uint8 yytable[] =
{
10, 1, 11, 5, 6, 0, 7, 9
0, 3, 8, 9, 10, 4, 0, 6, 11, 5,
8, 8
};
+static const yytype_uint8 yyr1[] =
+{
+ 0, 7, 8, 9, 9, 10, 11
+};
+static const yytype_uint8 yyr2[] =
+{
+ 0, 2, 1, 0, 2, 4, 2
+};
]])
AT_CLEANUP