X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/ea9e670d728ac659e139434de31ea9306ecdd117..53f8e4096d887c53d04e180f759016d3d12013db:/src/muscle-tab.c diff --git a/src/muscle-tab.c b/src/muscle-tab.c index 7a112045..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 { @@ -399,23 +411,27 @@ muscle_percent_variable_update (char const *variable, location variable_loc) { { "api.push_pull", "api.push-pull", }, { "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", }, + { 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; } @@ -425,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 =