mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 13:23:04 +00:00
Instead of having skeletons declare all valid %define variables and
%code qualifiers, provide macros that retrieve the associated values
and build these lists automatically. Thus Bison will now warn when a
variable or qualifier is not used by the skeleton in the current
invocation regardless of whether it might sometimes be used by that
skeleton in other invocations. Also, move all %define value macros to
the b4_percent_define_ namespace, and remove the %define "NAME" {CODE}
form, which is replaced by %code.
* data/bison.m4 (b4_check_for_unrecognized_names): Rename to...
(b4_check_user_names): ... this, and change the series of valid name
arguments to a single list argument for names used in the skeleton
similar to the existing list argument for names used in the grammar.
Warn instead of complaining.
(b4_get_percent_define, b4_get_percent_code): New to retrieve %define
values and %code code, to format %code code properly, and to build
lists of all %define variables and %code qualifiers used in the
skeleton: b4_skeleton_percent_define_variables and
b4_skeleton_percent_code_qualifiers.
(b4_check_percent_define_variables, b4_check_percent_code_qualifiers):
Remove, and...
(m4_wrap): ... m4_wrap b4_check_user_names invocations instead so that
the skeleton names lists can finish building first. In place of
b4_used_percent_define_variables and b4_used_percent_code_qualifiers,
expect the lists b4_user_percent_define_variables and
b4_user_percent_code_qualifiers.
* data/c++.m4: Where setting default values for b4_parser_class_name,
b4_location_type, b4_filename_type, b4_namespace, and
b4_define_location_comparison, update their names to the
b4_percent_define_ namespace.
* data/glr.c: Don't use b4_check_percent_define_variables and
b4_check_percent_code_qualifiers. Use b4_get_percent_code.
* data/glr.cc, data/lalr1.cc: Likewise, and use b4_get_percent_define.
(b4_parser_class_name, b4_namespace): Define these using
b4_get_percent_define for parser_class_name and namespace. Normally
this would be a bad idea since there might be cases when the variables
aren't used, but these variables are too pervasive in these skeletons
for that to be a problem.
* data/location.cc: Use b4_get_percent_define.
* data/push.c: Don't use b4_check_percent_define_variables and
b4_check_percent_code_qualifiers. Use b4_get_percent_code.
* data/yacc.c: Likewise, and don't call m4_exit in
b4_use_push_for_pull_if or m4_wrap code will never execute.
* src/muscle_tab.c, src/muscle_tab.h (muscle_grow_used_name_list):
Rename to...
(muscle_grow_user_name_list): ... this for consistency with the
terminology used in bison.m4.
* src/parse-gram.y (prologue_declaration): Prepend "percent_define_" to
%define variable names, and rename muscle used_percent_define_variables
to user_percent_define_variables.
(grammar_declaration): Rename muscle used_percent_code_qualifiers to
user_percent_code_qualifiers.
(content): Remove.
(content.opt): Replace content RHS with STRING RHS so %define "NAME"
{CODE} form is no longer accepted.
* tests/input.at (Reject bad %code qualifiers): Rename to...
(Reject unused %code qualifiers): ... this, and update test output.
(%define error): Update test output.
This commit is contained in:
@@ -298,11 +298,11 @@ muscle_boundary_grow (char const *key, boundary bound)
|
||||
}
|
||||
|
||||
void
|
||||
muscle_grow_used_name_list (char const *key, char const *used_name,
|
||||
muscle_grow_user_name_list (char const *key, char const *user_name,
|
||||
location loc)
|
||||
{
|
||||
muscle_grow (key, "[[[[", ",");
|
||||
muscle_grow (key, used_name, "");
|
||||
muscle_grow (key, user_name, "");
|
||||
muscle_grow (key, "]], [[", "");
|
||||
muscle_boundary_grow (key, loc.start);
|
||||
muscle_grow (key, "]], [[", "");
|
||||
|
||||
@@ -117,12 +117,10 @@ void muscles_m4_output (FILE *out);
|
||||
for special characters in the file name. */
|
||||
void muscle_boundary_grow (char const *key, boundary bound);
|
||||
|
||||
/* Grow KEY for the occurrence of the name USED_NAME at LOC appropriately for
|
||||
use with b4_check_for_unrecognized_names in ../data/bison.m4. USED_NAME
|
||||
is not escaped with digraphs, so it must not contain `[' or `]'. As a
|
||||
precondition on b4_check_for_unrecognized_names, it can't contain `,'
|
||||
either. */
|
||||
void muscle_grow_used_name_list (char const *key, char const *used_name,
|
||||
/* Grow KEY for the occurrence of the name USER_NAME at LOC appropriately for
|
||||
use with b4_check_user_names in ../data/bison.m4. USER_NAME is not escaped
|
||||
with digraphs, so it must not contain `[' or `]'. */
|
||||
void muscle_grow_user_name_list (char const *key, char const *user_name,
|
||||
location loc);
|
||||
|
||||
#endif /* not MUSCLE_TAB_H_ */
|
||||
|
||||
698
src/parse-gram.c
698
src/parse-gram.c
File diff suppressed because it is too large
Load Diff
@@ -165,7 +165,7 @@
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
{
|
||||
/* Line 1551 of yacc.c */
|
||||
/* Line 1535 of yacc.c */
|
||||
#line 97 "parse-gram.y"
|
||||
|
||||
symbol *symbol;
|
||||
@@ -178,7 +178,7 @@ typedef union YYSTYPE
|
||||
unsigned char character;
|
||||
}
|
||||
|
||||
/* Line 1551 of yacc.c */
|
||||
/* Line 1535 of yacc.c */
|
||||
#line 183 "parse-gram.h"
|
||||
YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
|
||||
@@ -183,12 +183,12 @@ static int current_prec = 0;
|
||||
|
||||
/* braceless is not to be used for rule or symbol actions, as it
|
||||
calls code_props_plain_init. */
|
||||
%type <chars> STRING "%{...%}" EPILOGUE braceless content content.opt
|
||||
%type <chars> STRING "%{...%}" EPILOGUE braceless content.opt
|
||||
%type <code> "{...}"
|
||||
%printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
|
||||
STRING
|
||||
%printer { fprintf (stderr, "{\n%s\n}", $$); }
|
||||
braceless content content.opt "{...}" "%{...%}" EPILOGUE
|
||||
braceless content.opt "{...}" "%{...%}" EPILOGUE
|
||||
|
||||
%type <uniqstr> TYPE ID ID_COLON
|
||||
%printer { fprintf (stderr, "<%s>", $$); } TYPE
|
||||
@@ -236,10 +236,15 @@ prologue_declaration:
|
||||
{
|
||||
/* FIXME: Special characters in $2 may break %define.
|
||||
For example: `['. */
|
||||
if (muscle_find_const ($2))
|
||||
warn_at (@2, _("%s: `%s' redefined"), "%define", $2);
|
||||
muscle_insert ($2, $3);
|
||||
muscle_grow_used_name_list ("used_percent_define_variables", $2, @2);
|
||||
char const name_prefix[] = "percent_define_";
|
||||
char *name = xmalloc (sizeof name_prefix + strlen ($2));
|
||||
strcpy (name, name_prefix);
|
||||
strcpy (name + sizeof name_prefix - 1, $2);
|
||||
if (muscle_find_const (name))
|
||||
warn_at (@2, _("%s `%s' redefined"), "%define variable", $2);
|
||||
muscle_insert (uniqstr_new (name), $3);
|
||||
free (name);
|
||||
muscle_grow_user_name_list ("user_percent_define_variables", $2, @2);
|
||||
}
|
||||
| "%defines" { defines_flag = true; }
|
||||
| "%defines" STRING
|
||||
@@ -332,7 +337,7 @@ grammar_declaration:
|
||||
muscle_code_grow (uniqstr_new (name), $3, @3);
|
||||
free (name);
|
||||
code_scanner_last_string_free ();
|
||||
muscle_grow_used_name_list ("used_percent_code_qualifiers", $2, @2);
|
||||
muscle_grow_user_name_list ("user_percent_code_qualifiers", $2, @2);
|
||||
}
|
||||
;
|
||||
|
||||
@@ -530,14 +535,9 @@ rhs:
|
||||
;
|
||||
|
||||
|
||||
/*-----------*
|
||||
| content. |
|
||||
*-----------*/
|
||||
|
||||
content:
|
||||
STRING
|
||||
| braceless
|
||||
;
|
||||
/*---------------*
|
||||
| content.opt. |
|
||||
*--------------*/
|
||||
|
||||
/* Some content or "1" by default. */
|
||||
content.opt:
|
||||
@@ -546,10 +546,14 @@ content.opt:
|
||||
static char one[] = "1";
|
||||
$$ = one;
|
||||
}
|
||||
| content
|
||||
| STRING
|
||||
;
|
||||
|
||||
|
||||
/*-------------*
|
||||
| braceless. |
|
||||
*-------------*/
|
||||
|
||||
braceless:
|
||||
"{...}"
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user