b4_symbol/type_foreach.

* data/lalr1.cc (b4_symbol_foreach, b4_type_foreach): New.
	Use them.
This commit is contained in:
Akim Demaille
2008-11-27 22:20:11 +01:00
parent 2bde91138d
commit e3c52a6362
2 changed files with 26 additions and 6 deletions

View File

@@ -1,3 +1,9 @@
2008-12-01 Akim Demaille <demaille@gostai.com>
b4_symbol/type_foreach.
* data/lalr1.cc (b4_symbol_foreach, b4_type_foreach): New.
Use them.
2008-12-01 Akim Demaille <demaille@gostai.com>
Use the symbol properties to output the printer/destructor for lalr1.cc.

View File

@@ -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<sizeof(union_type)> 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;
}