+2009-04-30 Joel E. Denny <jdenny@ces.clemson.edu>
+
+ 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_push_parser): 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.
+
2009-04-30 Joel E. Denny <jdenny@ces.clemson.edu>
Set all front-end %define defaults in one place.
for any NAME and VALUE. Omitting `=VALUE' on the command line is
equivalent to omitting `"VALUE"' in the declaration.
+** %define variables renamed.
+
+ The following %define variables
+
+ api.push_pull
+ lr.keep_unreachable_states
+
+ have been renamed to
+
+ api.push-pull
+ lr.keep-unreachable-states
+
+ The old names are now deprecated but will be maintained indefinitely
+ for backward compatibility.
+
** Temporary hack for adding a semicolon to the user action.
Previously, Bison appended a semicolon to every user action for
# -----------------
# Depends on individual skeletons to define b4_pure_flag, b4_push_flag, or
# b4_pull_flag if they use the values of the %define variables api.pure or
-# api.push_pull.
+# api.push-pull.
m4_define([b4_identification],
[[/* Identify Bison output. */
#define YYBISON 1
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Check the value of %define api.push_pull.
-b4_percent_define_default([[api.push_pull]], [[pull]])
-b4_percent_define_check_values([[[[api.push_pull]],
+# Check the value of %define api.push-pull.
+b4_percent_define_default([[api.push-pull]], [[pull]])
+b4_percent_define_check_values([[[[api.push-pull]],
[[pull]], [[push]], [[both]]]])
b4_define_flag_if([pull]) m4_define([b4_pull_flag], [[1]])
b4_define_flag_if([push]) m4_define([b4_push_flag], [[1]])
-m4_case(b4_percent_define_get([[api.push_pull]]),
+m4_case(b4_percent_define_get([[api.push-pull]]),
[pull], [m4_define([b4_push_flag], [[0]])],
[push], [m4_define([b4_pull_flag], [[0]])])
@subsection A Push Parser
@cindex push parser
@cindex push parser
-@findex %define api.push_pull
+@findex %define api.push-pull
(The current push parsing interface is experimental and may evolve.
More user feedback will help to stabilize it.)
Normally, Bison generates a pull parser.
The following Bison declaration says that you want the parser to be a push
-parser (@pxref{Decl Summary,,%define api.push_pull}):
+parser (@pxref{Decl Summary,,%define api.push-pull}):
@example
-%define api.push_pull "push"
+%define api.push-pull "push"
@end example
In almost all cases, you want to ensure that your push parser is also
@example
%define api.pure
-%define api.push_pull "push"
+%define api.push-pull "push"
@end example
There is a major notable functional difference between the pure push parser
Bison also supports both the push parser interface along with the pull parser
interface in the same generated parser. In order to get this functionality,
-you should replace the @code{%define api.push_pull "push"} declaration with the
-@code{%define api.push_pull "both"} declaration. Doing this will create all of
+you should replace the @code{%define api.push-pull "push"} declaration with the
+@code{%define api.push-pull "both"} declaration. Doing this will create all of
the symbols mentioned earlier along with the two extra symbols, @code{yyparse}
and @code{yypull_parse}. @code{yyparse} can be used exactly as it normally
would be used. However, the user should note that it is implemented in the
generated parser by calling @code{yypull_parse}.
This makes the @code{yyparse} function that is generated with the
-@code{%define api.push_pull "both"} declaration slower than the normal
+@code{%define api.push-pull "both"} declaration slower than the normal
@code{yyparse} function. If the user
calls the @code{yypull_parse} function it will parse the rest of the input
stream. It is possible to @code{yypush_parse} tokens to select a subgrammar
@end example
Adding the @code{%define api.pure} declaration does exactly the same thing to
-the generated parser with @code{%define api.push_pull "both"} as it did for
-@code{%define api.push_pull "push"}.
+the generated parser with @code{%define api.push-pull "both"} as it did for
+@code{%define api.push-pull "push"}.
@node Decl Summary
@subsection Bison Declaration Summary
@end itemize
@c api.pure
-@item api.push_pull
-@findex %define api.push_pull
+@item api.push-pull
+@findex %define api.push-pull
@itemize @bullet
@item Language(s): C (deterministic parsers only)
@item Default Value: @code{"pull"}
@end itemize
-@c api.push_pull
+@c api.push-pull
@item error-verbose
@findex %define error-verbose
@end itemize
@end itemize
-@item lr.keep_unreachable_states
-@findex %define lr.keep_unreachable_states
+@item lr.keep-unreachable-states
+@findex %define lr.keep-unreachable-states
@itemize @bullet
@item Language(s): all
However, Bison does not compute which goto actions are useless.
@end itemize
@end itemize
-@c lr.keep_unreachable_states
+@c lr.keep-unreachable-states
@item lr.type
@findex %define lr.type
More user feedback will help to stabilize it.)
You call the function @code{yypush_parse} to parse a single token. This
-function is available if either the @code{%define api.push_pull "push"} or
-@code{%define api.push_pull "both"} declaration is used.
+function is available if either the @code{%define api.push-pull "push"} or
+@code{%define api.push-pull "both"} declaration is used.
@xref{Push Decl, ,A Push Parser}.
@deftypefun int yypush_parse (yypstate *yyps)
More user feedback will help to stabilize it.)
You call the function @code{yypull_parse} to parse the rest of the input
-stream. This function is available if the @code{%define api.push_pull "both"}
+stream. This function is available if the @code{%define api.push-pull "both"}
declaration is used.
@xref{Push Decl, ,A Push Parser}.
More user feedback will help to stabilize it.)
You call the function @code{yypstate_new} to create a new parser instance.
-This function is available if either the @code{%define api.push_pull "push"} or
-@code{%define api.push_pull "both"} declaration is used.
+This function is available if either the @code{%define api.push-pull "push"} or
+@code{%define api.push-pull "both"} declaration is used.
@xref{Push Decl, ,A Push Parser}.
@deftypefun yypstate *yypstate_new (void)
More user feedback will help to stabilize it.)
You call the function @code{yypstate_delete} to delete a parser instance.
-function is available if either the @code{%define api.push_pull "push"} or
-@code{%define api.push_pull "both"} declaration is used.
+function is available if either the @code{%define api.push-pull "push"} or
+@code{%define api.push-pull "both"} declaration is used.
@xref{Push Decl, ,A Push Parser}.
@deftypefun void yypstate_delete (yypstate *yyps)
Java.
Push parsers are currently unsupported in Java and @code{%define
-api.push_pull} have no effect.
+api.push-pull} have no effect.
@acronym{GLR} parsers are currently unsupported in Java. Do not use the
@code{glr-parser} directive.
#! /usr/bin/perl -w
-# Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2006, 2008, 2009 Free Software Foundation, Inc.
#
# This file is part of Bison, the GNU Compiler Compiler.
#
qw(
[ %d api.pure ]
&
- [ %d api.push_pull=both ]
+ [ %d api.push-pull=both ]
));
}
/* 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.
| 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)
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;
+}
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_ */
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;
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,
muscle_syncline_grow (syncline_name, variable_loc);
muscle_user_name_list_grow ("percent_define_user_variables", variable,
variable_loc);
+
+ free (variable_tr);
}
/* This is used for backward compatibility, e.g., "%define api.pure"
-/* A Bison parser, made by GNU Bison 2.4.307-8f0d-dirty. */
+/* A Bison parser, made by GNU Bison 2.4.311-ba5c-dirty. */
/* Implementation for Bison's Yacc-like parsers in C
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "2.4.307-8f0d-dirty"
+#define YYBISON_VERSION "2.4.311-ba5c-dirty"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
-/* A Bison parser, made by GNU Bison 2.4.307-8f0d-dirty. */
+/* A Bison parser, made by GNU Bison 2.4.311-ba5c-dirty. */
/* Interface for Bison's Yacc-like parsers in C
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
# Simple calculator. -*- Autotest -*-
-# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free
-# Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+# 2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
AT_CHECK_CALC_LALR([%error-verbose])
AT_CHECK_CALC_LALR([%define api.pure %locations])
-AT_CHECK_CALC_LALR([%define api.push_pull "both" %define api.pure %locations])
+AT_CHECK_CALC_LALR([%define api.push-pull "both" %define api.pure %locations])
AT_CHECK_CALC_LALR([%error-verbose %locations])
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR([%define api.push_pull "both" %define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define api.push-pull "both" %define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
# Exercising Bison on conflicts. -*- Autotest -*-
-# Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009 Free Software
+# Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
]])
AT_DATA([[input-keep.y]],
-[[%define lr.keep_unreachable_states
+[[%define lr.keep-unreachable-states
]])
AT_CHECK([[cat input.y >> input-keep.y]])
]])
# Back-end.
+AT_DATA([[input.y]],
+[[%define api.push-pull "neither"
+%%
+start: ;
+]])
+AT_BISON_CHECK([[input.y]], [1], [],
+[[input.y:1.9-21: invalid value for %define variable `api.push-pull': `neither'
+input.y:1.9-21: accepted value: `pull'
+input.y:1.9-21: accepted value: `push'
+input.y:1.9-21: accepted value: `both'
+]])
+
+AT_CLEANUP
+
+## -------------------------------- ##
+## %define backward compatibility. ##
+## -------------------------------- ##
+
+AT_SETUP([[%define backward compatibility]])
+
+# The error messages tell us whether underscores in these variables are
+# being converted to dashes.
+
AT_DATA([[input.y]],
[[%define api.push_pull "neither"
%%
start: ;
]])
AT_BISON_CHECK([[input.y]], [1], [],
-[[input.y:1.9-21: invalid value for %define variable `api.push_pull': `neither'
+[[input.y:1.9-21: invalid value for %define variable `api.push-pull': `neither'
input.y:1.9-21: accepted value: `pull'
input.y:1.9-21: accepted value: `push'
input.y:1.9-21: accepted value: `both'
]])
+AT_DATA([[input.y]],
+[[%define lr.keep_unreachable_states "maybe"
+%%
+start: ;
+]])
+AT_BISON_CHECK([[input.y]], [1], [],
+[[input.y:1.9-34: invalid value for %define Boolean variable `lr.keep-unreachable-states'
+]])
+
+AT_DATA([[input.y]],
+[[%define foo_bar "baz"
+%%
+start: ;
+]])
+AT_BISON_CHECK([[input.y]], [0], [],
+[[input.y:1.9-15: warning: %define variable `foo_bar' is not used
+]])
+
AT_CLEANUP
## ------------------------- ##
# Checking Push Parsing. -*- Autotest -*-
-# Copyright (C) 2007 Free Software Foundation, Inc.
+# Copyright (C) 2007, 2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
void yyerror (char const *msg);
%}
-%define api.pure %define api.push_pull "push"
+%define api.pure %define api.push-pull "push"
%%
int yylex (void);
%}
-%define api.push_pull "]$1["
+%define api.push-pull "]$1["
%%
AT_DATA([[input.y]],
[[%glr-parser
-%define api.push_pull "push"
+%define api.push-pull "push"
%%
start: ;
]])
AT_BISON_CHECK([[input.y]], [0], [],
-[[input.y:2.9-21: warning: %define variable `api.push_pull' is not used
+[[input.y:2.9-21: warning: %define variable `api.push-pull' is not used
]])
AT_CLEANUP
[[%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-states]],
[[
S: 'a' A 'a' /* rule 1 */
| 'b' A 'b' /* rule 2 */
[[%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-states]],
[[
/* Similar to the last test case set but two states must be split. */
S: 'a' A 'a' /* rule 1 */
[[%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-states]],
[[
/* 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
]])])
AT_TEST_LR_TYPE([[Split During Added Lookahead Propagation]],
-[[%define lr.keep_unreachable_states]],
+[[%define lr.keep-unreachable-states]],
[[
/* 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.
# Torturing Bison. -*- Autotest -*-
-# Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007 Free Software Foundation,
-# Inc.
+# Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 Free Software
+# Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# just helps guarantee we don't let the YYSTACK_USE_ALLOCA feature affect
# push parsers.
AT_DATA_STACK_TORTURE([AT_USE_ALLOCA],
-[[%define api.push_pull "both"
+[[%define api.push-pull "both"
]])
AT_PARSER_CHECK([./input 20], 0, [], [ignore],
[[VALGRIND_OPTS="$VALGRIND_OPTS --log-fd=1"]])
[[VALGRIND_OPTS="$VALGRIND_OPTS --log-fd=1"]])
AT_DATA_STACK_TORTURE([AT_USE_ALLOCA],
-[[%define api.push_pull "both"
+[[%define api.push-pull "both"
]])
AT_PARSER_CHECK([./input 20], 0, [], [ignore],
[[VALGRIND_OPTS="$VALGRIND_OPTS --log-fd=1"]])