[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Rename variant and lex_symbols options
From: |
Akim Demaille |
Subject: |
Re: Rename variant and lex_symbols options |
Date: |
Tue, 16 Oct 2012 15:18:02 +0200 |
Le 16 oct. 2012 à 10:58, Akim Demaille a écrit :
> Le 17 févr. 2012 à 03:57, Joel E. Denny a écrit :
>
>>> Again, it has an influence on the API, so may
>>> api.tokens.constructors (we already have api.tokens.prefix
>>> which probably should have been api.token.prefix),
>>
>> This is my fault. My logic was to use plural when there's more than one
>> of something. However, I now see that always using singular is probably a
>> simpler rule to remember and not really so misleading as I thought. For
>> example, lr.default-reduction, lr.keep-unreachable-state, and
>> api.token.prefix would all have been fine.
>
> Part I, in master.
>
> commit 2a6b66c5fd063c8868f239a78ecfb11c899fd22c
> Author: Akim Demaille <address@hidden>
> Date: Tue Oct 16 10:51:38 2012 +0200
>
> api.tokens.prefix -> api.token.prefix
>
> See
> http://lists.gnu.org/archive/html/bison-patches/2012-02/msg00045.html
> Note that api.tokens.prefix has not been released, yet.
>
> * NEWS, data/bison.m4, doc/bison.texi, tests/c++.at,
> * tests/calc.at, tests/java.at, tests/local.at: Do it.
> * src/muscle-tab.c (muscle_percent_variable_update): Ensure
> backward compatibility.
Part II, in master.
commit f3bc338643cf15f345fa3a63811bd92869a42b89
Author: Akim Demaille <address@hidden>
Date: Tue Oct 16 13:57:31 2012 +0200
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.
diff --git a/NEWS b/NEWS
index 29b6b32..8cc3602 100644
--- a/NEWS
+++ b/NEWS
@@ -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
diff --git a/doc/bison.texi b/doc/bison.texi
index 0428c78..674aef7 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -5608,10 +5608,10 @@ Boolean.
@c lex_symbol
address@hidden ==================================================
lr.default-reductions
address@hidden ==================================================
lr.default-reduction
address@hidden lr.default-reductions
address@hidden %define lr.default-reductions
address@hidden lr.default-reduction
address@hidden %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
address@hidden History:
+introduced as @code{lr.default-reduction} in 2.5, renamed as
address@hidden in 2.8.
@end itemize
address@hidden ============================================
lr.keep-unreachable-states
address@hidden ============================================
lr.keep-unreachable-state
address@hidden lr.keep-unreachable-states
address@hidden %define lr.keep-unreachable-states
address@hidden lr.keep-unreachable-state
address@hidden %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
address@hidden lr.keep-unreachable-states
+introduced as @code{lr.keep_unreachable_states} in 2.3b, renamed as
address@hidden in 2.5, and as
address@hidden in 2.8.
address@hidden 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
address@hidden %define lr.default-reductions
address@hidden %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
address@hidden lr.default-reductions} directive.
address@hidden lr.default-reduction} directive.
address@hidden {Directive} {%define lr.default-reductions @var{WHERE}}
address@hidden {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
address@hidden %define lr.keep-unreachable-states
address@hidden %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.
address@hidden {Directive} {%define lr.keep-unreachable-states @var{VALUE}}
address@hidden {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
diff --git a/src/lalr.c b/src/lalr.c
index 1ceda00..53a5dbf 100644
--- a/src/lalr.c
+++ b/src/lalr.c
@@ -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);
}
diff --git a/src/main.c b/src/main.c
index 093e9cb..9a03630 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;
diff --git a/src/muscle-tab.c b/src/muscle-tab.c
index 9fe32ea..f3933c3 100644
--- a/src/muscle-tab.c
+++ b/src/muscle-tab.c
@@ -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;
diff --git a/src/print.c b/src/print.c
index e3795a9..f21aade 100644
--- a/src/print.c
+++ b/src/print.c
@@ -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")
diff --git a/src/reader.c b/src/reader.c
index a3f8668..f18b5b8 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -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);
diff --git a/src/tables.c b/src/tables.c
index 96354b1..186702b 100644
--- a/src/tables.c
+++ b/src/tables.c
@@ -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);
diff --git a/tests/conflicts.at b/tests/conflicts.at
index b3f6709..37c5405 100644
--- a/tests/conflicts.at
+++ b/tests/conflicts.at
@@ -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]])
diff --git a/tests/input.at b/tests/input.at
index 736ee25..b2a4fc5 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -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]],
diff --git a/tests/reduce.at b/tests/reduce.at
index 25ce83f..d2a5c55 100644
--- a/tests/reduce.at
+++ b/tests/reduce.at
@@ -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])
])