Extend the front-end API for %define variables to more completely

mirror the back-end.  This will be useful in the future.
* data/bison.m4 (b4_percent_define_get, b4_percent_define_ifdef):
Update comments to mention the new front-end counterparts of these
macros.
* src/muscle_tab.c (MUSCLE_COMMON_DECODE): New macro with common code
for muscle_string_decode and muscle_location_decode.
(muscle_string_decode): New static function.
(muscle_location_decode): Use MUSCLE_COMMON_DECODE.
(muscle_percent_define_get, muscle_percent_define_ifdef): New
functions.
(muscle_percent_define_flag_if): Use muscle_percent_define_ifdef and
muscle_percent_define_get to mimic the b4_percent_define_flag_if
implementation more closely.
(muscle_percent_define_invalid_value): New function.
* src/muscle_tab.h (muscle_percent_define_get,
muscle_percent_define_ifdef, muscle_percent_define_invalid_value):
Prototype.
This commit is contained in:
Joel E. Denny
2007-05-20 05:01:53 +00:00
parent 75ad86eebd
commit f124d4233f
4 changed files with 141 additions and 24 deletions

View File

@@ -131,6 +131,19 @@ void muscle_user_name_list_grow (char const *key, char const *user_name,
void muscle_percent_define_insert (char const *variable, location variable_loc,
char const *value);
/* Mimic b4_percent_define_get in ../data/bison.m4 exactly. That is, if the
%define variable VARIABLE is defined, return its value. Otherwise, return
the empty string. Also, record Bison's usage of VARIABLE by defining
b4_percent_define_bison_variables(VARIABLE). The caller is responsible for
freeing the memory of the returned string. */
char *muscle_percent_define_get (char const *variable);
/* Mimic b4_percent_define_ifdef in ../data/bison.m4 exactly. That is, if the
%define variable VARIABLE is defined, return true. Otherwise, return false.
Also, record Bison's usage of VARIABLE by defining
b4_percent_define_bison_variables(VARIABLE). */
bool muscle_percent_define_ifdef (char const *variable);
/* Mimic b4_percent_define_flag_if in ../data/bison.m4 exactly. That is, if
the %define variable VARIABLE is defined to "" or "true", return true. If
it is defined to "false", return false. Complain if it is undefined (a
@@ -145,6 +158,10 @@ bool muscle_percent_define_flag_if (char const *variable);
suspect that the value has yet influenced the output. */
void muscle_percent_define_default (char const *variable, char const *value);
/* Complain that the value set for the %define variable VARIABLE is
invalid. */
void muscle_percent_define_invalid_value (char const *variable);
/* Grow the muscle for the %code qualifier QUALIFIER appearing at QUALIFIER_LOC
in the grammar file with code CODE appearing at CODE_LOC. Record this as a
grammar occurrence of VARIABLE by invoking muscle_user_name_list_grow. */