X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/f6b561d9f9cbc6fc95bbb86518372a5cb52f45a6..53f8e4096d887c53d04e180f759016d3d12013db:/src/muscle-tab.c diff --git a/src/muscle-tab.c b/src/muscle-tab.c index 1789280f..28cfe561 100644 --- a/src/muscle-tab.c +++ b/src/muscle-tab.c @@ -384,11 +384,23 @@ muscle_user_name_list_grow (char const *key, char const *user_name, muscle_grow (key, "]]", ""); } +static +char * +define_directive (char const *assignment, char const *value) +{ + char const *fmt = value && *value ? "%%define %s %s" : "%%define %s"; + char *res = xmalloc (strlen (fmt) + strlen (assignment) + + (value ? strlen (value) : 0)); + sprintf (res, fmt, assignment, value); + return res; +} + /** If the \a variable name is obsolete, return the name to use, * otherwise \a variable. */ static char const * -muscle_percent_variable_update (char const *variable, location variable_loc) +muscle_percent_variable_update (char const *variable, location variable_loc, + char const **value) { typedef struct { @@ -398,21 +410,28 @@ muscle_percent_variable_update (char const *variable, location variable_loc) const conversion_type conversion[] = { { "api.push_pull", "api.push-pull", }, + { "api.tokens.prefix", "api.token.prefix", }, + { "lex_symbol", "api.token.constructor", }, { "location_type", "api.location.type", }, - { "lr.keep_unreachable_states", "lr.keep-unreachable-states", }, + { "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", }, + { NULL, NULL, } }; char const *res = variable; - int i; - for (i = 0; i < ARRAY_CARDINALITY (conversion); ++i) - if (STREQ (conversion[i].obsolete, variable)) + conversion_type const *c; + for (c = conversion; c->obsolete; ++c) + if (STREQ (c->obsolete, variable)) { - res = conversion[i].updated; - complain (&variable_loc, Wdeprecated, - _("deprecated %%define variable name: %s, use %s"), - quote (variable), quote_n (1, res)); + char *old = define_directive (c->obsolete, *value); + char *upd = define_directive (c->updated, *value); + deprecated_directive (&variable_loc, old, upd); + free (old); + free (upd); + res = c->updated; break; - } + } return res; } @@ -422,7 +441,7 @@ muscle_percent_define_insert (char const *var, location variable_loc, muscle_percent_define_how how) { /* Backward compatibility. */ - char const *variable = muscle_percent_variable_update (var, variable_loc); + char *variable = muscle_percent_variable_update (var, variable_loc, &value); char const *name = UNIQSTR_CONCAT ("percent_define(", variable, ")"); char const *loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")"); char const *syncline_name = @@ -605,8 +624,8 @@ muscle_percent_define_check_values (char const * const *values) quote (*variablep), quote_n (1, value)); i += SUB_INDENT; for (values = variablep + 1; *values; ++values) - complain_indent (&loc, complaint, &i, _("accepted value: %s"), - quote (*values)); + complain_indent (&loc, complaint | no_caret, &i, + _("accepted value: %s"), quote (*values)); } else {