mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
List accepted values for a %define enum variable with an invalid value.
Suggested by Akim Demaille at
<http://lists.gnu.org/archive/html/bison-patches/2009-04/msg00082.html>.
* data/bison.m4 (_b4_percent_define_check_values): Implement.
* src/muscle-tab.c (muscle_percent_define_check_values): Implement.
* tests/input.at (%define lr.default_reductions invalid values): Merge
into...
(%define enum variables): ... here, and update output.
(cherry picked from commit 25029e164a)
This commit is contained in:
@@ -575,35 +575,40 @@ muscle_percent_define_check_values (char const * const *values)
|
||||
{
|
||||
for (; *values; ++values)
|
||||
{
|
||||
char const *variable = *values;
|
||||
char const * const *variablep = values;
|
||||
char const *name;
|
||||
char *value;
|
||||
|
||||
MUSCLE_USER_NAME_CONVERT (name, "percent_define(", variable, ")");
|
||||
MUSCLE_USER_NAME_CONVERT (name, "percent_define(", *variablep, ")");
|
||||
|
||||
value = muscle_string_decode (name);
|
||||
if (value)
|
||||
{
|
||||
bool valid = false;
|
||||
for (++values; *values; ++values)
|
||||
{
|
||||
if (0 == strcmp (value, *values))
|
||||
{
|
||||
valid = true;
|
||||
while (*values)
|
||||
++values;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!*values)
|
||||
{
|
||||
location loc = muscle_percent_define_get_loc (*variablep);
|
||||
complain_at(loc,
|
||||
_("invalid value for %%define variable `%s': `%s'"),
|
||||
*variablep, value);
|
||||
for (values = variablep + 1; *values; ++values)
|
||||
complain_at (loc, _("accepted value: `%s'"), *values);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (*values)
|
||||
++values;
|
||||
}
|
||||
if (!valid)
|
||||
complain_at(muscle_percent_define_get_loc (variable),
|
||||
_("invalid value for %%define variable `%s': `%s'"),
|
||||
variable, value);
|
||||
free (value);
|
||||
}
|
||||
else
|
||||
fatal(_("undefined %%define variable `%s' passed to muscle_percent_define_check_values"),
|
||||
variable);
|
||||
fatal(_("undefined %%define variable `%s' passed to"
|
||||
" muscle_percent_define_check_values"),
|
||||
*variablep);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user