variables: use singular in %define variable names

See http://lists.gnu.org/archive/html/bison-patches/2012-02/msg00045.html

* doc/bison.texi, src/lalr.c, src/main.c, src/muscle-tab.c,
* src/print.c, src/reader.c, src/tables.c, tests/conflicts.at,
* tests/input.at, tests/reduce.at:
s/lr.default-reductions/lr.default-reduction/
s/lr.keep-unreachable-states/lr.keep-unreachable-state/.
* NEWS: Document.
This commit is contained in:
Akim Demaille
2012-10-16 13:57:31 +02:00
parent 2a6b66c5fd
commit f3bc338643
11 changed files with 62 additions and 50 deletions

8
NEWS
View File

@@ -211,11 +211,15 @@ GNU Bison NEWS
use these prefixed token names, although the grammar itself still
uses the short names (as in the sample rule given above).
** Variable api.namespace
** Renamed %define variables
The 'namespace' variable is renamed 'api.namespace'. Backward
The following variables have been renamed for consistency. Backward
compatibility is ensured, but upgrading is recommended.
lr.default-reductions -> lr.default-reduction
lr.keep-unreachable-states -> lr.keep-unreachable-state
namespace -> api.namespace
** Variable parse.error
This variable controls the verbosity of error messages. The use of the

View File

@@ -5608,10 +5608,10 @@ Boolean.
@c lex_symbol
@c ================================================== lr.default-reductions
@c ================================================== lr.default-reduction
@item lr.default-reductions
@findex %define lr.default-reductions
@item lr.default-reduction
@findex %define lr.default-reduction
@itemize @bullet
@item Language(s): all
@@ -5627,12 +5627,15 @@ feedback will help to stabilize it.)
@item @code{accepting} if @code{lr.type} is @code{canonical-lr}.
@item @code{most} otherwise.
@end itemize
@item History:
introduced as @code{lr.default-reduction} in 2.5, renamed as
@code{lr.default-reduction} in 2.8.
@end itemize
@c ============================================ lr.keep-unreachable-states
@c ============================================ lr.keep-unreachable-state
@item lr.keep-unreachable-states
@findex %define lr.keep-unreachable-states
@item lr.keep-unreachable-state
@findex %define lr.keep-unreachable-state
@itemize @bullet
@item Language(s): all
@@ -5641,7 +5644,10 @@ remain in the parser tables. @xref{Unreachable States}.
@item Accepted Values: Boolean
@item Default Value: @code{false}
@end itemize
@c lr.keep-unreachable-states
introduced as @code{lr.keep_unreachable_states} in 2.3b, renamed as
@code{lr.keep-unreachable-state} in 2.5, and as
@code{lr.keep-unreachable-state} in 2.8.
@c lr.keep-unreachable-state
@c ================================================== lr.type
@@ -7685,7 +7691,7 @@ and the benefits of IELR, @pxref{Bibliography,,Denny 2008 March}, and
@node Default Reductions
@subsection Default Reductions
@cindex default reductions
@findex %define lr.default-reductions
@findex %define lr.default-reduction
@findex %nonassoc
After parser table construction, Bison identifies the reduction with the
@@ -7767,9 +7773,9 @@ token for which there is a conflict. The correct action in this case is to
split the parse instead.
To adjust which states have default reductions enabled, use the
@code{%define lr.default-reductions} directive.
@code{%define lr.default-reduction} directive.
@deffn {Directive} {%define lr.default-reductions @var{WHERE}}
@deffn {Directive} {%define lr.default-reduction @var{WHERE}}
Specify the kind of states that are permitted to contain default reductions.
The accepted values of @var{WHERE} are:
@itemize
@@ -7892,7 +7898,7 @@ parser community for years, for the publication that introduces LAC,
@node Unreachable States
@subsection Unreachable States
@findex %define lr.keep-unreachable-states
@findex %define lr.keep-unreachable-state
@cindex unreachable states
If there exists no sequence of transitions from the parser's start state to
@@ -7905,7 +7911,7 @@ resolution because they are useless in the generated parser. However,
keeping unreachable states is sometimes useful when trying to understand the
relationship between the parser and the grammar.
@deffn {Directive} {%define lr.keep-unreachable-states @var{VALUE}}
@deffn {Directive} {%define lr.keep-unreachable-state @var{VALUE}}
Request that Bison allow unreachable states to remain in the parser tables.
@var{VALUE} must be a Boolean. The default is @code{false}.
@end deffn

View File

@@ -371,7 +371,7 @@ initialize_LA (void)
bool default_reduction_only_for_accept;
{
char *default_reductions =
muscle_percent_define_get ("lr.default-reductions");
muscle_percent_define_get ("lr.default-reduction");
default_reduction_only_for_accept = STREQ (default_reductions, "accepting");
free (default_reductions);
}

View File

