mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 15:53:03 +00:00
Remove quotes from variables names in %define directives and from
qualifiers in %code directives, and restrict the characters that are allowed in them to M4-friendly ones. For %define, continue to support the quoted form as a deprecated feature. Discussed starting at <http://lists.gnu.org/archive/html/bison-patches/2007-01/msg00023.html>. * NEWS (2.3a+): Add entry for the change to %define. Update entry for %code. * doc/bison.texinfo (Prologue Alternatives): Update. (Bison Declaration Summary): In %defines entry, update mention of `%code requires' and `%code provides'. (C++ Location Values): Update %define uses. (Calc++ Parser Interface): Likewise. (Calc++ Parser): Likewise, and update `%code requires' uses. (Bison Symbols): Update %code documentation. * src/parse-gram.y (prologue_declaration): For %define variables, use `variable' instead of `STRING'. (grammar_declaration): For %code qualifiers, use `ID' instead of `STRING'. (variable): New nonterminal that takes an `ID' or a `STRING'. * tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Update %code and %define uses. * tests/calc.at (_AT_DATA_CALC_Y): Update %define use. * tests/input.at (Reject unused %code qualifiers): Update %code uses. (%define errors): Update %define uses.
This commit is contained in:
478
src/parse-gram.c
478
src/parse-gram.c
File diff suppressed because it is too large
Load Diff
@@ -190,9 +190,9 @@ static int current_prec = 0;
|
||||
%printer { fprintf (stderr, "{\n%s\n}", $$); }
|
||||
braceless content.opt "{...}" "%{...%}" EPILOGUE
|
||||
|
||||
%type <uniqstr> TYPE ID ID_COLON
|
||||
%type <uniqstr> TYPE ID ID_COLON variable
|
||||
%printer { fprintf (stderr, "<%s>", $$); } TYPE
|
||||
%printer { fputs ($$, stderr); } ID
|
||||
%printer { fputs ($$, stderr); } ID variable
|
||||
%printer { fprintf (stderr, "%s:", $$); } ID_COLON
|
||||
|
||||
%type <integer> INT
|
||||
@@ -232,10 +232,8 @@ prologue_declaration:
|
||||
code_scanner_last_string_free ();
|
||||
}
|
||||
| "%debug" { debug_flag = true; }
|
||||
| "%define" STRING content.opt
|
||||
| "%define" variable content.opt
|
||||
{
|
||||
/* FIXME: Special characters in $2 may break %define.
|
||||
For example: `['. */
|
||||
char const name_prefix[] = "percent_define_";
|
||||
char *name = xmalloc (sizeof name_prefix + strlen ($2));
|
||||
strcpy (name, name_prefix);
|
||||
@@ -326,10 +324,8 @@ grammar_declaration:
|
||||
muscle_code_grow ("percent_code", $2, @2);
|
||||
code_scanner_last_string_free ();
|
||||
}
|
||||
| "%code" STRING braceless
|
||||
| "%code" ID braceless
|
||||
{
|
||||
/* FIXME: Special characters in $2 may break %code.
|
||||
For example: `['. */
|
||||
char const name_prefix[] = "percent_code_";
|
||||
char *name = xmalloc (sizeof name_prefix + strlen ($2));
|
||||
strcpy (name, name_prefix);
|
||||
@@ -535,9 +531,14 @@ rhs:
|
||||
;
|
||||
|
||||
|
||||
/*---------------*
|
||||
| content.opt. |
|
||||
*--------------*/
|
||||
/*----------------------------*
|
||||
| variable and content.opt. |
|
||||
*---------------------------*/
|
||||
|
||||
variable:
|
||||
ID
|
||||
| STRING { $$ = uniqstr_new ($1); } /* deprecated and not M4-friendly */
|
||||
;
|
||||
|
||||
/* Some content or "1" by default. */
|
||||
content.opt:
|
||||
|
||||
Reference in New Issue
Block a user