Пример #1
0
void
complain_args (location const *loc, warnings w, unsigned *indent,
               int argc, char *argv[])
{
  switch (argc)
  {
  case 1:
    complain_indent (loc, w, indent, "%s", _(argv[0]));
    break;
  case 2:
    complain_indent (loc, w, indent, _(argv[0]), argv[1]);
    break;
  case 3:
    complain_indent (loc, w, indent, _(argv[0]), argv[1], argv[2]);
    break;
  case 4:
    complain_indent (loc, w, indent, _(argv[0]), argv[1], argv[2], argv[3]);
    break;
  case 5:
    complain_indent (loc, w, indent, _(argv[0]), argv[1], argv[2], argv[3],
                     argv[4]);
    break;
  default:
    complain (loc, fatal, "too many arguments for complains");
    break;
  }
}
Пример #2
0
void
duplicate_directive (char const *directive,
                     location first, location second)
{
  unsigned i = 0;
  complain (&second, complaint, _("only one %s allowed per rule"), directive);
  i += SUB_INDENT;
  complain_indent (&first, complaint, &i, _("previous declaration"));
}
Пример #3
0
void
muscle_percent_define_insert (char const *var, location variable_loc,
                              muscle_kind kind,
                              char const *value,
                              muscle_percent_define_how how)
{
  /* Backward compatibility.  */
  char *variable = muscle_percent_variable_update (var, variable_loc, &value);
  uniqstr name = muscle_name (variable, NULL);
  uniqstr loc_name = muscle_name (variable, "loc");
  uniqstr syncline_name = muscle_name (variable, "syncline");
  uniqstr how_name = muscle_name (variable, "how");
  uniqstr kind_name = muscle_name (variable, "kind");

  /* 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)
        goto end;
      complain_indent (&variable_loc, complaint, &i,
                       _("%%define variable %s redefined"),
                       quote (variable));
      i += SUB_INDENT;
      location loc = muscle_percent_define_get_loc (variable);
      complain_indent (&loc, complaint, &i, _("previous definition"));
    }

  MUSCLE_INSERT_STRING (name, value);
  muscle_insert (loc_name, "");
  muscle_location_grow (loc_name, variable_loc);
  muscle_insert (syncline_name, "");
  muscle_syncline_grow (syncline_name, variable_loc);
  muscle_user_name_list_grow ("percent_define_user_variables", variable,
                              variable_loc);
  MUSCLE_INSERT_INT (how_name, how);
  MUSCLE_INSERT_STRING (kind_name, muscle_kind_string (kind));
 end:
  free (variable);
}
Пример #4
0
void
muscle_percent_define_check_values (char const * const *values)
{
  for (; *values; ++values)
    {
      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)
            {
              if (STREQ (value, *values))
                break;
            }
          if (!*values)
            {
              unsigned i = 0;
              location loc = muscle_percent_define_get_loc (*variablep);
              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_indent (&loc, complaint | no_caret | silent, &i,
                                 _("accepted value: %s"), quote (*values));
            }
          else
            {
              while (*values)
                ++values;
            }
          free (value);
        }
      else
        complain (NULL, fatal, _("%s: undefined %%define variable %s"),
                  "muscle_percent_define_check_values", quote (*variablep));
    }
}