Convert underscores to dashes in some %define variable names.

For now, just api.push-pull and lr.keep-unreachable-states.
Maintain old names for backward compatibility.
* NEWS (2.5): Document.
* data/c.m4 (b4_identification): Update comment.
* data/yacc.c: Update access.
* doc/bison.texinfo: Update.
* etc/bench.pl.in (bench_grammar): Update use.
* src/files.c (tr): Move to...
* src/getargs.c, src/getargs.h (tr): ... here because I can't
think of a better place to expose it.  My logic is that, for all
uses of tr so far, command-line arguments can be involved, and
getargs.h is already included.
* src/main.c (main): Update access.
* src/muscle_tab.c (muscle_percent_define_insert): Convert old
variable names to new variable names before assigning value.
* src/reader.c (reader): Update setting default.
* tests/calc.at: Update uses.
* tests/conflicts.at (Unreachable States After Conflict
Resolution): Update use.
* tests/input.at (%define enum variables): Update use.
(%define backward compatibility): New test group.
* tests/push.at: Update uses.
* tests/reduce.at: Update uses.
* tests/torture.at: Update uses.
This commit is contained in:
Joel E. Denny
2009-04-30 01:04:33 -04:00
parent 1c4aa81df1
commit 812775a039
20 changed files with 164 additions and 65 deletions

View File

@@ -1,7 +1,7 @@
/* Open and close files for Bison.
Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004,
2005, 2006, 2007, 2008 Free Software Foundation, Inc.
2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -136,15 +136,6 @@ xfclose (FILE *ptr)
| Compute ALL_BUT_EXT, ALL_BUT_TAB_EXT and output files extensions. |
`------------------------------------------------------------------*/
/* In the string S, replace all characters FROM by TO. */
static void
tr (char *s, char from, char to)
{
for (; *s; s++)
if (*s == from)
*s = to;
}
/* Compute extensions from the grammar file extension. */
static void
compute_exts_from_gf (const char *ext)

View File

@@ -663,3 +663,11 @@ getargs (int argc, char *argv[])
current_file = grammar_file = uniqstr_new (argv[optind]);
MUSCLE_INSERT_C_STRING ("file_name", grammar_file);
}
void
tr (char *s, char from, char to)
{
for (; *s; s++)
if (*s == from)
*s = to;
}

View File

@@ -140,4 +140,7 @@ void getargs (int argc, char *argv[]);
void language_argmatch (char const *arg, int prio, location loc);
void skeleton_arg (const char *arg, int prio, location loc);
/** In the string \c s, replace all characters \c from by \c to. */
void tr (char *s, char from, char to);
#endif /* !GETARGS_H_ */

View File

@@ -114,7 +114,7 @@ main (int argc, char *argv[])
declarations. */
timevar_push (TV_CONFLICTS);
conflicts_solve ();
if (!muscle_percent_define_flag_if ("lr.keep_unreachable_states"))
if (!muscle_percent_define_flag_if ("lr.keep-unreachable-states"))
{
state_number *old_to_new = xnmalloc (nstates, sizeof *old_to_new);
state_number nstates_old = nstates;

View File

@@ -403,10 +403,20 @@ void
muscle_percent_define_insert (char const *variable, location variable_loc,
char const *value)
{
char *variable_tr = NULL;
char const *name;
char const *loc_name;
char const *syncline_name;
/* Permit certain names with underscores for backward compatibility. */
if (0 == strcmp (variable, "api.push_pull")
|| 0 == strcmp (variable, "lr.keep_unreachable_states"))
{
variable_tr = strdup (variable);
tr (variable_tr, '_', '-');
variable = variable_tr;
}
MUSCLE_USER_NAME_CONVERT (name, "percent_define(", variable, ")");
MUSCLE_USER_NAME_CONVERT (loc_name, "percent_define_loc(", variable, ")");
MUSCLE_USER_NAME_CONVERT (syncline_name,
@@ -427,6 +437,8 @@ muscle_percent_define_insert (char const *variable, location variable_loc,
muscle_syncline_grow (syncline_name, variable_loc);
muscle_user_name_list_grow ("percent_define_user_variables", variable,
variable_loc);
free (variable_tr);
}
char *

View File

@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 2.4.1.52-77be. */
/* A Bison parser, made by GNU Bison 2.4.1.57-1d0f-dirty. */
/* Skeleton implementation for Bison's Yacc-like parsers in C
@@ -45,7 +45,7 @@
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "2.4.1.52-77be"
#define YYBISON_VERSION "2.4.1.57-1d0f-dirty"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"

View File

@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 2.4.1.52-77be. */
/* A Bison parser, made by GNU Bison 2.4.1.57-1d0f-dirty. */
/* Skeleton interface for Bison's Yacc-like parsers in C

View File

@@ -556,7 +556,7 @@ reader (void)
gram_parse ();
/* Set front-end %define variable defaults. */
muscle_percent_define_default ("lr.keep_unreachable_states", "false");
muscle_percent_define_default ("lr.keep-unreachable-states", "false");
{
char *lr_type;
/* IELR would be a better default, but LALR is historically the