* data/bison.m4 (b4_percent_define_flag_if): Don't treat 0 as false.
Complain if the value does not match empty, "true" or "false".
* data/c++.m4: Adjust default definitions of %define variables.
* data/java.m4: Adjust default definitions of %define variables.
* doc/bison.texinfo (Decl Summary): Adjust the %define entry according
to above behavior.
* tests/input.at (Boolean %define variables): Test new behavior.
+2007-01-30 Paolo Bonzini <bonzini@gnu.org>
+
+ * data/bison.m4 (b4_percent_define_flag_if): Don't treat 0 as false.
+ Complain if the value does not match empty, "true" or "false".
+ * data/c++.m4: Adjust default definitions of %define variables.
+ * data/java.m4: Adjust default definitions of %define variables.
+ * doc/bison.texinfo (Decl Summary): Adjust the %define entry according
+ to above behavior.
+ * tests/input.at (Boolean %define variables): Test new behavior.
+
2007-01-29 Paolo Bonzini <bonzini@gnu.org>
* NEWS: Mention java.
m4_define([b4_percent_define_flag_if],
[b4_percent_define_ifdef([$1],
[m4_case(b4_percent_define_get([$1]),
- [0], [$3], [false], [$3],
- [$2])],
- [m4_fatal([invalid %define variable passed to b4_percent_define_flag_if: ]$1)])])
+ [], [$2], [true], [$2], [false], [$3],
+ [m4_expand_once(
+ [b4_complain([[invalid value for %%define variable `%s']], [$1])],
+ [[b4_percent_define_flag_if($1)]])])],
+ [b4_fatal([[invalid %%define variable `%s' passed to b4_percent_define_flag_if]], [$1])])])
# b4_percent_define_default(VARIABLE, DEFAULT)
# --------------------------------------------
b4_percent_define_default([[location_type]], [[location]])
b4_percent_define_default([[filename_type]], [[std::string]])
b4_percent_define_default([[namespace]], m4_defn([b4_prefix]))
-b4_percent_define_default([[global_tokens_and_yystype]], [[0]])
+b4_percent_define_default([[global_tokens_and_yystype]], [[false]])
b4_percent_define_default([[define_location_comparison]],
[m4_if(b4_percent_define_get([[filename_type]]),
- [std::string], [[1]], [[0]])])
+ [std::string], [[true]], [[false]])])
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
# b4_public_if(TRUE, FALSE)
# -------------------------
-b4_percent_define_default([public], 0)
+b4_percent_define_default([[public]], [[false]])
m4_define([b4_public_if],
[b4_percent_define_flag_if([public], [$1], [$2])])
# b4_single_class_if(TRUE, FALSE)
# -------------------------------
-b4_percent_define_default([single_class], 0)
+b4_percent_define_default([[single_class]], [[false]])
m4_define([b4_single_class_if],
[b4_percent_define_flag_if([single_class], [$1], [$2])])
@end deffn
@xref{Tracing, ,Tracing Your Parser}.
-@deffn {Directive} %define @var{define-variable}
-@deffnx {Directive} %define @var{define-variable} @var{value}
-Define a variable to adjust Bison's behavior.
-The list of available variables and their meanings depends on the selected
-target language and/or the parser skeleton (@pxref{Decl Summary,,%language}).
-The @var{value} can be omitted for boolean variables; for
-boolean variables, the skeletons will treat a @var{value} of @samp{0}
-or @samp{false} as the boolean variable being false, and anything else
-as true.
+@deffn {Directive} %define @var{variable}
+@deffnx {Directive} %define @var{variable} "@var{value}"
+Define a variable to adjust Bison's behavior. The possible choices for
+@var{variable}, as well as their meanings, depends on the selected target
+language and/or the parser skeleton (@pxref{Decl Summary,,%language}).
+
+Some @var{variable}s may be used as boolean values: in this case, the
+skeleton will conventionally treat a @var{value} of @samp{false} as the
+boolean variable being false; a @var{value} of @samp{true}, or @var{value}
+being omitted altogether, will conversely define the variable as true.
@end deffn
@deffn {Directive} %defines
]])
AT_CLEANUP
+
+## --------------------------- ##
+## Boolean %define variables. ##
+## --------------------------- ##
+
+AT_SETUP([Boolean %define variables])
+
+AT_DATA([Input.y],
+[[%language "Java"
+%define public "maybe"
+%define parser_class_name "Input"
+%%
+start: ;
+]])
+
+AT_CHECK([[bison Input.y]], [1], [],
+[[Input.y: invalid value for %define variable `public'
+]])
+
+AT_CLEANUP