From ba206cf40acd26224d6619bda6a920e4c0744225 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 25 Nov 2008 21:38:45 +0100 Subject: [PATCH] Prepare the convergence bw C style and Java table generation. * data/bison.m4 (b4_tables_map, b4_tables_declare) (b4_tables_define): Rename as... (b4_integral_parser_tables_map, b4_parser_tables_declare) (b4_parser_tables_define): these. * data/c.m4 (b4_table_define): Rename as... (b4_integral_parser_table_define): this. * data/lalr1.cc: Adjust. (b4_table_define, b4_table_declare): Rename as... (b4_integral_parser_table_define) (b4_integral_parser_table_declare): these. (yyrline_): Move the comment where it is actually used. * data/yacc.c: Adjust. (yyrline): Use b4_integral_parser_table_define. --- ChangeLog | 17 +++++++++++++++++ data/bison.m4 | 20 ++++++++++---------- data/c.m4 | 6 +++--- data/lalr1.cc | 20 ++++++++++---------- data/yacc.c | 9 +++------ 5 files changed, 43 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8713fddf..c3fa7334 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2008-11-26 Akim Demaille + + Prepare the convergence bw C style and Java table generation. + * data/bison.m4 (b4_tables_map, b4_tables_declare) + (b4_tables_define): Rename as... + (b4_integral_parser_tables_map, b4_parser_tables_declare) + (b4_parser_tables_define): these. + * data/c.m4 (b4_table_define): Rename as... + (b4_integral_parser_table_define): this. + * data/lalr1.cc: Adjust. + (b4_table_define, b4_table_declare): Rename as... + (b4_integral_parser_table_define) + (b4_integral_parser_table_declare): these. + (yyrline_): Move the comment where it is actually used. + * data/yacc.c: Adjust. + (yyrline): Use b4_integral_parser_table_define. + 2008-11-26 Akim Demaille Regen. diff --git a/data/bison.m4 b/data/bison.m4 index efcf2bd0..33cc13bf 100644 --- a/data/bison.m4 +++ b/data/bison.m4 @@ -245,11 +245,11 @@ m4_define([_b4_args], -# b4_tables_map(MACRO) -# -------------------- +# b4_integral_parser_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], +m4_define([b4_integral_parser_tables_map], [$1([pact], [b4_pact], [[YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM.]]) @@ -283,15 +283,15 @@ $1([r2], [b4_r2], ]) -# b4_tables_declare -# b4_tables_define -# ----------------- +# b4_parser_tables_declare +# b4_parser_tables_define +# ------------------------ # Define/declare the (deterministic) parser tables. -m4_define([b4_tables_declare], -[b4_tables_map([b4_table_declare])]) +m4_define([b4_parser_tables_declare], +[b4_integral_parser_tables_map([b4_integral_parser_table_declare])]) -m4_define([b4_tables_define], -[b4_tables_map([b4_table_define])]) +m4_define([b4_parser_tables_define], +[b4_integral_parser_tables_map([b4_integral_parser_table_define])]) diff --git a/data/c.m4 b/data/c.m4 index 518c05b6..abde5a13 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -169,10 +169,10 @@ m4_define([b4_int_type_for], m4_define([b4_null], [0]) -# b4_table_define(TABLE-NAME, CONTENT, COMMENT) -# --------------------------------------------- +# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT) +# ------------------------------------------------------------- # Define "yy" which contents is CONTENT. -m4_define([b4_table_define], +m4_define([b4_integral_parser_table_define], [m4_ifval([$3], [b4_c_comment([$3], [ ]) ])dnl static const b4_int_type_for([$2]) yy$1[[]] = diff --git a/data/lalr1.cc b/data/lalr1.cc index b751a08f..0ccf2237 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -19,19 +19,19 @@ m4_include(b4_pkgdatadir/[c++.m4]) -# b4_table_declare(TABLE-NAME, CONTENT, COMMENT) -# ---------------------------------------------- +# b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT) +# -------------------------------------------------------------- # Declare "parser::yy_" which contents is CONTENT. -m4_define([b4_table_declare], +m4_define([b4_integral_parser_table_declare], [m4_ifval([$3], [b4_c_comment([$3], [ ]) ])dnl static const b4_int_type_for([$2]) yy$1_[[]];dnl ]) -# b4_table_define(TABLE-NAME, CONTENT, COMMENT) +# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT) # --------------------------------------------- # Define "parser::yy_" which contents is CONTENT. -m4_define([b4_table_define], +m4_define([b4_integral_parser_table_define], [ const b4_int_type_for([$2]) b4_parser_class_name::yy$1_[[]] = { @@ -676,7 +676,7 @@ m4_ifdef([b4_stype], static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_; /* Tables. */ -]b4_tables_declare[ +]b4_parser_tables_declare[ #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /// For a symbol, its name in clear. @@ -687,7 +687,8 @@ m4_ifdef([b4_stype], static std::string yytnamerr_ (const char *n);])[ #if YYDEBUG -]b4_table_declare([rline], [b4_rline])[ +]b4_integral_parser_table_declare([rline], [b4_rline], + [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[ /// Report on the debug stream that the rule \a r is going to be reduced. virtual void yy_reduce_print_ (int r); /// Print the state stack on the debug stream. @@ -1499,7 +1500,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_define[ +]b4_parser_tables_define[ #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. @@ -1512,8 +1513,7 @@ b4_error_verbose_if([int yystate, int yytoken], #endif #if YYDEBUG -]b4_table_define([rline], [b4_rline], - [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[ +]b4_integral_parser_table_define([rline], [b4_rline])[ // Print the state stack on the debug stream. void diff --git a/data/yacc.c b/data/yacc.c index eed13f7f..8b7a0601 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -501,11 +501,8 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] = }; #if YYDEBUG -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const ]b4_int_type_for([b4_rline])[ yyrline[] = -{ - ]b4_rline[ -}; +]b4_integral_parser_table_define([rline], [b4_rline], + [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[ #endif #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE @@ -530,7 +527,7 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] = #define YYTABLE_NINF ]b4_table_ninf[ -]b4_tables_define[ +]b4_parser_tables_define[ #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -- 2.45.2