]> git.saurik.com Git - bison.git/blobdiff - src/muscle-tab.c
maint: more syntax-checks
[bison.git] / src / muscle-tab.c
index a55b6c496200a0775ce56f9d0d26f9a36187db37..86363f5011bbb35ea91757b3152da78838c1421f 100644 (file)
@@ -388,7 +388,7 @@ muscle_user_name_list_grow (char const *key, char const *user_name,
  * otherwise \a variable. */
 static
 char const *
-muscle_percent_variable_update (char const *variable)
+muscle_percent_variable_update (char const *variable, location variable_loc)
 {
   typedef struct
   {
@@ -398,46 +398,55 @@ muscle_percent_variable_update (char const *variable)
   const conversion_type conversion[] =
     {
       { "api.push_pull", "api.push-pull", },
-      { "lr.keep_unreachable_states", "lr.keep-unreachable-states", },
+      { "api.tokens.prefix", "api.token.prefix", },
+      { "lex_symbol", "api.token.constructor", },
+      { "location_type", "api.location.type", },
+      { "lr.default-reductions", "lr.default-reduction", },
+      { "lr.keep-unreachable-states", "lr.keep-unreachable-state", },
+      { "lr.keep_unreachable_states", "lr.keep-unreachable-state", },
       { "namespace", "api.namespace", },
     };
+  char const *res = variable;
   int i;
-  for (i = 0; i < sizeof conversion / sizeof *conversion; ++i)
+  for (i = 0; i < ARRAY_CARDINALITY (conversion); ++i)
     if (STREQ (conversion[i].obsolete, variable))
-      return conversion[i].updated;
-  return variable;
+      {
+        res = conversion[i].updated;
+        complain (&variable_loc, Wdeprecated,
+                  _("deprecated %%define variable name: %s, use %s"),
+                  quote (variable), quote_n (1, res));
+        break;
+      }
+  return res;
 }
 
 void
-muscle_percent_define_insert (char const *variable, location variable_loc,
+muscle_percent_define_insert (char const *var, location variable_loc,
                               char const *value,
                               muscle_percent_define_how how)
 {
-  char const *name;
-  char const *loc_name;
-  char const *syncline_name;
-  char const *how_name;
-
-  /* Permit certain names with underscores for backward compatibility.  */
-  variable = muscle_percent_variable_update (variable);
-
-  name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
-  loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
-  syncline_name =
+  /* Backward compatibility.  */
+  char const *variable = muscle_percent_variable_update (var, variable_loc);
+  char const *name = UNIQSTR_CONCAT ("percent_define(", variable, ")");
+  char const *loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
+  char const *syncline_name =
     UNIQSTR_CONCAT ("percent_define_syncline(", variable, ")");
-  how_name = UNIQSTR_CONCAT ("percent_define_how(", variable, ")");
+  char const *how_name = UNIQSTR_CONCAT ("percent_define_how(", variable, ")");
 
   /* Command-line options are processed before the grammar file.  */
   if (how == MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE
       && muscle_find_const (name))
     {
       muscle_percent_define_how how_old = atoi (muscle_find_const (how_name));
+      unsigned i = 0;
       if (how_old == MUSCLE_PERCENT_DEFINE_F)
         return;
-      complain_at (variable_loc, complaint, _("%%define variable %s redefined"),
-                   quote (variable));
+      complain_indent (&variable_loc, complaint, &i,
+                       _("%%define variable %s redefined"),
+                       quote (variable));
+      i += SUB_INDENT;
       location loc = muscle_percent_define_get_loc (variable);
-      complain_at (loc, complaint, _("previous definition"));
+      complain_indent (&loc, complaint, &i, _("previous definition"));
     }
 
   MUSCLE_INSERT_STRING (name, value);
@@ -492,7 +501,7 @@ muscle_percent_define_get_loc (char const *variable)
 {
   char const *loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
   if (!muscle_find_const (loc_name))
-    complain (fatal, _("%s: undefined %%define variable %s"),
+    complain (NULL, fatal, _("%s: undefined %%define variable %s"),
               "muscle_percent_define_get_loc", quote (variable));
   return location_decode (loc_name);
 }
@@ -504,7 +513,7 @@ muscle_percent_define_get_syncline (char const *variable)
     UNIQSTR_CONCAT ("percent_define_syncline(", variable, ")");
   char const *syncline = muscle_find_const (syncline_name);
   if (!syncline)
-    complain (fatal, _("%s: undefined %%define variable %s"),
+    complain (NULL, fatal, _("%s: undefined %%define variable %s"),
               "muscle_percent_define_get_syncline", quote (variable));
   return syncline;
 }
@@ -543,14 +552,14 @@ muscle_percent_define_flag_if (char const *variable)
         {
           muscle_insert (invalid_boolean_name, "");
           location loc = muscle_percent_define_get_loc (variable);
-          complain_at (loc, complaint,
-                       _("invalid value for %%define Boolean variable %s"),
-                       quote (variable));
+          complain (&loc, complaint,
+                    _("invalid value for %%define Boolean variable %s"),
+                    quote (variable));
         }
       free (value);
     }
   else
-    complain (fatal, _("%s: undefined %%define variable %s"),
+    complain (NULL, fatal, _("%s: undefined %%define variable %s"),
               "muscle_percent_define_flag", quote (variable));
 
   return result;
@@ -593,13 +602,15 @@ muscle_percent_define_check_values (char const * const *values)
             }
           if (!*values)
             {
+              unsigned i = 0;
               location loc = muscle_percent_define_get_loc (*variablep);
-              complain_at (loc, complaint,
-                           _("invalid value for %%define variable %s: %s"),
-                           quote (*variablep), quote_n (1, value));
+              complain_indent (&loc, complaint, &i,
+                               _("invalid value for %%define variable %s: %s"),
+                               quote (*variablep), quote_n (1, value));
+              i += SUB_INDENT;
               for (values = variablep + 1; *values; ++values)
-                complain_at (loc, complaint, _("accepted value: %s"),
-                             quote (*values));
+                complain_indent (&loc, complaint | no_caret, &i,
+                                 _("accepted value: %s"), quote (*values));
             }
           else
             {
@@ -609,7 +620,7 @@ muscle_percent_define_check_values (char const * const *values)
           free (value);
         }
       else
-        complain (fatal, _("%s: undefined %%define variable %s"),
+        complain (NULL, fatal, _("%s: undefined %%define variable %s"),
                   "muscle_percent_define_check_values", quote (*variablep));
     }
 }