grammar: record the kind of %define variable values

Provide a means to tell the difference between "keyword" values (e.g.,
%define api.pull both), "string" values (e.g., %define file.name
"foo"), and "code" values (e.g., %define api.namespace {calc}).

Suggested by Joel E. Denny.
http://lists.gnu.org/archive/html/bison-patches/2013-03/msg00016.html

* src/muscle-tab.h, src/muscle-tab.c (muscle_kind, muscle_kind_new)
(muscle_kind_string): New.
(muscle_percent_define_insert): Take the kind as new argument.
Insert it in the muscle table.
Adjust callers.
* src/getargs.c: Adjust callers.
* src/parse-gram.y: Ditto.
(content.opt): Remove, replaced by...
(value): this new non-terminal, whose semantics value is stored
in the new "value" union member.
Provide a printer.
Support values in braces in additions to keyword and string values.

fuse me
This commit is contained in:
Akim Demaille
2013-04-04 16:38:17 +02:00
parent 36a17b50b5
commit 14bfd2e9d9
4 changed files with 88 additions and 17 deletions

View File

@@ -582,6 +582,7 @@ getargs (int argc, char *argv[])
if (value)
*value++ = 0;
muscle_percent_define_insert (name, command_line_location (),
muscle_string,
value ? value : "",
c == 'D' ? MUSCLE_PERCENT_DEFINE_D
: MUSCLE_PERCENT_DEFINE_F);
@@ -666,7 +667,8 @@ getargs (int argc, char *argv[])
case 't':
muscle_percent_define_insert ("parse.trace",
command_line_location (), "",
command_line_location (),
muscle_keyword, "",
MUSCLE_PERCENT_DEFINE_D);
break;