This file is part of Bison, the GNU Compiler Compiler.
- Bison is free software; you can redistribute it and/or modify
+ This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- Bison is distributed in the hope that it will be useful,
+ This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Bison; see the file COPYING. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include "system.h"
char const *name;
char const *loc_name;
char const *usage_name;
+ char const *invalid_boolean_name;
bool result = false;
MUSCLE_USER_NAME_CONVERT (name, "percent_define(", variable, ")");
MUSCLE_USER_NAME_CONVERT (loc_name, "percent_define_loc(", variable, ")");
MUSCLE_USER_NAME_CONVERT (usage_name, "percent_define_bison_variables(",
variable, ")");
+ MUSCLE_USER_NAME_CONVERT (invalid_boolean_name,
+ "percent_define_invalid_boolean(", variable, ")");
if (muscle_percent_define_ifdef (variable))
{
result = true;
else if (0 == strcmp (value, "false"))
result = false;
- else if (!muscle_find_const (usage_name))
- complain_at(muscle_location_decode (loc_name),
- _("invalid value for %%define boolean variable `%s'"),
- variable);
+ else if (!muscle_find_const (invalid_boolean_name))
+ {
+ muscle_insert (invalid_boolean_name, "");
+ complain_at(muscle_location_decode (loc_name),
+ _("invalid value for %%define Boolean variable `%s'"),
+ variable);
+ }
free (value);
}
else
}
void
-muscle_percent_define_invalid_value (char const *variable)
+muscle_percent_define_check_values (char const * const *values)
{
- char const *loc_name;
- MUSCLE_USER_NAME_CONVERT (loc_name, "percent_define_loc(", variable, ")");
- complain_at(muscle_location_decode (loc_name),
- _("invalid value for %%define variable `%s'"), variable);
+ for (; *values; ++values)
+ {
+ char const *variable = *values;
+ char const *name;
+ char const *loc_name;
+ char *value;
+
+ MUSCLE_USER_NAME_CONVERT (name, "percent_define(", variable, ")");
+ MUSCLE_USER_NAME_CONVERT (loc_name, "percent_define_loc(", variable, ")");
+
+ 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;
+ }
+ }
+ if (!valid)
+ complain_at(muscle_location_decode (loc_name),
+ _("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);
+ }
}
-
void
muscle_percent_code_grow (char const *qualifier, location qualifier_loc,
char const *code, location code_loc)