@@ -125,7 +125,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-state"))
{
state_number *old_to_new = xnmalloc (nstates, sizeof *old_to_new);
state_number nstates_old = nstates;

View File

@@ -400,7 +400,9 @@ muscle_percent_variable_update (char const *variable, location variable_loc)
{ "api.push_pull", "api.push-pull", },
{ "api.tokens.prefix", "api.token.prefix", },
{ "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", },
};
char const *res = variable;

View File

@@ -334,7 +334,7 @@ print_reductions (FILE *out, state *s)
if (default_reduction)
{
char *default_reductions =
muscle_percent_define_get ("lr.default-reductions");
muscle_percent_define_get ("lr.default-reduction");
print_reduction (out, width, _("$default"), default_reduction, true);
aver (STREQ (default_reductions, "most")
|| (STREQ (default_reductions, "consistent")

View File

@@ -641,7 +641,7 @@ static void
prepare_percent_define_front_end_variables (void)
{
/* Set %define front-end variable defaults. */
muscle_percent_define_default ("lr.keep-unreachable-states", "false");
muscle_percent_define_default ("lr.keep-unreachable-state", "false");
{
char *lr_type;
/* IELR would be a better default, but LALR is historically the
@@ -649,9 +649,9 @@ prepare_percent_define_front_end_variables (void)
muscle_percent_define_default ("lr.type", "lalr");
lr_type = muscle_percent_define_get ("lr.type");
if (STRNEQ (lr_type, "canonical-lr"))
muscle_percent_define_default ("lr.default-reductions", "most");
muscle_percent_define_default ("lr.default-reduction", "most");
else
muscle_percent_define_default ("lr.default-reductions", "accepting");
muscle_percent_define_default ("lr.default-reduction", "accepting");
free (lr_type);
}
@@ -659,7 +659,7 @@ prepare_percent_define_front_end_variables (void)
{
static char const * const values[] = {
"lr.type", "lalr", "ielr", "canonical-lr", NULL,
"lr.default-reductions", "most", "consistent", "accepting", NULL,
"lr.default-reduction", "most", "consistent", "accepting", NULL,
NULL
};
muscle_percent_define_check_values (values);

View File

@@ -308,7 +308,7 @@ action_row (state *s)
labeled as consistent. */
{
char *default_reductions =
muscle_percent_define_get ("lr.default-reductions");
muscle_percent_define_get ("lr.default-reduction");
if (STRNEQ (default_reductions, "most") && !s->consistent)
nodefault = true;
free (default_reductions);

View File

@@ -117,10 +117,10 @@ AT_NONASSOC_AND_EOF_CHECK([], [[incorrect]])
# We must disable default reductions in inconsistent states in order to
# have an explicit list of all expected tokens.
AT_NONASSOC_AND_EOF_CHECK([[-Dlr.default-reductions=consistent]],
AT_NONASSOC_AND_EOF_CHECK([[-Dlr.default-reduction=consistent]],
[[correct]])
# lr.default-reductions=consistent happens to work for this test case.
# lr.default-reduction=consistent happens to work for this test case.
# However, for other grammars, lookahead sets can be merged for
# different left contexts, so it is still possible to have an incorrect
# expected list. Canonical LR is almost a general solution (that is, it
@@ -310,12 +310,12 @@ AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr
# Even canonical LR doesn't foresee the error for 'a'!
AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr
%define lr.default-reductions consistent]],
%define lr.default-reduction consistent]],
[AT_PREVIOUS_STATE_GRAMMAR],
[AT_PREVIOUS_STATE_INPUT],
[[$end]], [[ab]])
AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr
%define lr.default-reductions accepting]],
%define lr.default-reduction accepting]],
[AT_PREVIOUS_STATE_GRAMMAR],
[AT_PREVIOUS_STATE_INPUT],
[[$end]], [[ab]])
@@ -396,13 +396,13 @@ AT_CONSISTENT_ERRORS_CHECK([[%glr-parser]],
[['b']], [[none]])
# No C++ or Java test because yychar cannot be manipulated by users.
AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reductions consistent]],
AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reduction consistent]],
[AT_USER_ACTION_GRAMMAR],
[AT_USER_ACTION_INPUT],
[['b']], [[none]])
# Canonical LR doesn't foresee the error for 'a'!
AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reductions accepting]],
AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reduction accepting]],
[AT_USER_ACTION_GRAMMAR],
[AT_USER_ACTION_INPUT],
[[$end]], [[a]])
@@ -416,7 +416,7 @@ AT_CONSISTENT_ERRORS_CHECK([[%define parse.lac full]],
[AT_USER_ACTION_INPUT],
[['b']], [[none]])
AT_CONSISTENT_ERRORS_CHECK([[%define parse.lac full
%define lr.default-reductions accepting]],
%define lr.default-reduction accepting]],
[AT_USER_ACTION_GRAMMAR],
[AT_USER_ACTION_INPUT],
[[$end]], [[none]])
@@ -1293,7 +1293,7 @@ state 7
]])
AT_DATA([[input-keep.y]],
[[%define lr.keep-unreachable-states
[[%define lr.keep-unreachable-state
]])
AT_CHECK([[cat input.y >> input-keep.y]])

View File

@@ -1139,15 +1139,15 @@ AT_SETUP([[%define enum variables]])
# Front-end.
AT_DATA([[input.y]],
[[%define lr.default-reductions bogus
[[%define lr.default-reduction bogus
%%
start: ;
]])
AT_BISON_CHECK([[input.y]], [[1]], [[]],
[[input.y:1.9-29: error: invalid value for %define variable 'lr.default-reductions': 'bogus'
input.y:1.9-29: accepted value: 'most'
input.y:1.9-29: accepted value: 'consistent'
input.y:1.9-29: accepted value: 'accepting'
[[input.y:1.9-28: error: invalid value for %define variable 'lr.default-reduction': 'bogus'
input.y:1.9-28: accepted value: 'most'
input.y:1.9-28: accepted value: 'consistent'
input.y:1.9-28: accepted value: 'accepting'
]])
# Back-end.
@@ -1194,8 +1194,8 @@ AT_DATA([[input.y]],
start: ;
]])
AT_BISON_CHECK([[input.y]], [1], [],
[[input.y:1.9-34: warning: deprecated %define variable name: 'lr.keep_unreachable_states', use 'lr.keep-unreachable-states' [-Wdeprecated]
input.y:1.9-34: error: invalid value for %define Boolean variable 'lr.keep-unreachable-states'
[[input.y:1.9-34: warning: deprecated %define variable name: 'lr.keep_unreachable_states', use 'lr.keep-unreachable-state' [-Wdeprecated]
input.y:1.9-34: error: invalid value for %define Boolean variable 'lr.keep-unreachable-state'
]])
AT_DATA([[input.y]],

View File

@@ -396,7 +396,7 @@ AT_TEST_LR_TYPE([[Single State Split]],
[[%left 'a'
// Conflict resolution renders state 12 unreachable for canonical LR(1). We
// keep it so that the paser table diff is easier to code.
%define lr.keep-unreachable-states]],
%define lr.keep-unreachable-state]],
[[
S: 'a' A 'a' /* rule 1 */
| 'b' A 'b' /* rule 2 */
@@ -629,7 +629,7 @@ AT_TEST_LR_TYPE([[Lane Split]],
[[%left 'a'
// Conflict resolution renders state 16 unreachable for canonical LR(1). We
// keep it so that the paser table diff is easier to code.
%define lr.keep-unreachable-states]],
%define lr.keep-unreachable-state]],
[[
/* Similar to the last test case set but two states must be split. */
S: 'a' A 'a' /* rule 1 */
@@ -873,7 +873,7 @@ AT_TEST_LR_TYPE([[Complex Lane Split]],
[[%left 'a'
// Conflict resolution renders state 16 unreachable for canonical LR(1). We
// keep it so that the paser table diff is easier to code.
%define lr.keep-unreachable-states]],
%define lr.keep-unreachable-state]],
[[
/* Similar to the last test case set but forseeing the S/R conflict from the
first state that must be split is becoming difficult. Imagine if B were
@@ -1139,7 +1139,7 @@ dnl PARSER-EXIT-VALUE, PARSER-STDOUT, PARSER-STDERR
]])])
AT_TEST_LR_TYPE([[Split During Added Lookahead Propagation]],
[[%define lr.keep-unreachable-states]],
[[%define lr.keep-unreachable-state]],
[[
/* The partial state chart diagram below is for LALR(1). State 0 is the start
state. States are iterated for successor construction in numerical order.
@@ -1443,28 +1443,28 @@ dnl PARSER-EXIT-VALUE, PARSER-STDOUT, PARSER-STDERR
## ------------------------------- ##
## %define lr.default-reductions. ##
## %define lr.default-reduction. ##
## ------------------------------- ##
# AT_TEST_LR_DEFAULT_REDUCTIONS(GRAMMAR, INPUT, TABLES)
# -----------------------------------------------------
m4_define([AT_TEST_LR_DEFAULT_REDUCTIONS],
[
AT_TEST_TABLES_AND_PARSE([[no %define lr.default-reductions]],
AT_TEST_TABLES_AND_PARSE([[no %define lr.default-reduction]],
[[most]], [[]],
[[]],
[$1], [$2], [[]], [$3])
AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions most]],
AT_TEST_TABLES_AND_PARSE([[%define lr.default-reduction most]],
[[most]], [[]],
[[%define lr.default-reductions most]],
[[%define lr.default-reduction most]],
[$1], [$2], [[]], [$3])
AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions consistent]],
AT_TEST_TABLES_AND_PARSE([[%define lr.default-reduction consistent]],
[[consistent]], [[]],
[[%define lr.default-reductions consistent]],
[[%define lr.default-reduction consistent]],
[$1], [$2], [[]], [$3])
AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions accepting]],
AT_TEST_TABLES_AND_PARSE([[%define lr.default-reduction accepting]],
[[accepting]], [[]],
[[%define lr.default-reductions accepting]],
[[%define lr.default-reduction accepting]],
[$1], [$2], [[]], [$3])
])