mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 09:13:04 +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:
@@ -178,7 +178,7 @@ m4_if([$1$2$3], $[1]$[2]$[3], [],
|
||||
# helping macros. So don't put any directly in the Bison file.
|
||||
AT_BISON_OPTION_PUSHDEFS([$5])
|
||||
AT_DATA_GRAMMAR([[input.y]],
|
||||
[[%code "requires" {
|
||||
[[%code requires {
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -196,8 +196,8 @@ m4_ifval([$6], [%union
|
||||
{
|
||||
int ival;
|
||||
}])
|
||||
AT_LALR1_CC_IF([%define "global_tokens_and_yystype"])
|
||||
m4_ifval([$6], [[%code "provides" {]], [[%code {]])
|
||||
AT_LALR1_CC_IF([%define global_tokens_and_yystype])
|
||||
m4_ifval([$6], [[%code provides {]], [[%code {]])
|
||||
AT_LALR1_CC_IF([typedef yy::location YYLTYPE;])
|
||||
[static int yylex (]AT_LEX_FORMALS[);
|
||||
]AT_LALR1_CC_IF([], [static void yyerror (const char *msg);])
|
||||
|
||||
@@ -41,7 +41,7 @@ AT_DATA_GRAMMAR([calc.y],
|
||||
[[/* Infix notation calculator--calc */
|
||||
]$4
|
||||
AT_SKEL_CC_IF(
|
||||
[%define "global_tokens_and_yystype"])[
|
||||
[%define global_tokens_and_yystype])[
|
||||
%{
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
@@ -710,81 +710,81 @@ AT_CLEANUP
|
||||
AT_SETUP([Reject unused %code qualifiers])
|
||||
|
||||
AT_DATA([input-c.y],
|
||||
[[%code "" {}
|
||||
%code "bad" {}
|
||||
%code "bad" {}
|
||||
[[%code q {}
|
||||
%code bad {}
|
||||
%code bad {}
|
||||
%%
|
||||
start: ;
|
||||
]])
|
||||
AT_CHECK([[bison input-c.y]], [0], [],
|
||||
[[input-c.y:1.7-8: warning: %code qualifier `' is not used
|
||||
input-c.y:2.7-11: warning: %code qualifier `bad' is not used
|
||||
input-c.y:3.7-11: warning: %code qualifier `bad' is not used
|
||||
[[input-c.y:1.7: warning: %code qualifier `q' is not used
|
||||
input-c.y:2.7-9: warning: %code qualifier `bad' is not used
|
||||
input-c.y:3.7-9: warning: %code qualifier `bad' is not used
|
||||
]])
|
||||
|
||||
AT_DATA([input-c-glr.y],
|
||||
[[%code "" {}
|
||||
%code "bad" {}
|
||||
%code "bad" {}
|
||||
[[%code q {}
|
||||
%code bad {}
|
||||
%code bad {}
|
||||
%%
|
||||
start: ;
|
||||
]])
|
||||
AT_CHECK([[bison input-c-glr.y]], [0], [],
|
||||
[[input-c-glr.y:1.7-8: warning: %code qualifier `' is not used
|
||||
input-c-glr.y:2.7-11: warning: %code qualifier `bad' is not used
|
||||
input-c-glr.y:3.8-12: warning: %code qualifier `bad' is not used
|
||||
[[input-c-glr.y:1.7: warning: %code qualifier `q' is not used
|
||||
input-c-glr.y:2.7-9: warning: %code qualifier `bad' is not used
|
||||
input-c-glr.y:3.8-10: warning: %code qualifier `bad' is not used
|
||||
]])
|
||||
|
||||
AT_DATA([input-c++.y],
|
||||
[[%code "" {}
|
||||
%code "bad" {}
|
||||
%code "" {}
|
||||
[[%code q {}
|
||||
%code bad {}
|
||||
%code q {}
|
||||
%%
|
||||
start: ;
|
||||
]])
|
||||
AT_CHECK([[bison input-c++.y]], [0], [],
|
||||
[[input-c++.y:1.7-8: warning: %code qualifier `' is not used
|
||||
input-c++.y:2.7-11: warning: %code qualifier `bad' is not used
|
||||
input-c++.y:3.8-9: warning: %code qualifier `' is not used
|
||||
[[input-c++.y:1.7: warning: %code qualifier `q' is not used
|
||||
input-c++.y:2.7-9: warning: %code qualifier `bad' is not used
|
||||
input-c++.y:3.8: warning: %code qualifier `q' is not used
|
||||
]])
|
||||
|
||||
AT_DATA([input-c++-glr.y],
|
||||
[[%code "bad" {}
|
||||
%code "" {}
|
||||
%code "" {}
|
||||
[[%code bad {}
|
||||
%code q {}
|
||||
%code q {}
|
||||
%%
|
||||
start: ;
|
||||
]])
|
||||
AT_CHECK([[bison input-c++-glr.y]], [0], [],
|
||||
[[input-c++-glr.y:1.7-11: warning: %code qualifier `bad' is not used
|
||||
input-c++-glr.y:2.7-8: warning: %code qualifier `' is not used
|
||||
input-c++-glr.y:3.7-8: warning: %code qualifier `' is not used
|
||||
[[input-c++-glr.y:1.7-9: warning: %code qualifier `bad' is not used
|
||||
input-c++-glr.y:2.7: warning: %code qualifier `q' is not used
|
||||
input-c++-glr.y:3.7: warning: %code qualifier `q' is not used
|
||||
]])
|
||||
|
||||
AT_DATA([special-char-@@.y],
|
||||
[[%code "bad" {}
|
||||
%code "" {}
|
||||
%code "" {}
|
||||
[[%code bad {}
|
||||
%code q {}
|
||||
%code q {}
|
||||
%%
|
||||
start: ;
|
||||
]])
|
||||
AT_CHECK([[bison special-char-@@.y]], [0], [],
|
||||
[[special-char-@@.y:1.7-11: warning: %code qualifier `bad' is not used
|
||||
special-char-@@.y:2.7-8: warning: %code qualifier `' is not used
|
||||
special-char-@@.y:3.7-8: warning: %code qualifier `' is not used
|
||||
[[special-char-@@.y:1.7-9: warning: %code qualifier `bad' is not used
|
||||
special-char-@@.y:2.7: warning: %code qualifier `q' is not used
|
||||
special-char-@@.y:3.7: warning: %code qualifier `q' is not used
|
||||
]])
|
||||
|
||||
AT_DATA([special-char-@:>@.y],
|
||||
[[%code "bad" {}
|
||||
%code "" {}
|
||||
%code "" {}
|
||||
[[%code bad {}
|
||||
%code q {}
|
||||
%code q {}
|
||||
%%
|
||||
start: ;
|
||||
]])
|
||||
AT_CHECK([[bison special-char-@:>@.y]], [0], [],
|
||||
[[special-char-@:>@.y:1.7-11: warning: %code qualifier `bad' is not used
|
||||
special-char-@:>@.y:2.7-8: warning: %code qualifier `' is not used
|
||||
special-char-@:>@.y:3.7-8: warning: %code qualifier `' is not used
|
||||
[[special-char-@:>@.y:1.7-9: warning: %code qualifier `bad' is not used
|
||||
special-char-@:>@.y:2.7: warning: %code qualifier `q' is not used
|
||||
special-char-@:>@.y:3.7: warning: %code qualifier `q' is not used
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
@@ -797,23 +797,23 @@ AT_CLEANUP
|
||||
AT_SETUP([%define errors])
|
||||
|
||||
AT_DATA([input.y],
|
||||
[[%define "var" "value1"
|
||||
%define "var" "value1"
|
||||
%define "var" "value2"
|
||||
%define "special1" "@:>@"
|
||||
%define "special2" "@<:@"
|
||||
[[%define var "value1"
|
||||
%define var "value1"
|
||||
%define var "value2"
|
||||
%define special1 "@:>@"
|
||||
%define special2 "@<:@"
|
||||
%%
|
||||
start: ;
|
||||
]])
|
||||
|
||||
AT_CHECK([[bison input.y]], [0], [],
|
||||
[[input.y:2.9-13: warning: %define variable `var' redefined
|
||||
input.y:3.10-14: warning: %define variable `var' redefined
|
||||
input.y:1.9-13: warning: %define variable `var' is not used
|
||||
input.y:2.9-13: warning: %define variable `var' is not used
|
||||
input.y:3.10-14: warning: %define variable `var' is not used
|
||||
input.y:4.9-18: warning: %define variable `special1' is not used
|
||||
input.y:5.9-18: warning: %define variable `special2' is not used
|
||||
[[input.y:2.9-11: warning: %define variable `var' redefined
|
||||
input.y:3.10-12: warning: %define variable `var' redefined
|
||||
input.y:1.9-11: warning: %define variable `var' is not used
|
||||
input.y:2.9-11: warning: %define variable `var' is not used
|
||||
input.y:3.10-12: warning: %define variable `var' is not used
|
||||
input.y:4.9-16: warning: %define variable `special1' is not used
|
||||
input.y:5.9-16: warning: %define variable `special2' is not used
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
Reference in New Issue
Block a user