From e3c52a63624c102a41f60bc741294cd3f23ceb89 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 27 Nov 2008 22:20:11 +0100 Subject: [PATCH] b4_symbol/type_foreach. * data/lalr1.cc (b4_symbol_foreach, b4_type_foreach): New. Use them. --- ChangeLog | 6 ++++++ data/lalr1.cc | 26 ++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index bb18059c..6f48b0e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-12-01 Akim Demaille + + b4_symbol/type_foreach. + * data/lalr1.cc (b4_symbol_foreach, b4_type_foreach): New. + Use them. + 2008-12-01 Akim Demaille Use the symbol properties to output the printer/destructor for lalr1.cc. diff --git a/data/lalr1.cc b/data/lalr1.cc index 76a0bcf2..667a464c 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -189,6 +189,20 @@ m4_define([b4_symbol_case_], ]) +# b4_symbol_foreach(MACRO) +# ------------------------ +# Invoke MACRO(SYMBOL-NUM) for each SYMBOL-NUM. +m4_define([b4_symbol_foreach], + [m4_map([$1], m4_defn([b4_symbol_numbers]))]) + +# b4_type_foreach(MACRO) +# ---------------------- +# Invoke MACRO(SYMBOL-NUMS) for each set of SYMBOL-NUMS for each type set. +m4_define([b4_type_foreach], + [m4_map([$1], m4_defn([b4_type_names]))]) + + + # b4_type_action_(NUMS) # --------------------- # Run actions for the symbol NUMS that all have the same type-name. @@ -227,7 +241,7 @@ b4_args(b4_symbol_if([$1], [has_type], m4_define([b4_symbol_constructor_declarations], [b4_variant_if([ // Symbol constructors declarations. -m4_map([b4_symbol_constructor_declaration_], m4_defn([b4_symbol_numbers]))])]) +b4_symbol_foreach([b4_symbol_constructor_declaration_])])]) @@ -346,7 +360,7 @@ m4_define([b4_symbol_constructor_definitions], ]b4_variant_if( [ // Implementation of make_symbol for each symbol type. -m4_map([b4_symbol_constructor_definition_], m4_defn([b4_symbol_numbers]))])]) +b4_symbol_foreach([b4_symbol_constructor_definition_])])]) # b4_symbol_variant(YYTYPE, YYVAL, ACTION, [ARGS]) @@ -358,7 +372,7 @@ m4_define([b4_symbol_variant], [$2.$3< $][3 >(m4_shift3($@))])dnl switch ($1) { -m4_map([b4_type_action_], m4_defn([b4_type_names]))[]dnl +b4_type_foreach([b4_type_action_])[]dnl default: break; } @@ -619,7 +633,7 @@ do { \ ]b4_variant_if( [ /// An auxiliary type to compute the largest semantic type. union union_type - {]m4_map([b4_char_sizeof], m4_defn([b4_type_names]))[}; + {]b4_type_foreach([b4_char_sizeof])[}; /// Symbol semantic values. typedef variant semantic_type;], @@ -1037,7 +1051,7 @@ b4_percent_code_get[]dnl // User destructor. switch (yytype) { -]m4_map([b4_symbol_destructor], m4_defn([b4_symbol_numbers]))dnl +]b4_symbol_foreach([b4_symbol_destructor])dnl [ default: break; }]b4_variant_if([ @@ -1058,7 +1072,7 @@ b4_percent_code_get[]dnl << yysym.location << ": "])[; switch (yytype) { -]m4_map([b4_symbol_printer], m4_defn([b4_symbol_numbers]))dnl +]b4_symbol_foreach([b4_symbol_printer])dnl [ default: break; } -- 2.45.2