* data/bison.m4 (b4_percent_define_get): Accept a default value.
* data/c++.m4: Do not provide a default value for the %define
variable location_type, rather, use b4_percent_define_get with a
default argument where its value is needed.
* data/lalr1.cc: Do not load location.cc (which outputs both
location.hh and position.hh) if the user defined location_type.
Do not include location.hh either.
+2010-05-04 Akim Demaille <demaille@gostai.com>
+
+ lalr1.cc: don't generate location.hh when location_type is defined
+ * data/bison.m4 (b4_percent_define_get): Accept a default value.
+ * data/c++.m4: Do not provide a default value for the %define
+ variable location_type, rather, use b4_percent_define_get with a
+ default argument where its value is needed.
+ * data/lalr1.cc: Do not load location.cc (which outputs both
+ location.hh and position.hh) if the user defined location_type.
+ Do not include location.hh either.
+
2010-05-04 Akim Demaille <demaille@gostai.com>
lalr1.cc: minor refactoring.
2010-05-04 Akim Demaille <demaille@gostai.com>
lalr1.cc: minor refactoring.
[m4_define([b4_percent_define_bison_variables(]$1[)])dnl
])
[m4_define([b4_percent_define_bison_variables(]$1[)])dnl
])
-# b4_percent_define_get(VARIABLE)
-# -------------------------------
-# Mimic muscle_percent_define_get in ../src/muscle-tab.h exactly. That is, if
-# the %define variable VARIABLE is defined, emit its value. Also, record
+# b4_percent_define_get(VARIABLE, [DEFAULT])
+# ------------------------------------------
+# Mimic muscle_percent_define_get in ../src/muscle-tab.h. That is, if
+# the %define variable VARIABLE is defined, emit its value. Contrary
+# to its C counterpart, return DEFAULT otherwise. Also, record
# Bison's usage of VARIABLE by defining
# b4_percent_define_bison_variables(VARIABLE).
#
# Bison's usage of VARIABLE by defining
# b4_percent_define_bison_variables(VARIABLE).
#
# b4_percent_define_get([[foo]])
m4_define([b4_percent_define_get],
[b4_percent_define_use([$1])dnl
# b4_percent_define_get([[foo]])
m4_define([b4_percent_define_get],
[b4_percent_define_use([$1])dnl
-m4_ifdef([b4_percent_define(]$1[)], [m4_indir([b4_percent_define(]$1[)])])])
+m4_ifdef([b4_percent_define(]$1[)],
+ [m4_indir([b4_percent_define(]$1[)])],
+ [$2])])
# b4_percent_define_get_loc(VARIABLE)
# -----------------------------------
# b4_percent_define_get_loc(VARIABLE)
# -----------------------------------
## ---------------- ##
b4_percent_define_default([[parser_class_name]], [[parser]])
## ---------------- ##
b4_percent_define_default([[parser_class_name]], [[parser]])
-b4_percent_define_default([[location_type]], [[location]])
+
+# Don't do that so that we remember whether we're using a user
+# request, or the default value.
+#
+# b4_percent_define_default([[location_type]], [[location_type]])
+
b4_percent_define_default([[filename_type]], [[std::string]])
b4_percent_define_default([[api.namespace]], m4_defn([b4_prefix]))
b4_percent_define_default([[filename_type]], [[std::string]])
b4_percent_define_default([[api.namespace]], m4_defn([b4_prefix]))
typedef YYSTYPE semantic_type;
#endif]b4_locations_if([
/// Symbol locations.
typedef YYSTYPE semantic_type;
#endif]b4_locations_if([
/// Symbol locations.
- typedef b4_percent_define_get([[location_type]]) location_type;])[
+ typedef b4_percent_define_get([[location_type]],
+ [[location]]) location_type;])[
/// Syntax errors thrown from user actions.
struct syntax_error : std::runtime_error
/// Syntax errors thrown from user actions.
struct syntax_error : std::runtime_error
b4_defines_if([],
[b4_fatal([b4_skeleton[: using %%defines is mandatory]])])
b4_defines_if([],
[b4_fatal([b4_skeleton[: using %%defines is mandatory]])])
-b4_locations_if(
-[# Backward compatibility.
-m4_define([b4_location_constructors])
-m4_include(b4_pkgdatadir/[location.cc])])
+b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
+ [# Backward compatibility.
+ m4_define([b4_location_constructors])
+ m4_include(b4_pkgdatadir/[location.cc])])])
m4_include(b4_pkgdatadir/[stack.hh])
b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
m4_include(b4_pkgdatadir/[stack.hh])
b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
#include <stdexcept>
#include <string>
#include <iostream>
#include <stdexcept>
#include <string>
#include <iostream>
-]b4_locations_if([#include "location.hh"])[
+]b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
+ [[#include "location.hh"]])])[
]b4_variant_if([b4_namespace_open
b4_variant_define
]b4_variant_if([b4_namespace_open
b4_variant_define