#define COMMON_DECODE(Value) \
case '$': \
- aver (*++(Value) == ']'); \
- aver (*++(Value) == '['); \
+ ++(Value); aver (*(Value) == '['); \
+ ++(Value); aver (*(Value) == ']'); \
+ ++(Value); aver (*(Value) == '['); \
obstack_sgrow (&muscle_obstack, "$"); \
break; \
case '@': \
location loc;
aver (value);
aver (*value == '[');
- aver (*++value == '[');
+ ++value; aver (*value == '[');
while (*++value)
switch (*value)
{
case ']':
{
char *boundary_str;
- aver (*++value == ']');
+ ++value; aver (*value == ']');
boundary_str = obstack_finish0 (&muscle_obstack);
switch (*++value)
{
case ',':
boundary_set_from_string (&loc.start, boundary_str);
obstack_free (&muscle_obstack, boundary_str);
- aver (*++value == ' ');
- aver (*++value == '[');
- aver (*++value == '[');
+ ++value; aver (*value == ' ');
+ ++value; aver (*value == '[');
+ ++value; aver (*value == '[');
break;
case '\0':
boundary_set_from_string (&loc.end, boundary_str);
/* The value of %define variable VARIABLE (corresponding to FIELD, if
defined). Do not register as used, but diagnose unset variables. */
+static
char const *
muscle_percent_define_get_raw (char const *variable, char const *field)
{
return value;
}
+/* The kind of VARIABLE. An error if undefined. */
+static muscle_kind
+muscle_percent_define_get_kind (char const *variable)
+{
+ return muscle_kind_new (muscle_percent_define_get_raw (variable, "kind"));
+}
+
+/* Check the kind of VARIABLE. An error if undefined. */
+static void
+muscle_percent_define_check_kind (char const *variable, muscle_kind kind)
+{
+ if (muscle_percent_define_get_kind (variable) != kind)
+ {
+ location loc = muscle_percent_define_get_loc (variable);
+ switch (kind)
+ {
+ case muscle_code:
+ complain (&loc, Wdeprecated,
+ "%%define variable '%s' requires '{...}' values",
+ variable);
+ break;
+ case muscle_keyword:
+ complain (&loc, Wdeprecated,
+ "%%define variable '%s' requires keyword values",
+ variable);
+ break;
+ case muscle_string:
+ complain (&loc, Wdeprecated,
+ "%%define variable '%s' requires '\"...\"' values",
+ variable);
+ break;
+ }
+ }
+}
+
+
location
muscle_percent_define_get_loc (char const *variable)
{
if (muscle_percent_define_ifdef (variable))
{
char *value = muscle_percent_define_get (variable);
+ muscle_percent_define_check_kind (variable, muscle_keyword);
if (value[0] == '\0' || STREQ (value, "true"))
result = true;
else if (STREQ (value, "false"))
if (!muscle_find_const (name))
{
MUSCLE_INSERT_STRING (name, value);
+ MUSCLE_INSERT_STRING (muscle_name (variable, "kind"), "keyword");
{
uniqstr loc_name = muscle_name (variable, "loc");
location loc;
char const * const *variablep = values;
uniqstr name = muscle_name (*variablep, NULL);
char *value = string_decode (name);
+ muscle_percent_define_check_kind (*variablep, muscle_keyword);
if (value)
{
for (++values; *values; ++values)