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 use these prefixed token names, although the grammar itself still
uses the short names (as in the sample rule given above). 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. 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 ** Variable parse.error
This variable controls the verbosity of error messages. The use of the This variable controls the verbosity of error messages. The use of the

View File

@@ -5608,10 +5608,10 @@ Boolean.
@c lex_symbol @c lex_symbol
@c ================================================== lr.default-reductions @c ================================================== lr.default-reduction
@item lr.default-reductions @item lr.default-reduction
@findex %define lr.default-reductions @findex %define lr.default-reduction
@itemize @bullet @itemize @bullet
@item Language(s): all @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{accepting} if @code{lr.type} is @code{canonical-lr}.
@item @code{most} otherwise. @item @code{most} otherwise.
@end itemize @end itemize
@item History:
introduced as @code{lr.default-reduction} in 2.5, renamed as
@code{lr.default-reduction} in 2.8.
@end itemize @end itemize
@c ============================================ lr.keep-unreachable-states @c ============================================ lr.keep-unreachable-state
@item lr.keep-unreachable-states @item lr.keep-unreachable-state
@findex %define lr.keep-unreachable-states @findex %define lr.keep-unreachable-state
@itemize @bullet @itemize @bullet
@item Language(s): all @item Language(s): all
@@ -5641,7 +5644,10 @@ remain in the parser tables. @xref{Unreachable States}.
@item Accepted Values: Boolean @item Accepted Values: Boolean
@item Default Value: @code{false} @item Default Value: @code{false}
@end itemize @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 @c ================================================== lr.type
@@ -7685,7 +7691,7 @@ and the benefits of IELR, @pxref{Bibliography,,Denny 2008 March}, and
@node Default Reductions @node Default Reductions
@subsection Default Reductions @subsection Default Reductions
@cindex default reductions @cindex default reductions
@findex %define lr.default-reductions @findex %define lr.default-reduction
@findex %nonassoc @findex %nonassoc
After parser table construction, Bison identifies the reduction with the 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. split the parse instead.
To adjust which states have default reductions enabled, use the 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. Specify the kind of states that are permitted to contain default reductions.
The accepted values of @var{WHERE} are: The accepted values of @var{WHERE} are:
@itemize @itemize
@@ -7892,7 +7898,7 @@ parser community for years, for the publication that introduces LAC,
@node Unreachable States @node Unreachable States
@subsection Unreachable States @subsection Unreachable States
@findex %define lr.keep-unreachable-states @findex %define lr.keep-unreachable-state
@cindex unreachable states @cindex unreachable states
If there exists no sequence of transitions from the parser's start state to 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 keeping unreachable states is sometimes useful when trying to understand the
relationship between the parser and the grammar. 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. Request that Bison allow unreachable states to remain in the parser tables.
@var{VALUE} must be a Boolean. The default is @code{false}. @var{VALUE} must be a Boolean. The default is @code{false}.
@end deffn @end deffn

View File

@@ -371,7 +371,7 @@ initialize_LA (void)
bool default_reduction_only_for_accept; bool default_reduction_only_for_accept;
{ {
char *default_reductions = 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"); default_reduction_only_for_accept = STREQ (default_reductions, "accepting");
free (default_reductions); free (default_reductions);
} }

View File

@@ -125,7 +125,7 @@ main (int argc, char *argv[])
declarations. */ declarations. */
timevar_push (TV_CONFLICTS); timevar_push (TV_CONFLICTS);
conflicts_solve (); 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 *old_to_new = xnmalloc (nstates, sizeof *old_to_new);
state_number nstates_old = nstates; 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.push_pull", "api.push-pull", },
{ "api.tokens.prefix", "api.token.prefix", }, { "api.tokens.prefix", "api.token.prefix", },
{ "location_type", "api.location.type", }, { "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", }, { "namespace", "api.namespace", },
}; };
char const *res = variable; char const *res = variable;

View File

@@ -334,7 +334,7 @@ print_reductions (FILE *out, state *s)
if (default_reduction) if (default_reduction)
{ {
char *default_reductions = 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); print_reduction (out, width, _("$default"), default_reduction, true);
aver (STREQ (default_reductions, "most") aver (STREQ (default_reductions, "most")
|| (STREQ (default_reductions, "consistent") || (STREQ (default_reductions, "consistent")

View File

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

View File

@@ -308,7 +308,7 @@ action_row (state *s)
labeled as consistent. */ labeled as consistent. */
{ {
char *default_reductions = char *default_reductions =
muscle_percent_define_get ("lr.default-reductions"); muscle_percent_define_get ("lr.default-reduction");
if (STRNEQ (default_reductions, "most") && !s->consistent) if (STRNEQ (default_reductions, "most") && !s->consistent)
nodefault = true; nodefault = true;
free (default_reductions); 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 # We must disable default reductions in inconsistent states in order to
# have an explicit list of all expected tokens. # 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]]) [[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 # However, for other grammars, lookahead sets can be merged for
# different left contexts, so it is still possible to have an incorrect # different left contexts, so it is still possible to have an incorrect
# expected list. Canonical LR is almost a general solution (that is, it # 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'! # Even canonical LR doesn't foresee the error for 'a'!
AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr 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_GRAMMAR],
[AT_PREVIOUS_STATE_INPUT], [AT_PREVIOUS_STATE_INPUT],
[[$end]], [[ab]]) [[$end]], [[ab]])
AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr 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_GRAMMAR],
[AT_PREVIOUS_STATE_INPUT], [AT_PREVIOUS_STATE_INPUT],
[[$end]], [[ab]]) [[$end]], [[ab]])
@@ -396,13 +396,13 @@ AT_CONSISTENT_ERRORS_CHECK([[%glr-parser]],
[['b']], [[none]]) [['b']], [[none]])
# No C++ or Java test because yychar cannot be manipulated by users. # 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_GRAMMAR],
[AT_USER_ACTION_INPUT], [AT_USER_ACTION_INPUT],
[['b']], [[none]]) [['b']], [[none]])
# Canonical LR doesn't foresee the error for 'a'! # 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_GRAMMAR],
[AT_USER_ACTION_INPUT], [AT_USER_ACTION_INPUT],
[[$end]], [[a]]) [[$end]], [[a]])
@@ -416,7 +416,7 @@ AT_CONSISTENT_ERRORS_CHECK([[%define parse.lac full]],
[AT_USER_ACTION_INPUT], [AT_USER_ACTION_INPUT],
[['b']], [[none]]) [['b']], [[none]])
AT_CONSISTENT_ERRORS_CHECK([[%define parse.lac full 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_GRAMMAR],
[AT_USER_ACTION_INPUT], [AT_USER_ACTION_INPUT],
[[$end]], [[none]]) [[$end]], [[none]])
@@ -1293,7 +1293,7 @@ state 7
]]) ]])
AT_DATA([[input-keep.y]], AT_DATA([[input-keep.y]],
[[%define lr.keep-unreachable-states [[%define lr.keep-unreachable-state
]]) ]])
AT_CHECK([[cat input.y >> input-keep.y]]) AT_CHECK([[cat input.y >> input-keep.y]])

View File

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

View File

@@ -396,7 +396,7 @@ AT_TEST_LR_TYPE([[Single State Split]],
[[%left 'a' [[%left 'a'
// Conflict resolution renders state 12 unreachable for canonical LR(1). We // Conflict resolution renders state 12 unreachable for canonical LR(1). We
// keep it so that the paser table diff is easier to code. // 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 */ S: 'a' A 'a' /* rule 1 */
| 'b' A 'b' /* rule 2 */ | 'b' A 'b' /* rule 2 */
@@ -629,7 +629,7 @@ AT_TEST_LR_TYPE([[Lane Split]],
[[%left 'a' [[%left 'a'
// Conflict resolution renders state 16 unreachable for canonical LR(1). We // Conflict resolution renders state 16 unreachable for canonical LR(1). We
// keep it so that the paser table diff is easier to code. // 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. */ /* Similar to the last test case set but two states must be split. */
S: 'a' A 'a' /* rule 1 */ S: 'a' A 'a' /* rule 1 */
@@ -873,7 +873,7 @@ AT_TEST_LR_TYPE([[Complex Lane Split]],
[[%left 'a' [[%left 'a'
// Conflict resolution renders state 16 unreachable for canonical LR(1). We // Conflict resolution renders state 16 unreachable for canonical LR(1). We
// keep it so that the paser table diff is easier to code. // 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 /* 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 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]], 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 /* 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. 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) # AT_TEST_LR_DEFAULT_REDUCTIONS(GRAMMAR, INPUT, TABLES)
# ----------------------------------------------------- # -----------------------------------------------------
m4_define([AT_TEST_LR_DEFAULT_REDUCTIONS], 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]], [[]], [[most]], [[]],
[[]], [[]],
[$1], [$2], [[]], [$3]) [$1], [$2], [[]], [$3])
AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions most]], AT_TEST_TABLES_AND_PARSE([[%define lr.default-reduction most]],
[[most]], [[]], [[most]], [[]],
[[%define lr.default-reductions most]], [[%define lr.default-reduction most]],
[$1], [$2], [[]], [$3]) [$1], [$2], [[]], [$3])
AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions consistent]], AT_TEST_TABLES_AND_PARSE([[%define lr.default-reduction consistent]],
[[consistent]], [[]], [[consistent]], [[]],
[[%define lr.default-reductions consistent]], [[%define lr.default-reduction consistent]],
[$1], [$2], [[]], [$3]) [$1], [$2], [[]], [$3])
AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions accepting]], AT_TEST_TABLES_AND_PARSE([[%define lr.default-reduction accepting]],
[[accepting]], [[]], [[accepting]], [[]],
[[%define lr.default-reductions accepting]], [[%define lr.default-reduction accepting]],
[$1], [$2], [[]], [$3]) [$1], [$2], [[]], [$3])
]) ])