Compare commits

..
Author SHA1 Message Date
Akim Demaille 2b63a84a5b lalr1.cc: provide %printer-based syntax-error messages.
* data/c++.m4: .
	* data/lalr1.cc: .
	* data/variant.hh: .
2009-08-26 13:33:33 +02:00
Akim Demaille a57ca64a80 lalr1.cc: pass the full lookahead to yysyntax_error_.
* data/lalr1.cc (yysyntax_error_): Instead of only taking the kind
	of the guilty token, take the full lookahead.
2009-08-26 13:25:11 +02:00
Akim Demaille 560d4c8dd9 lalr1.cc: minor changes.
* data/c++.m4: Space changes.
	* data/lalr1.cc (yysyntax_error_): Adjust signature.
2009-08-26 13:25:11 +02:00
Akim Demaille 911497f140 examples: fix variant.
* examples/variant.yy: Update to parse.assert and parse.trace.
2009-08-26 13:25:11 +02:00
Akim Demaille 3bed3a757f tests: portability fix.
* tests/input.at (Bad escapes in literals): Don't expect "echo
	'\0'" to output \ then 0.
2009-08-26 13:21:18 +02:00
Joel E. Denny aa0cb40d61 Actually handle the yytable zero value correctly this time.
* data/bison.m4 (b4_integral_parser_tables_map): Don't mention
zero values in the YYTABLE comments.
* data/glr.c (yytable_value_is_error): Don't check for zero
value.
* data/lalr1.cc (yy_table_value_is_error_): Likewise.
* data/yacc.c (yytable_value_is_error): Likewise.
* data/lalr1.java (yy_table_value_is_error_): Likewise.
(yysyntax_error): Fix typo in code: use yytable_ not yycheck_.
* src/tables.h: In header comments, explain why it's useless to
check for a zero value in yytable.
2009-08-26 03:05:46 -04:00
Joel E. Denny f2b30bdf37 More fixes related to last two patches.
* data/bison.m4 (b4_integral_parser_tables_map): Fix YYTABLE
comments: zero indicates syntax error not default action.
* data/c.m4 (b4_table_value_equals): Comment that YYID must be
defined.
* data/glr.c (yyis_pact_ninf): Rename to...
(yypact_value_is_default): ... this.
(yyisDefaultedState): Update for rename.
(yyis_table_ninf): Rename to...
(yytable_value_is_error): ... this, and check for value zero
besides just YYTABLE_NINF.
(yygetLRActions): Check for default value from yypact.  It
appears that this check is always performed before this function
is invoked, and so adding the check here is probably redundant.
However, the code may evolve after this subtlety is forgotten.
Also, update for rename to yytable_value_is_error.  Because that
macro now checks for zero, a different but equivalent branch of
the if-then-else here is evaluated.
(yyreportSyntaxError): Update for rename to
yytable_value_is_error.  The zero condition was mishandled
before.
(yyrecoverSyntaxError): Update for renames.  No behavioral
changes.
* data/lalr1.cc, data/lalr1.java (yy_pact_value_is_default_):
New function.
(yy_table_value_is_error_): New function.
(parse): Use new functions where possible.  No behavioral
changes.
(yysyntax_error_, yysyntax_error): Use yy_table_value_is_error_.
The zero condition was mishandled before.
* data/yacc.c (yyis_pact_ninf): Rename to...
(yypact_value_is_default): ... this.
(yyis_table_ninf): Rename to...
(yytable_value_is_error): ... this, and check for value zero
besides just YYTABLE_NINF.
(yysyntax_error): Update for rename to yytable_value_is_error.
The zero condition was mishandled before.
(yyparse): Update for renames.  No behavioral changes.
* src/tables.h: Improve comments about yypact, yytable, etc.
more.  Most importantly, say yytable value of zero means syntax
error not default action.
2009-08-25 20:34:09 -04:00
Joel E. Denny 53f036ce02 Fix %error-verbose for conflicts resolved by %nonassoc.
* NEWS (2.5): Document.
* data/glr.c (yyreportSyntaxError): Fix this by checking
yyis_table_ninf.
* data/yacc.c (yysyntax_error): Likewise.
* data/lalr1.cc (yysyntax_error_): Fix this by checking
yytable_ninf_.
* data/lalr1.java (yysyntax_error): Likewise.
* tests/conflicts.at (%nonassoc and eof): Update expected output
and remove FIXME.
2009-08-25 02:57:15 -04:00
Joel E. Denny 8741288212 Some code and documentation improvements.
* data/c.m4 (b4_table_value_equals): New macro to capture
some repeated code.
* data/glr.c (yyis_pact_ninf): Use it here.
(yyis_table_ninf): Likewise.
(yyreportSyntaxError): Improve internal comments.
* data/yacc.c (yyis_pact_ninf): New macro copied from glr.c.
Use it everywhere possible.
(yyis_table_ninf): Likewise.
(yysyntax_error): Improve internal comments.
* data/lalr1.cc (yysyntax_error_): Likewise.
* data/lalr1.java (yysyntax_error): Likewise.
* src/tables.h: Improve comments about yypact, yytable, etc.
2009-08-25 02:56:46 -04:00
Joel E. Denny e6c849d82a Use locale when quoting.
* src/scan-gram.l (SC_ESCAPED_STRING, SC_ESCAPED_CHARACTER): Use
quote rather than implementing quoting here.
2009-08-21 20:17:56 -04:00
Eric Blake b0778bdd0c Make previous patch more robust.
* src/output.c (ARRAY_CARDINALITY): New macro, copied from
argmatch.h.
(output_skeleton): Use it.
Suggested by Akim Demaille.

Signed-off-by: Eric Blake <[email protected]>
(cherry picked from commit 1266b63674)
2009-08-20 16:54:07 -06:00
Eric Blake d8911864c2 Import latest m4/m4.m4.
* submodules/autoconf: Update to autoconf 2.64.
* configure.ac (M4_GNU_OPTION): New define.
* src/output.c (output_skeleton): Use it to resolve FIXME.
* NEWS: Mention this.

Signed-off-by: Eric Blake <[email protected]>
(cherry picked from commit b9ad39c1fb)
2009-08-20 09:50:59 -06:00
Joel E. Denny c2724603c9 Fix complaints about escape sequences.
Discussed starting at
<http://lists.gnu.org/archive/html/bison-patches/2009-08/msg00036.html>.
* src/scan-gram.l (SC_ESCAPED_STRING, SC_ESCAPED_CHARACTER):
For a \0 and similar escape sequences meaning the null
character, report an invalid escape sequence instead of an
invalid null character because the latter does not actually
appear in the user's input.
In all escape sequence complaints, don't escape the initial
backslash, and don't quote when the sequence appears at the end
of the complaint line unless there's whitespace that quotearg
won't escape.
Consistently say "invalid" not "unrecognized".
Consistently prefer "empty character literal" over "extra
characters in character literal" warning for invalid escape
sequences; that is, consistently discard those sequences.
* tests/input.at (Bad escapes in literals): New.
2009-08-19 20:43:40 -04:00
Akim Demaille 17aed602c6 doc: fixes.
* doc/bison.texinfo: Fix minor Texinfo errors.
2009-08-19 14:51:50 +02:00
Akim Demaille 9142239a59 tests: distcc compliance.
* tests/synclines.at (AT_SYNCLINES_COMPILE): Discard distcc's
	error messages from the output.
2009-08-19 14:41:00 +02:00
Akim Demaille 171ad99d64 variables: simplify the upgrade of namespace into api.namespace.
This patch simplifies "variables: rename namespace as api.namespace",
commit 6750106107.
Suggested by Joel E. Denny in
http://lists.gnu.org/archive/html/bison-patches/2009-07/msg00006.html

	* src/muscle-tab.c (muscle_percent_variable_update): New.
	(muscle_percent_define_insert): Use it in replacement of the
	previous tr invocation.
	Remove variable_tr, no longer needed.
	* data/bison.m4 (b4_percent_define_copy_, b4_percent_define_copy):
	Remove.
	* data/c++.m4: No longer handle namespace -> api.namespace.
	* tests/input.at (%define backward compatibility): Check that
	namespace is treated as api.namespace.
2009-08-19 14:24:15 +02:00
Akim Demaille d59e456dbf 2009-08-19 Akim Demaille <[email protected]>
doc: %initial-action to initialize yylloc.
	Reported by Bill Allombert.
	* doc/bison.texinfo: Set fill-column to 76.
	(Location Type): Document the use of %initial-action to initialize
	yylloc.
2009-08-19 13:34:48 +02:00
Akim Demaille ceb8b8e6b5 lalr1.cc: use state_type.
* data/lalr1.cc (yysyntax_error_): Use state_type.
	Move argument names into yy*.
2009-08-19 10:37:00 +02:00
Akim Demaille 7580c37942 lalr1.cc: get rid of yyparse's yystate.
yystate and yystack_[0].state are equal, keep only the latter.
The former was also used as a temporary variable to compute the
post-reduction state.  Move this computation into an auxiliary
function.

	* data/glr.c (yyLRgotoState): Fuse variable definition and first
	assignment.
	* data/lalr1.cc (yy_lr_goto_state_): New.
	(yyparse): Use it.
	Replace remaining uses of yystate by yystate_[0].state.
	Remove the former.
2009-08-19 10:36:57 +02:00
Akim Demaille c4dc4c4671 lalr1.cc: destroy $$ when YYERROR is called.
* data/lalr1.cc (yyreduce): Compute the resulting state before
	running the user action so that yylhs is a valid symbol.
	(yyerrorlab): Since yylhs is complete (it knows its type), we can
	simply call yy_destroy_ to destroy $$ on YYERROR invocations.
	* tests/c++.at (AT_CHECK_VARIANTS): Test YYERROR with variants.
2009-08-19 10:36:53 +02:00
Joel E. Denny c67e466f9d maint: update for gnulib's recent update-copyright changes
* gnulib: Update.
* .x-update-copyright (COPYING): Add as it's no longer implied
when .x-update-copyright is present.
* cfg.mk (update-copyright-local): Remove, now ignored.
(update-copyright): Declare update-b4-copyright as a dependency.
2009-08-18 18:29:54 -04:00
Akim Demaille af6d235843 build: require gettext 0.17.
Suggested by Bruno Haible.
http://lists.gnu.org/archive/html/bug-bison/2009-08/msg00009.html

	* configure.ac: require gettext 0.17 to ensure compatibility with
	gnulib.
2009-08-17 12:58:02 +02:00
Akim Demaille 91a2b9b1b2 build: lower gettext requirements.
Bison was uselessly requiring the formatstring macros from
gettext, which resulted in mo files not being installed on systems
that perfectly supported Bison mo files.  Lower the requirement.
http://lists.gnu.org/archive/html/bug-bison/2009-08/msg00006.html

	* configure.ac: Require need-ngettext instead of
	need-formatstring-macros.
	Reported by Martin Jabocs.
	Suggested by Bruno Haible.
	* INSTALL: Restructure.
	(Internationalization): New.
(cherry picked from commit b9e42bb439)
2009-08-17 12:58:02 +02:00
Akim Demaille 13bcafb580 gnulib: update.
* gnulib: Update to newest.
2009-08-17 12:58:01 +02:00
Joel E. Denny 585935e895 maint: fix use of copyright year intervals.
* gnulib: Update.
* bootstrap.conf (gnulib_modules): Update getopt to getopt-gnu
as now recommended in gnulib/NEWS.
* build-aux/update-b4-copyright: Fix.
* cfg.mk (update-copyright-env): Configure update-copyright.
(cherry picked from commit 75ac158b82)
2009-08-14 18:50:49 -04:00
Joel E. Denny 83b60c97ee Make it easier to write deterministic tests.
Continues Akim's work from his 2009-06-10 commits.
* src/reader.c (check_and_convert_grammar): Don't add any
symbols after the first symbols_do invocation.
* src/symtab.c (symbols_sorted): New static global.
(user_token_number_redeclaration): Update comments.
(symbol_from_uniqstr): If a new symbol is being created, assert
that symbols_sorted hasn't been allocated yet.
(symbols_free): Free symbols_sorted.
(symbols_cmp, symbols_cmp_qsort): New functions.
(symbols_do): Sort symbol_table into symbols_sorted on first
invocation.
* tests/input.at (Numbered tokens): Recombine tests now that the
output should be deterministic across multiple numbers.
2009-08-13 01:24:18 -04:00
Akim Demaille 28169bab1f tests: GCC 4.5 compliance.
* tests/synclines.at (AT_SYNCLINES_COMPILE): Adjust to GCC 4.5's
	messages about #error.
2009-08-12 16:30:52 +02:00
Akim Demaille 9f14e18736 build: fix the generation of the documentation.
Some of our targets use "bison --help", but they can't depend on
"bison" itself (to avoid additional requirements on the user), so
they used to call "make src/bison" in the commands.  Then
concurrent builds may fail: one make might be aiming one of its
jobs at compiling src/bison, and another job at generating the man
page.  If the latter is faster than the former, then we have two
makes that concurrently try to compile src/bison.

This might also be a more convincing explanation for the failure
described in the patch "build: fix paths".

	* Makefile.am (SUFFIXES): Initialize.
	* build-aux/move-if-change: New, symlink to gnulib's.
	* build-aux/local.mk: Ship it.
	* doc/common.x: Remove, merged into...
	* doc/bison.x: here.
	* doc/local.mk (doc/bison.help): New.
	($(CROSS_OPTIONS_TEXI)): Depend on it.
	Use src/bison.
	(.x.1): Replace with...
	(doc/bison.1): this explicit, simpler, target.
	(common_dep): Remove, inlined where appropriate.
	(SUFFIXES, PREPATH): Remove, unused.
2009-08-12 16:30:48 +02:00
Akim Demaille d1b55e8115 gnulib: improve prefixing.
* configure.ac (gl_PREFIXED_LIBOBJS): Don't rename it, rather,
	change the value of...
	(gl_LIBOBJS): this.
	Adjust more variables.
	* etc/prefix-gnulib-mk (prefix_assignment): Don't rename
	gl_LIBOBJS.
	(prefix): Also transform rules whose targets have slashes.
	Use $prefix liberally.
	Map @MKDIR_P@ to $(MKDIR_P).
	Prefix directories that are mkdir'd.
2009-08-12 16:30:43 +02:00
Akim Demaille 838205d547 build: fix paths.
When using $(top_builddir) inconsistently, Make (including GNU
Make) is sometimes confused.  As a result it may want to build
lib/libbison.la and $(top_builddir)/lib/libbison.la (the same
file, different names) concurrently, which, amusingly enough,
might end with:

  ranlib lib/libbison.a
  ranlib lib/libbison.a
  make[2]: *** [lib/libbison.a] Segmentation fault

on OS X.

	* doc/local.mk, src/local.mk: Do not use $(top_builddir) when not
	needed.
2009-08-12 14:12:13 +02:00
Akim Demaille 67af719840 distcheck: fix.
* examples/calc++/Makefile.am: (EXTRA_DIST): Ship calc.stamp.
2009-08-12 14:02:01 +02:00
Joel E. Denny c467dc420d * tests/local.mk (TESTSUITE_AT): Add named-refs.at.
(cherry picked from commit 36dfe4662e)

Conflicts:

	tests/Makefile.am
2009-08-10 23:44:07 -04:00
Joel E. Denny dfaa48602d Miscellaneous code readability improvements.
* src/reader.c (reader): Move %define front-end variable
defaults and checking into...
(prepare_percent_define_front_end_variables): ... this new
function.

* src/scan-gram.l (INITIAL): For consistency with string
literals, don't store open quote on character literal.  It's
discarded before returning anyway.
(SC_ESCAPED_CHARACTER): Similarly, don't store close quote.
Make length test more readable, and make the character stored
for an empty literal more obvious while consistent with the
previous behavior.

* src/symtab.c, src/symtab.h: Rename USER_NUMBER_ALIAS to
USER_NUMBER_HAS_STRING_ALIAS throughout.
* src/symtab.c (symbol_make_alias): Remove comment from symtab.c
that is repeated in symtab.h.  Improve argument names to make it
clear which side of the symbol-string alias pair is which.
(symbol_check_alias_consistency): Improve local variable names
for the same purpose.
* src/symtab.h (struct symbol): Make comments about aliases
clearer.
(symbol_make_alias): Improve comments and argument name.
* src/output.c (token_definitions_output): Update for rename to
USER_NUMBER_HAS_STRING_ALIAS and improve comments about aliases.
2009-08-10 22:22:01 -04:00
Alex Rozenman ce268795cc Convert "misleading reference" messages to warnings.
* src/scan-code.l: New function 'show_sub_messages', more
	factoring.
	* tests/named-ref.at: Adjust tests.
2009-08-08 18:10:23 +03:00
Joel E. Denny 401b73afdf maint: run "make update-copyright" 2009-08-06 19:17:44 -04:00
Joel E. Denny a1a9422d4a maint: make update-b4-copyright easier to use
* build-aux/update-b4-copyright: In warnings, report line
numbers rather than character positions.
* cfg.mk (update-copyright-local): Set to update-b4-copyright so
that update-copyright runs it.
* gnulib: Update.
2009-08-06 18:31:45 -04:00
Joel E. Denny 0b61a8ec18 maint: clean up update-b4-copyright code
* build-aux/update-b4-copyright: Do not accept 2-digit
UPDATE_COPYRIGHT_YEAR, which was not handled correctly.
Don't accept a `[' in a b4_copyright argument.
Format code more consistently.
Don't assume b4*copyright never occurs.
2009-08-05 19:52:41 -04:00
Joel E. Denny 269e222e24 maint: automate b4_copyright updates.
* Makefile.am (update-b4-copyright): New target rule.
* build-aux/local.mk (EXTRA_DIST): Add update-b4-copyright.
* build-aux/update-b4-copyright: New.
* data/yacc.c: Remove stray characters around b4_copyright
invocations.
2009-08-04 21:27:06 -04:00
Joel E. Denny 35905f2b45 maint: automate annual package-wide copyright-year update.
* .x-update-copyright: New.
* Makefile.am (EXTRA_DIST): Remove maint.mk.
* bootstrap.conf (gnulib_modules): Add maintainer-makefile and
update-copyright.  Remove gnumakefile, which is implied by
maintainer-makefile.
* cfg.mk (bootstrap-tools): Copy from old maint.mk.
* gnulib: Update.
* maint.mk: Remove, now copied from gnulib.
* examples/extexi: Add missing "(C)" in copyright statement so
update-copyright can recognize it.
* src/LR0.h: Likewise.
* src/print.h: Likewise.
* src/print_graph.h: Likewise.
* src/named-ref.c: Likewise.
* src/named-ref.h: Likewise.
* src/gram.c: Add missing comma in copyright statement.
* src/gram.h: Likewise.
(cherry picked from commit dbbb64f091)

Conflicts:

	Makefile.am
	gnulib
	maint.mk
	src/gram.h
2009-08-04 20:22:30 -04:00
Joel E. Denny b30e18dc8a Fix "make distcheck".
* examples/calc++/Makefile.am: Say $(srcdir)/calc.stamp instead
of just calc.stamp.
(cherry picked from commit cfc9e431c3)
2009-08-04 16:02:56 -04:00
Joel E. Denny 8d90395dd7 Pacify "gcc -Wunused" for the input function from Flex.
Reported by Alex Rozenman.  This warning shows up with gcc-4.3.0
and later.
* src/scan-code.l: Add "%option noinput", which I cannot find in
the Flex manual, but which Flex has supported since at least as
far back as 2.5.4.  However, if any of our developers still use
Flex 2.5.4, they'll need to stop configuring with
--enable-gcc-warnings because "%option noinput" didn't work
correctly until Flex 2.5.6.
* src/scan-gram.l: Likewise.
* src/scan-skel.l: Likewise.
(cherry picked from commit 42f8609bbd)
2009-08-01 18:33:39 -04:00
Alex Rozenman 5add20ab89 Fix mail address in ChangeLog. 2009-07-31 22:34:54 +03:00
Alex Rozenman ba4184ec91 Fix --enable-gcc-warnings problems.
* src/reader.c: Adjust variable names.
	* src/scan-code.l: Fix prototypes and adjust names.
	* src/named-ref.c: Remove redundant "if".
2009-07-31 22:23:23 +03:00
Joel E. Denny 91a2af9753 Fix a --enable-gcc-warnings problem.
* src/scan-gram.l (SC_ESCAPED_CHARACTER): Actually use length
variable.
(cherry picked from commit a1ed2b71fa)
2009-07-29 13:49:25 -04:00
Joel E. Denny 3208e3f4d9 Warn about character literals not of length one.
* NEWS (2.5): Document.
* src/scan-gram.l (INITIAL): Remove comment that we don't check
the length.
(SC_ESCAPED_CHARACTER): Warn if length is wrong.
* tests/input.at (Bad character literals): New test group.
(cherry picked from commit ac9b0e954b)
2009-07-24 11:30:27 -04:00
Alex Rozenman 13cdf208ed Fix some memory leaks.
* src/named-ref.c: Add a pointer check (named_ref_free).
	* src/scan-code.l: New function (variant_table_free). Called in
	code_scanner_free.
	* src/symlist.c: Call to named_ref_free (symbol_list_free).
2009-07-24 21:04:16 +03:00
Joel E. Denny e459fb0e3c * src/lalr.c (state_lookahead_tokens_count): Correct comment.
(cherry picked from commit 2de160e12e)
2009-07-24 10:13:59 -04:00
Joel E. Denny c4be551734 Some M4 cleanup in the testsuite.
Suggested by Eric Blake at
<http://lists.gnu.org/archive/html/bison-patches/2009-04/msg00083.html>.
* tests/existing.at (_AT_TEST_EXISTING_GRAMMAR): Do not
complicate the code by distinguishing between a missing value
and an empty string value for an optional argument.  This fix is
allowed by the similar fix in AT_TEST_TABLES_AND_PARSE below.
* tests/local.at (_AT_TEST_TABLES_AND_PARSE): Merge into...
(AT_TEST_TABLES_AND_PARSE): ... this now that the special
arguments are not needed because of the following changes.
Fix stale comments.
Bison developers should use GNU M4 and should not use
POSIXLY_CORRECT when building the test suite, so do not
complicate the code by avoiding $10 and above.
Do not quote an empty string value for an optional argument, and
do not distinguish between a missing value and an empty string
value.
(cherry picked from commit cba975069a)
2009-07-22 15:18:59 -04:00
Joel E. Denny feeb56cd36 Revert unnecessary column realignment in --help output.
Reported by Akim Demaille at
<http://lists.gnu.org/archive/html/bison-patches/2009-06/msg00010.html>.
* src/getargs.c (usage): Here.
(cherry picked from commit 620b2e3691)
2009-07-15 04:41:38 -04:00
Alex Rozenman 629e4def0c Alphabetical order in src/local.mk.
* src/local.mk: Adjust.
2009-07-04 22:55:04 +03:00
Alex Rozenman f7c0fe197b Regen. 2009-07-04 21:29:06 +03:00
Alex Rozenman 872b52bc24 Style changes and factoring.
* src/named-ref.h: Add comments.
	* src/parse-gram.y: Readability and style changes.
	* src/reader.c: Factoring: assign_named_ref function.
	* src/scan-code.l: Factoring and style changes. Rename
	parse_named_ref to parse_ref. Use "c-ctype.h" from gnulib.
	Use "unsigned" type for variant index. Improve readablity.
	* src/scan-gram.l: Change error messages and add comments.
	* src/symlist.h: symbol_list_null: New function decl.
	* src/symlist.c: symbol_list_null: Implement here.
	* tests/named-refs.at: Adjust for new error messages.
2009-07-04 21:26:20 +03:00
Eric Blake 83ea2423f5 scan-code: avoid compiler warnings
* src/scan-code.l (parse_named_ref): Use correct specifiers.

Signed-off-by: Eric Blake <[email protected]>
(cherry picked from commit ae09ec8577)
2009-06-29 21:53:25 -06:00
Akim Demaille 5ece73eaa1 build: avoid concurrent extraction of calc++.
* examples/calc++/Makefile.am (calc.stamp): New.
	Depend on it to create the sources of calc++ so that concurrent
	builds don't launch several "extexi" in parallel.
	Not only this is inefficient, this also builds incorrect sources
	with several extractions mixed together.
2009-06-29 15:09:21 +02:00
Akim Demaille ad597a7877 parse.error: fix.
* data/bison.m4: Move code related to specific variables after the
	definition of the variable-maintaining macros so that we don't
	"invoke" b4_percent_define_check_values before it is defined.
2009-06-29 15:08:47 +02:00
Akim Demaille 2f5b478e4b Regen. 2009-06-29 13:37:54 +02:00
Akim Demaille 31b850d2d4 variables: parse.error
Implement, document, and test the replacement of %error-verbose
by %define parse.error "verbose".

	* data/bison.m4 (b4_error_verbose_if): Reimplement to track the
	values of the parse.error variable.
	Make "simple" its default value.
	Check the valid values.
	* src/parse-gram.y: Use %define parse.error.
	(PERCENT_ERROR_VERBOSE): New token.
	Support it.
	* src/scan-gram.l: Support %error-verbose.

	* doc/bison.texinfo (Decl Summary): Replace the documentation of
	%define error-verbose by that of %define parse.error.
	* NEWS: Document it.

	* tests/actions.at, tests/calc.at: Use parse.error instead of
	%error-verbose.
2009-06-29 13:37:44 +02:00
Alex Rozenman d70059ec73 Regen. 2009-06-27 20:35:25 +03:00
Alex RozenmanandAlex Rozenman b9f1d9a47a Named symbol references.
Discussed in:
http://lists.gnu.org/archive/html/bison-patches/2009-01/msg00000.html
http://lists.gnu.org/archive/html/bison-patches/2009-02/msg00002.html
http://lists.gnu.org/archive/html/bison-patches/2009-03/msg00009.html

	* src/parse-gram.y: Add new syntax (named_ref.opt).
	* src/reader.c: Store named refs in symbol lists.
	* src/reader.h: New argument for symbol_append and
	action_append functions.
	* src/scan-code.h: Add new field (named_ref) into
	code_props data structure. Keeps named ref of midrule
	actions.
	* src/scan-code.l: Support for named refs in semantic
	action code. New function 'parse_named_ref'.
	* src/scan-gram.l: Support bracketed id.
	* src/symlist.c: Store named refs in symbol lists.
	* src/symlist.h: New field in symbol list: named_ref.
	* src/named-ref.h: New file, a struct for named_ref.
	* src/named-ref.cp: New file, named_ref_new function.
	* src/local.mk: Add two new files.
	* tests/testsuite.at: Include new test group:
	* tests/named-refs.at: this new file.
2009-06-27 20:27:09 +03:00
Akim Demaille b5c212b61a hash: check insertion for memory exhaustion.
* src/uniqstr.c (uniqstr_new): New.
2009-06-25 06:06:38 +02:00
Akim Demaille 6750106107 variables: rename namespace as api.namespace.
Discussed in
http://lists.gnu.org/archive/html/bison-patches/2009-04/msg00033.html

	* data/bison.m4 (b4_percent_define_copy_, b4_percent_define_copy):
	New.
	(b4_percent_define_use): New.
	Use it where applicable.
	* data/c++.m4: Replace uses of the variable "namespace" by
	"api.namespace".
	Default the latter to the former.
	* doc/bison.texinfo (Decl Summary): Document "namespace" as
	obsolete.
	Document api.namespace.
	Use @samp to document %define uses, keep @code for identifiers.
	* NEWS: Likewise.
	* tests/c++.at, tests/input.at: Test api.namespace instead of
	namespace. (The tests passed with namespace.)
2009-06-24 17:38:48 +02:00
Akim Demaille 4197678606 style changes.
* data/xslt/xml2dot.xsl, data/xslt/xml2xhtml.xsl: Space changes.
	* src/print-xml.c: Style changes.
	* tests/conflicts.at: Comment changes.
2009-06-11 14:53:05 +02:00
Akim Demaille 44bb908485 xml: beware of user strings used to give a %prec to rules.
* tests/conflicts.at (%prec with user strings): New.
	* src/gram.c (grammar_rules_print_xml): Escape the precedence for
	XML output.
2009-06-11 14:53:03 +02:00
Akim Demaille 04d1e39dd3 hash: check insertion for memory exhaustion.
* src/muscle-tab.c (muscle_insert, muscle_grow)
	* src/state.c (state_hash_insert): Check the return value of
	hash_insert.
2009-06-11 14:42:12 +02:00
Akim Demaille a887366955 tests: honor TESTSUITEFLAGS in every check target.
* tests/local.mk (RUN_TESTSUITE): New.
	(check-local, installcheck-local, maintainer-check-g++)
	(maintainer-check-posix, maintainer-check-valgrind): Use it.
2009-06-11 14:36:57 +02:00
Akim Demaille b584460cc3 gnulib: update.
The previous patch accidently sent back gnulib in the past.
Reported by Eric Blake.

	* gnulib: update to latest.
2009-06-11 09:15:36 +02:00
Akim Demaille 8893145a0c deterministic test suite.
Some consistency checks on symbols are performed after all the
symbols were read, by an iteration over the symbol table.  This
traversal is nondeterministic, which can be a problem for test
cases.

Avoid this.

Addresses another form of nondeterminism reported by Joel E. Denny.
http://lists.gnu.org/archive/html/bison-patches/2009-05/msg00023.html

	* tests/input.at (Numbered tokens): Split the hexadecimal/decimal
	test in two.
	Use different file names for the three tests to make the
	maintenance easier.
2009-06-10 20:16:39 +02:00
Akim Demaille 92d7a23ace gnulib: update.
* gnulib: Update to latest.
	* lib/.cvsignore, lib/.gitignore, m4/.cvsignore,
	* m4/.gitignore: Regen.
	* src/symtab.c (symbol_from_uniqstr, semantic_type_from_uniqstr):
	Call xalloc_die on hash_insert failures.
	Requested by the new __warn_unused_result__ attribute of
	hash_insert.
2009-06-10 10:56:19 +02:00
Akim Demaille 12cf133f34 deterministic user-token-number redeclaration errors.
Address nondeterminism reported by Joel E. Denny.
http://lists.gnu.org/archive/html/bison-patches/2009-05/msg00023.html

	* src/uniqstr.h: Comment changes.
	* src/location.h (boundary_cmp, location_cmp): New.
	* src/symtab.c (user_token_number_redeclaration): New.
	(symbol_translation): Use it.
	* tests/input.at (Numbered tokens): Adjust the expected output.
2009-06-10 10:38:42 +02:00
Akim Demaille 796a2b0ab0 build: avoid ignored errors.
* doc/local.mk ($(CROSS_OPTIONS_TEXI)): Don't generate ignored
	errors, they pollute the output.
2009-05-25 17:03:47 +02:00
Joel E. Denny 0b6d43c52f Convert multiple variable definition warnings to complaints.
* NEWS (2.5): Add a new entry for that change.
* doc/bison.texinfo (Decl Summary): Update %define entry.
(Bison Options): Update -D/--define/-F/--force-define entry.
* src/muscle-tab.c (muscle_percent_define_insert): Implement.
* src/muscle-tab.h (muscle_percent_define_insert): Update
comments.
* tests/input.at (`%define errors'): Update.
(`%define, --define, --force-define'): Update.
(cherry picked from commit e3a33f7c23)
2009-05-23 02:37:22 -04:00
Joel E. Denny de5ab9400a -F/--force-define and relative %define/-D/--define priorities.
* NEWS (2.5): Add documentation to -D/--define entry.
* build-aux/cross-options.pl: Hard-code association of
--force-define with %define.
* doc/bison.texinfo (Decl Summary): In %define entry,
cross-reference command-line options.
(Bison Options): Add documentation to -D/--define entry.
(Option Cross Key): Widen column for --force-define row.
* src/getargs.c (usage): Document -F/--force-define.  Realign
options in output.
(short_options, long_options, getargs): Parse -F/--force-define,
and update muscle_percent_define_insert invocations.
* src/muscle-tab.h (muscle_percent_define_how): New enum type.
(muscle_percent_define_insert): Add argument with that type.
* src/muscle-tab.c (muscle_percent_define_insert): Implement
-F/--force-define behavior and priorities.
(muscle_percent_define_ensure): Update
muscle_percent_define_insert invocation.
* src/parse-gram.y (prologue_declaration): Update
muscle_percent_define_insert invocations.
* tests/input.at (`%define, --define'): Rename to...
(`%define, --define, --force-define'): ... this and extend.
(cherry picked from commit 34d4193815)

Conflicts:

	src/getargs.c
	src/parse-gram.c
	src/parse-gram.h
	src/parse-gram.y
2009-05-23 00:24:30 -04:00
Joel E. Denny f8e7258f7f Update some comments to make sense for -D.
* data/bison.m4 (b4_check_user_names): In header comments, say
"user occurrence" instead of "grammar occurrence".
* src/muscle-tab.h (muscle_percent_define_insert): Likewise.
(muscle_percent_code_grow): Likewise just for consistency.
(cherry picked from commit 246c4efafe)

Conflicts:

	src/muscle-tab.h
2009-05-23 00:00:02 -04:00
Joel E. Denny b987342bab * data/c++.m4 (b4_namespace_close): Simplify slightly.
(cherry picked from commit e7bfa8b721)
2009-05-20 18:05:03 -04:00
Joel E. Denny 4977e0a7d9 Handle a trailing `:' in a user-supplied C++ namespace better.
* data/c++.m4 (b4_namespace_close): Don't let it be printed
among the closing braces here.  This fix might make the
generated code easier to debug, but otherwise it should be
insignificant because a trailing `:' is a C++ error already.
(cherry picked from commit 8c221795af)
2009-05-19 18:16:08 -04:00
Akim Demaille 9b04dad70a remove useless variable.
* src/getargs.c (skeleton_arg): Remove now useless variable.
	Should help the compiler see that this printf-like call is sane.
2009-05-19 11:34:17 +02:00
Akim Demaille 4c6622c2dd Rename token.prefix as api.tokens.prefix.
Discussed here.
http://lists.gnu.org/archive/html/bison-patches/2009-05/msg00024.html.

	* NEWS, data/bison.m4, data/c.m4, data/java.m4, doc/bison.texinfo,
	* tests/c++.at, tests/calc.at, tests/java.at, tests/local.at
	(token.prefix): Rename as...
	(api.tokens.prefix): this.
2009-05-15 16:10:52 +02:00
Akim Demaille 3c248d705d doc: use C++ headers.
* doc/bison.texinfo (Calc++ Scanner): Prefer C++ headers to C
	headers.
2009-05-11 08:27:14 +02:00
Akim Demaille 99c08fb662 doc: token.prefix
* doc/bison.simple (Decl Summary): Document token.prefix.
	(Calc++ Parser): Various fixes.
	Formatting changes.
	Use token.prefix.
	Introduce a macro TOKEN to shorten the code and make it more
	readable.
	(Calc++ Scanner): Adjust.
	* NEWS (Variable token.prefix): New.
2009-05-11 08:26:36 +02:00
Akim Demaille ab2a9f5793 tests: check token numbers.
* tests/input.at (Numbered tokens): New.
2009-05-05 09:49:55 +02:00
Akim Demaille 84a1cb5ad0 bison: catch bad symbol names.
* src/scan-gram.l({int}{id}): Report as an invalid identifier.
	* tests/input.at: Adjust.
2009-05-04 21:44:40 +02:00
Akim Demaille cdf3f11338 identifiers: dashes are letters.
Dashes can now start identifiers (symbols and directives).

	* src/scan-gram.l ({letter}): Add dash.
	({id}): Remove it.
	* tests/input.at (Symbols): Adjust.
	Remove stray comment.
	* tests/regression.at (Invalid inputs): Adjust error message.
	* doc/bison.texinfo (Symbols): Update.
2009-05-04 21:38:42 +02:00
Joel E. Denny 98a345a219 Declare %code to be a permanent feature.
* NEWS (2.4.2): Here.
* doc/bison.texinfo (Prologue Alternatives): Don't say it's
experimental.
(Decl Summary): Likewise.
(cherry picked from commit cefb18280b)
2009-05-01 03:07:35 -04:00
Joel E. Denny 6721294104 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.
(cherry picked from commit 812775a039)

Conflicts:

	data/c.m4
	etc/bench.pl.in
	src/parse-gram.c
	src/parse-gram.h
	tests/conflicts.at
2009-04-30 03:43:58 -04:00
Joel E. Denny ba5c6d94b6 Set all front-end %define defaults in one place.
* src/main.c (main): Move lr.keep_unreachable_states default...
* src/reader.c (reader): ... to here.
(cherry picked from commit 1c4aa81df1)
2009-04-30 02:52:19 -04:00
Joel E. Denny 5bab9d0862 Rename lr.default_reductions to lr.default-reductions.
* NEWS (2.5): Here.
* doc/bison.texinfo: Here.
* src/lalr.c (initialize_LA): Here.
* src/print.c (print_reductions): Here.
* src/reader.c (reader): Here.
* src/tables.c (action_row): Here.
* tests/input.at (%define enum variables): Here.
* tests/reduce.at (AT_TEST_LR_DEFAULT_REDUCTIONS): Here.
(cherry picked from commit 1d0f55cc84)
2009-04-30 02:48:47 -04:00
Joel E. Denny d521ee19f8 Pacify ./configure --enable-gcc-warnings.
* tests/input.at (Symbols): Prototype yyerror and yylex.
(cherry picked from commit 0b59345789)

Conflicts:

	ChangeLog
2009-04-29 20:54:59 -04:00
Joel E. Denny c9aded4b88 Document how `%define "var" "value"' is not M4-friendly.
* src/parse-gram.y (variable): In comments here.
(cherry picked from commit 904ea1bca411d4d5f4f729e7f2982841a858f5ea)

Conflicts:

	src/parse-gram.c
2009-04-29 20:19:17 -04:00
Joel E. Denny 8f0d265e9d Clean up recent patches a little.
Reported by Akim Demaille.
* doc/bison.texinfo (Understanding): Fix typos.
* src/print.c (print_reductions): Don't use negated variable.
(cherry picked from commit 379261b3fd)
2009-04-24 02:54:47 -04:00
Joel E. Denny f49097730e List accepted values for a %define enum variable with an invalid value.
Suggested by Akim Demaille at
<http://lists.gnu.org/archive/html/bison-patches/2009-04/msg00082.html>.
* data/bison.m4 (_b4_percent_define_check_values): Implement.
* src/muscle-tab.c (muscle_percent_define_check_values): Implement.
* tests/input.at (%define lr.default_reductions invalid values): Merge
into...
(%define enum variables): ... here, and update output.
(cherry picked from commit 25029e164a)
2009-04-24 02:54:10 -04:00
Joel E. Denny 110ef36a1a Rename "default rule" to "default reduction".
This includes changing variable names in code, changing
comments, and renaming %define lr.default_rules to %define
lr.default_reductions.
* NEWS (2.5): Update IELR documentation.
* data/bison.m4 (b4_integral_parser_tables_map): Adjust YYDEFACT
documentation.
* data/glr.c, data/lalr1.java: Sync copyright dates.
* doc/bison.texinfo (Decl Summary): Adjust lr.default_reductions
and lr.type documentation.  Make some other wording
improvements.
(Glossary): Adjust cross-references and Default Reduction
definition.
* src/lalr.c (state_lookahead_tokens_count): Adjust code.
Remove a confusing comment pointed out by Akim Demaille.
(initialize_LA): Adjust code.
* src/print-xml.c (print_reductions): Adjust code.
* src/print.c (print_reductions): Adjust code.
* src/reader.c (reader): Adjust code.
* src/tables.c (action_row): Adjust code.
(token_actions): Adjust code.
* src/tables.h: Adjust YYDEFACT documentation.
* tests/input.at (%define lr.default_rules invalid values):
Rename test group to...
(%define lr.default_reductions invalid values): ... this, and
update grammar file and expected output.
* tests/reduce.at (AT_TEST_LR_DEFAULT_RULES): Rename to...
(AT_TEST_LR_DEFAULT_REDUCTIONS): ... this, and update.
2009-04-23 04:18:13 -04:00
Akim Demaille 746ee38c7c tests: check the use of dashes and periods in symbols.
* tests/input.at (Symbol): New test group.
2009-04-21 22:19:35 +02:00
Joel E. Denny eb45ef3ba6 Document %define lr.type and lr.default_rules.
* NEWS (2.5): Add an entry.
* src/getargs.c (usage): Mention IELR(1) and canonical LR(1)
besides just LALR(1) and GLR(1).
* doc/bison.texinfo (Introduction): Likewise.
(Language and Grammar): Bison is no longer limited to LALR(1)
restrictions.
(GLR parsing): Say deterministic or LR(1) rather than LALR(1)
when trying to distinguish from GLR.  Talk about LR(1) grammars
rather than LALR(1) grammars.
(Decl Summary): In %define api.push_pull entry, say it applies
to deterministic parsers in C rather than LALR(1) parsers in C.
Add lr.default_rules entry.
Add lr.type entry.
(Mystery Conflicts): Bison is no longer limited to LALR(1)
restrictions.
(Generalized LR Parsing): Same changes as for the previous GLR
section.
(Memory Management): Say deterministic rather than LALR(1).
(Understanding): Correct some bison output.
Index discussion of "accepting state".
Say deterministic rather than LALR(1).
(Bison Options): In --yacc entry, say deterministic rather than
LALR(1).
In --report, --graph, and --xml entries, just don't mention
LALR(1).
(C++ Parsers): Say deterministic rather than LALR(1).
(Table of Symbols): Likewise in YYSTACK_USE_ALLOCA entry.
(Glossary): Add Accepting State, Consistent State, Default Rule,
and IELR(1) definitions.
In Generalized LR (GLR) definition, make same changes as in
previous GLR sections.
In LALR(1) definition, say Bison uses LALR(1) by default rather
than implying Bison is limited to LALR(1).
(LocalWords): Add IELR.
(cherry picked from commit 34a6c2d19b)
2009-04-21 06:01:19 -04:00
Joel E. Denny db34f79889 Finish implementing %define lr.type.
Its value can be "LALR", "IELR", or "canonical LR".
* lib/timevar.def (TV_IELR_PHASE1): New var.
(TV_IELR_PHASE2): New var.
(TV_IELR_PHASE3): New var.
(TV_IELR_PHASE4): New var.
* src/local.mk (src_bison_SOURCES): Add AnnotationList.c,
AnnotationList.h, InadequacyList.c, InadequacyList.h, Sbitset.c,
Sbitset.h, ielr.c, and ielr.h.
* src/getargs.h, src/getargs.c (enum trace, trace_args,
trace_types): Add trace_ielr.
* src/lalr.h, src/lalr.c (ngotos): Export it.
(F): Rename to...
(goto_follows): ... this, update all uses, and export it.
(set_goto_map): Export it.
(map_goto): Export it.
(compute_lookahead_tokens): Don't free goto_follows yet.  Now
handled in ielr.
(initialize_LA): Export it.  Move lookback allocation to...
(lalr): ... here because, for canonical LR, initialize_LA must
be invoked but lookback and much of the rest of LALR isn't
needed.
* main.c (main): Instead of lalr, invoke ielr, which invokes
lalr.
* src/reader.c (reader): Default lr.type to "LALR".
Default lr.default_rules to "accepting" if lr.type is "canonical
LR".  Leave the default as "all" otherwise.
Check for a valid lr.type value.
* src/state.h, src/state.c (struct state_list): Add state_list
member.
(state_new): Initialize state_list member to NULL.
(state_new_isocore): New function, exported.
* tests/existing.at (AT_TEST_EXISTING_GRAMMAR): New macro that
exercises all values of lr.type.
(GNU AWK Grammar): Rename test group to...
(GNU AWK 3.1.0 Grammar): ... this, and extend to use
AT_TEST_EXISTING_GRAMMAR.
(GNU Cim Grammar): Extend to use AT_TEST_EXISTING_GRAMMAR.
(GNU pic Grammar): Rename test group to...
(GNU pic (Groff 1.18.1) Grammar): ... this, and extend to use
AT_TEST_EXISTING_GRAMMAR.
* tests/reduce.at (AT_TEST_LR_TYPE): New macro that exercises
all values of lr.type.
(Single State Split): New test groups using AT_TEST_LR_TYPE.
(Lane Split): Likewise.
(Complex Lane Split): Likewise.
(Split During Added Lookahead Propagation): Likewise.
2009-04-21 06:00:09 -04:00
Joel E. Denny 7fe11bb55c Add new files for IELR and canonical LR implementation.
* src/AnnotationList.c: New.
* src/AnnotationList.h: New.
* src/InadequacyList.c: New.
* src/InadequacyList.h: New.
* src/Sbitset.c: New.
* src/Sbitset.h: New.
* src/ielr.c: New.
* src/ielr.h: New.
2009-04-21 05:59:36 -04:00
Joel E. Denny 7254f6a840 Implement %define lr.default_rules.
Its value describes the states that are permitted to contain
default rules: "all", "consistent", or "accepting".
* src/reader.c (reader): Default lr.default_rules to "all".
Check for a valid lr.default_rules value.
* src/lalr.c (state_lookahead_tokens_count): If lr.default_rules
is "accepting", then only mark the accepting state as
consistent.
(initialize_LA): Tell state_lookahead_tokens_count whether
lr.default_rules is "accepting".
* src/tables.c (action_row): If lr.default_rules is not "all",
then disable default rules in inconsistent states.
* src/print.c (print_reductions): Use this opportunity to
perform some assertions about whether lr.default_rules was
obeyed correctly.
* tests/local.at (AT_TEST_TABLES_AND_PARSE): New macro that
helps with checking the parser tables for a grammar.
* tests/input.at (%define lr.default_rules invalid values): New
test group.
* tests/reduce.at (AT_TEST_LR_DEFAULT_RULES): New macro using
AT_TEST_TABLES_AND_PARSE.
(`no %define lr.default_rules'): New test group generated by
AT_TEST_LR_DEFAULT_RULES.
(`%define lr.default_rules "all"'): Likewise.
(`%define lr.default_rules "consistent"'): Likewise.
(`%define lr.default_rules "accepting"'): Likewise.
2009-04-21 05:58:05 -04:00
Akim Demaille 72e727f2ec Formatting change. 2009-04-20 23:52:25 +02:00
Akim Demaille 90462b8dd9 bison: factoring.
* src/output.c (token_definitions_output): Use symbol_id_get
	instead of duplicating its logic.
	* TODO (YYERRCODE): Extend.
2009-04-20 23:52:15 +02:00
Akim Demaille 71b00ed874 variables: prefer error-verbose to error_verbose.
* data/bison.m4 (b4_error_verbose_if): Based on error-verbose
	instead of error_verbose.
	* src/scan-gram.l (%error-verbose): Map the error-verbose
	variable.
	* doc/bison.texinfo: Promote %define error-verbose instead of
	%error-verbose.
	* tests/actions.at: Prefer %define error-verbose to %error-verbose.
2009-04-20 23:17:54 +02:00
Akim Demaille 1c72905811 Regen.
* src/parse-gram.h, src/parse-gram.c: Regen.
2009-04-20 23:17:54 +02:00
Akim Demaille 4f646c3794 variables: accept dashes.
* data/bison.m4 (b4_percent_define_if_define_): Also map dashes to
	underscores.
	* src/scan-gram.l ({id}): Also accept dashes after the initial
	letter.
	({directive}): Use {id}.
	* src/parse-gram.y: Comment and formatting changes.
	* doc/bison.texinfo (Symbols): Adjust the lexical definitions of
	symbols.
	* src/complain.h, src/complain.c (yacc_at): New.
	* src/symtab.c (symbol_new): Use yacc_at to report inappropriate
	symbol names.
	* src/output.c (token_definitions_output): Do not #define token
	names with dashes.
2009-04-20 23:17:51 +02:00
Akim Demaille 184e317956 Consistently refer to Yacc, not YACC.
* src/getargs.c (usage, warnings_args): s/YACC/Yacc/.
2009-04-20 13:23:49 +02:00
Joel E. Denny 41253c3a9d Pacify make maintainer-check-posix.
* tests/input.at (%define, --define): Move bison command-line
options before grammar file name.
2009-04-17 16:14:17 -04:00
Joel E. Denny 197b82ba54 Document semicolon warnings.
* NEWS (2.5): Here.
(cherry picked from commit a2d0567444)
2009-04-17 00:25:13 -04:00
Akim Demaille 16dc0d9025 Fix ChangeLog. 2009-04-14 08:18:24 +02:00
Akim Demaille 0c90a1f5e9 variables: use parse.assert' instead of assert'.
* TODO (assert): Remove.
	* data/bison.m4 (b4_assert_if): Replace with...
	(b4_parse_assert_if): this.
	* data/lalr1.cc, data/variant.hh, tests/c++.at: Adjust.
	* doc/bison.texinfo (Decl Summary): Document parse.assert.
2009-04-14 08:11:19 +02:00
Akim Demaille fa81950916 variables: use parse.assert' instead of debug'.
* src/getargs.c (getargs): Map -t to %define trace.parse.
	* src/scan-gram.l (%debug): Map to %define trace.parse.
	* data/bison.m4 (b4_percent_define_if_define): Map `.' in variable
	names to `_' in macro names.
	(b4_debug_if): Replace with...
	(b4_parse_trace_if): this.
	* data/glr.c, data/glr.cc, data/lalr1.cc, data/lalr1.java,
	* data/yacc.c: Adjust.
	* doc/bison.texinfo (Decl Summary): Document %debug as obsoleted.
	Use @code to label the variable list.
	Document the variable parse.trace.
	(Tracing): Promote the parse.trace variable.
	* TODO: %printer is not documented.
2009-04-14 08:11:16 +02:00
Akim Demaille f7dae1ea51 doc: minor fixes.
* doc/bison.texinfo (Decl Summary): Fix entry about %debug.
	(Table of Symbols): Remove duplicate entry for %debug.
2009-04-14 08:11:11 +02:00
Eric Blake 3535c0714e submodules: update to latest
* submodules/autoconf: Use latest upstream Autoconf.

Signed-off-by: Eric Blake <[email protected]>
(cherry picked from commit 7ba0d59da0)
2009-04-10 07:37:47 -06:00
Eric Blake cf48f6755c Work around autoconf 2.63b bug in testsuite.
* tests/output.at (AT_CHECK_OUTPUT_FILE_NAME): Avoid tripping
autoconf bug related to # in test.

Signed-off-by: Eric Blake <[email protected]>
(cherry picked from commit ab3a683f05)
2009-04-10 07:15:43 -06:00
Joel E. Denny 50cca36825 * NEWS (2.5): New section. Describe new -D/--define feature. 2009-04-06 17:36:08 -04:00
Akim Demaille 3583d96b77 Regen.
* src/parse-gram.h, src/parse-gram.c: Regen.
2009-04-06 13:24:58 +02:00
Akim Demaille 00f5d57533 rename muscle_tab.* as muscle-tab.* for consistency.
* src/muscle_tab.h, src/muscle_tab.c: Rename as...
	* src/muscle-tab.h, src/muscle-tab.c: these.
	* src/getargs.c, src/local.mk, src/main.c, src/output.c,
	* src/parse-gram.y, src/reader.c, src/scan-code.l: Adjust.
2009-04-06 13:24:54 +02:00
Akim Demaille 76bf510242 Makefile: introduce $(BISON).
* src/local.mk (BISON): New.
	(YACC): Use it.
2009-04-06 13:24:50 +02:00
Akim Demaille bc0f573730 parser: handle %locations as %define locations.
* src/getargs.h, src/getargs.c (locations_flag): Remove.
	* src/getargs.c, src/scan-code.l: Use muscle_percent_define_ensure
	to set "locations" to true.
	* src/output.c (prepare): Don't output "locations".
	* src/scan-gram.l (%locations): Handle it as a %<flag>.
	* src/parse-gram.y: It's no longer a token.
	Don't handle it.
	* data/bison.m4 (b4_locations_if): Define it with
	b4_percent_define_if_define.
	* data/c.m4, data/glr.cc: Adjust.
2009-04-06 13:24:47 +02:00
Akim Demaille 697c912fa4 Regen.
* src/parse-gram.c: Regen.
2009-04-06 13:24:43 +02:00
Akim Demaille 4920ae8b66 muscle: factor the handling of obsolete of obsolete directives.
Suggested by Joel E. Denny.

	* src/muscle_tab.h, src/muscle_tab.c (muscle_percent_define_ensure):
	New, extracted from...
	* src/parse-gram.y (prologue_declaration: pure-parser): here.
	Remove it.
	(prologue_declaration: "%<flag>"): Use
	muscle_percent_define_ensure.
	(%error-verbose, %pure-parser): No longer tokens.
	* src/scan-gram.l (pure-parser): Return as a %<flag>.
2009-04-06 13:24:32 +02:00
Joel E. Denny 1d5b3c08fe Fix options documentation.
* build-aux/cross-options.pl: As in --help output, write optional
arguments as [=ARG] not =[ARG].
* doc/bison.texinfo (Bison Options): Add -W/--warnings argument.
2009-04-06 02:56:13 -04:00
Joel E. Denny 62c99cf4ea Replace BISON_PROG_GNU_M4 with Autoconf's AC_PROG_GNU_M4.
If the first m4 in $PATH is wrong, it keeps looking.  Moreover, its
requirements for a correct m4 are stricter.
* m4/m4.m4: Make it a symbolic link to submodules/autoconf/m4/m4.m4.
* configure.ac: Update to use AC_PROG_GNU_M4.
Reported by Eric Blake.
2009-04-04 20:58:46 -04:00
Joel E. Denny 1c93f35bfa Help with updating web manual.
* HACKING: Incorporate instructions from gnulib/doc/README.
* bootstrap.conf (gnulib_modules): Add gendocs.
2009-04-03 18:54:41 -04:00
Akim Demaille 86cfae0a48 Regen.
* src/parse-gram.h, src/parse-gram.c: Regen.
2009-04-03 10:34:15 +02:00
Akim Demaille ba061fa6f2 Factor %FLAG at scan level.
* src/parse-gram.y (PERCENT_DEBUG, PERCENT_ERROR_VERBOSE): Token
	definitions and associated rules, replaced by....
	(PERCENT_FLAG): this new token type, and rule.
	* src/scan-gram.l (RETURN_PERCENT_FLAG): New.
	Use it for %debug and %error-verbose.
2009-04-03 10:32:10 +02:00
Akim Demaille b19ebeb335 Regen.
* src/parse-gram.h, src/parse-gram.c: Regen.
2009-04-03 10:31:42 +02:00
Akim Demaille 001a16a9cd Update ChangeLog. 2009-04-03 10:30:30 +02:00
Akim Demaille 0ce615753e Treat %debug as %define debug.
* data/bison.m4 (b4_debug_if): New.
	* data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c,
	* data/lalr1.java: Use it instead of b4_debug_flag.
	* src/getargs.h, src/getargs.c (debug_flag): Remove.
	* src/output.c (prepare): Don't output it.
	* src/parse-gram.y: Treat %debug as %define debug.
2009-04-03 10:26:10 +02:00
Akim Demaille dc450175c0 Regen.
* src/parse-gram.h, src/parse-gram.c: Regen.
2009-04-03 10:26:10 +02:00
Akim Demaille b3a2272a73 Treat %error-verbose as %define error_verbose.
This allows to pass -Derror_verbose on the command line.  Better yet, it
allows to pass -Derror_verbose=$(ERROR_VERBOSE), with ERROR_VERBOSE being
defined as false or true.

	* data/bison.m4 (b4_percent_define_if_define): Instead of relying
	on b4_percent_define_ifdef, for does not check the defined value,
	but only whether the symbol is defined, rely on
	b4_percent_define_flag_if, so that a value of "false" is processed
	as a false.
	If not defined, define the flag to "false".
	(b4_error_verbose_if): New.
	* data/glr.c, data/lalr1.cc, data/yacc.c: Use it instead of
	b4_error_verbose_flag.
	* src/getargs.h, src/getargs.c (error_verbose_flag): Remove.
	* src/output.c (prepare): Don't output it.
	* src/parse-gram.y (%error-verbose): Treat as %define error_verbose.
2009-04-03 10:26:09 +02:00
Joel E. Denny 92822affc5 Fix strange %define locations for default values.
Reported by Akim Demaille at
<http://lists.gnu.org/archive/html/bug-bison/2007-12/msg00001.html>
and discussed again starting at
<http://lists.gnu.org/archive/html/bison-patches/2008-11/msg00102.html>.
* data/bison.m4 (b4_percent_define_default): Leave syncline blank
because location information is bogus.
Use angle brackets to delimit fake file name because square brackets
look like over-quoted m4.  Choose a better fake file name.
Use negative line numbers.
* src/muscle_tab.c (muscle_percent_define_default): Likewise.
* src/location.c (location_print): If line for a boundary is negative,
only print that boundary's file name.
* src/location.h: Document that.
* tests/skeletons.at (%define Boolean variables: invalid skeleton
defaults): Update output.
2009-04-03 03:55:08 -04:00
Joel E. Denny e021191bcf Pacify ./configure --enable-gcc-warnings.
* Makefile.am (AM_CFLAGS): Remove $(WERROR_CFLAGS) because many files
in lib won't compile with it.
* src/local.mk (src_bison_CFLAGS): Use $(WERROR_CFLAGS) here only.
2009-04-03 00:32:27 -04:00
Akim Demaille 78f654185a bootstrap: --help to stdout.
* bootstrap (usage): Don't send --help to stderr.
	Use a here doc instead of a long string.
2009-03-31 11:11:26 +02:00
Akim Demaille f7e241f4af bootstrap: README-hacking no longer exists
* bootstrap (checkout_only_file): Set to HACKING.
2009-03-31 11:11:16 +02:00
Akim Demaille 1f9d82480e ChangeLog: formatting changes. 2009-03-27 07:28:26 +01:00
Akim Demaille 31d3e51094 doc: merge HACKING and README-hacking.
Two files is confusing.
Reported by Alexandre Duret-Lutz.

	* README-hacking: Merge into...
	* HACKING (Working from the repository): here.
2009-03-27 07:27:21 +01:00
Akim Demaille 81535bfa35 doc: update README-hacking.
* README-hacking: We now use git and git submodules.
	Reported by Ralf Wildenhues and Alexandre Duret-Lutz.
2009-03-27 07:27:07 +01:00
Akim Demaille 56f772e95e lalr1.cc: avoid GCC 4.3 warnings.
GCC 4.3 now warns about "a || b && c" and asks for explicit
parentheses.
Reported by Alexandre Duret-Lutz.
	* data/location.cc: Update copyright years.
	(Position::operator==): Use parens to make precedence explicit.
	Compare lines and columns first, as they are more likely to be
	different, and they are faster to compare.
2009-03-27 07:26:24 +01:00
Akim Demaille 11c073b7e5 gnulib: update.
* gnulib: Update to latest.
	* src/local.mk (AM_CFLAGS): Move to...
	* Makefile.am: here.
	* etc/prefix-gnulib-mk (prefix_assignment): Also transform
	AM_CFLAGS.
2009-03-27 07:23:53 +01:00
Akim Demaille 91be6b283e Comment changes. 2009-03-02 17:06:55 +01:00
Akim Demaille cbf25ce74f Share b4_yytranslate_define.
* data/lalr1.cc (b4_yytranslate_define): Move to...
	* data/c++.m4: here.
2009-03-02 16:34:09 +01:00
Akim Demaille 882f02ed83 Use locations in the variant example.
Yes, this obfuscates the point of this example, variants only.  But glr.cc
cannot work (yet?) without locations.  This change makes it easier to use
this example with glr.cc.

	* examples/variant.yy (assert): %define it.
	(locations): Request them.
	(yylex): Bind the location to the stage.
2009-03-02 16:30:57 +01:00
Akim Demaille 0623bacc05 Dub make_TOKEN as a public type interface.
* data/c++.m4 (b4_symbol_constructor_declare)
	(b4_symbol_constructor_define): New empty stubs.
	(b4_public_types_declare, b4_public_types_define): Use them.
	* data/lalr1.cc (b4_symbol_constructor_declare)
	(b4_symbol_constructor_declare_)
	(b4_symbol_constructor_define_, b4_symbol_constructor_define):
	Move to...
	* data/variant.hh: here.
	Remove the "b4_variant_if" parts, as variant.hh is loaded only if
	needed.
	* data/lalr1.cc: No longer invoke b4_symbol_constructor_define and
	b4_symbol_constructor_declare, as it is now done by
	b4_public_types_define and b4_public_types_declare.
2009-03-02 16:27:48 +01:00
Akim Demaille 5f5a90dff6 Coding style changes.
* data/lalr1.cc (b4_symbol_constructor_declaration_)
	(b4_symbol_constructor_declarations)
	(b4_symbol_constructor_definition_)
	(b4_symbol_constructor_definitions)
	(b4_yytranslate_definition): Rename as...
	(b4_symbol_constructor_declare_)
	(b4_symbol_constructor_declare)
	(b4_symbol_constructor_define_)
	(b4_symbol_constructor_define)
	(b4_yytranslate_define): these.
	* data/variant.hh (b4_variant_definition): Rename as...
	(b4_variant_define): this.
2009-03-02 16:24:21 +01:00
Akim Demaille b47b6ff7fd Factor b4_assert_if, b4_lex_symbol_if, and b4_variant_if.
* data/bison.m4 (b4_percent_define_if_define): New.
	* data/c++.m4 (b4_variant_if): Move to...
	* data/bison.m4: Here, using b4_percent_define_if_define.
	* data/lalr1.cc (b4_assert_if, b4_lex_symbol_if): Move to...
	* data/bison.m4: Here, using b4_percent_define_if_define.
2009-03-02 16:20:26 +01:00
Akim Demaille 1d6b689b26 Dub symbol_type_base as a public type.
* data/c++.m4 (b4_public_types_declare): Now define
	symbol_type_base and symbol_type.
	(b4_public_types_define): New.
	In both cases, the definitions are taken verbatim from lalr1.cc.
	* data/lalr1.cc: Adjust.
2009-03-02 16:15:28 +01:00
Akim Demaille 4f84717d23 b4_public_types_declare.
* data/c++.m4 (b4_public_types_declare): New.
	* data/glr.cc, data/lalr1.cc: Use it.
2009-03-02 16:12:11 +01:00
Akim Demaille b9e4eb5b72 b4_semantic_type_declare.
* data/c++.m4 (b4_semantic_type_declare): New.
	Factors and generalizes what was in glr.cc and lalr1.cc.
	* data/variant.hh (b4_semantic_type_declare): Redefine it for
	variants.
	* data/lalr1.cc, data/glr.cc: Use it.
2009-03-02 16:08:07 +01:00
Akim Demaille 6a6e7f0c65 Upgrade gnulib.
* gnulib: Upgrade from master.
	* lib/.cvsignore, lib/.gitignore, m4/.cvsignore, m4/.gitignore:
	Regen.
2009-02-26 00:12:14 +01:00
Akim Demaille e9e61b0002 Remove useless arguments.
* data/glr.c (yy_reduce_print): $$ and @$ are not used and not
	relevant.
2009-02-25 23:45:46 +01:00
Akim Demaille 3eead995a4 Comment changes.
* data/lalr1.cc: here.
2009-02-25 23:41:40 +01:00
Akim Demaille 87f28efe7e Fix glr.cc's debug level handling.
* data/glr.cc (yydebug_): Remove, as it is actually yydebug from
	glr.c which is used.
	(debug_level, set_debug_level): Adjust.
2009-02-25 23:38:27 +01:00
Akim Demaille 9be2a009c4 Copyright years.
* data/glr.c: Add 2007 and 2008 here, consistenly with the comments.
2009-02-25 23:34:45 +01:00
Akim Demaille 07a6e87d46 Style changes.
* etc/bench.pl.in (generate_grammar_list): Consitently use
	location_type, not yy::location.
2009-02-25 23:31:34 +01:00
Akim Demaille 33c78bd23e Comment change.
* data/lalr1.cc: here.
2009-02-25 23:28:15 +01:00
Akim Demaille 49572920dd Make yyparser::error public.
* data/lalr1.cc: here.
	There is no good reason to keep it private (and it is convenient
	to use it from the scanner for instance).  It is already public in
	glr.cc.
2009-02-19 22:16:19 +01:00
Akim Demaille 88654b47c9 Comment changes.
* data/glr.cc: here.
2009-02-19 22:12:44 +01:00
Akim Demaille 4524c55bcf Remove trailing blanks.
The epilogue has its own ending \n, no need to add another.

	* data/glr.c, data/lalr1.java, data/yacc.c: dnl when outputing the
	epilogue.
	* data/glr.cc: dnl when extending the epilogue.
	Remove stray "private:".
2009-02-19 22:08:08 +01:00
Akim Demaille 6ceccee88d Use b4_c_modern.
* data/c.m4 (b4_c_function_decl): Here.
2009-02-19 22:02:56 +01:00
Akim Demaille 9c6a89660e Comment changes.
* data/lalr1.cc: here.
2009-02-19 21:58:13 +01:00
Akim Demaille 507aa0e2a8 Extract variant.hh
* data/variant.hh: New, extracted from...
	* data/lalr1.cc: here.
	Adjust.
	* data/local.mk: Adjust.
2009-02-19 21:53:58 +01:00
Akim Demaille 51bacae6b5 Extract stack.hh from lalr1.cc.
* data/stack.hh: New.
	* data/lalr1.cc: Extract from here.
	* data/local.mk: Adjust.
2009-02-19 21:49:46 +01:00
Joel E. Denny 06c3084fb5 Add reminder about uploading public key to keys.gnupg.net.
* HACKING (Release Procedure): Here.
2009-02-03 03:14:12 -05:00
Samuel TardieuandAkim Demaille 253192e69a Force a large alignment of a variant structure.
This is a temporary band-aid until Bison gets proper alignment handling.
We need it on ARM.

	* data/lalr1.cc (variant): Declare the buffer as a union to force
	the same alignment as "long double".
2009-01-28 15:46:05 +01:00
Akim Demaille 0ea583d250 Update NEWS.
* NEWS: Import changes in 2.4.1 and 2.4.2.
2009-01-28 15:45:00 +01:00
Akim Demaille 402b123d0c Reformat NEWS.
* NEWS: Use more outline-mode markup.
	Suggested by Jim Meyering.
2009-01-28 15:39:30 +01:00
Akim Demaille 74553c98a2 Fix grep portability issues.
Grep on Solaris does not support -q.
Reported by Summum Bonum.

	* NEWS: Add a stub for 2.4.2.
	* THANKS: Add Summum Bonum.
	* tests/atlocal.in (EGREP): New.
	(CC, CXX, XSLTPROC): Make it possible to override them via
	envvars.
	* tests/java.at: Use $EGREP instead of egrep.
	Use AT_CHECK's ignore instead of grep's -q.
2009-01-28 15:29:47 +01:00
Akim Demaille 84eedf86fe Pass the token type to yysyntax_error.
* data/yacc.c (yysyntax_error): Take the transated token instead
	of the raw number.
	Adjust callers.
	* TODO: Update.
2008-12-11 10:47:14 +01:00
Akim Demaille 5860cc8c1c Formatting changes.
* data/glr.c: Formatting changes.
2008-12-11 10:47:10 +01:00
Akim Demaille 2b008529ed Propagate i18n changes into glr.c.
* TODO: Update.
	* data/glr.c (yyreportSyntaxError): Use "switch" instead of
	building the error message format dynamically.
	* data/lalr1.java: Formatting changes.
2008-12-11 10:47:06 +01:00
Akim Demaille 2cd1af957a Use testsuite -C.
* tests/local.mk: Replace "cd && testsuite" by "testsuite -C".
	Solves problems when top_srcdir is an absolute path.
	Suggested by Eric Blake.
	* configure.ac: Require Autoconf 2.62.
2008-12-11 10:46:25 +01:00
Akim Demaille eeb2942237 Simplify the i18n of the error messages.
* data/lalr1.cc: Comment changes.
	* data/yacc.c (yysyntax_error): Rewrite, using a switch as in
	lalr1.cc instead of building dynamically the format string.
2008-12-11 10:45:52 +01:00
Akim Demaille e5fa6147ef Really add autoconf as a submodule.
* submodules/autoconf: New.
2008-12-08 14:00:34 +01:00
Akim Demaille 6617622c9a Fix portability issue in the test suite.
* tests/local.at (AT_MATCHES_CHECK): New.
	Based on Perl instead of Sed.  Sed has too many portability
	pitfalls, not ever Sed is GNU Sed.
	* tests/actions.at (Fix user actions without a trailing semicolon):
	Use it.
2008-12-08 10:34:01 +01:00
Akim Demaille 2ca1136c7c Update data/README.
* data/README: Document glr.cc, lalr1.java, m4sugar and xslt.
2008-12-08 09:47:35 +01:00
Akim Demaille 6c63b895fb Install autoconf as a submodule to get m4sugar.
* .gitmodules: Add submodules/autoconf.
	* data/m4sugar/foreach.m4, data/m4sugar/m4sugar.m4: Now links into
	submodules/autoconf.
2008-12-08 09:47:31 +01:00
Akim Demaille 417e31d2c3 Test token.prefix in all the skeletons.
* data/java.m4 (b4_token_enum): Use the token.prefix.
	* tests/local.at (AT_BISON_OPTION_PUSHDEFS): Define AT_TOKEN_PREFIX.
	* tests/calc.at (_AT_DATA_CALC_Y): Use it.
	Add checks for yacc.c, glr.c, lalr1.cc and glr.cc.
	* tests/java.at: Comment changes.
	(AT_CHECK_JAVA_MINIMAL): Define the END token.
	(Java parser class and package names): Add token.prefix check.
2008-12-08 09:47:26 +01:00
Akim Demaille 97abf54412 Fix regeneration of atconfig.
* tests/local.mk (tests/atconfig): The rule was incorrect, but
	remove it: now that there is no tests/Makefile.am, the top-level
	Makefile properly updates atconfig when needed.
2008-12-08 09:44:38 +01:00
Di-an Jan e8cd1ad655 Implement the FIXME that ends an user action with a semicolon
if it seems necessary.

* src/scan-code.l (flex rules section): Flag cpp directive from
any `#' to the first unescaped end-of-line.  Semicolon is not
needed after `;', `{', '}', or cpp directives and is needed after
any other token (whitespaces and comments have no effect).
* tests/actions.at (Fix user actions without a trailing semicolon):
New test.
* tests/input.at (AT_CHECK_UNUSED_VALUES): Add semicolons to
to make user actions complete statements.
Adjust column numbers in error messages.
* tests/regression.at (Fix user actions without a trailing semicolon):
Remove.  Covered by new test.
2008-12-07 21:54:45 -08:00
Akim Demaille ce9447fc6a Update gnulib.
* gnulib: Update from master.
2008-12-07 22:16:37 +01:00
Eric Blake d333175f63 Avoid compiler warning.
* src/output.c (muscle_insert_item_number_table): Delete unused
function.

Signed-off-by: Eric Blake <[email protected]>
2008-12-05 16:16:15 -07:00
Eric Blake 215b40ac9e Build testsuite with newer autoconf.
* tests/output.at (m4_expand): Don't override in newer autoconf,
where the underlying implementation changed.
* tests/cxx-type.at (_AT_RESOLVED_GLR_OUTPUT)
(_AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_AMBIG_GLR_OUTPUT)
(_AT_AMBIG_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
(_AT_VERBOSE_GLR_STDERR): Expand to double-quoted strings,
since some of them contain unbalanced ')'.

Signed-off-by: Eric Blake <[email protected]>
2008-12-02 10:59:17 -07:00
Akim Demaille 30c10fafcc Fixes in the ChangeLog.
* ChangeLog: Fix typos.
	Formatting changes.
2008-12-01 22:56:43 +01:00
Akim Demaille 3bb211139b Use b4_symbol for printers and destructors everywhere.
* data/bison.m4 (b4_symbol_action_location): New.
	* data/c.m4 (b4_symbol_actions): Remove.
	Adjust all callers to use by b4_symbol_foreach and the corresponding
	b4_symbol_printer/destructor macro.
	* data/glr.cc: Adjust.
	* data/lalr1.java: Adjust the %destructor sanity check.
	* src/output.c (symbol_code_props_output): Remove, we no longer
	need the b4_symbol_printers/destructors tables.
2008-12-01 22:32:33 +01:00
Akim Demaille fb7c5b1f23 Use b4_symbol_case_.
* data/lalr1.cc, data/bison.m4 (b4_symbol_action): Use
	b4_symbol_case_.
2008-12-01 22:29:20 +01:00
Akim Demaille cf6fb2226d Move b4_symbol based macro to bison.m4.
* data/lalr1.cc (b4_symbol_, b4_symbol, b4_symbol_if)
	(b4_symbol_action, b4_symbol_destructor, b4_symbol_printer)
	(b4_symbol_case_, b4_symbol_foreach, b4_type_action_)
	(b4_type_foreach): Move to...
	* data/bison.m4: Here.
	* data/lalr1.cc (b4_symbol_action): Specialize for C++: use
	b4_symbol_value_template instead of b4_symbol_value.

s b4_symbols in bison.m4
2008-12-01 22:25:51 +01:00
Akim Demaille e3c52a6362 b4_symbol/type_foreach.
* data/lalr1.cc (b4_symbol_foreach, b4_type_foreach): New.
	Use them.
2008-12-01 22:22:35 +01:00
Akim Demaille 2bde91138d Use the symbol properties to output the printer/destructor for lalr1.cc.
Instead of defining complex list of tuples to define various properties of
the symbols, we now prefer to define symbols as "structs" in m4: using the
symbol key (its number), and the property name, b4_symbol gives it value.
Use this to handle destructors and printers.

	* src/output.c (CODE_PROP): New.
	(prepare_symbol_definitions): Use it to define the printer and
	destructor related attributes of the symbols.
	* data/lalr1.cc (b4_symbol_actions): Rename as...
	(b4_symbol_action): this.
	Use b4_symbol instead of 6 arguments.
	(b4_symbol_printer, b4_symbol_destructor): New.
	Use them instead of b4_symbol_actions.
2008-12-01 22:19:11 +01:00
Akim Demaille 44494bf684 Avoid capturing variables too easily.
* src/muscle_tab.h (MUSCLE_INSERT_BOOL, MUSCLE_OBSTACK_SGROW): Use
	v__ and p__ instead of v and p.
2008-12-01 22:15:51 +01:00
Akim Demaille fad814bd0c Remove spurious empty line before syncline.
* data/bison.m4 (b4_syncline): Don't output an empty line before
	the output.
2008-12-01 22:11:50 +01:00
Akim Demaille feda5527b3 Convert lib/Makefile.am into lib/local.mk.
The real problem is rather gnulib.mk, which itself is extracted from a
Makefile.am that gnulib expects to the "recursive".  The tool
prefix-gnulib-mk converts such a gnulib.mk to be non-recursive.  Also,
some AC_SUBST variables need to be adjusted.

	* etc/prefix-gnulib-mk: New.
	* bootstrap (slurp): Use it to convert further gnulib.mk.
	* lib/Makefile.am: Rename as...
	* lib/local.mk: this.
	Adjust to be prefixed.
	* Makefile.am, configure.ac: Adjust.
	* src/local.mk (AM_CPPFLAGS): Extend it, don't define it.
2008-11-26 11:09:19 +01:00
Akim Demaille 56ddee7f8d s/_FLAGS/FLAGS/.
* tests/local.mk (TESTSUITE_FLAGS, AUTOTEST_FLAGS): Rename as...
	(TESTSUITEFLAGS, AUTOTESTFLAGS): these to compy with the GCS.
	Reported by Eric Blake.
2008-11-26 10:31:53 +01:00
Akim Demaille 728e89a09b Use b4_parser_tables_define in glr.cc.
* data/glr.c: Use b4_parser_tables_define instead of defining the
	(deterministic integral) tables by hand.
2008-11-26 10:11:46 +01:00
Akim Demaille 2c1bf9bd68 Use b4_parser_tables_define in Java.
* data/java.m4 (b4_typed_parser_table): Rename as...
	(b4_typed_parser_table_define): this, for consistency.
	Accept a comment as $4.
	Move $2 into yy*_.
	(b4_integral_parser_table): Rename as...
	(b4_integral_parser_table_define): this.
	* data/lalr1.java: Adjust all uses.
	Use b4_parser_tables_define instead of generation by hand.
2008-11-26 10:08:41 +01:00
Akim Demaille ba206cf40a Prepare the convergence bw C style and Java table generation.
* data/bison.m4 (b4_tables_map, b4_tables_declare)
	(b4_tables_define): Rename as...
	(b4_integral_parser_tables_map, b4_parser_tables_declare)
	(b4_parser_tables_define): these.
	* data/c.m4 (b4_table_define): Rename as...
	(b4_integral_parser_table_define): this.
	* data/lalr1.cc: Adjust.
	(b4_table_define, b4_table_declare): Rename as...
	(b4_integral_parser_table_define)
	(b4_integral_parser_table_declare): these.
	(yyrline_): Move the comment where it is actually used.
	* data/yacc.c: Adjust.
	(yyrline): Use b4_integral_parser_table_define.
2008-11-26 10:05:20 +01:00
Akim Demaille d12f8e4940 Regen.
* src/parse-gram.h, src/parse-gram.c: Regen.
2008-11-26 10:02:17 +01:00
Akim Demaille 0991e29b75 Factor the generation of the (integral) tables bw yacc.c and lalr1.cc.
* data/lalr1.cc (b4_tables_map): Move to...
	* data/bison.m4: here.
	Update the comment for yytable during the flight.
	(b4_tables_declare, b4_tables_define): New.
	* data/lalr1.cc: Use them.
	* data/c.m4 (b4_table_define): New.
	* data/yacc.c: Use b4_tables_define instead of output the tables
	by hand.
	* tests/regression.at (Web2c Actions): Adjust the expected output,
	the order of the tables changed.
2008-11-26 09:58:50 +01:00
Akim Demaille 3d3bc1fe30 Get rid of (yy)rhs and (yy)prhs.
These tables are no longer needed in the parsers, and they don't seem to
be useful.  They are not documented either.

	* src/output.c (prepare_rules): Get rid of rhs and prhs.
	Adjust the computation of (yy)r2.
2008-11-26 09:55:31 +01:00
Akim Demaille 08c81469c6 Rule length is unsigned.
* src/gram.h, src/gram.c (rule_rhs_length): Return a size_t.
2008-11-26 09:52:05 +01:00
Akim Demaille 932b0c960a Get rid of lalr1-split.cc.
It was no longer maintainer.

	* data/lalr1-split.cc: Remove.
	* etc/bench.pl.in (bench_fusion_parser): Remove.
	Adjust.
2008-11-26 09:48:24 +01:00
Akim Demaille 8452c667e6 Use yy* consistently.
* data/glr.c: Now that yyrhs no longer exists as a global
	variable, rename local "rhs" variables into "yyrhs" for
	consistency.
2008-11-26 09:44:21 +01:00
Akim Demaille 783aa653f4 Get rid of yyrhs and yyprhs in glr.c.
* data/glr.c (yyrhs, yyprhs): Remove.
	Instead, use the state stack and yystos.
2008-11-25 23:11:34 +01:00
Akim Demaille 6130b75585 Flag glr tests.
* tests/local.at (_AT_BISON_OPTION_PUSHDEFS): If glr, declare it
	as an Autotest keyword.
2008-11-25 23:08:09 +01:00
Akim Demaille 95a7b1c934 Prefer TESTSUITE_FLAGS.
TESTSUITEFLAGS is barely readable.

	* tests/local.mk (TESTSUITE_FLAGS): Default to $(TESTSUITEFLAGS)
	for backward compatibility.
	Use the former instead of the latter.
2008-11-25 23:01:23 +01:00
Akim Demaille b4f1840114 Get rid of yyrhs and yyprhs in larl1.java.
* data/lalr1.java (yyrhs_, yyprhs_): Remove.
	(yy_reduce_print): Rather, use yystos_ and the state stack.
2008-11-25 22:50:10 +01:00
Akim Demaille c265fd6beb Formatting changes. 2008-11-25 22:25:16 +01:00
Akim Demaille 68dbdee86a Get rid of yyrhs and yyprhs in yacc.c.
They were used to get the symbol types, given a rule number,  when
displaying the top of the stack before a reduction.  But the symbol type
is available from the state stack.  This has two be benefits: two tables
less in the parser (making it smaller), and a more consistent use of the
three stacks which will help to fuse them.

	* data/yacc.c (yyprhs, yyrhs): Remove.
	(YY_REDUCE_PRINT): Pass yyssp to yy_reduce_print.
	(yy_reduce_print): Take yyssp as argument.
	Use it, together with yystos, to get the symbol type.
	* tests/regression.at (Web2c Report): Remove these tables from the
	expected output.
2008-11-25 22:21:24 +01:00
Akim Demaille 6ab1adbe1e b4_tables_map.
The point is to factor the generation of the tables across skeletons.
This is language dependant.

	* data/c.m4 (b4_comment_): New.
	Should be usable to define how to generate tables independently of
	the language.
	(b4_c_comment): New.
	(b4_comment): Bounce to b4_c_comment.
	Now support $2 = [PREFIX] for indentation.
	* data/lalr1.cc (b4_table_declare): Don't output a comment if
	there is no comment.
	Indent it properly when there is one.
	Output the ending semicolon.
	(b4_table_define): Space changes.
	Output the ending semicolon.
	(b4_tables_map): New.
	Use it twice instead of declaring and defining the (integral)
	tables by hand.
2008-11-25 22:18:09 +01:00
Akim Demaille 0fddb3d59f b4_table_declare.
* data/lalr1.cc (b4_table_declare): New.
	Use it to declare the tables defined with b4_table_define.
	(b4_table_define): Declare a third arg to match b4_table_declare
	signature.
	Move all the comments around invocations of b4_table_define into
	the invocations itselves.
	Move things around to have the order for declarations and
	definitions.
2008-11-25 22:14:39 +01:00
Akim Demaille c4ddc0fb0b Formatting changes.
* data/lalr1.java: here.
2008-11-25 22:11:09 +01:00
Akim Demaille e0c653e7e6 b4_args is more general than only C++.
* data/lalr1.cc (b4_args, _b4_args): Move to...
	* data/bison.m4: here.
2008-11-25 22:07:23 +01:00
Di-an Jan 4182a0a186 Implement no-XXX arguments for --warnings, --report, --trace.
* src/getargs.c (flags_argmatch): Handles no-XXX.
	Fix typo in doxygen comment.
2008-11-21 13:09:16 -08:00
Akim Demaille 01466c3ebe Display the changes in cross-options.texi.
* build-aux/cross-options.pl ($sep): New, to separate items.
	* doc/local.mk ($(CROSS_OPTIONS_TEXI)): Use diff to display the
	changes.
2008-11-21 21:25:16 +01:00
Di-an Jan a7c09cba09 Improves options in the manual.
* doc/bison.texinfo (-g, -x): Add space before argument.
	(Option Cross Key): Implement FIXME: listing directives also.
	* build-aux/cross-options.pl:  Read from <STDIN> rather than <>.
	(Short Option): Special case -d.  Put arguments inside @option.
	(Bison Directive): Add column, automatically extracted from
	src/scan-gram.l (actual name passed as the first argument)
	with special case for %define.
	* doc/local.mk (doc/cross-options.texi): Pass src/scan-gram.l
	to build-aux/cross-options.pl.
	* src/getargs.c (usage): Document limitations of cross-options.pl.
	* src/scan-gram.l: Likewise.
2008-11-20 12:36:30 -08:00
Joel E. Denny 6c88b51e83 Fix unexpanded macros in GLR defines file.
Reported by Csaba Raduly at
<http://lists.gnu.org/archive/html/bug-bison/2008-11/msg00048.html>.
* THANKS (Csaba Raduly): Add.
* data/glr.c: Fix overquoting on b4_prefix for yylval and yylloc.
* tests/calc.at (_AT_DATA_CALC_Y): If %defines is specified, generate
lexer in a separate module that includes the defines file.
(AT_CHECK_CALC): From AT_FULL_COMPILE, request compilation of lexer
source.
* tests/local.at (_AT_BISON_OPTION_PUSHDEFS): Push AT_DEFINES_IF.
Adjust AT_LOC and AT_VAL to use AT_NAME_PREFIX.
(AT_BISON_OPTION_POPDEFS): Pop AT_DEFINES_IF.
(AT_DATA_SOURCE_PROLOGUE): New.
(AT_DATA_GRAMMAR_PROLOGUE): Use AT_DATA_SOURCE_PROLOGUE.
(AT_DATA_SOURCE): New.
(AT_FULL_COMPILE): Extend to support an additional source file.
2008-11-19 00:24:34 -05:00
Akim Demaille 1e03480793 More TODO.
* TODO: More short term issues.
2008-11-18 21:06:21 +01:00
Akim Demaille e3dda35c52 Regen.
* src/parse-gram.h, src/parse-gram.c: Regen.
2008-11-18 21:03:02 +01:00
Akim Demaille bd187d7b65 Use b4_subtract where possible.
* data/lalr1.cc (b4_subtract): Move to...
	* data/bison.m4: here.
	* data/glr.c (b4_rhs_data): Use it.
	* data/yacc.c (b4_rhs_value, b4_rhs_location): Use it.
2008-11-18 20:57:26 +01:00
Akim Demaille 6085ab0d78 Remove incorrect mode specification.
* data/glr.cc: Don't pretend it's C code.
2008-11-18 20:53:21 +01:00
Joel E. Denny 9ce405ce1d Simplify last patch slightly.
* src/getargs.c (getargs): Here.
2008-11-17 10:51:17 -05:00
Joel E. Denny a8beef7e6a Fix last warning from --enable-gcc-warnings.
* src/getargs.c (getargs): Don't assign const address to non-const
pointer.
2008-11-17 10:36:28 -05:00
Joel E. Denny d50eea6df5 Don't let maintainer-*-check targets force a version update.
* cfg.mk (_is-dist-target): Implement.  maintainer-check* was already
handled.
2008-11-17 09:50:11 -05:00
Di-an JanandPaolo Bonzini f5f419debe Fix formatting and content of bison.texinfo menus
* doc/bison.texinfo: Synchronize ``Detail Node Listing''.
Align menus.  Adjust word wrapping.  Use node names for menu names.
(Examples): Don't abbreviate node names.
(LocalWords): Remove abbreviations.
(Copying): Make description a sentence.
(Java Action Features): Remove period to match the rest of menu.
2008-11-17 11:08:26 +01:00
Di-an JanandPaolo Bonzini d73e55e022 Handles several --enable-gcc-warnings.
* src/getargs.c (command_line_location): Set parameters to void.
* src/output.c (symbol_type_name_cmp): Make static.
(symbols_by_type_name): Set parameters to void.
(symbol_definitions_output): Remove unused parameter.  Rename as...
(prepare_symbol_definitions): this.
(muscles_output): Move symbol_definitions_output to...
(output): here as prepare_symbol_definitions.
* tests/c++.at (AT_CHECK_VARIANTS): Remove unused parameters of main.
(AT_CHECK_NAMESPACE): Make unused parameter lloc unnamed.
2008-11-17 11:01:41 +01:00
Di-an JanandPaolo Bonzini 68c989dea9 Use AT_DATA_GRAMMAR for C++ variants compiled tests.
* tests/c++.at (AT_CHECK_VARIANTS): Fixes tests 198-202.
Use AT_DATA_GRAMMAR instead of AT_DATA for compiled tests.
2008-11-17 11:00:07 +01:00
Akim Demaille 90290ce5dd Fix ChangeLog. 2008-11-16 19:52:33 +01:00
Akim Demaille 23ce6f4cb3 Add missing $(EXEEXT).
* doc/local.mk ($(CROSS_OPTIONS_TEXI)): The target is
	"src/bison$(EXEEXT)".
	Reported by Di-an Jan.
2008-11-16 19:49:35 +01:00
Akim Demaille c5fc95d688 Update ignores.
* data/.cvsignore, data/.gitignore, examples/.cvsignore,
	* examples/.gitignore:
	Remove.
	* build-aux/.cvsignore, build-aux/.gitignore, doc/.cvsignore,
	* doc/.gitignore, etc/.cvsignore, etc/.gitignore, src/.cvsignore,
	* src/.gitignore, tests/.cvsignore, tests/.gitignore:
	Remove MAkefile and Makefile.in.
2008-11-16 19:46:16 +01:00
Akim Demaille dd704c3561 Update TODO.
* TODO: Update.
2008-11-15 15:03:31 +01:00
Akim Demaille dab244d548 Formatting changes.
* tests/input.at: here.
2008-11-15 14:47:02 +01:00
Akim Demaille 4b4da9fb83 Remove duplicate header inclusion.
* src/LR0.c: here.
2008-11-15 14:43:39 +01:00
Akim Demaille 4ea3f53d26 Regen.
* src/parse-gram.h, src/parse-gram.c: Regen.
2008-11-15 14:42:37 +01:00
Akim Demaille b06df3c2c7 Fixes. 2008-11-15 14:41:58 +01:00
Akim Demaille cb823b6f0c Support parametric types.
There are two issues to handle: first scanning nested angle bracket pairs
to support types such as std::pair< std::string, std::list<std::string> > >.

Another issue is to address idiosyncracies of C++: do not glue two closing
angle brackets together (otherwise it's operator>>), and avoid sticking
blindly a TYPE to the opening <, as it can result in '<:' which is a
digraph for '['.

	* src/scan-gram.l (brace_level): Rename as...
	(nesting): this.
	(SC_TAG): New.
	Implement support for complex tags.
	(tag): Accept \n, but not <.
	* data/lalr1.cc (b4_symbol_value, b4_symbol_value_template)
	(b4_symbol_variant): Leave space around types as parameters.
	* examples/variant.yy: Use nested template types and leading ::.
	* src/parse-gram.y (TYPE, TYPE_TAG_ANY, TYPE_TAG_NONE, type.opt):
	Rename as...
	(TAG, TAG_ANY, TAG_NONE, tag.opt): these.
	* tests/c++.at: Test parametric types.
2008-11-15 14:30:05 +01:00
Akim DemailleandAkim Demaille 7b6e67533e Test token.prefix.
This is not sufficient, but we test at least that the make_SYMBOL
interface is not affected by token.prefix.  A more general test
will be implemented when the support of token.prefix is generalized
to more skeletons.

	* tests/c++.at: One more variant test, using token.prefix.
2008-11-15 14:26:46 +01:00
Akim DemailleandAkim Demaille dddec53788 Test the make_TOKEN interface.
* tests/c++.at (AT_CHECK_VARIANTS): Require and use locations.
	Factor the common code in yylex.
	Use it to test "%define lex_symbol".
2008-11-15 14:23:27 +01:00
Akim DemailleandAkim Demaille 7d3e21ba7b Formatting change. 2008-11-15 14:20:28 +01:00
Akim DemailleandAkim Demaille 4fc55348e5 Simplify code for variants bench marks.
* etc/bench.pl.in (&generate_grammar_list): Define and use
	location_type.
	Factor the common code in yylex.
2008-11-15 14:17:15 +01:00
Akim Demaille 070e650956 Better error message.
* bootstrap (find_tool): Fix the error message.
2008-11-15 11:33:00 +01:00
Akim Demaille 0078681b6b Update variant.yy to newest interface.
* examples/variant.yy: Define lex_symbol.
	Adjust.
2008-11-15 11:29:57 +01:00
Akim Demaille ff084799a3 Don't use locations in variant.yy.
* examples/variant.yy: Adjust to not using locations.
2008-11-15 11:26:58 +01:00
Akim Demaille b0d79ec65d Comment changes.
* data/local.mk, etc/local.mk, examples/local.mk: Use Automake
	comments for the license.
2008-11-15 11:23:53 +01:00
Akim Demaille d4977ce3e7 Remove tests/Makefile.am.
* tests/Makefile.am: Rename as...
	* tests/local.mk: this.
	* Makefile.am, configure.ac: Adjust.
	* Makefile.am (DISTCLEANFILES): Define.
	(maintainer-check, maintainer-xml-check, maintainer-push-check):
	Remove, we no longer need to bounce to the real targets.
2008-11-15 11:20:20 +01:00
Akim Demaille 87f1149ae2 Comment changes. 2008-11-15 11:17:14 +01:00
Akim Demaille 3641590697 djgpp/local.mk.
* Makefile.am (EXTRA_DIST): Move djgpp related part to...
	* djgpp/local.mk: this new file.
2008-11-15 11:13:57 +01:00
Akim Demaille e2c2f69650 Remove doc/Makefile.am.
* doc/Makefile.am: Rename as...
	* doc/local.mk: this.
	Adjust paths
	* Makefile.am, configure.ac: Adjust.
	* Makefile.am (MOSTLYCLEANFILES): New.
	* src/local.mk: Adjust.
2008-11-15 11:10:03 +01:00
Akim Demaille 2ead32e61c Move sc_tight_scope into maint.mk.
It does not work, and I don't know how it was supposed to work: it seems
to be looking for sources in the build tree.  I just moved it at a better
place, fixing it is still required.

	* src/local.mk (echo): Remove.
	(sc_tight_scope): Move to...
	* maint.mk: here.
2008-11-15 11:06:45 +01:00
Akim Demaille 2df9ec3774 Regen.
* src/parse-gram.h, src/parse-gram.c: Regen.
2008-11-15 11:05:29 +01:00
Akim Demaille 0305d25eb0 Remove src/Makefile.am.
* src/Makefile.am: Rename as...
	* src/local.mk: this.
	Prefix all the paths with src/.
	(AUTOMAKE_OPTIONS): Build object files in the sub dirs.
	(AM_CPPFLAGS): Find find in builddir/src.
	(YACC): Move the flags into...
	(AM_YFLAGS): here.
	* maint.mk (sc_tight_scope): Disable.
	It used to bounce to the version in src/Makefile.am which is now
	part of this very Makefile.
	* Makefile.am, configure.ac: Adjust.
	* src/scan-code-c.c, src/scan-code.l: We can no longer rely on
	include "..." to find files "here": we are no longer in src/, so
	qualify the includes with src/.
	* doc/Makefile.am (PREPATH): No longer include the top_builddir
	prefix.
	(.x.1): Adjust to be able to create src/foo from the top level
	Makefile, instead of going bounce to src/Makefile the creation of
	foo.
2008-11-15 10:47:15 +01:00
Akim Demaille 5277c0a304 Remove useless variable.
* doc/Makefile.am (srcsrcdir): Remove.
2008-11-15 10:44:06 +01:00
Akim Demaille 6a5aa0cdbb Remove data/Makefile.am.
* data/Makefile.am: Rename as...
	* data/local.mk: this.
	Adjust paths.
	* Makefile.am, configure.ac: Adjust.
2008-11-15 10:39:38 +01:00
Akim Demaille 7cb794dcdd Remove etc/Makefile.am.
* etc/Makefile.am: Rename as...
	* etc/local.mk: this.
	Adjust.
	* Makefile.am, configure.ac: Adjust.
2008-11-15 10:34:53 +01:00
Akim Demaille cd409e3b50 Remove examples/local.mk.
examples/calc++/Makefile.am might be interesting to keep as is, since
it is an example in itself.

	* examples/Makefile.am: Rename as...
	* examples/local.mk: this.
	Adjust.
	* Makefile.am, configure.ac: Adjust.
2008-11-15 10:31:05 +01:00
Akim Demaille 9a1e42148a Remove build-aux/Makefile.am.
Recursive Makefiles are really way too slow, let's get rid of some of
them.

	* build-aux/Makefile.am: Rename as...
	* build-aux/local.mk: this.
	Adjust paths.
	* Makefile.am, configure.ac: Adjust.
2008-11-15 10:27:05 +01:00
Akim Demaille 0634493cdd Provide convenience constructors for locations and positions.
* data/location.cc (position::position): Accept file, line and
	column as arguments with default values.
	Always qualify initial line and column literals as unsigned.
	(location::location): Provide convenience constructors.
2008-11-15 10:23:51 +01:00
Akim Demaille fe1b448ada Instead of using make_symbol<TOK_FOO>, generate make_FOO for each token type.
Using template buys us nothing, and makes it uselessly complex to
construct a symbol.  Besides, it could not be generalized to other
languages, while make_FOO would work in C/Java etc.

	* data/lalr1.cc (b4_symbol_): New.
	(b4_symbol): Use it.
	(b4_symbol_constructor_declaration_)
	(b4_symbol_constructor_definition_): Instead of generating
	specializations of an overloaded template function, just generate
	several functions whose names are forged from the token names
	without the token.prefix.
	(b4_symbol_constructor_declarations): Generate them for all the
	symbols, not just by class of symbol type, now that instead of
	specializing a function template by the token, we generate a
	function named after the token.
	(b4_symbol_constructor_specialization_)
	(b4_symbol_constructor_specializations): Remove.
	* etc/bench.pl.in: Adjust to this new API.
2008-11-15 10:20:02 +01:00
Akim Demaille 5679f31101 %define token.prefix.
Provide a means to add a prefix to the name of the tokens as output in the
generated files.  Because of name clashes, it is good to have such a
prefix such as TOK_ that protects from names such as EOF, FILE etc.
But it clutters the grammar itself.

	* data/bison.m4 (token.prefix): Empty by default.
	* data/c.m4 (b4_token_enum, b4_token_define): Use it.
	* data/lalr1.cc (b4_symbol): Ditto.
2008-11-13 07:08:24 +01:00
Akim Demaille 3204049e31 Compute at M4 time some of the subtractions.
* data/lalr1.cc (b4_substract): New.
	(b4_rhs_data): Use it.
2008-11-13 07:04:47 +01:00
Akim Demaille 202598d3ab symbol::token.
This is allows the user to get the type of a token return by
yylex.

	* data/lalr1.cc (symbol::token): New.
	(yytoknum_): Define when %define lex_symbol, independently of
	%debug.
	(yytoken_number_): Move into...
	(symbol::token): here, since that's the only use.
	The other one is YYPRINT which was not officially supported
	by lalr1.cc, and anyway it did not work since YYPRINT uses this
	array under a different name (yytoknum).
2008-11-13 07:01:41 +01:00
Akim Demaille fc2476c7cd YYERRCODE.
* TODO (YYERRCODE): Mention the case of $undef.
2008-11-13 06:58:34 +01:00
Akim Demaille 865f1e9f85 TODO: YYPRINT.
* TODO (YYPRINT): New.
2008-11-13 06:55:23 +01:00
Akim Demaille cb0b136a63 Comment changes.
* data/lalr1.cc, data/yacc.c: Fix the description of the
	yytranslate and yytoknum tables.
2008-11-13 06:52:05 +01:00
Akim Demaille 2c086d2959 Define make_symbol in the header.
To reach good performances these functions should be inlined (yet this is
to measure precisely).  To this end they must be available to the caller.

	* data/lalr1.cc (b4_symbol_constructor_definition_): Qualify
	location_type with the class name.
	Since will now be output in the header, declare "inline".
	No longer use b4_symbol_constructor_specializations, but
	b4_symbol_constructor_definitions in the header.
	Don't call it in the *.cc file.
2008-11-13 06:48:22 +01:00
Akim Demaille 1c4af3813e Define yytranslate in the header for lex_symbol.
* data/lalr1.cc: Move the invocation of b4_yytranslate_definition
	into the header file when using %define lex_symbol.
	(yytranslate_): Declare inline.
2008-11-13 06:44:50 +01:00
Akim Demaille e51b0a82be Define the constructors of symbol_type in b4_symbol_constructor_definitions.
The constructors are called by the make_symbol functions, which a
forthcoming patch will move elsewhere.  Hence the interest of putting them
together.

The stack_symbol_type does not need to be moved, it is used only by the
parser.

	* data/lalr1.cc: Move symbol_type and symbol_base_type
	constructors into...
	(b4_symbol_constructor_definitions): here.
	Adjust.
2008-11-13 06:41:42 +01:00
Akim Demaille 788355718f Make it easier to move the definition of yytranslate_.
Forthcoming changes will make it possible to use yytranslate_
from outside the parser implementation file.

	* data/lalr1.cc (b4_yytranslate_definition): New.
	Use it.
2008-11-13 06:36:51 +01:00
Akim Demaille c1e6c88ca3 Remove useless class specification.
* data/lalr1.cc (b4_symbol_constructor_specialization_): No need
	to refer to the class name to use a type defined by the class for
	arguments of member functions.
2008-11-13 06:33:51 +01:00
Akim Demaille 4654b0c0a8 Finer input type for yytranslate.
This patch is debatable: the tradition expects yylex to return an int
which happens to correspond to token_number (which is an enum).  This
allows for instance to return characters (such as '*' etc.).  But this
goes against the stronger typing I am trying to have with the new
lex interface which return a symbol_type.  So in this case, feed
yytranslate_ with a token_type.

	* data/lalr1.cc (yytranslate_): When in %define lex-symbol,
	expect a token_type.
2008-11-13 06:30:35 +01:00
Akim Demaille dd735e4ee6 Honor lex-params in %define lex_symbol mode.
* data/lalr1.cc: Use b4_lex_param.
2008-11-13 06:27:15 +01:00
Akim Demaille 6659366cda Simplify names.
* src/output.c (symbol_definitions_output): Rename symbol
	attributes type_name and has_type_name as type and has_type.
	* data/lalr1.cc: Adjust uses.
2008-11-13 06:24:01 +01:00
Akim Demaille e9805e5743 Use b4_type_names for the union type.
The union used to compute the size of the variant used to iterate over the
type of all the symbols, with a lot of redundancy.  Now iterate over the
lists of symbols having the same type-name.

	* data/lalr1.cc (b4_char_sizeof_): New.
	(b4_char_sizeof): Use it.
	Adjust to be called with a list of numbers instead of a single
	number.
	Adjust its caller for new-line issues.
2008-11-13 06:20:59 +01:00
Akim Demaille aea10ef46f Define the "identifier" of a symbol.
Symbols may have several string representations, for instance if they
have an alias.  What I call its "id" is a string that can be used as
an identifier.  May not exist.

Currently the symbols which have the "tag_is_id" flag set are those that
don't have an alias.  Look harder for the id.

	* src/output.c (is_identifier): Move to...
	* src/symtab.c (is_identifier): here.
	* src/symtab.h, src/symtab.c (symbol_id_get): New.
	* src/output.c (symbol_definitions_output): Use it to define "id"
	and "has_id".
	Remove the definition of "tag_is_id".
	* data/lalr1.cc: Use the "id" and "has_id" whereever "tag" and
	"tag_is_id" were used to produce code.
	We still use "tag" for documentation.
2008-11-13 06:17:09 +01:00
Akim Demaille 086fd1137d Regen.
* src/parse-gram.h, src/parse-gram.c: Regen.
2008-11-11 16:41:28 +01:00
Akim Demaille 2ea7730c56 Locations are no longer required by lalr1.cc.
* data/lalr1.cc (_b4_args, b4_args): New.
	Adjust all uses of locations to make them optional.
	* tests/c++.at (AT_CHECK_VARIANTS): No longer use the locations.
	(AT_CHECK_NAMESPACE): Check the use of locations.
	* tests/calc.at (_AT_DATA_CALC_Y): Adjust to be usable with or
	without locations with lalr1.cc.
	Test these cases.
	* tests/output.at: Check lalr1.cc with and without location
	support.
	* tests/regression.at (_AT_DATA_EXPECT2_Y, _AT_DATA_DANCER_Y):
	Don't use locations.
2008-11-11 16:38:10 +01:00
Akim Demaille 7ca2266adc AT_FULL_COMPILE.
* tests/local.at (AT_FULL_COMPILE): New.
	* tests/actions.at, tests/calc.at, tests/regression.at: Use it.
2008-11-11 16:11:52 +01:00
Akim Demaille 1a7a65f9d5 Support parens in calc++.
* doc/bison.texinfo (Calc++ Scanner, Calc++ Parser): Support parens.
	* examples/calc++/test (run): Check the expected output.
	Adjust callers.
	Check parens too.
2008-11-11 16:08:44 +01:00
Akim Demaille c944f7f22d Simplify lalr1.cc since %defines is mandatory.
* data/lalr1.cc: Remove useless calls to b4_defines_if.
2008-11-11 16:05:29 +01:00
Akim Demaille dada3cd19e TODO: yyfmt.
* TODO (yysyntax_error): New item.
2008-11-11 16:02:21 +01:00
Akim Demaille 422c18f48d Prefer M4 to CPP.
* data/lalr1.cc: Use b4_error_verbose_if instead of #if
	YYERROR_VERBOSE.
2008-11-11 15:59:05 +01:00
Akim Demaille a0ffc1751e Support i18n of the parse error messages.
* TODO (lalr1.cc/I18n): Remove.
	* data/lalr1.cc (yysyntax_error_): Support the translation of the
	error messages, as done in yacc.c.
	Stay within the yy* pseudo namespace.
2008-11-11 15:55:54 +01:00
Akim Demaille 00a8a0832d More TODO.
* TODO (single stack, yysyntax_error): New.
2008-11-11 15:52:14 +01:00
Akim Demaille 0927787504 Make it possible to return a symbol_type from yylex.
* data/lalr1.cc (b4_lex_symbol_if): New.
	(parse): When lex_symbol is defined, expected yylex to return the
	complete lookahead.
	* etc/bench.pl.in (generate_grammar_list): Extend to support this
	yylex interface.
	(bench_variant_parser): Exercise it.
2008-11-11 15:48:52 +01:00
Akim Demaille 64c1b92a4f Remove useless bench case.
* etc/bench.pl.in (bench_variant_parser): VARIANT_DESTROY is
	no longer used.
2008-11-11 15:45:45 +01:00
Akim Demaille 2722aa42bd Improve display of directives.
* etc/bench.pl.in (parse_term): Don't add useless eol.
2008-11-11 15:42:40 +01:00
Akim Demaille 918eb7c5ae Use string_cast in the bench.
* etc/bench.pl.in (generate_grammar_list): Define and use
	string_cast.
2008-11-11 15:39:28 +01:00
Akim Demaille 39be90223b Replace yychar with a Boolean.
* data/lalr1.cc (parse::yychar): Replace by...
	(parse::yyempty): this.
2008-11-11 15:36:23 +01:00
Akim Demaille a2e3fa7768 Factor the tables.
* TODO: New item.
2008-11-11 15:33:12 +01:00
Akim Demaille aba12ad162 Let yytranslate handle the eof case.
* data/lalr1.cc (yytranslate_): Handle the EOF case.
	Adjust callers.
	No longer expect yychar to be equal to yyeof_, rather, test the
	lookahead's (translated) kind.
2008-11-11 15:29:39 +01:00
Akim Demaille 27cb5b5901 yychar cannot be empty in yyerrlab.
* TODO (yychar == yyempty_): New.
	* data/lalr1.cc: Remove the handling of this case.
	This eases forthcoming changes related to yychar and yytranslate.
2008-11-11 15:26:17 +01:00
Akim Demaille fce629c0ef Bench: syntactic sugar for %define/#define.
* etc/bench.pl.in (parse_dirs): Support %d and #d with arguments.
	(&bench_push_parser, bench_variant_parser): Use this feature.
	(&eat): New.
	Use it.
2008-11-11 15:23:13 +01:00
Akim Demaille ce6719605b Less memory pressure on the "list" bench.
* etc/bench.pl.in (generate_grammar_list): Do not accumulate all
	the values, to limit memory pressure.
2008-11-11 15:20:03 +01:00
Akim Demaille 2873fdf8b1 Introduce make_symbol.
make_symbol provides a means to construct a full symbol (kind, value,
location) in a single shot.  It is meant to be a Symbol constructor,
parameterized by the symbol kind so that overloading would prevent
incorrect kind/value pairs.  Unfortunately parameterized constructors do
not work well in C++ (unless the parameter also appears as an argument,
which is not acceptable), hence the use of a function instead of a
constructor.

	* data/lalr1.cc (b4_symbol_constructor_declaration_)
	(b4_symbol_constructor_declarations)
	(b4_symbol_constructor_specialization_)
	(b4_symbol_constructor_specializations)
	(b4_symbol_constructor_definition_)
	(b4_symbol_constructor_definitions): New.
	Use them where appropriate to generate declaration, declaration of
	the specializations, and implementations of the templated
	overloaded function "make_symbol".
	(variant::variant): Always define a default ctor.
	Also provide a copy ctor.
	(symbol_base_type, symbol_type): New ctor overloads for value-less
	symbols.
	(symbol_type): Now public, so that functions such as yylex can use
	it.
2008-11-11 15:16:53 +01:00
Akim Demaille 8be046d7b8 Inform m4 whether a tag is a valid id.
* src/output.c (is_identifier): New.
	(symbol_definitions_output): Use it to define tag_is_id.
	But maybe this should be done at m4 level?
2008-11-11 15:12:28 +01:00
Akim Demaille de62edee66 Add ChangeLog entry for the previous checkin. 2008-11-11 14:48:56 +01:00
Akim Demaille 11707b2b48 Get rid of tabulations in the Java output.
Test 214 was failing: it greps with a pattern containing [    ]* which
obviously meant to catch spaces and tabs, but contained only tabs.
Tabulations in sources are a nuisance, so to simplify the matter, get rid
of all the tabulations in the Java sources.  The other skeletons will be
treated equally later.

	* data/java.m4, data/lalr1.java: Untabify.
	* tests/java.at: Simplify AT_CHECK_JAVA_GREP invocations:
	tabulations are no longer generated.
2008-11-11 14:42:35 +01:00
Paolo Bonzini 905f069774 Replace m4/warning.m4 with warnings module.
* bootstrap.conf: Replace m4/warning.m4 with warnings module.
* configure.ac: Adjust usage.
* lib/Makefile.am: Replace $(WARNING_CFLAGS) with $(WARN_CFLAGS).
* src/Makefile.am: Replace $(WARNING_CFLAGS) with $(WARN_CFLAGS).
* tests/atlocal.in: Replace $(WARNING_*FLAGS) with $(WARN_*FLAGS).
2008-11-11 13:37:36 +01:00
Di-an JanandPaolo Bonzini 09ccae9b18 Work around Java's ``code too large'' problem for parser tables.
* data/java.m4 (b4_typed_parser_table, b4_integral_parser_table): New.
* data/lalr1.java (yypact_, yydefact_, yypgoto_, yydefgoto_,
yytable_, yycheck_, yystos_, yytoken_number_, yyr1_, yyr2_, yyrhs_
yyprhs_, yyrline_, yytranslate_table_): Use b4_integral_parser_table.
(yytname_): Use b4_typed_parser_table.
* doc/bison.texinfo (Java Bison Interface): Add note on Java's
``code too large'' error.
2008-11-10 14:34:53 +01:00
Di-an JanandPaolo Bonzini 1979121c96 Various Java skeleton improvements.
* NEWS: Document them.

General Java skeleton improvements.
* configure.ac (gt_JAVACOMP): Request target of 1.4, which allows
using gcj < 4.3 in the testsuite, according to comments in
gnulib/m4/javacomp.m4.
* data/java.m4 (stype, parser_class_name, lex_throws, throws,
location_type, position_type): Remove extraneous brackets from
b4_percent_define_default.
(b4_lex_param, b4_parse_param): Remove extraneous brackets from
m4_define and m4_define_default.
* data/lalr1.java (b4_pre_prologue): Change to b4_user_post_prologue,
which marks the end of user code with appropriate syncline, like all
the other skeletons.
(b4_user_post_prologue): Add.  Don't silently drop.
(yylex): Remove.
(parse): Inline yylex.
* doc/bison.texinfo (bisonVersion, bisonSkeleton): Document.
(%{...%}): Fix typo of %code imports.
* tests/java.at (AT_JAVA_COMPILE): Add "java" keyword.
Support annotations on parser class with %define annotations.
* data/lalr1.java (annotations): Add to parser class modifier.
* doc/bison.texinfo (Java Parser Interface): Document
%define annotations.
(Java Declarations Summary): Document %define annotations.
* tests/java.at (Java parser class modifiers): Test annotations.
Do not generate code for %error-verbose unless requested.
* data/lalr1.java (errorVerbose): Rename to yyErrorVerbose.
Make private.  Make conditional on %error-verbose.
(getErrorVerbose, setErrorVerbose): New.
(yytnamerr_): Make conditional on %error-verbose.
(yysyntax_error): Make some code conditional on %error-verbose.
* doc/bison.texinfo (Java Bison Interface): Remove the parts
about %error-verbose having no effect.
(getErrorVerbose, setErrorVerbose): Document.
Move constants for token names to Lexer interface.
* data/lalr1.java (Lexer): Move EOF, b4_token_enums(b4_tokens) here.
* data/java.m4 (b4_token_enum): Indent for move to Lexer interface.
(parse): Qualify EOF to Lexer.EOF.
* doc/bison.texinfo (Java Parser Interface): Move documentation of
EOF and token names to Java Lexer Interface.
* tests/java.at (_AT_DATA_JAVA_CALC_Y): Remove Calc qualifier.
Make yyerror public.
* data/lalr1.java (Lexer.yyerror): Use longer parameter name.
(yyerror): Change to public.  Add Javadoc comments.  Use longer
parameter names.  Make the body rather than the declarator
conditional on %locations.
* doc/bison.texinfo (yyerror): Document.  Don't mark as protected.
Allow user to add code to the constructor with %code init.
* data/java.m4 (b4_init_throws): New, for %define init_throws.
* data/lalr1.java (YYParser.YYParser): Add b4_init_throws.
Add %code init to the front of the constructor body.
* doc/bison.texinfo (YYParser.YYParser): Document %code init
and %define init_throws.
(Java Declarations Summary): Document %code init and
%define init_throws.
* tests/java.at (Java %parse-param and %lex-param): Adjust grep.
(Java constructor init and init_throws): Add tests.
2008-11-10 14:34:52 +01:00
Akim Demaille 42f832d680 Update TODO.
* TODO (-D): is implemented.
	(associativity): Same precedence must have the same associativity.
	For instance, how can a * b / c be parsed if * is %left and / is
	%right?
	(YYERRORCODE, YYFAIL, YYBACKUP): New.
2008-11-10 12:04:37 +01:00
Akim Demaille 247efe346c Formatting changes. 2008-11-10 12:01:19 +01:00
Akim Demaille 5d73144067 More information about the symbols.
* src/output.c (type_names_output): Document all the symbols,
	including those that don't have a type-name.
	(symbol_definitions_output): Define "is_token" and
	"has_type_name".
	* data/lalr1.cc (b4_type_action_): Skip symbols that have an empty
	type-name, now that they are defined too in b4_type_names.
2008-11-10 11:58:01 +01:00
Akim Demaille 21db118b64 Regen. 2008-11-10 11:54:38 +01:00
Akim Demaille 6ed15cde29 Make parser::yytranslate static.
Small speedup (1%) on the list grammar.  And makes yytranslate_ available
in non member functions.

	* data/lalr1.cc (yytranslate_): Does not need to be a instance
	function.
2008-11-10 11:50:57 +01:00
Akim Demaille 30bb2edccf Avoid trailing spaces.
* data/c.m4: b4_comment(TEXT): Don't indent empty lines.
	* data/lalr1.cc: Don't indent before rule and symbol actions, as
	they can be empty, and anyway this incorrectly indents the first
	action.
2008-11-10 11:47:49 +01:00
Akim Demaille b3a28fd4e9 Comment changes. 2008-11-10 11:44:13 +01:00
Akim Demaille 914202bdac Use "enum" for integral constants.
This is just nicer to read, I observed no speedup.

	* data/lalr1.cc (yyeof_, yylast_, yynnts_, yyempty_, yyfinal_)
	(yterror_, yyerrcode_, yyntokens_): Define as members of an enum.
	(yyuser_token_number_max_, yyundef_token_): Move into...
	(yytranslate_): here.
2008-11-10 11:41:00 +01:00
Akim Demaille c17f9a4a62 Shortcuts in bench directives.
* etc/bench.pl.in (parse_dirs): New.
	Use it.
	(bench_variant_parser, bench_fusion_parser): Use %s and %d.
	Create the benches in "benches/".
2008-11-10 11:35:54 +01:00
Akim Demaille b9855ea55b Formatting changes.
* data/lalr1.cc: here.
2008-11-10 11:32:12 +01:00
Akim Demaille 6e0977873a Adjust verbose message to using emacs.
* etc/bench.pl.in: Inform compilation-mode when we change the
	directory.
	(generate_grammar_list): Recognize %define "variant" in addition
	to %define variant.
2008-11-10 11:29:06 +01:00
Akim Demaille 4c3cc7da5d Classify symbols by type-name.
* src/uniqstr.h (UNIQSTR_CMP): New.
	* src/output.c (symbol_type_name_cmp, symbols_by_type_name)
	(type_names_output): New.
	(muscles_output): Use it.
	* data/lalr1.cc (b4_symbol_action_): Remove.
	(b4_symbol_case_, b4_type_action_): New.
	Adjust uses of b4_symbol_action_ to use b4_type_action_.
2008-11-10 11:25:36 +01:00
Akim Demaille d69c9694a7 Change the handling of the symbols in the skeletons.
Before we were using tables which lines were the symbols and which
columns were things like number, tag, type-name etc.  It is was
difficult to extend: each time a column was added, all the numbers had
to be updated (you asked for colon $2, not for "tag").  Also, it was
hard to filter these tables when only a subset of the symbols (say the
tokens, or the nterms, or the tokens that have and external number
*and* a type-name) was of interest.

Now instead of monolithic tables, we define one macro per cell.  For
instance "b4_symbol(0, tag)" is a macro name which contents is
self-decriptive.  The macro "b4_symbol" provides easier access to
these cells.

	* src/output.c (type_names_output): Remove.
	(symbol_numbers_output, symbol_definitions_output): New.
	(muscles_output): Call them.
	(prepare_symbols): Define b4_symbols_number.
2008-11-10 11:21:50 +01:00
Akim Demaille 5263bea9f7 --trace=muscles
* src/getargs.h, src/getargs.c (trace_muscle): New.
	(trace_types, trace_args): Support it.
	* src/output.c (output_skeleton): Use it.
2008-11-10 11:18:09 +01:00
Akim Demaille 4175f6bba2 muscles_output.
* src/output.c (muscles_output): New, extracted from...
	(output_skeleton): here.
	Adjust.
2008-11-10 11:15:00 +01:00
Akim Demaille 1de69d6a33 Formatting changes. 2008-11-10 11:11:52 +01:00
Akim Demaille 36db78a733 Update the variant example.
* examples/variant.yy: Formatting changes.
	One stage build.
2008-11-10 11:08:09 +01:00
Akim Demaille e5eb92e794 Support constructor with an argument.
This improves the "list" bench by 2%.

	* data/lalr1.cc (variant::build): Add an overloaded version with
	an argument.
	* tests/c++.at (AT_CHECK_VARIANT): Check it.
2008-11-10 11:04:31 +01:00
Akim Demaille 763074102b Test variants.
* tests/c++.at (AT_CHECK_VARIANTS): New.
	Use it with and without %define assert.
2008-11-10 11:00:58 +01:00
Akim Demaille f7398526b6 Regen. 2008-11-10 11:00:40 +01:00
Akim Demaille d78f0ac9d8 Add %precedence support.
Unfortunately it is not possible to reuse the %prec directive.  This
is because to please POSIX, we do not require to end the rules with a
semicolon.  As a result,

foo: bar %prec baz

is ambiguous: either a rule which precedence is that of baz, or a rule,
and then a declaration of the precedence of the token baz.

	* doc/bison.texinfo: Document %precedence.
	(Precedence Only): New.
	* src/assoc.h, src/assoc.c (precedence_assoc): New.
	* src/conflicts.c (resolve_sr_conflict): Support it.
	* src/scan-gram.l, src/parse-gram.y (%precedence): New token.
	Parse it.
	* tests/calc.at: Use %precedence for NEG.
	* tests/conflicts.at (%precedence does not suffice)
	(%precedence suffices): New tests.
2008-11-10 10:48:15 +01:00
Akim Demaille c85be41a07 Make benches in a sub dirs.
* etc/bench.pl.in ($dir): New.
	Use it.
	Check the use of constructors with an argument.
	(bench_variant_parser): Fix.
2008-11-09 20:57:06 +01:00
Akim Demaille db65ca1f12 fix eof condition 2008-11-09 20:54:03 +01:00
Akim Demaille 9b0efa5bc2 Fix --help. 2008-11-09 20:50:39 +01:00
Akim Demaille 432ac57aaa Require the generation of parse-gram.output.
* src/Makefile.am (YACC): Pass --report=all.
2008-11-09 20:10:00 +01:00
Akim Demaille deef2a0a4d Formatting changes. 2008-11-09 20:06:27 +01:00
Akim Demaille df72984aa5 Update TODO.
* TODO: Remove obsolete items.
	Update others.
2008-11-09 20:03:30 +01:00
Akim Demaille f10e19fd1a Enhance bench.pl.
* etc/bench.pl.in (parse, parse_expr, parse_term, parse_fact)
	(@token, $grammar, $bench): New.
	(generate_grammar_variant): Rename as...
	(generate_grammar_list): this.
	(generate_grammar): Adjust.
	(bench_grammar): Rename as...
	(bench): this.
	Use it in the various bench-marking routines.
	(-b, -g): New options.
2008-11-09 20:00:29 +01:00
Akim Demaille 5de9c59301 Use a static hierarchy for symbols in the C++ parser.
* data/lalr1.cc (symbol_base_type, symbol_type)
	(stack_symbol_type): Make it a static hierarchy.
	Adjust dependencies.
2008-11-09 19:57:30 +01:00
Akim Demaille 757f8f98fc bench.pl -d, --directive.
* etc/bench.pl.in (@directive): New.
	(&bench_grammar): Use it.
	(&bench_list_grammar): New, to provide access to the "variant"
	grammar.
	Use it.
	(getopts): Support -d, --directive.
2008-11-09 19:54:29 +01:00
Akim Demaille d3be4f6d42 Use inline for small operations.
* data/lalr1.cc (symbol_base_type, symbol_type)
	(stack_symbol_type): Declare constructor and other operations as
	inline.
	(yy_destroy_): Inline.
2008-11-09 19:51:28 +01:00
Akim Demaille 1f7d007bf6 Introduce a hierarchy for symbols.
* data/lalr1.cc (symbol_base_type, symbol_type): New.
	(data_type): Rename as...
	(stack_symbol_type): this.
	Derive from symbol_base_type.
	(yy_symbol_value_print_): Merge into...
	(yy_symbol_print_): this.
	Rename as...
	(yy_print_): this.
	(yydestruct_): Rename as...
	(yy_destroy_): this.
	(b4_symbols_actions, YY_SYMBOL_PRINT): Adjust.
	(parser::parse): yyla is now of symbol_type.
	Use its type member instead of yytoken.
2008-11-09 19:48:20 +01:00
Akim Demaille bc0b0477e2 Rename data_type and stack_symbol_type.
* data/lalr1.cc (data_type): Rename as...
	(stack_symbol_type): this.
2008-11-09 19:45:14 +01:00
Akim Demaille 57295d14f9 Handle semantic value and location together.
* data/lalr1.cc (b4_symbol_actions): Bounce $$ and @$ to
	yydata.value and yydata.location.
	(yy_symbol_value_print_, yy_symbol_print_, yydestruct_)
	(YY_SYMBOL_PRINT): Now take semantic value and location as a
	single arg.
	Adjust all callers.
	(yydestruct_): New overload for a stack symbol.
2008-11-09 19:42:08 +01:00
Akim Demaille e9b0834e18 Push a complete symbol, not connected parts.
* data/lalr1.cc (yypush_): Take a data_type&, not disconnected
	state, value and location.
	Adjust callers.
2008-11-09 19:39:09 +01:00
Akim Demaille 6082531abb Agregate yylval and yylloc.
* data/lalr1.cc (parser::yylval, parser::yylloc): Replace by...
	(parser::yyla): this.
2008-11-09 19:36:04 +01:00
Akim Demaille 33c195cc37 Rely on the state stack to display reduction traces.
To display rhs symbols before a reduction, we used information about the rule
reduced, which required the tables yyrhs and yyprhs.  Now use rely only on the
state stack to get the same information.

	* data/lalr1.cc (b4_rhs_data, b4_rhs_state): New.
	Use them.
	(parser::yyrhs_, parser::yyprhs_): Remove.
	(parser::yy_reduce_print_): Use the state stack.
2008-11-09 19:33:04 +01:00
Akim Demaille e1f93869da Fuse yyval and yyloc into yylhs.
* data/lalr1.cc (b4_lhs_value, b4_lhs_location): Adjust to using
	yylhs.
	(parse): Replace yyval and yyloc with yylhs.value and
	yylhs.location.
	After a user action, compute yylhs.state earlier.
	(yyerrlab1): Do not play tricks with yylhs.location, rather, use a
	fresh error_token.
2008-11-09 19:29:38 +01:00
Di-an JanandPaolo Bonzini 2935744b3a Remove unused variable.
* src/output.c (type_names_output): Remove unused variable sep.
2008-11-09 12:28:59 +01:00
Paolo Bonzini bbf9ca3740 Change tests/output.at quoting.
* tests/output.at (AT_CHECK_OUTPUT): Use conventional m4 quoting when
expanding arguments.
2008-11-09 12:28:50 +01:00
Joel E. Denny d9a9b96bb5 Don't add a semicolon to actions for %skeleton or %language.
It breaks Java test cases as reported by Akim Demaille.
* src/scan-code.l: Implement.
2008-11-07 17:21:23 -05:00
Joel E. Denny 5136519230 Clean up %skeleton and %language priority implementation.
* src/getargs.c (skeleton_prio): Use default_prio rather than 2, and
remove static qualifier because others will soon need to see it.
(language_prio): Likewise.
(getargs): Use command_line_prio rather than 0.
* src/getargs.h (command_line_prio, grammar_prio, default_prio): New
enum fields.
(skeleton_prio): Extern it.
(language_prio): Extern it.
* src/parse-gram.y: Use grammar_prio rather than 1.
2008-11-07 17:20:44 -05:00
Akim Demaille 9380cfd008 Moving push traces into yypush_.
* data/lalr1.cc (yypush_): Now takes a optional trace message.
	Adjust all uses.
2008-11-07 21:38:54 +01:00
Akim Demaille 8901f32e4a The single-stack C++ parser is now the standard one.
* data/lalr1.cc: Rename as...
	* data/lalr1-split.cc: this.
	* data/lalr1-fusion.cc: Rename as...
	* data/lalr1.cc: this.
	* etc/bench.pl.in: Adjust.
2008-11-07 21:38:45 +01:00
Akim Demaille 8cdabf02ea Avoid empty-if warnings.
Reported by Quentin Hocquet.

	* data/lalr1-fusion.cc (YY_SYMBOL_PRINT, YY_REDUCE_PRINT)
	(YY_STACK_PRINT): Provide some contents even when !YYDEBUG.
2008-11-07 21:38:40 +01:00
Akim Demaille 5a893c2b26 Pass command line location to skeleton_arg and language_argmatch.
* src/getargs.h, src/getargs.c (skeleton_arg, language_argmatch):
	The location argument is now mandatory.
	Adjust all dependencies.
	(getargs): Use command_line_location.
2008-11-07 21:38:36 +01:00
Akim Demaille 58697c6d89 -D, --define.
* src/getargs.c (usage): Document -D.
	Fix help string for --locations.
	(command_line_location): New.
	(short_options, long_options, getargs): Support -D, --define.
	(getargs): Move -d support at the right place.
	* doc/bison.texinfo (Bison Options): Update.
	* tests/input.at (%define, --define): New.
2008-11-07 21:38:31 +01:00
Akim Demaille 9fe5a4571e Initialize the muscle table before parsing the command line.
* src/getargs.c (quotearg.h, muscle_tab.h): Include.
	(getargs): Define file_name.
	* src/main.c (main): Initialize muscle_tab before calling
	getargs.
	* src/muscle_tab.c (muscle_init): No longer define file_name, as
	its value is not available yet.
2008-11-07 21:38:27 +01:00
Akim Demaille 56c5eca973 Locations without columns for command line arguments.
* src/location.c (location_print): Don't display negative columns.
	* src/location.h: Document this.
2008-11-07 21:38:23 +01:00
Akim Demaille 9b9e0a7d46 Fix --help.
* src/getargs.c (usage): Fix help string for -W.
2008-11-07 21:38:19 +01:00
Akim Demaille 74eae918c3 Handle more general types of option arguments.
* build-aux/cross-options.pl: The argument ends at the first
	space, not the first non-symbol character.
	Use @var for each word appearing the argument description.
2008-11-07 21:38:14 +01:00
Akim Demaille a3d4c6fbb1 Destroy the variants that remain on the stack in case of error.
* data/lalr1-fusion.cc (yydestruct_): Invoke the variant's
	destructor.
	Display the value only if yymsg is nonnull.
	(yyreduce): Invoke yydestruct_ when popping lhs symbols.
2008-11-07 21:38:10 +01:00
Akim Demaille 2d32fc9fe2 Add "%define assert" to variants.
This is used to help the user catch cases where some value gets
ovewritten by a new one.  This should not happen, as this will
probably leak.

Unfortunately this uncovered a bug in the C++ parser itself: the
lookahead value was not destroyed between two calls to yylex.  For
instance if the previous lookahead was a std::string, and then an int,
then the value of the std::string was correctly taken (i.e., the
lookahead was now an empty string), but std::string structure itself
was not reclaimed.

This is now done in variant::build(other&) (which is used to take the
value of the lookahead): other is not only stolen from its value, it
is also destroyed.  This incurs a new performance penalty of a few
percent, and union becomes faster again.

	* data/lalr1-fusion.cc (variant::build(other&)): Destroy other.
	(b4_variant_if): New.
	(variant::built): New.
	Use it whereever the status of the variant changes.
	* etc/bench.pl.in: Check the penalty of %define assert.
2008-11-07 21:38:06 +01:00
Akim Demaille f6038cb8c3 Use "%define variant" in bench.pl.
* etc/bench.pl.in: No longer use the pseudo directive %variants,
	just use %define variants.
2008-11-07 21:37:56 +01:00
Akim Demaille ccde1f98b0 Regen.
* src/parse-gram.h, src/parse-gram.c: Regen.
2008-11-07 21:28:37 +01:00
Joel E. Denny 58bd33b7fc Fix user actions without a trailing semicolon.
Reported by Sergei Steshenko at
<http://lists.gnu.org/archive/html/bug-bison/2008-11/msg00001.html>.
* THANKS (Sergei Steshenko): Add.
* src/scan-code.l (SC_RULE_ACTION): Fix it.
* tests/regression.at (Fix user actions without a trailing semicolon):
New test case.
2008-11-04 15:58:57 -05:00
Akim Demaille 639867b52f Use b4_copyright_years.
* data/yacc.c (b4_copyright_years): New.
	Fix its value according to the comments in the file.
	Use it and undefine it.
2008-11-04 21:43:55 +01:00
Akim Demaille 3c26260608 Formatting changes.
* data/lalr1-fusion.cc, src/parse-gram.y: here.
2008-11-04 21:43:51 +01:00
Akim Demaille a2b93d5278 Formatting changes.
* data/lalr1-fusion.cc: here.
2008-11-04 21:43:46 +01:00
Akim Demaille 3a2803df74 Use strict on bench.pl.
* etc/bench.pl.in (&run, &generate_grammar): New.
	Rename the grammar generating functions for consistency.
	Change the interface so that the list of benches to run is passed
	as (optionless) arguments.
	(&compile): Use &run.
2008-11-04 21:43:41 +01:00
Akim Demaille a0d4650a09 Remove spurious initial empty lines.
* data/glr.c, data/glr.cc, data/lalr1.cc, data/lalr1.java,
	* data/yacc.c: End the @output lines with an @.
2008-11-04 21:43:36 +01:00
Akim Demaille cac9e09bbf Improve the display of sizes.
* etc/bench.p.in: Higher precision.
	Sort by decreasing size.
2008-11-04 21:43:32 +01:00
Akim Demaille 4af4348a3f Don't memcpy C++ structures.
* data/lalr1-fusion.cc (b4_symbol_variant): Adjust additional
	arguments.
	(variant::build): New overload for
	copy-construction-that-destroys.
	(variant::swap): New.
	(parser::yypush_): Use it in variant mode.
2008-11-04 21:43:28 +01:00
Akim Demaille ef05c4d6f9 Better defaults for bench.pl.
* etc/bench.pl.in ($verbose, $cflags, $iterations): Change the
	default values.
	Adjust &verbose uses.
	(-q, --quiet): New.
2008-11-04 21:43:24 +01:00
Akim Demaille 9718cfa902 Make variant.yy more complex.
std::list cannot be copied via memcpy, they are more demanding than
std::string.  Use one std::list to strengthen the test.

	* examples/variant.yy: Use lalr1-fusion.cc, not lalr1.cc.
	Adjust.
	Create a list of strings, instead of a single large string.
2008-11-04 21:43:19 +01:00
Akim Demaille a6df593dfe bench.pl --bench.
* etc/bench.pl.in (--bench, $bench): New.
2008-11-04 21:43:05 +01:00
Akim Demaille 006a030300 Sort methods.
* data/lalr1-fusion.cc (destroy): Use as() in its definition.
	Define it after as().
2008-11-04 21:21:56 +01:00
Akim Demaille faef34664a Useless parens.
* data/lalr1-fusion.cc (b4_rhs_location): Remove useless parens.
2008-11-04 21:21:51 +01:00
Akim Demaille 2141adedf4 Issue missing synclines after user actions.
* data/c.m4 (b4_case): Issue synclines on the output file.
2008-11-04 21:21:47 +01:00
Akim Demaille e426d17bc5 Remove trailing empty line.
* data/lalr1-fusion.cc: Don't add an empty line after the user's
	epilogue.
2008-11-04 21:21:43 +01:00
Akim Demaille a9ce3f5413 Fix output of copyright years.
* data/bison.m4 (b4_copyright): Fix the indentation of the
	copyright year paragraph.
	Use b4_copyright_years when no years are given.
	* data/lalr1.cc, data/lalr1-fusion.cc, data/location.cc
	(b4_copyright_years): New.
	Use it.
2008-11-04 21:21:38 +01:00
Akim Demaille 59c544c268 Avoid the spurious initial empty line.
* data/lalr1-fusion.cc, data/location.cc: Put a trailing "@" at
	the end of @output request to suppress the empty line that
	results.
2008-11-04 21:21:34 +01:00
Akim Demaille 96b15448b9 Remove parser::rhs_number_type.
* data/lalr1-fusion.cc (rhs_number_type): No longer define it.
	(yyrhs_): Use b4_table_define.
2008-11-04 21:21:30 +01:00
Akim Demaille f063317430 Fix iteration type.
* data/lalr1-fusion.cc: Use an int to iterate up to an int.
2008-11-04 21:21:25 +01:00
Akim Demaille 417b80040b Factor the declaration of the integer tables.
* data/lalr1-fusion.cc (b4_table_define): New.
	Use it.
2008-11-04 21:21:20 +01:00
Akim Demaille 1a5246c66f Fix indentation of tables in lalr1.cc
* data/lalr1-fusion.cc: Fix the indentation.
2008-11-03 22:01:27 +01:00
Akim Demaille f8a95c9c12 Destroy the lhs symbols after reduction.
* data/lalr1-fusion.cc (parse): After the user action, when in
	variant mode, destroy the lhs symbols.
2008-11-03 22:01:22 +01:00
Akim Demaille d7f4d82382 Simplify yysyntax_error_ use.
* data/lalr1-fusion.cc (yysyntax_error_): Always pass it the token
	type, but make it unnamed in the declaration when it is not used.
2008-11-03 22:01:18 +01:00
Akim Demaille 8b9c89fb65 Let yy::variant::build return an lvalue.
* data/lalr1-fusion.cc (variant::build): Return a reference to the
	object.
2008-11-03 22:01:14 +01:00
Akim Demaille 83243c24ba Define yy::variant only when needed.
* data/lalr1-fusion.cc (yy::variant): Define only if variants are
	used.
2008-11-03 22:01:10 +01:00
Akim Demaille 429b4848d4 Bench the three-stack lalr1.cc.
* etc/bench.pl.in: Bench the three-stack lalr1.cc vs. the
	one-stack one.
2008-11-03 22:01:06 +01:00
Akim Demaille 414c76a461 Fail on parse error in calc++.
* doc/bison.texinfo (calc++.cc): Propagate failures to the exit
	status.
	* examples/calc++/test ($me, $number, $exit, run): New.
	Use them to propagate errors to the exit status.
2008-11-03 22:01:01 +01:00
Akim Demaille 8a5783fd0c Don't specify the skeleton twice in the example.
* examples/calc++/Makefile.am: Don't pass -S to Bison, the grammar
	file does what is needed.
2008-11-03 22:00:57 +01:00
Akim Demaille 0cc5bead40 bench: Improve output.
* etc/bench.pl.in (bench_grammar): Tune the printf format.
2008-11-03 22:00:53 +01:00
Akim Demaille 5b421a4e8e bench: check impact of %debug on variants.
* etc/bench.pl.in (variant_grammar): Fix the computation of
	$variant.
	Generate a grammar file that can work with or without %debug.
	Do use the @directive.
	(bench_variant_parser): Check impact of %debug.
	(@directives): Rename all the occurrences to...
	(@directive): this, for consistency.
2008-11-03 22:00:48 +01:00
Akim Demaille d11ee647c3 bench: report the size too.
* etc/bench.pl.in ($iterations): Defaults to -3.
	(&bench_grammar): Require hireswallclock.
	Compute and display the size of the result.
	More comments.
2008-11-03 22:00:44 +01:00
Akim Demaille e1b74b92a0 bench: More use of the verbosity level.
* etc/bench.pl.in ($verbose, &verbose): New.
	Use them.
	More POD documentation.
2008-11-03 22:00:39 +01:00
Akim Demaille 7e5f9c54c0 bench.pl: a command line interface
* etc/bench.pl.in: More doc.
	Some fixes in the documentation.
	($cflags, $iterations, &help, &getopt): New.
	Use them.
	(&variant_grammar): Let the number of stages be 10 times what is
	specified.
2008-11-03 22:00:34 +01:00
Akim Demaille 7109a18d18 Bench the use of Boost.Variants.
* etc/bench.pl.in ($cxx, &variant_grammar, &bench_variant_parser):
	New.
	(&compile): Be ready to compile C++ parsers.
	(&bench_push_parser): Move debug information to the outermost
	level.
	* THANKS: Add Michiel De Wilde.
2008-11-03 22:00:27 +01:00
Akim Demaille 922730fe36 bench.pl: Pass directives as a list instead of as a string.
* etc/bench.pl.in (&directives): New.
	(&triangular_grammar, &calc_grammar): Use it to format the Bison
	directives.
	(&triangular_grammar): Do use the directives (were ignored).
	(&bench_grammar, &bench_push_parser): Adjust to pass lists of
	directives.
2008-11-03 22:00:21 +01:00
Akim Demaille 7484f1d4f3 Improve genericity of bench.pl.
* etc/bench.pl.in (&bench_grammar): Take the set of benches as
	argument.
	(&bench_push_parser): New.
	Call it.
2008-11-03 22:00:17 +01:00
Akim Demaille 15129f2525 Add documentation to bench.pl.
* etc/bench.pl.in: Comment changes.
2008-11-03 22:00:12 +01:00
Akim Demaille 0e0ed236ab Fuse the three stacks into a single one.
In order to make it easy to perform benchmarks to ensure that there are no
performance loss, lalr1.cc is forked into lalr1-fusion.cc.  Eventually,
lalr1-fusion.cc will replace lalr1.cc.

Meanwhile, to make sure that lalr1-fusion.cc is correctly exercized by the
test suite, the user must install a symbolic link from lalr1.cc to it.

Instead of having three stacks (state, value, location), use a stack
of triples.  This considerably simplifies the code (and it will be
easier not to require locations as currently does the C++ parser),
and also gives a 10% speedup according to etc/bench (probably mainly since
memory allocation is done once instead of three times).

Another motivation is to make it easier to destruct properly
semantic values: now that they are bound to their state (hence
symbol type) it will be easier to call the appropriate destructor.

These changes should probably benefit the C parser too.

	* data/lalr1.cc: Copy as...  * data/lalr1-fusion.cc: this new
	file.
	(b4_rhs_value, b4_rhs_location): New definitions overriding those
	from c++.m4.
	(state_stack_type, semantic_stack_type, location_stack_type)
	(yystate_stack_, yysemantic_stack_, yylocation_stack_): Remove.
	(data_type, stack_type, yystack_): New.
	(YYLLOC_DEFAULT, yypush_): Adjust.
	(yyerror_range): Now based on data_type, not location_type.
2008-11-03 21:59:59 +01:00
Akim Demaille 7dedf26e55 Push the state, value, and location at the same time.
This is needed to prepare a forthcoming patch that fuses the three
stacks into one.

	* data/lalr1.cc (parser::yypush_): New.
	(parser::yynewstate): Change the semantics: instead of arriving to
	this label when value and location have been pushed, but yystate
	is to be pushed on the state stack, now the three of them must
	have been pushed before.  yystate still must be the new state.
	This allows to use yypush_ everywhere instead of individual
	handling of the stacks.
2008-11-03 21:51:02 +01:00
Akim Demaille c4585f1e2d Prefer references to pointers.
* data/lalr1.cc (b4_symbol_actions): New, overrides the default C
	definition to use references instead of pointers.
	(yy_symbol_value_print_, yy_symbol_print_, yydestruct_):
	Take the value and location as references.
	Adjust callers.
2008-11-03 21:50:57 +01:00
Akim Demaille 56017c172b stack::size instead of stack::height.
* data/lalr1.cc (stack::height): Rename as...
	(stack::size): this.
	Fix the output type.
	Comment changes.
2008-11-03 21:50:53 +01:00
Akim Demaille 5ab8c47bcf Use variants to support objects as semantic values.
This patch was inspired by work by Michiel De Wilde.  But he used Boost
variants which (i) requires Boost on the user side, (ii) is slow, and
(iii) has useless overhead (the parser knows the type of the semantic value
there is no reason to duplicate this information as Boost.Variants do).

This implementation reserves a buffer large enough to store the largest
objects.  yy::variant implements this buffer.  It was implemented with
Quentin Hocquet.

	* src/output.c (type_names_output): New.
	(output_skeleton): Invoke it.
	* data/c++.m4 (b4_variant_if): New.
	(b4_symbol_value): If needed, provide a definition for variants.
	* data/lalr1.cc (b4_symbol_value, b4_symbol_action_)
	(b4_symbol_variant, _b4_char_sizeof_counter, _b4_char_sizeof_dummy)
	(b4_char_sizeof, yy::variant): New.
	(parser::parse): If variants are requested, define
	parser::union_type, parser::variant, change the definition of
	semantic_type, construct $$ before running the user action instead
	of performing a default $$ = $1.
	* examples/variant.yy: New.
	Based on an example by Michiel De Wilde.
2008-11-03 21:50:48 +01:00
Akim Demaille 1fa5d8bbf9 Parameterize the extraction of semantic values.
To make future changes easier, no longer rely on ".TYPE" being the
way to get a semantic value.

	* data/c.m4 (b4_symbol_value): New.
	Use it.
	* data/c++.m4, data/yacc.c: Use it.
	* data/glr.c: Use b4_symbol_value.
	(b4_rhs_data): New.
	Use it.
2008-11-03 21:50:38 +01:00
Akim Demaille 91ba8a55b1 Prepare easier M4 changes.
* data/lalr1.cc: Use escaped [] instead of literals to prepare
	future changes.
2008-11-03 21:50:11 +01:00
235 changed files with 12107 additions and 12759 deletions
+32
View File
@@ -0,0 +1,32 @@
*.cache
*.flc
*.prj
*~
.tarball-version
.version
ABOUT-NLS
COPYING
GNUmakefile
INSTALL
Makefile
Makefile.in
_*
a.exe
a.out
aclocal.m4
b.out
bison-*
conf[0-9]*
confdefs*
config.log
config.status
configure
configure.lineno
conftest*
gnulib
javacomp.sh
javaexec.sh
maint.mk
patches
releases
stamp-h*
-2
View File
@@ -1,4 +1,3 @@
/*.cache /*.cache
/*.flc /*.flc
/*.prj /*.prj
@@ -31,4 +30,3 @@
/patches /patches
/releases /releases
/stamp-h* /stamp-h*
-1
View File
@@ -1,5 +1,4 @@
COPYING COPYING
^bootstrap$
^doc/fdl\.texi$ ^doc/fdl\.texi$
^doc/gpl-3\.0\.texi$ ^doc/gpl-3\.0\.texi$
^doc/yacc\.1\.in$ ^doc/yacc\.1\.in$
+2485 -2107
View File
File diff suppressed because it is too large Load Diff
+21 -49
View File
@@ -158,20 +158,6 @@ Register your changes.
$ git checkin ... $ git checkin ...
For a suggestion of what gnulib commit might be stable enough for a
formal release, see the ChangeLog in the latest gnulib snapshot at:
http://erislabs.net/ianb/projects/gnulib/
The autoconf files we use are currently:
m4/m4.m4
lib/m4sugar/m4sugar.m4
lib/m4sugar/foreach.m4
These files don't change very often in autoconf, so it should be
relatively straight-forward to examine the differences in order to
decide whether to update.
* Test suite * Test suite
@@ -186,9 +172,6 @@ release:
that 1. Bison compiles cleanly, 2. the parsers it produces compile that 1. Bison compiles cleanly, 2. the parsers it produces compile
cleanly too. cleanly too.
- Build with -DGNULIB_POSIXCHECK. It suggests gnulib modules that can
fix portability issues.
- run `make maintainer-check' which: - run `make maintainer-check' which:
- runs `valgrind -q bison' to run Bison under Valgrind. - runs `valgrind -q bison' to run Bison under Valgrind.
- runs the parsers under Valgrind. - runs the parsers under Valgrind.
@@ -214,13 +197,8 @@ release:
* Release Procedure * Release Procedure
** Update the submodules. See above. ** Try to get the *.pot files to the Translation Project at least one week
before a stable release, to give them time to translate them.
** Try to get the *.pot files to the Translation Project at least one
week before a stable release, to give them time to translate them.
Before generating the *.pot files, make sure that po/POTFILES.in and
runtime-po/POTFILES.in list all files with translatable strings.
This helps: grep -l '\<_(' *
** Tests ** Tests
See above. See above.
@@ -232,17 +210,9 @@ causes it to be rejected by recent Gettext releases; please report
these to the Translation Project. these to the Translation Project.
** Update README ** Update README
Make sure the information in README is current. Most notably, make sure Make sure the information in this file is current. Most notably, make sure it
it recommends a version of GNU M4 that is compatible with the latest recommends a version of GNU M4 that is compatible with the latest Bison
Bison sources. sources.
** Check copyright years.
We update years in copyright statements throughout Bison once at the
start of every year by running `make update-copyright'. However, before
a release, it's good to verify that it's actually been run. Besides the
copyright statement for each Bison file, check the copyright statements
that the skeletons insert into generated parsers, and check all
occurrences of PACKAGE_COPYRIGHT_YEAR in configure.ac.
** Update NEWS ** Update NEWS
The version number, *and* the date of the release (including for The version number, *and* the date of the release (including for
@@ -251,6 +221,9 @@ betas).
** Update ChangeLog ** Update ChangeLog
Should have an entry similar to `Version 1.49b.'. Should have an entry similar to `Version 1.49b.'.
** Update configure.ac
Be sure PACKAGE_COPYRIGHT_YEAR is up-to-date.
** Tag the release ** Tag the release
Before Bison will build with the right version number, you must tag the release Before Bison will build with the right version number, you must tag the release
in git. Do this after all other changes. The command is similar to: in git. Do this after all other changes. The command is similar to:
@@ -356,21 +329,19 @@ To generate a template announcement file:
make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement
where alpha can be replaced by beta or stable and F125BDF3 should be where alpha can be replaced by beta or major and F125BDF3 should be replaced
replaced with your key ID. with your key ID. For an example of how to fill out the template, search the
mailing list archives for the most recent release announcement.
Complete/fix the announcement file. The generated list of recipients Complete/fix the announcement file, and send it at least to
([email protected], [email protected], [email protected], [email protected] (if a real release, or a ``serious beta''),
bison-patches@gnu.org, and [email protected]) is bug-[email protected], [email protected], [email protected],
appropriate for a stable release or a ``serious beta''. For any other and [email protected].
release, drop at least [email protected]. For an example of how to fill
out the rest of the template, search the mailing list archives for the
most recent release announcement.
For a stable release, send the same announcement on the comp.compilers Send the same announcement on the comp.compilers newsgroup by sending
newsgroup by sending email to [email protected]. Do not make any Cc as email to [email protected]. Do not make any Cc as the moderator will
the moderator will throw away anything cross-posted or Cc'ed. It really throw away anything cross-posted or Cc'ed. It really needs to be a
needs to be a separate message. separate message.
** Bump the version number ** Bump the version number
In configure.ac. Run `make'. So that developers don't accidentally add new In configure.ac. Run `make'. So that developers don't accidentally add new
@@ -383,7 +354,8 @@ Push these changes.
----- -----
Copyright (C) 2002-2005, 2007-2011 Free Software Foundation, Inc. Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009
Free Software Foundation, Inc.
This file is part of GNU Bison. This file is part of GNU Bison.
+39 -37
View File
@@ -1,47 +1,51 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*- ## Process this file with automake to produce Makefile.in -*-Makefile-*-
## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
## Free Software Foundation, Inc.
## Copyright (C) 2001-2011 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
# This program is free software: you can redistribute it and/or modify ## the Free Software Foundation, either version 3 of the License, or
# it under the terms of the GNU General Public License as published by ## (at your option) any later version.
# the Free Software Foundation, either version 3 of the License, or ##
# (at your option) any later version. ## This program is distributed in the hope that it will be useful,
# ## but WITHOUT ANY WARRANTY; without even the implied warranty of
# This program is distributed in the hope that it will be useful, ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# but WITHOUT ANY WARRANTY; without even the implied warranty of ## GNU General Public License for more details.
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##
# GNU General Public License for more details. ## You should have received a copy of the GNU General Public License
# ## along with this program. If not, see <http://www.gnu.org/licenses/>.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
SUBDIRS = build-aux po runtime-po lib data src doc examples tests etc SUBDIRS = po runtime-po .
if BISON_CXX_WORKS
SUBDIRS += examples/calc++
endif
# Files installed for use by Automake. # Files installed for use by Automake.
aclocaldir = @aclocaldir@ aclocaldir = @aclocaldir@
aclocal_DATA = m4/bison-i18n.m4 aclocal_DATA = m4/bison-i18n.m4
EXTRA_DIST = .prev-version .version cfg.mk \ EXTRA_DIST = .prev-version .version \
OChangeLog PACKAGING \ cfg.mk \
djgpp/Makefile.maint djgpp/README.in djgpp/config.bat \ OChangeLog PACKAGING
djgpp/config.sed djgpp/config.site djgpp/config_h.sed \
djgpp/subpipe.c djgpp/subpipe.h djgpp/djunpack.bat \
djgpp/fnchange.lst djgpp/testsuite.sed
# Initialization before completion by local.mk's.
.PHONY: maintainer-check AM_CFLAGS = $(WARN_CFLAGS)
maintainer-check: AM_CPPFLAGS =
cd tests && $(MAKE) $(AM_MAKEFLAGS) $@ BUILT_SOURCES =
DISTCLEANFILES =
.PHONY: maintainer-push-check MOSTLYCLEANFILES =
maintainer-push-check: SUFFIXES =
cd tests && $(MAKE) $(AM_MAKEFLAGS) $@ include build-aux/local.mk
include data/local.mk
.PHONY: maintainer-xml-check include djgpp/local.mk
maintainer-xml-check: include doc/local.mk
cd tests && $(MAKE) $(AM_MAKEFLAGS) $@ include etc/local.mk
include examples/local.mk
include lib/local.mk
include src/local.mk
include tests/local.mk
# See comments in build-aux/git-version-gen. However, we make .version depend # See comments in build-aux/git-version-gen. However, we make .version depend
# on configure so that .version and VERSION/PACKAGE_VERSION stay in sync in the # on configure so that .version and VERSION/PACKAGE_VERSION stay in sync in the
@@ -52,17 +56,15 @@ maintainer-xml-check:
# a developer might naively reference .version in a test case while the bison # a developer might naively reference .version in a test case while the bison
# executable still compiles with VERSION, and so the test case might fail or # executable still compiles with VERSION, and so the test case might fail or
# pass incorrectly. # pass incorrectly.
BUILT_SOURCES = $(top_srcdir)/.version BUILT_SOURCES += $(top_srcdir)/.version
$(top_srcdir)/.version: configure $(top_srcdir)/.version: configure
echo $(VERSION) > $@-t && mv $@-t $@ echo $(VERSION) > $@-t && mv $@-t $@
dist-hook: dist-hook:
echo $(VERSION) > $(distdir)/.tarball-version echo $(VERSION) > $(distdir)/.tarball-version
.PHONY: update-b4-copyright update-package-copyright-year .PHONY: update-b4-copyright
update-b4-copyright: update-b4-copyright:
find data -type f \ find data -type f \
| grep -v -E '^data/bison.m4$$' \ | grep -v -E '^data/bison.m4$$' \
| xargs $(build_aux)/$@ | xargs $(build_aux)/$@
@echo 'warning: src/parse-gram.[hc] may need to be regenerated.' @echo 'warning: src/parse-gram.[hc] may need to be regenerated.'
update-package-copyright-year:
$(build_aux)/$@ configure.ac
+68 -352
View File
@@ -1,48 +1,50 @@
Bison News Bison News
---------- ----------
* Changes in version 2.5 (2011-05-14): * Changes in version ?.? (????-??-??):
** Grammar symbol names can now contain non-initial dashes: ** Java skeleton improvements:
Consistently with directives (such as %error-verbose) and with The constants for token names were moved to the Lexer interface.
%define variables (e.g. push-pull), grammar symbol names may contain Also, it is possible to add code to the parser's constructors using
dashes in any position except the beginning. This is a GNU "%code init" and "%define init_throws".
extension over POSIX Yacc. Thus, use of this extension is reported
by -Wyacc and rejected in Yacc mode (--yacc).
** Named references: ** Variable api.tokens.prefix
Historically, Yacc and Bison have supported positional references The variable api.tokens.prefix changes the way tokens are identified in
($n, $$) to allow access to symbol values from inside of semantic the generated files. This is especially useful to avoid collisions
actions code. with identifiers in the target language. For instance
Starting from this version, Bison can also accept named references. %token FILE for ERROR
When no ambiguity is possible, original symbol names may be used %define api.tokens.prefix "TOK_"
as named references: %%
start: FILE for ERROR;
if_stmt : "if" cond_expr "then" then_stmt ';' will generate the definition of the symbols TOK_FILE, TOK_for, and
{ $if_stmt = mk_if_stmt($cond_expr, $then_stmt); } TOK_ERROR in the generated sources. In particular, the scanner must
use these prefixed token names, although the grammar itself still
uses the short names (as in the sample rule given above).
In the more common case, explicit names may be declared: ** Variable api.namespace
stmt[res] : "if" expr[cond] "then" stmt[then] "else" stmt[else] ';' The "namespace" variable is renamed "api.namespace". Backward
{ $res = mk_if_stmt($cond, $then, $else); } compatibility is ensured, but upgrading is recommended.
Location information is also accessible using @name syntax. When ** Variable parse.error
accessing symbol names containing dots or dashes, explicit bracketing
($[sym.1]) must be used.
These features are experimental in this version. More user feedback The variable error controls the verbosity of error messages. The
will help to stabilize them. use of the %error-verbose directive is deprecated in favor of
%define parse.error "verbose".
** IELR(1) and canonical LR(1): * Changes in version 2.5 (????-??-??):
** IELR(1) and Canonical LR(1) Support
IELR(1) is a minimal LR(1) parser table generation algorithm. That IELR(1) is a minimal LR(1) parser table generation algorithm. That
is, given any context-free grammar, IELR(1) generates parser tables is, given any context-free grammar, IELR(1) generates parser tables
with the full language-recognition power of canonical LR(1) but with with the full language recognition power of canonical LR(1) but with
nearly the same number of parser states as LALR(1). This reduction nearly the same number of parser states as LALR(1). This reduction in
in parser states is often an order of magnitude. More importantly, parser states is often an order of magnitude. More importantly,
because canonical LR(1)'s extra parser states may contain duplicate because canonical LR(1)'s extra parser states may contain duplicate
conflicts in the case of non-LR(1) grammars, the number of conflicts conflicts in the case of non-LR(1) grammars, the number of conflicts
for IELR(1) is often an order of magnitude less as well. This can for IELR(1) is often an order of magnitude less as well. This can
@@ -53,62 +55,22 @@ Bison News
default. You can specify the type of parser tables in the grammar default. You can specify the type of parser tables in the grammar
file with these directives: file with these directives:
%define lr.type lalr %define lr.type "LALR"
%define lr.type ielr %define lr.type "IELR"
%define lr.type canonical-lr %define lr.type "canonical LR"
The default-reduction optimization in the parser tables can also be The default reduction optimization in the parser tables can also be
adjusted using `%define lr.default-reductions'. For details on both adjusted using `%define lr.default-reductions'. See the documentation
of these features, see the new section `Tuning LR' in the Bison for `%define lr.type' and `%define lr.default-reductions' in the
manual. section `Bison Declaration Summary' in the Bison manual for the
details.
These features are experimental. More user feedback will help to These features are experimental. More user feedback will help to
stabilize them. stabilize them.
** LAC (Lookahead Correction) for syntax error handling: ** Multiple %define's for any variable is now an error not a warning.
Canonical LR, IELR, and LALR can suffer from a couple of problems ** %define can now be invoked via the command line.
upon encountering a syntax error. First, the parser might perform
additional parser stack reductions before discovering the syntax
error. Such reductions can perform user semantic actions that are
unexpected because they are based on an invalid token, and they
cause error recovery to begin in a different syntactic context than
the one in which the invalid token was encountered. Second, when
verbose error messages are enabled (with %error-verbose or the
obsolete `#define YYERROR_VERBOSE'), the expected token list in the
syntax error message can both contain invalid tokens and omit valid
tokens.
The culprits for the above problems are %nonassoc, default
reductions in inconsistent states, and parser state merging. Thus,
IELR and LALR suffer the most. Canonical LR can suffer only if
%nonassoc is used or if default reductions are enabled for
inconsistent states.
LAC is a new mechanism within the parsing algorithm that solves
these problems for canonical LR, IELR, and LALR without sacrificing
%nonassoc, default reductions, or state merging. When LAC is in
use, canonical LR and IELR behave almost exactly the same for both
syntactically acceptable and syntactically unacceptable input.
While LALR still does not support the full language-recognition
power of canonical LR and IELR, LAC at least enables LALR's syntax
error handling to correctly reflect LALR's language-recognition
power.
Currently, LAC is only supported for deterministic parsers in C.
You can enable LAC with the following directive:
%define parse.lac full
See the new section `LAC' in the Bison manual for additional
details including a few caveats.
LAC is an experimental feature. More user feedback will help to
stabilize it.
** %define improvements:
*** Can now be invoked via the command line:
Each of these command-line options Each of these command-line options
@@ -125,9 +87,9 @@ Bison News
except that the manner in which Bison processes multiple definitions except that the manner in which Bison processes multiple definitions
for the same NAME differs. Most importantly, -F and --force-define for the same NAME differs. Most importantly, -F and --force-define
quietly override %define, but -D and --define do not. For further quietly override %define, but -D and --define do not. For further
details, see the section `Bison Options' in the Bison manual. details, see the section "Bison Options" in the Bison manual.
*** Variables renamed: ** %define variables renamed.
The following %define variables The following %define variables
@@ -142,97 +104,15 @@ Bison News
The old names are now deprecated but will be maintained indefinitely The old names are now deprecated but will be maintained indefinitely
for backward compatibility. for backward compatibility.
*** Values no longer need to be quoted in the grammar file: ** Symbols names
If a %define value is an identifier, it no longer needs to be placed Consistently with directives (such as %error-verbose) and variables
within quotations marks. For example, (e.g. push-pull), symbol names may include dashes in any position,
similarly to periods and underscores. This is GNU extension over
POSIX Yacc whose use is reported by -Wyacc, and rejected in Yacc
mode (--yacc).
%define api.push-pull "push" ** Temporary hack for adding a semicolon to the user action.
can be rewritten as
%define api.push-pull push
*** Unrecognized variables are now errors not warnings.
*** Multiple invocations for any variable is now an error not a warning.
** Unrecognized %code qualifiers are now errors not warnings.
** Character literals not of length one:
Previously, Bison quietly converted all character literals to length
one. For example, without warning, Bison interpreted the operators in
the following grammar to be the same token:
exp: exp '++'
| exp '+' exp
;
Bison now warns when a character literal is not of length one. In
some future release, Bison will start reporting an error instead.
** Destructor calls fixed for lookaheads altered in semantic actions:
Previously for deterministic parsers in C, if a user semantic action
altered yychar, the parser in some cases used the old yychar value to
determine which destructor to call for the lookahead upon a syntax
error or upon parser return. This bug has been fixed.
** C++ parsers use YYRHSLOC:
Similarly to the C parsers, the C++ parsers now define the YYRHSLOC
macro and use it in the default YYLLOC_DEFAULT. You are encouraged
to use it. If, for instance, your location structure has `first'
and `last' members, instead of
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) \
{ \
(Current).first = (Rhs)[1].location.first; \
(Current).last = (Rhs)[N].location.last; \
} \
else \
{ \
(Current).first = (Current).last = (Rhs)[0].location.last; \
} \
while (false)
use:
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) \
{ \
(Current).first = YYRHSLOC (Rhs, 1).first; \
(Current).last = YYRHSLOC (Rhs, N).last; \
} \
else \
{ \
(Current).first = (Current).last = YYRHSLOC (Rhs, 0).last; \
} \
while (false)
** YYLLOC_DEFAULT in C++:
The default implementation of YYLLOC_DEFAULT used to be issued in
the header file. It is now output in the implementation file, after
the user %code sections so that its #ifndef guard does not try to
override the user's YYLLOC_DEFAULT if provided.
** YYFAIL now produces warnings and Java parsers no longer implement it:
YYFAIL has existed for many years as an undocumented feature of
deterministic parsers in C generated by Bison. More recently, it was
a documented feature of Bison's experimental Java parsers. As
promised in Bison 2.4.2's NEWS entry, any appearance of YYFAIL in a
semantic action now produces a deprecation warning, and Java parsers
no longer implement YYFAIL at all. For further details, including a
discussion of how to suppress C preprocessor warnings about YYFAIL
being unused, see the Bison 2.4.2 NEWS entry.
** Temporary hack for adding a semicolon to the user action:
Previously, Bison appended a semicolon to every user action for Previously, Bison appended a semicolon to every user action for
reductions when the output language defaulted to C (specifically, when reductions when the output language defaulted to C (specifically, when
@@ -253,152 +133,32 @@ Bison News
about a missing semicolon where it did not before. Future releases of about a missing semicolon where it did not before. Future releases of
Bison will cease to append semicolons entirely. Bison will cease to append semicolons entirely.
** Verbose syntax error message fixes: ** Character literals not of length one.
When %error-verbose or the obsolete `#define YYERROR_VERBOSE' is Previously, Bison quietly converted all character literals to length
specified, syntax error messages produced by the generated parser one. For example, without warning, Bison interpreted the operators in
include the unexpected token as well as a list of expected tokens. the following grammar to be the same token:
The effect of %nonassoc on these verbose messages has been corrected
in two ways, but a more complete fix requires LAC, described above:
*** When %nonassoc is used, there can exist parser states that accept no exp: exp '++'
tokens, and so the parser does not always require a lookahead token | exp '+' exp
in order to detect a syntax error. Because no unexpected token or ;
expected tokens can then be reported, the verbose syntax error
message described above is suppressed, and the parser instead
reports the simpler message, `syntax error'. Previously, this
suppression was sometimes erroneously triggered by %nonassoc when a
lookahead was actually required. Now verbose messages are
suppressed only when all previous lookaheads have already been
shifted or discarded.
*** Previously, the list of expected tokens erroneously included tokens Bison now warns when a character literal is not of length one. In
that would actually induce a syntax error because conflicts for them some future release, Bison will report an error instead.
were resolved with %nonassoc in the current parser state. Such
tokens are now properly omitted from the list.
*** Expected token lists are still often wrong due to state merging ** Verbose error messages fixed for nonassociative tokens.
(from LALR or IELR) and default reductions, which can both add
invalid tokens and subtract valid tokens. Canonical LR almost
completely fixes this problem by eliminating state merging and
default reductions. However, there is one minor problem left even
when using canonical LR and even after the fixes above. That is,
if the resolution of a conflict with %nonassoc appears in a later
parser state than the one at which some syntax error is
discovered, the conflicted token is still erroneously included in
the expected token list. Bison's new LAC implementation,
described above, eliminates this problem and the need for
canonical LR. However, LAC is still experimental and is disabled
by default.
** Java skeleton fixes: When %error-verbose is specified, syntax error messages produced by
the generated parser include the unexpected token as well as a list of
expected tokens. Previously, this list erroneously included tokens
that would actually induce a syntax error because conflicts for them
were resolved with %nonassoc. Such tokens are now properly omitted
from the list.
*** A location handling bug has been fixed. * Changes in version 2.4.2 (????-??-??):
*** The top element of each of the value stack and location stack is now
cleared when popped so that it can be garbage collected.
*** Parser traces now print the top element of the stack.
** -W/--warnings fixes:
*** Bison now properly recognizes the `no-' versions of categories:
For example, given the following command line, Bison now enables all
warnings except warnings for incompatibilities with POSIX Yacc:
bison -Wall,no-yacc gram.y
*** Bison now treats S/R and R/R conflicts like other warnings:
Previously, conflict reports were independent of Bison's normal
warning system. Now, Bison recognizes the warning categories
`conflicts-sr' and `conflicts-rr'. This change has important
consequences for the -W and --warnings command-line options. For
example:
bison -Wno-conflicts-sr gram.y # S/R conflicts not reported
bison -Wno-conflicts-rr gram.y # R/R conflicts not reported
bison -Wnone gram.y # no conflicts are reported
bison -Werror gram.y # any conflict is an error
However, as before, if the %expect or %expect-rr directive is
specified, an unexpected number of conflicts is an error, and an
expected number of conflicts is not reported, so -W and --warning
then have no effect on the conflict report.
*** The `none' category no longer disables a preceding `error':
For example, for the following command line, Bison now reports
errors instead of warnings for incompatibilities with POSIX Yacc:
bison -Werror,none,yacc gram.y
*** The `none' category now disables all Bison warnings:
Previously, the `none' category disabled only Bison warnings for
which there existed a specific -W/--warning category. However,
given the following command line, Bison is now guaranteed to
suppress all warnings:
bison -Wnone gram.y
** Precedence directives can now assign token number 0:
Since Bison 2.3b, which restored the ability of precedence
directives to assign token numbers, doing so for token number 0 has
produced an assertion failure. For example:
%left END 0
This bug has been fixed.
* Changes in version 2.4.3 (2010-08-05):
** Bison now obeys -Werror and --warnings=error for warnings about
grammar rules that are useless in the parser due to conflicts.
** Problems with spawning M4 on at least FreeBSD 8 and FreeBSD 9 have
been fixed.
** Failures in the test suite for GCC 4.5 have been fixed.
** Failures in the test suite for some versions of Sun Studio C++ have
been fixed.
** Contrary to Bison 2.4.2's NEWS entry, it has been decided that
warnings about undefined %prec identifiers will not be converted to
errors in Bison 2.5. They will remain warnings, which should be
sufficient for POSIX while avoiding backward compatibility issues.
** Minor documentation fixes.
* Changes in version 2.4.2 (2010-03-20):
** Some portability problems that resulted in failures and livelocks
in the test suite on some versions of at least Solaris, AIX, HP-UX,
RHEL4, and Tru64 have been addressed. As a result, fatal Bison
errors should no longer cause M4 to report a broken pipe on the
affected platforms.
** `%prec IDENTIFIER' requires IDENTIFIER to be defined separately.
POSIX specifies that an error be reported for any identifier that does
not appear on the LHS of a grammar rule and that is not defined by
%token, %left, %right, or %nonassoc. Bison 2.3b and later lost this
error report for the case when an identifier appears only after a
%prec directive. It is now restored. However, for backward
compatibility with recent Bison releases, it is only a warning for
now. In Bison 2.5 and later, it will return to being an error.
[Between the 2.4.2 and 2.4.3 releases, it was decided that this
warning will not be converted to an error in Bison 2.5.]
** Detection of GNU M4 1.4.6 or newer during configure is improved. ** Detection of GNU M4 1.4.6 or newer during configure is improved.
** Warnings from gcc's -Wundef option about undefined YYENABLE_NLS,
YYLTYPE_IS_TRIVIAL, and __STRICT_ANSI__ in C/C++ parsers are now
avoided.
** %code is now a permanent feature. ** %code is now a permanent feature.
A traditional Yacc prologue directive is written in the form: A traditional Yacc prologue directive is written in the form:
@@ -422,51 +182,6 @@ Bison News
Bison's Java feature as a whole including its current usage of %code Bison's Java feature as a whole including its current usage of %code
is still considered experimental. is still considered experimental.
** YYFAIL is deprecated and will eventually be removed.
YYFAIL has existed for many years as an undocumented feature of
deterministic parsers in C generated by Bison. Previously, it was
documented for Bison's experimental Java parsers. YYFAIL is no longer
documented for Java parsers and is formally deprecated in both cases.
Users are strongly encouraged to migrate to YYERROR, which is
specified by POSIX.
Like YYERROR, you can invoke YYFAIL from a semantic action in order to
induce a syntax error. The most obvious difference from YYERROR is
that YYFAIL will automatically invoke yyerror to report the syntax
error so that you don't have to. However, there are several other
subtle differences between YYERROR and YYFAIL, and YYFAIL suffers from
inherent flaws when %error-verbose or `#define YYERROR_VERBOSE' is
used. For a more detailed discussion, see:
http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html
The upcoming Bison 2.5 will remove YYFAIL from Java parsers, but
deterministic parsers in C will continue to implement it. However,
because YYFAIL is already flawed, it seems futile to try to make new
Bison features compatible with it. Thus, during parser generation,
Bison 2.5 will produce a warning whenever it discovers YYFAIL in a
rule action. In a later release, YYFAIL will be disabled for
%error-verbose and `#define YYERROR_VERBOSE'. Eventually, YYFAIL will
be removed altogether.
There exists at least one case where Bison 2.5's YYFAIL warning will
be a false positive. Some projects add phony uses of YYFAIL and other
Bison-defined macros for the sole purpose of suppressing C
preprocessor warnings (from GCC cpp's -Wunused-macros, for example).
To avoid Bison's future warning, such YYFAIL uses can be moved to the
epilogue (that is, after the second `%%') in the Bison input file. In
this release (2.4.2), Bison already generates its own code to suppress
C preprocessor warnings for YYFAIL, so projects can remove their own
phony uses of YYFAIL if compatibility with Bison releases prior to
2.4.2 is not necessary.
** Internationalization.
Fix a regression introduced in Bison 2.4: Under some circumstances,
message translations were not installed although supported by the
host system.
* Changes in version 2.4.1 (2008-12-11): * Changes in version 2.4.1 (2008-12-11):
** In the GLR defines file, unexpanded M4 macros in the yylval and yylloc ** In the GLR defines file, unexpanded M4 macros in the yylval and yylloc
@@ -1514,7 +1229,8 @@ End:
----- -----
Copyright (C) 1995-2011 Free Software Foundation, Inc. Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of Bison, the GNU Parser Generator. This file is part of Bison, the GNU Parser Generator.
+1 -1
View File
@@ -36,7 +36,7 @@ to the bison package.
----- -----
Copyright (C) 2002, 2005, 2009-2011 Free Software Foundation, Inc. Copyright (C) 2002, 2005, 2009 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
+2 -6
View File
@@ -33,10 +33,6 @@ Please send bug reports to <[email protected]>. Please include the
version number from `bison --version', and a complete, self-contained version number from `bison --version', and a complete, self-contained
test case in each bug report. test case in each bug report.
* Copyright statements
For any copyright year range specified as YYYY-ZZZZ in this package,
note that the range specifies every single year in that closed interval.
Local Variables: Local Variables:
mode: outline mode: outline
@@ -44,8 +40,8 @@ End:
----- -----
Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2011 Free Software Copyright (C) 1992, 1998, 1999, 2003, 2004, 2005, 2008-2009 Free
Foundation, Inc. Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
+1 -1
View File
@@ -12,7 +12,7 @@ the problems you encounter.
----- -----
Copyright (C) 2002, 2004, 2009-2011 Free Software Foundation, Inc. Copyright (C) 2002, 2004, 2009 Free Software Foundation, Inc.
This file is part of GNU Bison. This file is part of GNU Bison.
+4 -12
View File
@@ -8,13 +8,11 @@ Alexander Belopolsky [email protected]
Alexandre Duret-Lutz [email protected] Alexandre Duret-Lutz [email protected]
Andreas Schwab [email protected] Andreas Schwab [email protected]
Andrew Suffield [email protected] Andrew Suffield [email protected]
Angelo Borsotti [email protected]
Anthony Heading [email protected] Anthony Heading [email protected]
Arnold Robbins [email protected] Arnold Robbins [email protected]
Art Haas [email protected] Art Haas [email protected]
Baron Schwartz [email protected] Baron Schwartz [email protected]
Benoit Perrot [email protected] Benoit Perrot [email protected]
Bernd Kiefer [email protected]
Bert Deknuydt [email protected] Bert Deknuydt [email protected]
Bill Allombert [email protected] Bill Allombert [email protected]
Bob Rossi [email protected] Bob Rossi [email protected]
@@ -26,13 +24,11 @@ Christian Burger [email protected]
Cris Bailiff [email protected] Cris Bailiff [email protected]
Cris van Pelt [email protected] Cris van Pelt [email protected]
Csaba Raduly [email protected] Csaba Raduly [email protected]
Dagobert Michelsen [email protected]
Daniel Hagerty [email protected] Daniel Hagerty [email protected]
David J. MacKenzie [email protected] David J. MacKenzie [email protected]
Derek M. Jones [email protected] Derek M. Jones [email protected]
Di-an Jan [email protected] Di-an Jan [email protected]
Dick Streefland [email protected] Dick Streefland [email protected]
Didier Godefroy [email protected]
Enrico Scholz [email protected] Enrico Scholz [email protected]
Eric Blake [email protected] Eric Blake [email protected]
Evgeny Stambulchik [email protected] Evgeny Stambulchik [email protected]
@@ -41,19 +37,15 @@ Florian Krohm [email protected]
Frank Heckenbach [email protected] Frank Heckenbach [email protected]
Frans Englich [email protected] Frans Englich [email protected]
Georg Sauthoff [email protected] Georg Sauthoff [email protected]
George Neuner [email protected]
Goran Uddeborg [email protected] Goran Uddeborg [email protected]
Guido Trentalancia [email protected] Guido Trentalancia [email protected]
H. Merijn Brand [email protected] H. Merijn Brand [email protected]
Hans Aberg [email protected] Hans Aberg [email protected]
Jan Nieuwenhuizen [email protected] Jan Nieuwenhuizen [email protected]
Jerry Quinn [email protected]
Jesse Thilo [email protected] Jesse Thilo [email protected]
Jim Kent [email protected] Jim Kent [email protected]
Jim Meyering [email protected] Jim Meyering [email protected]
Joel E. Denny joeldenny@joeldenny.org Joel E. Denny jdenny@ces.clemson.edu
Johan van Selst [email protected]
Jonathan Nieder [email protected]
Juan Manuel Guerrero [email protected] Juan Manuel Guerrero [email protected]
Kees Zeelenberg [email protected] Kees Zeelenberg [email protected]
Keith Browne [email protected] Keith Browne [email protected]
@@ -66,7 +58,7 @@ Martin Nylin [email protected]
Matt Kraai [email protected] Matt Kraai [email protected]
Matt Rosing [email protected] Matt Rosing [email protected]
Michael Hayes [email protected] Michael Hayes [email protected]
Michael Raskin 7c6f434c@mail.ru Michiel De Wilde mdewilde.agilent@gmail.com
Mickael Labau [email protected] Mickael Labau [email protected]
Mike Castle [email protected] Mike Castle [email protected]
Neil Booth [email protected] Neil Booth [email protected]
@@ -74,7 +66,6 @@ Nelson H. F. Beebe [email protected]
Nicolas Burrus [email protected] Nicolas Burrus [email protected]
Nicolas Tisserand [email protected] Nicolas Tisserand [email protected]
Noah Friedman [email protected] Noah Friedman [email protected]
Odd Arild Olsen [email protected]
Oleg Smolsky [email protected] Oleg Smolsky [email protected]
Paolo Bonzini [email protected] Paolo Bonzini [email protected]
Pascal Bart [email protected] Pascal Bart [email protected]
@@ -84,6 +75,7 @@ Per Allansson [email protected]
Peter Fales [email protected] Peter Fales [email protected]
Peter Hamorsky [email protected] Peter Hamorsky [email protected]
Piotr Gackiewicz [email protected] Piotr Gackiewicz [email protected]
Quentin Hocquet [email protected]
Quoc Peyrot [email protected] Quoc Peyrot [email protected]
R Blake [email protected] R Blake [email protected]
Raja R Harinath [email protected] Raja R Harinath [email protected]
@@ -103,7 +95,7 @@ Tom Lane [email protected]
Tom Tromey [email protected] Tom Tromey [email protected]
Tommy Nordgren [email protected] Tommy Nordgren [email protected]
Troy A. Johnson [email protected] Troy A. Johnson [email protected]
Tys Lefering twlevo@gmail.com Tys Lefering twlevo@xs4all.nl
Vin Shelton [email protected] Vin Shelton [email protected]
Wayne Green [email protected] Wayne Green [email protected]
Wolfram Wagner [email protected] Wolfram Wagner [email protected]
+184 -42
View File
@@ -1,5 +1,179 @@
-*- outline -*- -*- outline -*-
* Short term
** Use b4_symbol in all the skeleton
Then remove the older system, including the tables generated by
output.c
** Update the documentation on gnu.org
** Get rid of fake #lines [Bison: ...]
Possibly as simple as checking whether the column number is nonnegative.
I have seen messages like the following from GCC.
<built-in>:0: fatal error: opening dependency file .deps/libltdl/argz.Tpo: No such file or directory
** Discuss about %printer/%destroy in the case of C++.
It would be very nice to provide the symbol classes with an operator<<
and a destructor. Unfortunately the syntax we have chosen for
%destroy and %printer make them hard to reuse. For instance, the user
is invited to write something like
%printer { debug_stream() << $$; } <my_type>;
which is hard to reuse elsewhere since it wants to use
"debug_stream()" to find the stream to use. The same applies to
%destroy: we told the user she could use the members of the Parser
class in the printers/destructors, which is not good for an operator<<
since it is no longer bound to a particular parser, it's just a
(standalone symbol).
** Rename LR0.cc
as lr0.cc, why upper case?
** bench several bisons.
Enhance bench.pl with %b to run different bisons.
** Use b4_symbol everywhere.
Move its definition in the more standard places and deploy it in other
skeletons.
* Various
** YYPRINT
glr.c inherits its symbol_print function from c.m4, which supports
YYPRINT. But to use YYPRINT yytoknum is needed, which not defined by
glr.c.
Anyway, IMHO YYPRINT is obsolete and should be restricted to yacc.c.
** YYERRCODE
Defined to 256, but not used, not documented. Probably the token
number for the error token, which POSIX wants to be 256, but which
Bison might renumber if the user used number 256. Keep fix and doc?
Throw away?
Also, why don't we output the token name of the error token in the
output? It is explicitly skipped:
/* Skip error token and tokens without identifier. */
if (sym != errtoken && id)
Of course there are issues with name spaces, but if we disable we have
something which seems to be more simpler and more consistent instead
of the special case YYERRCODE.
enum yytokentype {
error = 256,
// ...
};
We could (should?) also treat the case of the undef_token, which is
numbered 257 for yylex, and 2 internal. Both appear for instance in
toknum:
const unsigned short int
parser::yytoken_number_[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
while here
enum yytokentype {
TOK_EOF = 0,
TOK_EQ = 258,
so both 256 and 257 are "mysterious".
const char*
const parser::yytname_[] =
{
"\"end of command\"", "error", "$undefined", "\"=\"", "\"break\"",
** YYFAIL
It is seems to be *really* obsolete now, shall we remove it?
** YYBACKUP
There is no test about it, no examples in the doc, and I'm not sure
what it should look like. For instance what follows crashes.
%error-verbose
%debug
%pure-parser
%code {
# include <stdio.h>
# include <stdlib.h>
# include <assert.h>
static void yyerror (const char *msg);
static int yylex (YYSTYPE *yylval);
}
%%
exp:
'a' { printf ("a: %d\n", $1); }
| 'b' { YYBACKUP('a', 123); }
;
%%
static int
yylex (YYSTYPE *yylval)
{
static char const input[] = "b";
static size_t toknum;
assert (toknum < sizeof input);
*yylval = (toknum + 1) * 10;
return input[toknum++];
}
static void
yyerror (const char *msg)
{
fprintf (stderr, "%s\n", msg);
}
int
main (void)
{
yydebug = !!getenv("YYDEBUG");
return yyparse ();
}
** yychar == yyempty_
The code in yyerrlab reads:
if (yychar <= YYEOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
There are only two yychar that can be <= YYEOF: YYEMPTY and YYEOF.
But I can't produce the situation where yychar is YYEMPTY here, is it
really possible? The test suite does not exercise this case.
This shows that it would be interesting to manage to install skeleton
coverage analysis to the test suite.
** Table definitions
It should be very easy to factor the definition of the various tables,
including the separation bw declaration and definition. See for
instance b4_table_define in lalr1.cc. This way, we could even factor
C vs. C++ definitions.
* From lalr1.cc to yacc.c
** Single stack
Merging the three stacks in lalr1.cc simplified the code, prompted for
other improvements and also made it faster (probably because memory
management is performed once instead of three times). I suggest that
we do the same in yacc.c.
** yysyntax_error
The code bw glr.c and yacc.c is really alike, we can certainly factor
some parts.
* Header guards * Header guards
From Franc,ois: should we keep the directory part in the CPP guard? From Franc,ois: should we keep the directory part in the CPP guard?
@@ -18,10 +192,6 @@ find something clean (not like YYLSP_NEEDED...).
Before releasing, make sure the documentation ("Understanding your Before releasing, make sure the documentation ("Understanding your
parser") refers to the current `output' format. parser") refers to the current `output' format.
* lalr1.cc
** vector
Move to using vector, drop stack.hh.
* Report * Report
** GLR ** GLR
@@ -96,9 +266,6 @@ must be in the scanner: we must not parse what is in a switched off
part of %if. Akim Demaille thinks it should be in the parser, so as part of %if. Akim Demaille thinks it should be in the parser, so as
to avoid falling into another CPP mistake. to avoid falling into another CPP mistake.
** -D, --define-muscle NAME=VALUE
To define muscles via cli. Or maybe support directly NAME=VALUE?
** XML Output ** XML Output
There are couple of available extensions of Bison targeting some XML There are couple of available extensions of Bison targeting some XML
output. Some day we should consider including them. One issue is output. Some day we should consider including them. One issue is
@@ -139,7 +306,8 @@ this issue. Does anybody have it?
Some history of Bison and some bibliography would be most welcome. Some history of Bison and some bibliography would be most welcome.
Are there any Texinfo standards for bibliography? Are there any Texinfo standards for bibliography?
** %printer
Wow, %printer is not documented. Clearly mark YYPRINT as obsolete.
* Java, Fortran, etc. * Java, Fortran, etc.
@@ -169,15 +337,14 @@ Show reductions.
** Skeleton strategy ** Skeleton strategy
Must we keep %token-table? Must we keep %token-table?
* src/print_graph.c
Find the best graph parameters.
* BTYacc * BTYacc
See if we can integrate backtracking in Bison. Charles-Henri de See if we can integrate backtracking in Bison. Charles-Henri de
Boysson <[email protected]> is working on this, and already has some Boysson <[email protected]> has been working on this, but never gave
results. Vadim Maslow, the maintainer of BTYacc was contacted, and we the results.
stay in touch with him. Adjusting the Bison grammar parser will be
needed to support some extra BTYacc features. This is less urgent. Vadim Maslow, the maintainer of BTYacc was once contacted. Adjusting
the Bison grammar parser will be needed to support some extra BTYacc
features. This is less urgent.
** Keeping the conflicted actions ** Keeping the conflicted actions
First, analyze the differences between byacc and btyacc (I'm referring First, analyze the differences between byacc and btyacc (I'm referring
@@ -192,9 +359,6 @@ very feasible to use the very same conflict tables.
** Adjust the skeletons ** Adjust the skeletons
Import the skeletons for C and C++. Import the skeletons for C and C++.
** Improve the skeletons
Have them support yysymprint, yydestruct and so forth.
* Precedence * Precedence
@@ -203,15 +367,6 @@ It is unfortunate that there is a total order for precedence. It
makes it impossible to have modular precedence information. We should makes it impossible to have modular precedence information. We should
move to partial orders (sounds like series/parallel orders to me). move to partial orders (sounds like series/parallel orders to me).
** Correlation b/w precedence and associativity
Also, I fail to understand why we have to assign the same
associativity to operators with the same precedence. For instance,
why can't I decide that the precedence of * and / is the same, but the
latter is nonassoc?
If there is really no profound motivation, we should find a new syntax
to allow specifying this.
** RR conflicts ** RR conflicts
See if we can use precedence between rules to solve RR conflicts. See See if we can use precedence between rules to solve RR conflicts. See
what POSIX says. what POSIX says.
@@ -240,20 +395,6 @@ $<type_name>$ = $<type_name>1. I therefore think that one should implement
a Bison option where every typed default rule is explicitly written out a Bison option where every typed default rule is explicitly written out
(same typed ruled can of course be grouped together). (same typed ruled can of course be grouped together).
Note: Robert Anisko handles this. He knows how to do it.
* Warnings
It would be nice to have warning support. See how Autoconf handles
them, it is fairly well described there. It would be very nice to
implement this in such a way that other programs could use
lib/warnings.[ch].
Don't work on this without first announcing you do, as I already have
thought about it, and know many of the components that can be used to
implement it.
* Pre and post actions. * Pre and post actions.
From: Florian Krohm <[email protected]> From: Florian Krohm <[email protected]>
Subject: YYACT_EPILOGUE Subject: YYACT_EPILOGUE
@@ -287,7 +428,8 @@ Equip the parser with a means to create the (visual) parse tree.
----- -----
Copyright (C) 2001-2004, 2006, 2008-2011 Free Software Foundation, Inc. Copyright (C) 2001, 2002, 2003, 2004, 2006, 2008-2009 Free Software
Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
+224 -508
View File
File diff suppressed because it is too large Load Diff
+16 -25
View File
@@ -1,6 +1,6 @@
# Bootstrap configuration. # Bootstrap configuration.
# Copyright (C) 2006-2011 Free Software Foundation, Inc. # Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -17,17 +17,12 @@
# gnulib modules used by this package. # gnulib modules used by this package.
gnulib_modules=' gnulib_modules='
announce-gen argmatch assert calloc-posix close config-h c-strcase announce-gen argmatch config-h c-strcase configmake dirname error
configmake dirname error extensions fopen-safer gendocs getopt-gnu extensions fopen-safer gendocs getopt-gnu gettext git-version-gen hash
gettext git-version-gen hash inttypes isnan javacomp-script inttypes javacomp-script javaexec-script maintainer-makefile malloc
javaexec-script ldexpl maintainer-makefile malloc-gnu mbschr mbsrchr mbswidth obstack quote quotearg stdbool stpcpy strerror strtoul
mbswidth obstack perror pipe-posix quote quotearg realloc-posix strverscmp unistd unistd-safer unlocked-io update-copyright unsetenv
spawn-pipe stdbool stpcpy strdup-posix strerror strtoul strverscmp verify warnings xalloc xalloc-die xstrndup
unistd unistd-safer unlocked-io update-copyright unsetenv verify
warnings xalloc xalloc-die xstrndup
fprintf-posix printf-posix snprintf-posix sprintf-posix
vsnprintf-posix vsprintf-posix
' '
# Additional xgettext options to use. Use "\\\newline" to break lines. # Additional xgettext options to use. Use "\\\newline" to break lines.
@@ -46,30 +41,26 @@ XGETTEXT_OPTIONS_RUNTIME=$XGETTEXT_OPTIONS'\\\
# Gettext supplies these files, but we don't need them since # Gettext supplies these files, but we don't need them since
# we don't have an intl subdirectory. # we don't have an intl subdirectory.
excluded_files=' excluded_files='
m4/codeset.m4
m4/glibc2.m4 m4/glibc2.m4
m4/glibc21.m4
m4/intdiv0.m4 m4/intdiv0.m4
m4/intl.m4 m4/intl.m4
m4/intldir.m4 m4/intldir.m4
m4/intmax.m4 m4/intmax.m4
m4/inttypes_h.m4
m4/lcmessage.m4 m4/lcmessage.m4
m4/lock.m4 m4/lock.m4
m4/longdouble.m4 m4/longdouble.m4
m4/printf-posix.m4
m4/signed.m4 m4/signed.m4
m4/size_max.m4
m4/uintmax_t.m4 m4/uintmax_t.m4
m4/ulonglong.m4 m4/ulonglong.m4
m4/visibility.m4 m4/visibility.m4
m4/xsize.m4
' '
bootstrap_epilogue() # In directories like lib/, m4/, and po/, generate both these files because we
{ # still try to support CVS emulation.
# Make sure we don't need src/bison, which usually doesn't exist at vc_ignore='.cvsignore .gitignore'
# the time of a bootstrap.
touch src/parse-gram.[ch]
}
# Keep our bootstrap script in sync with gnulib's. If we ever need to
# maintain our own bootstrap script again, set this to false, remove
# the bootstrap entry from the file .x-update-copyright, and add any
# needed copyright years to the copyright statement in the bootstrap
# script.
bootstrap_sync=true
+19
View File
@@ -0,0 +1,19 @@
announce-gen
compile
config.guess
config.rpath
config.sub
depcomp
gendocs.sh
git-version-gen
install-sh
javacomp.sh.in
javaexec.sh.in
link-warning.h
mdate-sh
missing
texinfo.tex
update-copyright
useless-if-before-free
vc-list-files
ylwrap
-7
View File
@@ -1,9 +1,4 @@
/Makefile
/Makefile.in
/announce-gen /announce-gen
/arg-nonnull.h
/c++defs.h
/compile /compile
/config.guess /config.guess
/config.rpath /config.rpath
@@ -21,6 +16,4 @@
/update-copyright /update-copyright
/useless-if-before-free /useless-if-before-free
/vc-list-files /vc-list-files
/warn-on-use.h
/ylwrap /ylwrap
-2
View File
@@ -1,2 +0,0 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-
EXTRA_DIST = prev-version.txt cross-options.pl update-b4-copyright
+5
View File
@@ -0,0 +1,5 @@
EXTRA_DIST += \
build-aux/cross-options.pl \
build-aux/move-if-change \
build-aux/prev-version.txt \
build-aux/update-b4-copyright
+1
View File
@@ -0,0 +1 @@
../gnulib/build-aux/move-if-change
+2 -2
View File
@@ -3,8 +3,8 @@
# Update b4_copyright invocations or b4_copyright_years definitions to # Update b4_copyright invocations or b4_copyright_years definitions to
# include the current year. # include the current year.
# Copyright (C) 2009-2011 Free Software Foundation, Inc. # Copyright (C) 2009 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option) # the Free Software Foundation; either version 3, or (at your option)
-49
View File
@@ -1,49 +0,0 @@
#!/usr/bin/perl -0777 -pi
# In configure.ac, update PACKAGE_COPYRIGHT_YEAR to the current year.
# Copyright (C) 2010-2011 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
my $this_year = $ENV{UPDATE_COPYRIGHT_YEAR};
if (!$this_year || $this_year !~ m/^\d{4}$/)
{
my ($sec, $min, $hour, $mday, $month, $year) = localtime (time ());
$this_year = $year + 1900;
}
my $old_re = <<'EOF'
(
MACRO\(
\[PACKAGE_COPYRIGHT_YEAR],
\s*\[
)
(\d{4})
(?=])
EOF
;
foreach my $macro ("AC_DEFINE", "AC_SUBST")
{
my $this_old_re = $old_re;
$this_old_re =~ s/MACRO/$macro/;
if (!s/$this_old_re/$1$this_year/x)
{
print STDERR
"$ARGV: warning: failed to update PACKAGE_COPYRIGHT_YEAR in"
. " $macro.\n";
}
}
+4 -9
View File
@@ -1,6 +1,5 @@
# Customize maint.mk -*- makefile -*- # Customize maint.mk -*- makefile -*-
# Copyright (C) 2008-2009 Free Software Foundation, Inc.
# Copyright (C) 2008-2011 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -40,14 +39,10 @@ local-checks-to-skip = changelog-check
# The local directory containing the checked-out copy of gnulib used in # The local directory containing the checked-out copy of gnulib used in
# this release. Used solely to get a date for the "announcement" target. # this release. Used solely to get a date for the "announcement" target.
gnulib_dir = $(srcdir)/gnulib gnulib_dir = $(srcdir)/../../gnulib
bootstrap-tools = autoconf,automake,flex,gettext,gnulib bootstrap-tools = autoconf,automake,flex,gnulib
announcement_Cc_ = \ update-copyright: update-b4-copyright
[email protected], [email protected], [email protected], \
[email protected]
update-copyright: update-b4-copyright update-package-copyright-year
update-copyright-env = \ update-copyright-env = \
UPDATE_COPYRIGHT_FORCE=1 UPDATE_COPYRIGHT_USE_INTERVALS=1 UPDATE_COPYRIGHT_FORCE=1 UPDATE_COPYRIGHT_USE_INTERVALS=1
+28 -41
View File
@@ -1,6 +1,7 @@
# Configure template for GNU Bison. -*-Autoconf-*- # Configure template for GNU Bison. -*-Autoconf-*-
# #
# Copyright (C) 2001-2011 Free Software Foundation, Inc. # Copyright (C) 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 # 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 # it under the terms of the GNU General Public License as published by
@@ -15,36 +16,25 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# In order for some versions of Sun Studio to compile our C++ test cases # testsuite -C appears in 2.62.
# correctly, we need Autoconf 2.64 or better to handle the restrict AC_PREREQ(2.62)
# keyword in at least string.h from gnulib.
AC_PREREQ(2.64)
AC_INIT([GNU Bison], AC_INIT([GNU Bison],
m4_esyscmd([build-aux/git-version-gen .tarball-version]), m4_esyscmd([build-aux/git-version-gen .tarball-version]),
[[email protected]]) [[email protected]])
AC_DEFINE([PACKAGE_COPYRIGHT_YEAR], [2011], AC_DEFINE([PACKAGE_COPYRIGHT_YEAR], [2008],
[The copyright year for this package]) [The copyright year for this package])
AC_SUBST([PACKAGE_COPYRIGHT_YEAR], [2011]) AC_SUBST([PACKAGE_COPYRIGHT_YEAR], [2008])
AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
# Automake 1.10.3 and 1.11.1 fix a security flaw discussed here: # We don't have a file m4/Makefile.am, so we need Automake 1.8 or later.
# # We want gnits strictness only when rolling a formal release so that we can,
# http://thread.gmane.org/gmane.comp.sysutils.autotools.announce/131 # for example, run make dist at other times without being required to add a
# # bogus NEWS entry.
# To avoid 1.11, we make 1.11.1 the minimum version. AM_INIT_AUTOMAKE([1.8 dist-bzip2]
# m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [-], [gnu], [gnits]))
# We want gnits strictness only when rolling a stable release. For
# release candidates, we use version strings like 2.4.3_rc1, but gnits
# doesn't like that, so we let the underscore disable gnits. Between
# releases, we want to be able run make dist without being required to
# add a bogus NEWS entry. In that case, the version string
# automatically contains a dash, which we also let disable gnits.
AM_INIT_AUTOMAKE([1.11.1 dist-bzip2]
m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]],
[gnu], [gnits]))
AC_CONFIG_HEADERS([lib/config.h:lib/config.hin]) AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
# Checks for the compiler. # Checks for the compiler.
@@ -78,12 +68,7 @@ if test "${enableval}" = yes; then
gl_WARN_ADD([-Wshadow]) gl_WARN_ADD([-Wshadow])
gl_WARN_ADD([-Wstrict-prototypes]) gl_WARN_ADD([-Wstrict-prototypes])
AC_SUBST([WARN_CFLAGS]) AC_SUBST([WARN_CFLAGS])
# Warnings for the test suite only. AC_DEFINE([lint], 1, [Define to 1 if the compiler is checking for lint.])
gl_WARN_ADD([-Wundef], [WARN_CFLAGS_TEST])
WARN_CXXFLAGS_TEST="$WARN_CXXFLAGS $WARN_CFLAGS_TEST"
WARN_CFLAGS_TEST="$WARN_CFLAGS $WARN_CFLAGS_TEST"
AC_SUBST([WARN_CXXFLAGS_TEST])
AC_SUBST([WARN_CFLAGS_TEST])
fi fi
BISON_TEST_FOR_WORKING_C_COMPILER BISON_TEST_FOR_WORKING_C_COMPILER
@@ -94,8 +79,8 @@ AC_ARG_ENABLE([yacc],
, [enable_yacc=yes]) , [enable_yacc=yes])
case $enable_yacc in case $enable_yacc in
yes) yes)
YACC_SCRIPT=yacc YACC_SCRIPT=src/yacc
YACC_LIBRARY=liby.a;; YACC_LIBRARY=lib/liby.a;;
*) *)
YACC_SCRIPT= YACC_SCRIPT=
YACC_LIBRARY=;; YACC_LIBRARY=;;
@@ -135,7 +120,7 @@ BISON_PREREQ_TIMEVAR
# We use gnulib, which is only guaranteed to work properly with the # We use gnulib, which is only guaranteed to work properly with the
# latest Gettext. # latest Gettext.
AM_GNU_GETTEXT([external], [need-ngettext]) AM_GNU_GETTEXT([external], [need-ngettext])
AM_GNU_GETTEXT_VERSION([0.18]) AM_GNU_GETTEXT_VERSION([0.17])
BISON_I18N BISON_I18N
# Internationalized parsers. # Internationalized parsers.
@@ -149,7 +134,7 @@ AC_CONFIG_FILES([etc/bench.pl], [chmod +x etc/bench.pl])
# Initialize the test suite. # Initialize the test suite.
AC_CONFIG_TESTDIR(tests) AC_CONFIG_TESTDIR(tests)
AC_CONFIG_FILES([tests/Makefile tests/atlocal]) AC_CONFIG_FILES([tests/atlocal])
AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison]) AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
AC_CHECK_PROGS([VALGRIND], [valgrind]) AC_CHECK_PROGS([VALGRIND], [valgrind])
AC_PROG_CXX AC_PROG_CXX
@@ -160,17 +145,19 @@ AC_SUBST([GCC])
AC_SUBST([O0CFLAGS], [`echo $CFLAGS | sed 's/-O[[0-9]] *//'`]) AC_SUBST([O0CFLAGS], [`echo $CFLAGS | sed 's/-O[[0-9]] *//'`])
AC_SUBST([O0CXXFLAGS], [`echo $CXXFLAGS | sed 's/-O[[0-9]] *//'`]) AC_SUBST([O0CXXFLAGS], [`echo $CXXFLAGS | sed 's/-O[[0-9]] *//'`])
gt_JAVACOMP([1.3]) gt_JAVACOMP([1.3], [1.4])
gt_JAVAEXEC gt_JAVAEXEC
# We use gnulib, but from lib/local.mk instead of lib/Makefile.am.
# So prefix paths with lib/. See also etc/prefix-gnulib-mk.
gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, , lib/,g'`
for ac_var in ALLOCA_H ERRNO_H FCNTL_H GETOPT_H INTTYPES_H \
STDBOOL_H STDINT_H SYS_WAIT_H WCHAR_H WCTYPE_H
do
eval "test 'x$ac_var' = x || $ac_var=lib/\$$ac_var"
done
AC_CONFIG_FILES([Makefile AC_CONFIG_FILES([Makefile
build-aux/Makefile
po/Makefile.in po/Makefile.in
data/Makefile examples/calc++/Makefile
etc/Makefile doc/yacc.1])
examples/Makefile
examples/calc++/Makefile
lib/Makefile src/Makefile
doc/Makefile
doc/yacc.1])
AC_OUTPUT AC_OUTPUT
-2
View File
@@ -1,2 +0,0 @@
Makefile.in
Makefile
-2
View File
@@ -1,2 +0,0 @@
/Makefile.in
/Makefile
-29
View File
@@ -1,29 +0,0 @@
## Copyright (C) 2002, 2005-2011 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
dist_pkgdata_DATA = README bison.m4 \
c-skel.m4 c.m4 yacc.c glr.c \
c++-skel.m4 c++.m4 location.cc lalr1.cc glr.cc \
java-skel.m4 java.m4 lalr1.java
m4sugardir = $(pkgdatadir)/m4sugar
dist_m4sugar_DATA = m4sugar/m4sugar.m4 m4sugar/foreach.m4
xsltdir = $(pkgdatadir)/xslt
dist_xslt_DATA = \
xslt/bison.xsl \
xslt/xml2dot.xsl \
xslt/xml2text.xsl \
xslt/xml2xhtml.xsl
+1 -1
View File
@@ -52,7 +52,7 @@ into various formats.
----- -----
Copyright (C) 2002, 2008-2011 Free Software Foundation, Inc. Copyright (C) 2002, 2008-2009 Free Software Foundation, Inc.
This file is part of GNU Bison. This file is part of GNU Bison.
+275 -36
View File
@@ -1,8 +1,8 @@
-*- Autoconf -*- -*- Autoconf -*-
# Language-independent M4 Macros for Bison. # Language-independent M4 Macros for Bison.
# Copyright (C) 2002, 2004, 2005, 2006, 2007, 2008, 2009
# Copyright (C) 2002, 2004-2011 Free Software Foundation, Inc. # Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -22,14 +22,17 @@
## Identification. ## ## Identification. ##
## ---------------- ## ## ---------------- ##
# b4_copyright(TITLE, YEARS) # b4_copyright(TITLE, [YEARS])
# -------------------------- # ----------------------------
# If YEARS are not defined, use b4_copyright_years.
m4_define([b4_copyright], m4_define([b4_copyright],
[b4_comment([A Bison parser, made by GNU Bison b4_version.]) [b4_comment([A Bison parser, made by GNU Bison b4_version.])
b4_comment([$1 b4_comment([$1
m4_text_wrap([Copyright (C) $2 Free Software Foundation, Inc.], [ ]) ]m4_dquote(m4_text_wrap([Copyright (C)
]m4_ifval([$2], [[$2]], [m4_defn([b4_copyright_years])])[
Free Software Foundation, Inc.]))[
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@@ -209,6 +212,87 @@ m4_define([b4_ints_in],
[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])]) [m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
# b4_subtract(LHS, RHS)
# ---------------------
# Evaluate LHS - RHS if they are integer literals, otherwise expand
# to (LHS) - (RHS).
m4_define([b4_subtract],
[m4_bmatch([$1$2], [^[0123456789]*$],
[m4_eval([$1 - $2])],
[($1) - ($2)])])
# b4_args(ARG1, ...)
# _b4_args(ARG1, ...)
# -------------------
# Join with comma, skipping empty arguments.
# b4_args calls itself recursively until it sees the first non-empty
# argument, then calls _b4_args which prepends each non-empty argument
# with a comma.
m4_define([b4_args],
[m4_if([$#$1],
[1], [],
[m4_ifval([$1],
[$1[]_$0(m4_shift($@))],
[$0(m4_shift($@))])])])
# _b4_args(ARGS1, ...)
# --------------------
m4_define([_b4_args],
[m4_if([$#$1],
[1], [],
[m4_ifval([$1], [, $1])[]$0(m4_shift($@))])])
# b4_integral_parser_tables_map(MACRO)
# -------------------------------------
# Map MACRO on all the integral tables. MACRO is expected to have
# the signature MACRO(TABLE-NAME, CONTENT, COMMENT).
m4_define([b4_integral_parser_tables_map],
[$1([pact], [b4_pact],
[[YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM.]])
$1([defact], [b4_defact],
[[YYDEFACT[S] -- default reduction number in state S. Performed when
YYTABLE does not specify something else to do. Zero means the default
is an error.]])
$1([pgoto], [b4_pgoto], [[YYPGOTO[NTERM-NUM].]])
$1([defgoto], [b4_defgoto], [[YYDEFGOTO[NTERM-NUM].]])
$1([table], [b4_table],
[[YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If YYTABLE_NINF, syntax error.]])
$1([check], [b4_check])
$1([stos], [b4_stos],
[[STOS_[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM.]])
$1([r1], [b4_r1],
[[YYR1[YYN] -- Symbol number of symbol that rule YYN derives.]])
$1([r2], [b4_r2],
[[YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.]])
])
# b4_parser_tables_declare
# b4_parser_tables_define
# ------------------------
# Define/declare the (deterministic) parser tables.
m4_define([b4_parser_tables_declare],
[b4_integral_parser_tables_map([b4_integral_parser_table_declare])])
m4_define([b4_parser_tables_define],
[b4_integral_parser_tables_map([b4_integral_parser_table_define])])
## ------------------ ## ## ------------------ ##
## Decoding options. ## ## Decoding options. ##
@@ -247,16 +331,120 @@ m4_define([b4_$3_if],
# ----------------------------- # -----------------------------
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise. # Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
b4_define_flag_if([defines]) # Whether headers are requested. b4_define_flag_if([defines]) # Whether headers are requested.
b4_define_flag_if([error_verbose]) # Whether error are verbose.
b4_define_flag_if([glr]) # Whether a GLR parser is requested. b4_define_flag_if([glr]) # Whether a GLR parser is requested.
b4_define_flag_if([locations]) # Whether locations are tracked.
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled. b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated. b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
## ------------------------- ## ## --------- ##
## Assigning token numbers. ## ## Symbols. ##
## ------------------------- ## ## --------- ##
# b4_symbol_(NUM, FIELD)
# ----------------------
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
# undefined.
m4_define([b4_symbol_],
[m4_indir([b4_symbol($1, $2)])])
# b4_symbol(NUM, FIELD)
# ---------------------
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
# undefined. If FIELD = id, prepend the prefix.
m4_define([b4_symbol],
[m4_case([$2],
[id], [m4_do([b4_percent_define_get([api.tokens.prefix])],
[b4_symbol_([$1], [id])])],
[b4_symbol_($@)])])
# b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE)
# -------------------------------------------
# If FIELD about symbol #NUM is 1 expand IF-TRUE, if is 0, expand IF-FALSE.
# Otherwise an error.
m4_define([b4_symbol_if],
[m4_case(b4_symbol([$1], [$2]),
[1], [$3],
[0], [$4],
[m4_fatal([$0: field $2 of $1 is not a Boolean:] b4_symbol([$1], [$2]))])])
# b4_symbol_action_location(SYMBOL-NUM, KIND)
# -------------------------------------------
# Report the location of the KIND action as FILE:LINE.
m4_define([b4_symbol_action_location],
[b4_symbol([$1], [$2_file]):b4_syncline([b4_symbol([$1], [$2_line])])])
# b4_symbol_action(SYMBOL-NUM, KIND)
# ----------------------------------
# Run the action KIND (destructor or printer) for SYMBOL-NUM.
# Same as in C, but using references instead of pointers.
m4_define([b4_symbol_action],
[b4_symbol_if([$1], [has_$2],
[m4_pushdef([b4_dollar_dollar],
[b4_symbol_value([(*yyvaluep)],
b4_symbol_if([$1], [has_type],
[b4_symbol([$1], [type])]))])dnl
m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl
b4_symbol_case_([$1])
b4_syncline([b4_symbol([$1], [$2_line])], ["b4_symbol([$1], [$2_file])"])
b4_symbol([$1], [$2])
b4_syncline([@oline@], [@ofile@])
break;
m4_popdef([b4_at_dollar])dnl
m4_popdef([b4_dollar_dollar])dnl
])])
# b4_symbol_destructor(SYMBOL-NUM)
# b4_symbol_printer(SYMBOL-NUM)
# --------------------------------
m4_define([b4_symbol_destructor], [b4_symbol_action([$1], [destructor])])
m4_define([b4_symbol_printer], [b4_symbol_action([$1], [printer])])
# b4_symbol_case_(SYMBOL-NUM)
# ---------------------------
# Issue a "case NUM" for SYMBOL-NUM.
m4_define([b4_symbol_case_],
[ case b4_symbol([$1], [number]): // b4_symbol([$1], [tag])
])
# b4_symbol_foreach(MACRO)
# ------------------------
# Invoke MACRO(SYMBOL-NUM) for each SYMBOL-NUM.
m4_define([b4_symbol_foreach],
[m4_map([$1], m4_defn([b4_symbol_numbers]))])
## ------- ##
## Types. ##
## ------- ##
# b4_type_action_(NUMS)
# ---------------------
# Run actions for the symbol NUMS that all have the same type-name.
# Skip NUMS that have no type-name.
m4_define([b4_type_action_],
[b4_symbol_if([$1], [has_type],
[m4_map([b4_symbol_case_], [$@])[]dnl
b4_dollar_dollar([b4_symbol([$1], [number])],
[b4_symbol([$1], [tag])],
[b4_symbol([$1], [type])]);
break;
])])
# b4_type_foreach(MACRO)
# ----------------------
# Invoke MACRO(SYMBOL-NUMS) for each set of SYMBOL-NUMS for each type set.
m4_define([b4_type_foreach],
[m4_map([$1], m4_defn([b4_type_names]))])
## ----------- ## ## ----------- ##
@@ -274,8 +462,8 @@ m4_define([b4_basename],
# b4_syncline(LINE, FILE) # b4_syncline(LINE, FILE)
# ----------------------- # -----------------------
m4_define([b4_syncline], m4_define([b4_syncline],
[b4_flag_if([synclines], [ [b4_flag_if([synclines],
b4_sync_end([__line__], [b4_basename(m4_quote(__file__))]) [b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
b4_sync_start([$1], [$2])])]) b4_sync_start([$1], [$2])])])
m4_define([b4_sync_end], [b4_comment([Line $1 of $2])]) m4_define([b4_sync_end], [b4_comment([Line $1 of $2])])
@@ -312,10 +500,10 @@ b4_define_user_code([stype])
# b4_check_user_names(WHAT, USER-LIST, BISON-NAMESPACE) # b4_check_user_names(WHAT, USER-LIST, BISON-NAMESPACE)
# ----------------------------------------------------- # --------------------------------------------------------
# Complain if any name of type WHAT is used by the user (as recorded in # Warn if any name of type WHAT is used by the user (as recorded in USER-LIST)
# USER-LIST) but is not used by Bison (as recorded by macros in the # but is not used by Bison (as recorded by macros in the namespace
# namespace BISON-NAMESPACE). # BISON-NAMESPACE).
# #
# USER-LIST must expand to a list specifying all user occurrences of all names # USER-LIST must expand to a list specifying all user occurrences of all names
# of type WHAT. Each item in the list must be a triplet specifying one # of type WHAT. Each item in the list must be a triplet specifying one
@@ -353,9 +541,9 @@ m4_pushdef([b4_user_name], m4_car(b4_occurrence))dnl
m4_pushdef([b4_start], m4_car(m4_shift(b4_occurrence)))dnl m4_pushdef([b4_start], m4_car(m4_shift(b4_occurrence)))dnl
m4_pushdef([b4_end], m4_shift(m4_shift(b4_occurrence)))dnl m4_pushdef([b4_end], m4_shift(m4_shift(b4_occurrence)))dnl
m4_ifndef($3[(]m4_quote(b4_user_name)[)], m4_ifndef($3[(]m4_quote(b4_user_name)[)],
[b4_complain_at([b4_start], [b4_end], [b4_warn_at([b4_start], [b4_end],
[[%s `%s' is not used]], [[%s `%s' is not used]],
[$1], [b4_user_name])])[]dnl [$1], [b4_user_name])])[]dnl
m4_popdef([b4_occurrence])dnl m4_popdef([b4_occurrence])dnl
m4_popdef([b4_user_name])dnl m4_popdef([b4_user_name])dnl
m4_popdef([b4_start])dnl m4_popdef([b4_start])dnl
@@ -364,7 +552,6 @@ m4_popdef([b4_end])dnl
## --------------------- ## ## --------------------- ##
## b4_percent_define_*. ## ## b4_percent_define_*. ##
## --------------------- ## ## --------------------- ##
@@ -377,11 +564,10 @@ m4_define([b4_percent_define_use],
[m4_define([b4_percent_define_bison_variables(]$1[)])dnl [m4_define([b4_percent_define_bison_variables(]$1[)])dnl
]) ])
# b4_percent_define_get(VARIABLE, [DEFAULT]) # b4_percent_define_get(VARIABLE)
# ------------------------------------------ # -------------------------------
# Mimic muscle_percent_define_get in ../src/muscle-tab.h. That is, if # Mimic muscle_percent_define_get in ../src/muscle_tab.h exactly. That is, if
# the %define variable VARIABLE is defined, emit its value. Contrary # the %define variable VARIABLE is defined, emit its value. Also, record
# to its C counterpart, return DEFAULT otherwise. Also, record
# Bison's usage of VARIABLE by defining # Bison's usage of VARIABLE by defining
# b4_percent_define_bison_variables(VARIABLE). # b4_percent_define_bison_variables(VARIABLE).
# #
@@ -390,14 +576,11 @@ m4_define([b4_percent_define_use],
# b4_percent_define_get([[foo]]) # b4_percent_define_get([[foo]])
m4_define([b4_percent_define_get], m4_define([b4_percent_define_get],
[b4_percent_define_use([$1])dnl [b4_percent_define_use([$1])dnl
m4_ifdef([b4_percent_define(]$1[)], m4_ifdef([b4_percent_define(]$1[)], [m4_indir([b4_percent_define(]$1[)])])])
[m4_indir([b4_percent_define(]$1[)])],
[$2])])
# b4_percent_define_get_loc(VARIABLE) # b4_percent_define_get_loc(VARIABLE)
# ----------------------------------- # -----------------------------------
# Mimic muscle_percent_define_get_loc in ../src/muscle-tab.h exactly. That is, # Mimic muscle_percent_define_get_loc in ../src/muscle_tab.h exactly. That is,
# if the %define variable VARIABLE is undefined, complain fatally since that's # if the %define variable VARIABLE is undefined, complain fatally since that's
# a Bison or skeleton error. Otherwise, return its definition location in a # a Bison or skeleton error. Otherwise, return its definition location in a
# form approriate for the first two arguments of b4_warn_at, b4_complain_at, or # form approriate for the first two arguments of b4_warn_at, b4_complain_at, or
@@ -416,7 +599,7 @@ m4_popdef([b4_loc])],
# b4_percent_define_get_syncline(VARIABLE) # b4_percent_define_get_syncline(VARIABLE)
# ---------------------------------------- # ----------------------------------------
# Mimic muscle_percent_define_get_syncline in ../src/muscle-tab.h exactly. # Mimic muscle_percent_define_get_syncline in ../src/muscle_tab.h exactly.
# That is, if the %define variable VARIABLE is undefined, complain fatally # That is, if the %define variable VARIABLE is undefined, complain fatally
# since that's a Bison or skeleton error. Otherwise, return its definition # since that's a Bison or skeleton error. Otherwise, return its definition
# location as a b4_syncline invocation. Don't record this as a Bison usage of # location as a b4_syncline invocation. Don't record this as a Bison usage of
@@ -433,7 +616,7 @@ m4_define([b4_percent_define_get_syncline],
# b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE]) # b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE])
# ------------------------------------------------------ # ------------------------------------------------------
# Mimic muscle_percent_define_ifdef in ../src/muscle-tab.h exactly. That is, # Mimic muscle_percent_define_ifdef in ../src/muscle_tab.h exactly. That is,
# if the %define variable VARIABLE is defined, expand IF-TRUE, else expand # if the %define variable VARIABLE is defined, expand IF-TRUE, else expand
# IF-FALSE. Also, record Bison's usage of VARIABLE by defining # IF-FALSE. Also, record Bison's usage of VARIABLE by defining
# b4_percent_define_bison_variables(VARIABLE). # b4_percent_define_bison_variables(VARIABLE).
@@ -443,12 +626,18 @@ m4_define([b4_percent_define_get_syncline],
# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]]) # b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
m4_define([b4_percent_define_ifdef], m4_define([b4_percent_define_ifdef],
[m4_ifdef([b4_percent_define(]$1[)], [m4_ifdef([b4_percent_define(]$1[)],
[m4_define([b4_percent_define_bison_variables(]$1[)])$2], [b4_percent_define_use([$1])$2],
[$3])]) [$3])])
## --------- ##
## Options. ##
## --------- ##
# b4_percent_define_flag_if(VARIABLE, IF-TRUE, [IF-FALSE]) # b4_percent_define_flag_if(VARIABLE, IF-TRUE, [IF-FALSE])
# -------------------------------------------------------- # --------------------------------------------------------
# Mimic muscle_percent_define_flag_if in ../src/muscle-tab.h exactly. That is, # Mimic muscle_percent_define_flag_if in ../src/muscle_tab.h exactly. That is,
# if the %define variable VARIABLE is defined to "" or "true", expand IF-TRUE. # if the %define variable VARIABLE is defined to "" or "true", expand IF-TRUE.
# If it is defined to "false", expand IF-FALSE. Complain if it is undefined # If it is defined to "false", expand IF-FALSE. Complain if it is undefined
# (a Bison or skeleton error since the default value should have been set # (a Bison or skeleton error since the default value should have been set
@@ -469,9 +658,10 @@ m4_define([b4_percent_define_flag_if],
[[b4_percent_define_flag_if($1)]])])], [[b4_percent_define_flag_if($1)]])])],
[b4_fatal([[undefined %%define variable `%s' passed to b4_percent_define_flag_if]], [$1])])]) [b4_fatal([[undefined %%define variable `%s' passed to b4_percent_define_flag_if]], [$1])])])
# b4_percent_define_default(VARIABLE, DEFAULT) # b4_percent_define_default(VARIABLE, DEFAULT)
# -------------------------------------------- # --------------------------------------------
# Mimic muscle_percent_define_default in ../src/muscle-tab.h exactly. That is, # Mimic muscle_percent_define_default in ../src/muscle_tab.h exactly. That is,
# if the %define variable VARIABLE is undefined, set its value to DEFAULT. # if the %define variable VARIABLE is undefined, set its value to DEFAULT.
# Don't record this as a Bison usage of VARIABLE as there's no reason to # Don't record this as a Bison usage of VARIABLE as there's no reason to
# suspect that the value has yet influenced the output. # suspect that the value has yet influenced the output.
@@ -487,9 +677,23 @@ m4_define([b4_percent_define_default],
[[<skeleton default value>:-1.-1]]]])dnl [[<skeleton default value>:-1.-1]]]])dnl
m4_define([b4_percent_define_syncline(]$1[)], [[]])])]) m4_define([b4_percent_define_syncline(]$1[)], [[]])])])
# b4_percent_define_if_define(VARIABLE)
# -------------------------------------
# Define b4_VARIABLE_if that executes its $1 or $2 depending whether
# VARIABLE was %defined. The characters `.' and `-' in VARIABLE are mapped
# to `_'.
m4_define([b4_percent_define_if_define_],
[m4_define(m4_bpatsubst([b4_$1_if], [[-.]], [_]),
[b4_percent_define_flag_if([$1], [$2], [$3])])])
m4_define([b4_percent_define_if_define],
[b4_percent_define_default([[$1]], [[false]])
b4_percent_define_if_define_([$1], $[1], $[2])])
# b4_percent_define_check_values(VALUES) # b4_percent_define_check_values(VALUES)
# -------------------------------------- # --------------------------------------
# Mimic muscle_percent_define_check_values in ../src/muscle-tab.h exactly # Mimic muscle_percent_define_check_values in ../src/muscle_tab.h exactly
# except that the VALUES structure is more appropriate for M4. That is, VALUES # except that the VALUES structure is more appropriate for M4. That is, VALUES
# is a list of sublists of strings. For each sublist, the first string is the # is a list of sublists of strings. For each sublist, the first string is the
# name of a %define variable, and all remaining strings in that sublist are the # name of a %define variable, and all remaining strings in that sublist are the
@@ -561,6 +765,41 @@ m4_define([b4_percent_code_ifdef],
[$3])]) [$3])])
## ------------------ ##
## Common variables. ##
## ------------------ ##
# Default values for %define.
# ---------------------------
# If the api.tokens.prefix, it is empty.
m4_percent_define_default([[api.tokens.prefix]], [[]])
# b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
# b4_lex_symbol_if([IF-YYLEX-RETURNS-A-COMPLETE-SYMBOL], [IF-NOT])
# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT])
# ----------------------------------------------
b4_percent_define_if_define([lex_symbol])
b4_percent_define_if_define([locations]) # Whether locations are tracked.
b4_percent_define_if_define([parse.assert])
b4_percent_define_if_define([parse.trace])
b4_percent_define_if_define([variant])
# b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT])
# ------------------------------------------------------
# Map %define parse.error "(simple|verbose)" to b4_error_verbose_if and
# b4_error_verbose_flag.
b4_percent_define_default([[parse.error]], [[simple]])
b4_percent_define_check_values([[[[parse.error]],
[[simple]], [[verbose]]]])
m4_define([b4_error_verbose_flag],
m4_case(b4_percent_define_get([[parse.error]]),
[simple], [[0]],
[verbose], [[1]]))
b4_define_flag_if([error_verbose])
## ----------------------------------------------------------- ## ## ----------------------------------------------------------- ##
## After processing the skeletons, check that all the user's ## ## After processing the skeletons, check that all the user's ##
## %define variables and %code qualifiers were used by Bison. ## ## %define variables and %code qualifiers were used by Bison. ##
+1 -2
View File
@@ -1,8 +1,7 @@
-*- Autoconf -*- -*- Autoconf -*-
# C++ skeleton dispatching for Bison. # C++ skeleton dispatching for Bison.
# Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
# Copyright (C) 2006-2007, 2009-2011 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
+311 -17
View File
@@ -2,7 +2,8 @@
# C++ skeleton for Bison # C++ skeleton for Bison
# Copyright (C) 2002-2011 Free Software Foundation, Inc. # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -23,27 +24,24 @@ m4_include(b4_pkgdatadir/[c.m4])
## Default values. ## ## Default values. ##
## ---------------- ## ## ---------------- ##
# Default parser class name.
b4_percent_define_default([[parser_class_name]], [[parser]]) b4_percent_define_default([[parser_class_name]], [[parser]])
b4_percent_define_default([[location_type]], [[location]])
# Don't do that so that we remember whether we're using a user
# request, or the default value.
#
# b4_percent_define_default([[location_type]], [[location]])
b4_percent_define_default([[filename_type]], [[std::string]]) b4_percent_define_default([[filename_type]], [[std::string]])
b4_percent_define_default([[namespace]], m4_defn([b4_prefix])) b4_percent_define_default([[api.namespace]], m4_defn([b4_prefix]))
b4_percent_define_default([[global_tokens_and_yystype]], [[false]]) b4_percent_define_default([[global_tokens_and_yystype]], [[false]])
b4_percent_define_default([[define_location_comparison]], b4_percent_define_default([[define_location_comparison]],
[m4_if(b4_percent_define_get([[filename_type]]), [m4_if(b4_percent_define_get([[filename_type]]),
[std::string], [[true]], [[false]])]) [std::string], [[true]], [[false]])])
## ----------- ## ## ----------- ##
## Namespace. ## ## Namespace. ##
## ----------- ## ## ----------- ##
m4_define([b4_namespace_ref], [b4_percent_define_get([[namespace]])]) m4_define([b4_namespace_ref], [b4_percent_define_get([[api.namespace]])])
# Don't permit an empty b4_namespace_ref. Any `::parser::foo' appended to it # Don't permit an empty b4_namespace_ref. Any `::parser::foo' appended to it
# would compile as an absolute reference with `parser' in the global namespace. # would compile as an absolute reference with `parser' in the global namespace.
@@ -53,7 +51,7 @@ m4_define([b4_namespace_ref], [b4_percent_define_get([[namespace]])])
# include the header, which is always generated. If we ever need to permit # include the header, which is always generated. If we ever need to permit
# internal linkage somehow, surely we can find a cleaner approach. # internal linkage somehow, surely we can find a cleaner approach.
m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [], m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
[b4_complain_at(b4_percent_define_get_loc([[namespace]]), [b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
[[namespace reference is empty]])]) [[namespace reference is empty]])])
# Instead of assuming the C++ compiler will do it, Bison should reject any # Instead of assuming the C++ compiler will do it, Bison should reject any
@@ -64,20 +62,20 @@ m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
# Specifically, don't allow empty names as b4_namespace_open would just convert # Specifically, don't allow empty names as b4_namespace_open would just convert
# those into anonymous namespaces, and that might tempt some users. # those into anonymous namespaces, and that might tempt some users.
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*::]), [-1], [], m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*::]), [-1], [],
[b4_complain_at(b4_percent_define_get_loc([[namespace]]), [b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
[[namespace reference has consecutive "::"]])]) [[namespace reference has consecutive "::"]])])
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*$]), [-1], [], m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*$]), [-1], [],
[b4_complain_at(b4_percent_define_get_loc([[namespace]]), [b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
[[namespace reference has a trailing "::"]])]) [[namespace reference has a trailing "::"]])])
m4_define([b4_namespace_open], m4_define([b4_namespace_open],
[b4_user_code([b4_percent_define_get_syncline([[namespace]]) [b4_user_code([b4_percent_define_get_syncline([[api.namespace]])
[namespace ]m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref), [namespace ]m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref),
[^\(.\)[ ]*::], [\1])), [^\(.\)[ ]*::], [\1])),
[::], [ { namespace ])[ {]])]) [::], [ { namespace ])[ {]])])
m4_define([b4_namespace_close], m4_define([b4_namespace_close],
[b4_user_code([b4_percent_define_get_syncline([[namespace]]) [b4_user_code([b4_percent_define_get_syncline([[api.namespace]])
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]), m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
[^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*], [^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*],
[\1])), [\1])),
@@ -101,12 +99,307 @@ m4_map_sep([ b4_token_enum], [,
## Semantic Values. ## ## Semantic Values. ##
## ----------------- ## ## ----------------- ##
# b4_semantic_type_declare
# ------------------------
# Declare semantic_type.
m4_define([b4_semantic_type_declare],
[ /// Symbol semantic values.
m4_ifdef([b4_stype],
[ union semantic_type
{b4_user_stype
};],
[m4_if(b4_tag_seen_flag, 0,
[[ typedef int semantic_type;]],
[[ typedef YYSTYPE semantic_type;]])])])
# b4_public_types_declare
# -----------------------
# Define the public types: token, semantic value, location, and so forth.
# Depending on %define token_lex, may be output in the header or source file.
m4_define([b4_public_types_declare],
[[#ifndef YYSTYPE
]b4_semantic_type_declare[
#else
typedef YYSTYPE semantic_type;
#endif]b4_locations_if([
/// Symbol locations.
typedef b4_percent_define_get([[location_type]]) location_type;])[
/// Tokens.
struct token
{
]b4_token_enums(b4_tokens)[
};
/// Token type.
typedef token::yytokentype token_type;
/// A complete symbol, with its type.
template <typename Exact>
struct symbol_base_type
{
/// Default constructor.
inline symbol_base_type ();
/// Constructor.]b4_locations_if([
inline symbol_base_type (const location_type& l)])[;
inline symbol_base_type (]b4_args(
[const semantic_type& v],
b4_locations_if([const location_type& l]))[);
/// Release the memory allocated to members.
/// Reclaim the semantic value using the %destructor directive.
void clear ();
/// Print the semantic value using the %printer directive.
std::ostream& print (std::ostream& o) const;
/// Print everything about the symbol (type, value, location).
std::ostream& dump (std::ostream& o) const;
/// Return this with its exact type.
const Exact& self () const;
Exact& self ();
/// Return the type of this symbol.
int type_get () const;
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
/// The name for the type.
const char *type_name () const;
#endif
/// The semantic value.
semantic_type value;]b4_locations_if([
/// The location.
location_type location;])[
};
/// External form of a symbol: its type and attributes.
struct symbol_type : symbol_base_type<symbol_type>
{
/// The parent class.
typedef symbol_base_type<symbol_type> super_type;
/// Default constructor.
inline symbol_type ();
/// Constructor.
inline symbol_type (]b4_args([int t],
[const semantic_type& v],
b4_locations_if([const location_type& l]))[);
inline symbol_type (]b4_args([int t],
b4_locations_if([const location_type& l]))[);
/// The symbol type.
int type;
/// Return the type corresponding to this state.
inline int type_get_ () const;
/// Its token.
token_type token () const;
};
]b4_symbol_constructor_declare])
# b4_public_types_define
# ----------------------
# Provide the implementation needed by the public types.
m4_define([b4_public_types_define],
[[ // symbol_base_type.
template <typename Exact>
]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type ()
: value()]b4_locations_if([
, location()])[
{
}]b4_locations_if([[
template <typename Exact>
]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (const location_type& l)
: value()
, location(l)
{
}]])[
template <typename Exact>
]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (]b4_args(
[const semantic_type& v],
b4_locations_if([const location_type& l]))[)
: value(v)]b4_locations_if([
, location(l)])[
{
}
template <typename Exact>
void
]b4_parser_class_name[::symbol_base_type<Exact>::clear ()
{
int yytype = type_get ();
// User destructor.
switch (yytype)
{
]b4_symbol_foreach([b4_symbol_destructor])dnl
[ default:
break;
}]b4_variant_if([
// Type destructor.
b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[
}
template <typename Exact>
std::ostream&
]b4_parser_class_name[::symbol_base_type<Exact>::print (std::ostream& yystream) const
{
#define debug_stream() yystream
switch (type_get ())
{
]b4_symbol_foreach([b4_symbol_printer])dnl
[ default:
break;
}
#undef debug_stream
return yystream;
}
template <typename Exact>
std::ostream&
]b4_parser_class_name[::symbol_base_type<Exact>::dump (std::ostream& yystream) const
{
int yytype = type_get ();
yystream << (yytype < yyntokens_ ? "token" : "nterm")
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
<< ' ' << type_name ()
#endif
<< " ("]b4_locations_if([
<< location << ": "])[;
print (yystream);
return yystream << ')';
}
template <typename Exact>
const Exact&
]b4_parser_class_name[::symbol_base_type<Exact>::self () const
{
return static_cast<const Exact&>(*this);
}
template <typename Exact>
Exact&
]b4_parser_class_name[::symbol_base_type<Exact>::self ()
{
return static_cast<Exact&>(*this);
}
template <typename Exact>
int
]b4_parser_class_name[::symbol_base_type<Exact>::type_get () const
{
return self ().type_get_ ();
}
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
template <typename Exact>
const char *
]b4_parser_class_name[::symbol_base_type<Exact>::type_name () const
{
return ]b4_parser_class_name[::yytname_[type_get ()];
}
#endif
// symbol_type.
]b4_parser_class_name[::symbol_type::symbol_type ()
: super_type ()
, type ()
{
}
]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
[int t],
b4_locations_if([const location_type& l]))[)
: super_type (]b4_locations_if([l])[)
, type (t)
{
}
]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
[int t],
[const semantic_type& v],
b4_locations_if([const location_type& l]))[)
: super_type (v]b4_locations_if([, l])[)
, type (t)
{
}
int
]b4_parser_class_name[::symbol_type::type_get_ () const
{
return type;
}
]b4_lex_symbol_if([[
]b4_parser_class_name[::token_type
]b4_parser_class_name[::symbol_type::token () const
{
// YYTOKNUM[NUM] -- (External) token number corresponding to the
// (internal) symbol number NUM (which must be that of a token). */
static
const ]b4_int_type_for([b4_toknum])[
yytoken_number_[] =
{
]b4_toknum[
};
return static_cast<token_type> (yytoken_number_[type]);
}
]])[]dnl
b4_symbol_constructor_define])
# b4_symbol_constructor_declare
# b4_symbol_constructor_define
# -----------------------------
# Declare/define symbol constructors for all the value types.
# Use at class-level. Redefined in variant.hh.
m4_define([b4_symbol_constructor_declare], [])
m4_define([b4_symbol_constructor_define], [])
# b4_yytranslate_define
# ---------------------
# Define yytranslate_. Sometimes used in the header file,
# sometimes in the cc file.
m4_define([b4_yytranslate_define],
[[ // Symbol number corresponding to token number t.
]b4_parser_class_name[::token_number_type
]b4_parser_class_name[::yytranslate_ (]b4_lex_symbol_if([token_type],
[int])[ t)
{
static
const token_number_type
translate_table[] =
{
]b4_translate[
};
const unsigned int user_token_number_max_ = ]b4_user_token_number_max[;
const token_number_type undef_token_ = ]b4_undef_token_number[;
if (static_cast<int>(t) <= yyeof_)
return yyeof_;
else if (static_cast<unsigned int> (t) <= user_token_number_max_)
return translate_table[t];
else
return undef_token_;
}
]])
# b4_lhs_value([TYPE]) # b4_lhs_value([TYPE])
# -------------------- # --------------------
# Expansion of $<TYPE>$. # Expansion of $<TYPE>$.
m4_define([b4_lhs_value], m4_define([b4_lhs_value],
[(yyval[]m4_ifval([$1], [.$1]))]) [b4_symbol_value([yyval], [$1])])
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE]) # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
@@ -114,7 +407,8 @@ m4_define([b4_lhs_value],
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
# symbols on RHS. # symbols on RHS.
m4_define([b4_rhs_value], m4_define([b4_rhs_value],
[(yysemantic_stack_@{($1) - ($2)@}m4_ifval([$3], [.$3]))]) [b4_symbol_value([yysemantic_stack_@{($1) - ($2)@}], [$3])])
# b4_lhs_location() # b4_lhs_location()
# ----------------- # -----------------
+1 -2
View File
@@ -1,8 +1,7 @@
-*- Autoconf -*- -*- Autoconf -*-
# C skeleton dispatching for Bison. # C skeleton dispatching for Bison.
# Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
# Copyright (C) 2006-2007, 2009-2011 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
+64 -31
View File
@@ -1,8 +1,8 @@
-*- Autoconf -*- -*- Autoconf -*-
# C M4 Macros for Bison. # C M4 Macros for Bison.
# Copyright (C) 2002, 2004, 2005, 2006, 2007, 2008, 2009
# Copyright (C) 2002, 2004-2011 Free Software Foundation, Inc. # Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -21,11 +21,34 @@
## Identification. ## ## Identification. ##
## ---------------- ## ## ---------------- ##
# b4_comment(TEXT) # b4_comment_(TEXT, OPEN, CONTINUE, END)
# ---------------- # -------------------------------------
m4_define([b4_comment], [/* m4_bpatsubst([$1], [ # Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
], [ # Avoid adding indentation to the first line, as the indentation comes
]) */]) # from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]).
#
# Prefix all the output lines with PREFIX.
m4_define([b4_comment_], [$2[]m4_bpatsubst([$1], [
\(.\)], [
$3\1])$4])
# b4_c_comment(TEXT, [PREFIX])
# ----------------------------
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
# Avoid adding indentation to the first line, as the indentation comes
# from "/*". That's why we don't patsubst([$1], [^\(.\)], [ \1]).
#
# Prefix all the output lines with PREFIX.
m4_define([b4_c_comment],
[b4_comment_([$1], [$2/* ], [$2 ], [$2 */])])
# b4_comment(TEXT, [PREFIX])
# --------------------------
# By default, C comments.
m4_define([b4_comment], [b4_c_comment($@)])
# b4_identification # b4_identification
# ----------------- # -----------------
@@ -52,7 +75,7 @@ m4_define([b4_identification],
#define YYPULL ]b4_pull_flag])[ #define YYPULL ]b4_pull_flag])[
/* Using locations. */ /* Using locations. */
#define YYLSP_NEEDED ]b4_locations_flag[ #define YYLSP_NEEDED ]b4_locations_if([1], [0])[
]]) ]])
@@ -157,6 +180,17 @@ m4_define([b4_table_value_equals],
m4_define([b4_null], [0]) m4_define([b4_null], [0])
# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
# -------------------------------------------------------------
# Define "yy<TABLE-NAME>" which contents is CONTENT.
m4_define([b4_integral_parser_table_define],
[m4_ifval([$3], [b4_c_comment([$3], [ ])
])dnl
static const b4_int_type_for([$2]) yy$1[[]] =
{
$2
};dnl
])
## ------------------------- ## ## ------------------------- ##
@@ -167,7 +201,7 @@ m4_define([b4_null], [0])
# ----------------------------------------- # -----------------------------------------
# Output the definition of this token as #define. # Output the definition of this token as #define.
m4_define([b4_token_define], m4_define([b4_token_define],
[#define $1 $2 [#define b4_percent_define_get([api.tokens.prefix])$1 $2
]) ])
@@ -185,7 +219,7 @@ m4_map([b4_token_define], [$@])])
# --------------------------------------- # ---------------------------------------
# Output the definition of this token as an enum. # Output the definition of this token as an enum.
m4_define([b4_token_enum], m4_define([b4_token_enum],
[$1 = $2]) [b4_percent_define_get([api.tokens.prefix])$1 = $2])
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER) # b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
@@ -216,6 +250,21 @@ m4_define([b4_token_enums_defines],
]) ])
## ----------------- ##
## Semantic Values. ##
## ----------------- ##
# b4_symbol_value(VAL, [TYPE])
# ----------------------------
# Given a semantic value VAL ($$, $1 etc.), extract its value of type
# TYPE if TYPE is given, otherwise just return VAL. The result can be
# used safetly, it is put in parens to avoid nasty precedence issues.
# TYPE is *not* put in braces, provide some if needed.
m4_define([b4_symbol_value],
[($1[]m4_ifval([$2], [.$2]))])
## --------------------------------------------- ## ## --------------------------------------------- ##
## Defining C functions in both K&R and ANSI-C. ## ## Defining C functions in both K&R and ANSI-C. ##
@@ -304,7 +353,7 @@ m4_define([b4_c_knr_formal_decl],
# ----------------------------------------------------------- # -----------------------------------------------------------
# Declare the function NAME. # Declare the function NAME.
m4_define([b4_c_function_decl], m4_define([b4_c_function_decl],
[#if defined __STDC__ || defined __cplusplus [#if b4_c_modern
b4_c_ansi_function_decl($@) b4_c_ansi_function_decl($@)
#else #else
$2 $1 (); $2 $1 ();
@@ -363,24 +412,8 @@ m4_define([b4_sync_start], [[#]line $1 $2])
m4_define([b4_case], m4_define([b4_case],
[ case $1: [ case $1:
$2 $2
break;])
# b4_symbol_actions(FILENAME, LINENO,
# SYMBOL-TAG, SYMBOL-NUM,
# SYMBOL-ACTION, SYMBOL-TYPENAME)
# -------------------------------------------------
m4_define([b4_symbol_actions],
[m4_pushdef([b4_dollar_dollar],
[m4_ifval([$6], [(yyvaluep->$6)], [(*yyvaluep)])])dnl
m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl
case $4: /* $3 */
b4_syncline([$2], [$1])
$5;
b4_syncline([@oline@], [@ofile@]) b4_syncline([@oline@], [@ofile@])
break; break;])
m4_popdef([b4_at_dollar])dnl
m4_popdef([b4_dollar_dollar])dnl
])
# b4_yydestruct_generate(FUNCTION-DECLARATOR) # b4_yydestruct_generate(FUNCTION-DECLARATOR)
@@ -413,8 +446,8 @@ b4_parse_param_use[]dnl
switch (yytype) switch (yytype)
{ {
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[ ]b4_symbol_foreach([b4_symbol_destructor])dnl
default: [ default:
break; break;
} }
}]dnl }]dnl
@@ -454,7 +487,7 @@ b4_parse_param_use[]dnl
# endif # endif
switch (yytype) switch (yytype)
{ {
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl ]b4_symbol_foreach([b4_symbol_printer])dnl
[ default: [ default:
break; break;
} }
+162 -248
View File
@@ -1,8 +1,8 @@
-*- C -*- -*- C -*-
# GLR skeleton for Bison # GLR skeleton for Bison
# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
# Copyright (C) 2002-2011 Free Software Foundation, Inc. # Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -35,8 +35,8 @@ m4_define_default([b4_stack_depth_init], [200])
## ------------------------ ## ## ------------------------ ##
b4_define_flag_if([pure]) b4_define_flag_if([pure])
# If glr.cc is including this file and thus has already set b4_pure_flag, # If glr.cc is including this file and thus has already set b4_pure_flag, don't
# do not change the value of b4_pure_flag, and do not record a use of api.pure. # change the value of b4_pure_flag, and don't record a use of api.pure.
m4_ifndef([b4_pure_flag], m4_ifndef([b4_pure_flag],
[b4_percent_define_default([[api.pure]], [[false]]) [b4_percent_define_default([[api.pure]], [[false]])
m4_define([b4_pure_flag], m4_define([b4_pure_flag],
@@ -109,7 +109,15 @@ m4_define([b4_pure_formals],
# -------------------- # --------------------
# Expansion of $<TYPE>$. # Expansion of $<TYPE>$.
m4_define([b4_lhs_value], m4_define([b4_lhs_value],
[((*yyvalp)[]m4_ifval([$1], [.$1]))]) [b4_symbol_value([(*yyvalp)], [$1])])
# b4_rhs_data(RULE-LENGTH, NUM)
# -----------------------------
# Expand to the semantic stack place that contains value and location
# of symbol number NUM in a rule of length RULE-LENGTH.
m4_define([b4_rhs_data],
[((yyGLRStackItem const *)yyvsp)@{YYFILL (b4_subtract([$2], [$1]))@}.yystate])
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE]) # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
@@ -117,7 +125,7 @@ m4_define([b4_lhs_value],
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
# symbols on RHS. # symbols on RHS.
m4_define([b4_rhs_value], m4_define([b4_rhs_value],
[(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3]))]) [b4_symbol_value([b4_rhs_data([$1], [$2]).yysemantics.yysval], [$3])])
@@ -137,7 +145,7 @@ m4_define([b4_lhs_location],
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
# on RHS. # on RHS.
m4_define([b4_rhs_location], m4_define([b4_rhs_location],
[(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yyloc)]) [(b4_rhs_data([$1], [$2]).yyloc)])
@@ -150,7 +158,7 @@ m4_changecom()
m4_divert_push(0)dnl m4_divert_push(0)dnl
@output(b4_parser_file_name@)@ @output(b4_parser_file_name@)@
b4_copyright([Skeleton implementation for Bison GLR parsers in C], b4_copyright([Skeleton implementation for Bison GLR parsers in C],
[2002-2011]) [2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009])
[ [
/* C GLR parser skeleton written by Paul Hilfinger. */ /* C GLR parser skeleton written by Paul Hilfinger. */
@@ -216,7 +224,7 @@ b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
/* Enabling traces. */ /* Enabling traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
# define YYDEBUG ]b4_debug_flag[ # define YYDEBUG ]b4_parse_trace_if([1], [0])[
#endif #endif
/* Enabling verbose error messages. */ /* Enabling verbose error messages. */
@@ -224,7 +232,7 @@ b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
# undef YYERROR_VERBOSE # undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1 # define YYERROR_VERBOSE 1
#else #else
# define YYERROR_VERBOSE ]b4_error_verbose_flag[ # define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[
#endif #endif
/* Enabling the token table. */ /* Enabling the token table. */
@@ -248,7 +256,7 @@ b4_percent_code_get[]dnl
#include <string.h> #include <string.h>
#ifndef YY_ #ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS # if YYENABLE_NLS
# if ENABLE_NLS # if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid) # define YY_(msgid) dgettext ("bison-runtime", msgid)
@@ -310,8 +318,7 @@ b4_percent_code_get[]dnl
#ifndef __attribute__ #ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */ /* This feature is available in gcc versions 2.5 and later. */
# if (! defined __GNUC__ || __GNUC__ < 2 \ # if (! defined __GNUC__ || __GNUC__ < 2 \
|| (__GNUC__ == 2 && __GNUC_MINOR__ < 5) \ || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__)
|| (defined __STRICT_ANSI__ && __STRICT_ANSI__))
# define __attribute__(Spec) /* empty */ # define __attribute__(Spec) /* empty */
# endif # endif
#endif #endif
@@ -360,19 +367,6 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
}; };
#if YYDEBUG #if YYDEBUG
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
YYRHS. */
static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
{
]b4_prhs[
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
{
]b4_rhs[
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const ]b4_int_type_for([b4_rline])[ yyrline[] = static const ]b4_int_type_for([b4_rline])[ yyrline[] =
{ {
@@ -389,17 +383,10 @@ static const char *const yytname[] =
}; };
#endif #endif
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ #define YYPACT_NINF ]b4_pact_ninf[
static const ]b4_int_type_for([b4_r1])[ yyr1[] = #define YYTABLE_NINF ]b4_table_ninf[
{
]b4_r1[
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ ]b4_parser_tables_define[
static const ]b4_int_type_for([b4_r2])[ yyr2[] =
{
]b4_r2[
};
/* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */ /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
static const ]b4_int_type_for([b4_dprec])[ yydprec[] = static const ]b4_int_type_for([b4_dprec])[ yydprec[] =
@@ -413,43 +400,6 @@ static const ]b4_int_type_for([b4_merger])[ yymerger[] =
]b4_merger[ ]b4_merger[
}; };
/* YYDEFACT[S] -- default reduction number in state S. Performed when
YYTABLE doesn't specify something else to do. Zero means the default
is an error. */
static const ]b4_int_type_for([b4_defact])[ yydefact[] =
{
]b4_defact[
};
/* YYPDEFGOTO[NTERM-NUM]. */
static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
{
]b4_defgoto[
};
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
#define YYPACT_NINF ]b4_pact_ninf[
static const ]b4_int_type_for([b4_pact])[ yypact[] =
{
]b4_pact[
};
/* YYPGOTO[NTERM-NUM]. */
static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] =
{
]b4_pgoto[
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If YYTABLE_NINF, syntax error. */
#define YYTABLE_NINF ]b4_table_ninf[
static const ]b4_int_type_for([b4_table])[ yytable[] =
{
]b4_table[
};
/* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
list of conflicting reductions corresponding to action entry for list of conflicting reductions corresponding to action entry for
state STATE-NUM in yytable. 0 means no conflicts. The list in state STATE-NUM in yytable. 0 means no conflicts. The list in
@@ -468,19 +418,6 @@ dnl We probably ought to introduce a type for confl.
{ {
]b4_conflicting_rules[ ]b4_conflicting_rules[
}; };
static const ]b4_int_type_for([b4_check])[ yycheck[] =
{
]b4_check[
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const ]b4_int_type_for([b4_stos])[ yystos[] =
{
]b4_stos[
};
/* Prevent warning if -Wmissing-prototypes. */ /* Prevent warning if -Wmissing-prototypes. */
]b4_c_ansi_function_decl([yyparse], [int], b4_parse_param)[ ]b4_c_ansi_function_decl([yyparse], [int], b4_parse_param)[
@@ -563,9 +500,12 @@ static const int YYEMPTY = -2;
typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG; typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
#define YYCHK(YYE) \ #define YYCHK(YYE) \
do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \ do { \
while (YYID (0)) YYRESULTTAG yyflag = YYE; \
if (yyflag != yyok) \
return yyflag; \
} while (YYID (0))
#if YYDEBUG #if YYDEBUG
@@ -574,23 +514,23 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
# endif # endif
# define YYDPRINTF(Args) \ # define YYDPRINTF(Args) \
do { \ do { \
if (yydebug) \ if (yydebug) \
YYFPRINTF Args; \ YYFPRINTF Args; \
} while (YYID (0)) } while (YYID (0))
]b4_yy_symbol_print_generate([b4_c_ansi_function_def])[ ]b4_yy_symbol_print_generate([b4_c_ansi_function_def])[
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \ do { \
if (yydebug) \ if (yydebug) \
{ \ { \
YYFPRINTF (stderr, "%s ", Title); \ YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, Type, \ yy_symbol_print (stderr, Type, \
Value]b4_locations_if([, Location])[]b4_user_args[); \ Value]b4_locations_if([, Location])[]b4_user_args[); \
YYFPRINTF (stderr, "\n"); \ YYFPRINTF (stderr, "\n"); \
} \ } \
} while (YYID (0)) } while (YYID (0))
/* Nonzero means print parse trace. It is left uninitialized so that /* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */ multiple parsers can coexist. */
@@ -1068,8 +1008,7 @@ yygetLRActions (yyStateNum yystate, int yytoken,
static inline yyStateNum static inline yyStateNum
yyLRgotoState (yyStateNum yystate, yySymbol yylhs) yyLRgotoState (yyStateNum yystate, yySymbol yylhs)
{ {
int yyr; int yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate) if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate)
return yytable[yyr]; return yytable[yyr];
else else
@@ -1110,11 +1049,11 @@ yynewGLRStackItem (yyGLRStack* yystackp, yybool yyisState)
* stack #K of *STACKP. */ * stack #K of *STACKP. */
static void static void
yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate, yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate,
yyGLRState* rhs, yyRuleNum yyrule) yyGLRState* yyrhs, yyRuleNum yyrule)
{ {
yySemanticOption* yynewOption = yySemanticOption* yynewOption =
&yynewGLRStackItem (yystackp, yyfalse)->yyoption; &yynewGLRStackItem (yystackp, yyfalse)->yyoption;
yynewOption->yystate = rhs; yynewOption->yystate = yyrhs;
yynewOption->yyrule = yyrule; yynewOption->yyrule = yyrule;
if (yystackp->yytops.yylookaheadNeeds[yyk]) if (yystackp->yytops.yylookaheadNeeds[yyk])
{ {
@@ -1345,7 +1284,7 @@ yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
* semantic value of YYRHS under the action for YYRULE. */ * semantic value of YYRHS under the action for YYRULE. */
static inline void static inline void
yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState, yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule) size_t yyposn, yyGLRState* yyrhs, yyRuleNum yyrule)
{ {
yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate; yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
@@ -1357,7 +1296,7 @@ yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
yystackp->yytops.yystates[yyk] = yynewState; yystackp->yytops.yystates[yyk] = yynewState;
/* Invokes YY_RESERVE_GLRSTACK. */ /* Invokes YY_RESERVE_GLRSTACK. */
yyaddDeferredAction (yystackp, yyk, yynewState, rhs, yyrule); yyaddDeferredAction (yystackp, yyk, yynewState, yyrhs, yyrule);
} }
/** Pop the symbols consumed by reduction #RULE from the top of stack /** Pop the symbols consumed by reduction #RULE from the top of stack
@@ -1375,12 +1314,12 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
if (yystackp->yysplitPoint == NULL) if (yystackp->yysplitPoint == NULL)
{ {
/* Standard special case: single stack. */ /* Standard special case: single stack. */
yyGLRStackItem* rhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk]; yyGLRStackItem* yyrhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
YYASSERT (yyk == 0); YYASSERT (yyk == 0);
yystackp->yynextFree -= yynrhs; yystackp->yynextFree -= yynrhs;
yystackp->yyspaceLeft += yynrhs; yystackp->yyspaceLeft += yynrhs;
yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate; yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
return yyuserAction (yyrule, yynrhs, rhs, return yyuserAction (yyrule, yynrhs, yyrhs,
yyvalp, yylocp, yystackp]b4_user_args[); yyvalp, yylocp, yystackp]b4_user_args[);
} }
else else
@@ -1423,8 +1362,7 @@ do { \
`----------------------------------------------------------*/ `----------------------------------------------------------*/
/*ARGSUSED*/ static inline void /*ARGSUSED*/ static inline void
yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule]b4_user_formals[)
YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
{ {
int yynrhs = yyrhsLength (yyrule); int yynrhs = yyrhsLength (yyrule);
yybool yynormal __attribute__ ((__unused__)) = yybool yynormal __attribute__ ((__unused__)) =
@@ -1432,8 +1370,6 @@ yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystackp->yytops.yystates[yyk]; yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
int yylow = 1; int yylow = 1;
int yyi; int yyi;
YYUSE (yyvalp);
YYUSE (yylocp);
]b4_parse_param_use[]dnl ]b4_parse_param_use[]dnl
[ YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n", [ YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
(unsigned long int) yyk, yyrule - 1, (unsigned long int) yyk, yyrule - 1,
@@ -1442,7 +1378,8 @@ yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
for (yyi = 0; yyi < yynrhs; yyi++) for (yyi = 0; yyi < yynrhs; yyi++)
{ {
YYFPRINTF (stderr, " $%d = ", yyi + 1); YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], yy_symbol_print (stderr,
]yystos@{b4_rhs_data(yynrhs, yyi + 1).yylrState@}[,
&]b4_rhs_value(yynrhs, yyi + 1)[ &]b4_rhs_value(yynrhs, yyi + 1)[
]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
b4_user_args[); b4_user_args[);
@@ -1473,7 +1410,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
YYSTYPE yysval; YYSTYPE yysval;
YYLTYPE yyloc; YYLTYPE yyloc;
YY_REDUCE_PRINT ((yystackp, yyk, yyrule, &yysval, &yyloc]b4_user_args[)); YY_REDUCE_PRINT ((yystackp, yyk, yyrule]b4_user_args[));
YYCHK (yydoAction (yystackp, yyk, yyrule, &yysval, YYCHK (yydoAction (yystackp, yyk, yyrule, &yysval,
&yyloc]b4_user_args[)); &yyloc]b4_user_args[));
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc); YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc);
@@ -1771,11 +1708,11 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
{ {
if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn) if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "", YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1])); yytokenName (yystos[yystates[yyi-1]->yylrState]));
else else
YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "", YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]), yytokenName (yystos[yystates[yyi-1]->yylrState]),
(unsigned long int) (yystates[yyi - 1]->yyposn + 1), (unsigned long int) (yystates[yyi-1]->yyposn + 1),
(unsigned long int) yystates[yyi]->yyposn); (unsigned long int) yystates[yyi]->yyposn);
} }
else else
@@ -1802,7 +1739,7 @@ yyreportAmbiguity (yySemanticOption* yyx0,
yyerror (]b4_yyerror_args[YY_("syntax is ambiguous")); yyerror (]b4_yyerror_args[YY_("syntax is ambiguous"));
return yyabort; return yyabort;
}]b4_locations_if([[ }
/** Starting at and including state S1, resolve the location for each of the /** Starting at and including state S1, resolve the location for each of the
* previous N1 states that is unresolved. The first semantic option of a state * previous N1 states that is unresolved. The first semantic option of a state
@@ -1860,7 +1797,7 @@ yyresolveLocations (yyGLRState* yys1, int yyn1,
yylloc = yylloc_current; yylloc = yylloc_current;
} }
} }
}]])[ }
/** Resolve the ambiguity represented in state S, perform the indicated /** Resolve the ambiguity represented in state S, perform the indicated
* actions, and set the semantic value of S. If result != yyok, the chain of * actions, and set the semantic value of S. If result != yyok, the chain of
@@ -1894,8 +1831,8 @@ yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
{ {
switch (yypreference (yybest, yyp)) switch (yypreference (yybest, yyp))
{ {
case 0:]b4_locations_if([[ case 0:
yyresolveLocations (yys, 1, yystackp]b4_user_args[);]])[ yyresolveLocations (yys, 1, yystackp]b4_user_args[);
return yyreportAmbiguity (yybest, yyp]b4_pure_args[); return yyreportAmbiguity (yybest, yyp]b4_pure_args[);
break; break;
case 1: case 1:
@@ -2088,130 +2025,109 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
/*ARGSUSED*/ static void /*ARGSUSED*/ static void
yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[) yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
{ {
if (yystackp->yyerrState != 0) if (yystackp->yyerrState == 0)
return;
#if ! YYERROR_VERBOSE
yyerror (]b4_lyyerror_args[YY_("syntax error"));
#else
yySymbol yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
size_t yysize0 = yytnamerr (NULL, yytokenName (yytoken));
size_t yysize = yysize0;
size_t yysize1;
yybool yysize_overflow = yyfalse;
char* yymsg = NULL;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = 0;
/* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per
"expected"). */
int yycount = 0;
/* There are many possibilities here to consider:
- If this state is a consistent state with a default action, then
the only way this function was invoked is if the default action
is an error action. In that case, don't check for expected
tokens because there are none.
- The only way there can be no lookahead present (in yychar) is if
this state is a consistent state with a default action. Thus,
detecting the absence of a lookahead is sufficient to determine
that there is no unexpected or expected token to report. In that
case, just report a simple "syntax error".
- Don't assume there isn't a lookahead just because this state is a
consistent state with a default action. There might have been a
previous inconsistent state, consistent state with a non-default
action, or user semantic action that manipulated yychar.
- Of course, the expected token list depends on states to have
correct lookahead information, and it depends on the parser not
to perform extra reductions after fetching a lookahead from the
scanner and before detecting a syntax error. Thus, state merging
(from LALR or IELR) and default reductions corrupt the expected
token list. However, the list is correct for canonical LR with
one exception: it will still contain any token that will not be
accepted due to an error action in a later state.
*/
if (yytoken != YYEMPTY)
{ {
int yyn = yypact[yystackp->yytops.yystates[0]->yylrState]; #if YYERROR_VERBOSE
yyarg[yycount++] = yytokenName (yytoken); int yyn;
if (!yypact_value_is_default (yyn)) yyn = yypact[yystackp->yytops.yystates[0]->yylrState];
{ if (YYPACT_NINF < yyn && yyn <= YYLAST)
/* Start YYX at -YYN if negative to avoid negative indexes in {
YYCHECK. In other words, skip the first -YYN actions for this yySymbol yytoken = YYTRANSLATE (yychar);
state because they are default actions. */ size_t yysize0 = yytnamerr (NULL, yytokenName (yytoken));
int yyxbegin = yyn < 0 ? -yyn : 0; size_t yysize = yysize0;
/* Stay within bounds of both yycheck and yytname. */ size_t yysize1;
int yychecklim = YYLAST - yyn + 1; yybool yysize_overflow = yyfalse;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; char* yymsg = NULL;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = 0;
/* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for this
state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
/* Number of reported tokens (one for the "unexpected", one per
"expected"). */
int yycount = 0;
int yyx; int yyx;
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
&& !yytable_value_is_error (yytable[yyx + yyn]))
{
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{
yycount = 1;
yysize = yysize0;
break;
}
yyarg[yycount++] = yytokenName (yyx);
yysize1 = yysize + yytnamerr (NULL, yytokenName (yyx));
yysize_overflow |= yysize1 < yysize;
yysize = yysize1;
}
}
}
switch (yycount) yyarg[yycount++] = yytokenName (yytoken);
{
#define YYCASE_(N, S) \ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
case N: \ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
yyformat = S; \ && !yytable_value_is_error (yytable[yyx + yyn]))
break {
YYCASE_(0, YY_("syntax error")); if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
YYCASE_(1, YY_("syntax error, unexpected %s")); {
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); yycount = 1;
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); yysize = yysize0;
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); break;
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); }
yyarg[yycount++] = yytokenName (yyx);
yysize1 = yysize + yytnamerr (NULL, yytokenName (yyx));
yysize_overflow |= yysize1 < yysize;
yysize = yysize1;
}
switch (yycount)
{
#define YYCASE_(N, S) \
case N: \
yyformat = S; \
break
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
#undef YYCASE_ #undef YYCASE_
}
yysize1 = yysize + strlen (yyformat);
yysize_overflow |= yysize1 < yysize;
yysize = yysize1;
if (!yysize_overflow)
yymsg = (char *) YYMALLOC (yysize);
if (yymsg)
{
char *yyp = yymsg;
int yyi = 0;
while ((*yyp = *yyformat))
{
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyformat += 2;
} }
else
{ yysize1 = yysize + strlen (yyformat);
yyp++; yysize_overflow |= yysize1 < yysize;
yyformat++; yysize = yysize1;
}
} if (!yysize_overflow)
yyerror (]b4_lyyerror_args[yymsg); yymsg = (char *) YYMALLOC (yysize);
YYFREE (yymsg);
} if (yymsg)
else {
{ char *yyp = yymsg;
yyerror (]b4_lyyerror_args[YY_("syntax error")); int yyi = 0;
yyMemoryExhausted (yystackp); while ((*yyp = *yyformat))
} {
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyformat += 2;
}
else
{
yyp++;
yyformat++;
}
}
yyerror (]b4_lyyerror_args[yymsg);
YYFREE (yymsg);
}
else
{
yyerror (]b4_lyyerror_args[YY_("syntax error"));
yyMemoryExhausted (yystackp);
}
}
else
#endif /* YYERROR_VERBOSE */ #endif /* YYERROR_VERBOSE */
yynerrs += 1; yyerror (]b4_lyyerror_args[YY_("syntax error"));
yynerrs += 1;
}
} }
/* Recover from a syntax error on *YYSTACKP, assuming that *YYSTACKP->YYTOKENP, /* Recover from a syntax error on *YYSTACKP, assuming that *YYSTACKP->YYTOKENP,
@@ -2348,7 +2264,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
yychar = YYEMPTY; yychar = YYEMPTY;
yylval = yyval_default; yylval = yyval_default;
]b4_locations_if([ ]b4_locations_if([
#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL #if YYLTYPE_IS_TRIVIAL
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[; yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[; yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
#endif #endif
@@ -2654,9 +2570,7 @@ yypdumpstack (yyGLRStack* yystackp)
YYFPRINTF (stderr, "\n"); YYFPRINTF (stderr, "\n");
} }
#endif #endif
] ]b4_epilogue[]dnl
b4_epilogue
dnl dnl
dnl glr.cc produces its own header. dnl glr.cc produces its own header.
dnl dnl
@@ -2664,7 +2578,7 @@ m4_if(b4_skeleton, ["glr.c"],
[b4_defines_if( [b4_defines_if(
[@output(b4_spec_defines_file@)@ [@output(b4_spec_defines_file@)@
b4_copyright([Skeleton interface for Bison GLR parsers in C], b4_copyright([Skeleton interface for Bison GLR parsers in C],
[2002-2011]) [2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009])
b4_shared_declarations b4_shared_declarations
@@ -2674,5 +2588,5 @@ b4_pure_if([],
b4_locations_if([b4_pure_if([], b4_locations_if([b4_pure_if([],
[extern YYLTYPE ]b4_prefix[lloc;]) [extern YYLTYPE ]b4_prefix[lloc;])
]) ])
])]) ])])[]dnl
m4_divert_pop(0) m4_divert_pop(0)
+21 -48
View File
@@ -1,8 +1,6 @@
-*- C -*-
# C++ GLR skeleton for Bison # C++ GLR skeleton for Bison
# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Copyright (C) 2002-2011 Free Software Foundation, Inc. # Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -29,7 +27,7 @@
# #
# The additional arguments are stored as members of the parser # The additional arguments are stored as members of the parser
# object, yyparser. The C routines need to carry yyparser # object, yyparser. The C routines need to carry yyparser
# throughout the C parser; that easy: just let yyparser become an # throughout the C parser; that's easy: make yyparser an
# additional parse-param. But because the C++ skeleton needs to # additional parse-param. But because the C++ skeleton needs to
# know the "real" original parse-param, we save them # know the "real" original parse-param, we save them
# (b4_parse_param_orig). Note that b4_parse_param is overquoted # (b4_parse_param_orig). Note that b4_parse_param is overquoted
@@ -39,14 +37,14 @@
# The locations # The locations
# #
# We use location.cc just like lalr1.cc, but because glr.c stores # We use location.cc just like lalr1.cc, but because glr.c stores
# the locations in a (C++) union, the position and location classes # the locations in a union, the position and location classes
# must not have a constructor. Therefore, contrary to lalr1.cc, we # must not have a constructor. Therefore, contrary to lalr1.cc, we
# must not define "b4_location_constructors". As a consequence the # must not define "b4_location_constructors". As a consequence the
# user must initialize the first positions (in particular the # user must initialize the first positions (in particular the
# filename member). # filename member).
# We require a pure interface using locations. # We require a pure interface using locations.
m4_define([b4_locations_flag], [1]) m4_define([b4_percent_define(locations)], [])
m4_define([b4_pure_flag], [1]) m4_define([b4_pure_flag], [1])
# The header is mandatory. # The header is mandatory.
@@ -54,8 +52,7 @@ b4_defines_if([],
[b4_fatal([b4_skeleton[: using %%defines is mandatory]])]) [b4_fatal([b4_skeleton[: using %%defines is mandatory]])])
m4_include(b4_pkgdatadir/[c++.m4]) m4_include(b4_pkgdatadir/[c++.m4])
b4_percent_define_ifdef([[location_type]], [], m4_include(b4_pkgdatadir/[location.cc])
[m4_include(b4_pkgdatadir/[location.cc])])
m4_define([b4_parser_class_name], m4_define([b4_parser_class_name],
[b4_percent_define_get([[parser_class_name]])]) [b4_percent_define_get([[parser_class_name]])])
@@ -126,8 +123,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [ ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
:])[ :])[
#if YYDEBUG #if YYDEBUG
]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false), ]m4_ifset([b4_parse_param], [ ], [ :])[yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
#endif]b4_parse_param_cons[ #endif]b4_parse_param_cons[
{ {
} }
@@ -156,7 +152,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
YYUSE (yylocationp); YYUSE (yylocationp);
switch (yytype) switch (yytype)
{ {
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl ]b4_symbol_foreach([b4_symbol_printer])dnl
[ default: [ default:
break; break;
} }
@@ -190,19 +186,18 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
]b4_parser_class_name[::debug_level_type ]b4_parser_class_name[::debug_level_type
]b4_parser_class_name[::debug_level () const ]b4_parser_class_name[::debug_level () const
{ {
return yydebug_; return yydebug;
} }
void void
]b4_parser_class_name[::set_debug_level (debug_level_type l) ]b4_parser_class_name[::set_debug_level (debug_level_type l)
{ {
yydebug_ = l; yydebug = l;
} }
#endif #endif
]m4_popdef([b4_parse_param])dnl ]m4_popdef([b4_parse_param])dnl
b4_namespace_close[ b4_namespace_close[
]]) ]])
@@ -220,7 +215,7 @@ m4_popdef([b4_parse_param])
m4_divert_push(0) m4_divert_push(0)
@output(b4_spec_defines_file@)@ @output(b4_spec_defines_file@)@
b4_copyright([Skeleton interface for Bison GLR parsers in C++], b4_copyright([Skeleton interface for Bison GLR parsers in C++],
[2002-2006, 2009-2011])[ [2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009])[
/* C++ GLR parser skeleton written by Akim Demaille. */ /* C++ GLR parser skeleton written by Akim Demaille. */
@@ -231,15 +226,20 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
#include <string> #include <string>
#include <iostream> #include <iostream>
]b4_percent_define_ifdef([[location_type]], [],
[[#include "location.hh"]])[
/* Using locations. */ /* Using locations. */
#define YYLSP_NEEDED ]b4_locations_flag[ #define YYLSP_NEEDED ]b4_locations_if([1], [0])[
]b4_namespace_open[
class position;
class location;
]b4_namespace_close[
#include "location.hh"
/* Enabling traces. */ /* Enabling traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
# define YYDEBUG ]b4_debug_flag[ # define YYDEBUG ]b4_parse_trace_if([1], [0])[
#endif #endif
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
@@ -266,29 +266,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
class ]b4_parser_class_name[ class ]b4_parser_class_name[
{ {
public: public:
/// Symbol semantic values. ]b4_public_types_declare[
#ifndef YYSTYPE
]m4_ifdef([b4_stype],
[ union semantic_type
{
b4_user_stype
};],
[m4_if(b4_tag_seen_flag, 0,
[[ typedef int semantic_type;]],
[[ typedef YYSTYPE semantic_type;]])])[
#else
typedef YYSTYPE semantic_type;
#endif
/// Symbol locations.
typedef ]b4_percent_define_get([[location_type]],
[[location]])[ location_type;
/// Tokens.
struct token
{
]b4_token_enums(b4_tokens)[
};
/// Token type.
typedef token::yytokentype token_type;
/// Build a parser object. /// Build a parser object.
]b4_parser_class_name[ (]b4_parse_param_decl[); ]b4_parser_class_name[ (]b4_parse_param_decl[);
@@ -310,14 +288,11 @@ b4_user_stype
/// Set the current debugging level. /// Set the current debugging level.
void set_debug_level (debug_level_type l); void set_debug_level (debug_level_type l);
private:
public: public:
/// Report a syntax error. /// Report a syntax error.
/// \param loc where the syntax error is found. /// \param loc where the syntax error is found.
/// \param msg a description of the syntax error. /// \param msg a description of the syntax error.
virtual void error (const location_type& loc, const std::string& msg); virtual void error (const location_type& loc, const std::string& msg);
private:
#if YYDEBUG #if YYDEBUG
public: public:
@@ -337,11 +312,9 @@ b4_user_stype
const location_type* yylocationp); const location_type* yylocationp);
private: private:
/* Debugging. */ /* Debugging. */
int yydebug_;
std::ostream* yycdebug_; std::ostream* yycdebug_;
#endif #endif
/// \brief Reclaim the memory associated to a symbol. /// \brief Reclaim the memory associated to a symbol.
/// \param yymsg Why this token is reclaimed. /// \param yymsg Why this token is reclaimed.
/// \param yytype The symbol type. /// \param yytype The symbol type.
+1 -2
View File
@@ -1,8 +1,7 @@
-*- Autoconf -*- -*- Autoconf -*-
# Java skeleton dispatching for Bison. # Java skeleton dispatching for Bison.
# Copyright (C) 2007, 2009 Free Software Foundation, Inc.
# Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
+59 -35
View File
@@ -2,7 +2,7 @@
# Java language support for Bison # Java language support for Bison
# Copyright (C) 2007-2011 Free Software Foundation, Inc. # Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@ m4_define([b4_comment], [/* m4_bpatsubst([$1], [
# -------------------------- # --------------------------
# Join two lists with a comma if necessary. # Join two lists with a comma if necessary.
m4_define([b4_list2], m4_define([b4_list2],
[$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2]) [$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2])
# b4_percent_define_get3(DEF, PRE, POST, NOT) # b4_percent_define_get3(DEF, PRE, POST, NOT)
@@ -37,8 +37,8 @@ m4_define([b4_list2],
# Expand to the value of DEF surrounded by PRE and POST if it's %define'ed, # Expand to the value of DEF surrounded by PRE and POST if it's %define'ed,
# otherwise NOT. # otherwise NOT.
m4_define([b4_percent_define_get3], m4_define([b4_percent_define_get3],
[m4_ifval(m4_quote(b4_percent_define_get([$1])), [m4_ifval(m4_quote(b4_percent_define_get([$1])),
[$2[]b4_percent_define_get([$1])[]$3], [$4])]) [$2[]b4_percent_define_get([$1])[]$3], [$4])])
@@ -103,7 +103,7 @@ m4_define([b4_identification],
m4_define([b4_int_type], m4_define([b4_int_type],
[m4_if(b4_ints_in($@, [-128], [127]), [1], [byte], [m4_if(b4_ints_in($@, [-128], [127]), [1], [byte],
b4_ints_in($@, [-32768], [32767]), [1], [short], b4_ints_in($@, [-32768], [32767]), [1], [short],
[int])]) [int])])
# b4_int_type_for(NAME) # b4_int_type_for(NAME)
# --------------------- # ---------------------
@@ -117,6 +117,27 @@ m4_define([b4_int_type_for],
m4_define([b4_null], [null]) m4_define([b4_null], [null])
# b4_typed_parser_table_define(TYPE, NAME, DATA, COMMENT)
# -------------------------------------------------------
m4_define([b4_typed_parser_table_define],
[m4_ifval([$4], [b4_comment([$4])
])dnl
[private static final ]$1[ yy$2_[] = yy$2_init();
private static final ]$1[[] yy$2_init()
{
return new ]$1[[]
{
]$3[
};
}]])
# b4_integral_parser_table_define(NAME, DATA, COMMENT)
#-----------------------------------------------------
m4_define([b4_integral_parser_table_define],
[b4_typed_parser_table_define([b4_int_type_for([$2])], [$1], [$2], [$3])])
## ------------------------- ## ## ------------------------- ##
## Assigning token numbers. ## ## Assigning token numbers. ##
## ------------------------- ## ## ------------------------- ##
@@ -125,8 +146,8 @@ m4_define([b4_null], [null])
# --------------------------------------- # ---------------------------------------
# Output the definition of this token as an enum. # Output the definition of this token as an enum.
m4_define([b4_token_enum], m4_define([b4_token_enum],
[ /** Token number, to be returned by the scanner. */ [ /** Token number, to be returned by the scanner. */
public static final int $1 = $2; static final int b4_percent_define_get([api.tokens.prefix])$1 = $2;
]) ])
@@ -154,24 +175,27 @@ m4_define([b4_case], [ case $1:
## ---------------- ## ## ---------------- ##
m4_define([b4_yystype], [b4_percent_define_get([[stype]])]) m4_define([b4_yystype], [b4_percent_define_get([[stype]])])
b4_percent_define_default([[stype]], [[Object]])]) b4_percent_define_default([[stype]], [[Object]])
# %name-prefix # %name-prefix
m4_define_default([b4_prefix], [[YY]]) m4_define_default([b4_prefix], [[YY]])
b4_percent_define_default([[parser_class_name]], [b4_prefix[]Parser])]) b4_percent_define_default([[parser_class_name]], [b4_prefix[]Parser])
m4_define([b4_parser_class_name], [b4_percent_define_get([[parser_class_name]])]) m4_define([b4_parser_class_name], [b4_percent_define_get([[parser_class_name]])])
b4_percent_define_default([[lex_throws]], [[java.io.IOException]])]) b4_percent_define_default([[lex_throws]], [[java.io.IOException]])
m4_define([b4_lex_throws], [b4_percent_define_get([[lex_throws]])]) m4_define([b4_lex_throws], [b4_percent_define_get([[lex_throws]])])
b4_percent_define_default([[throws]], [])]) b4_percent_define_default([[throws]], [])
m4_define([b4_throws], [b4_percent_define_get([[throws]])]) m4_define([b4_throws], [b4_percent_define_get([[throws]])])
b4_percent_define_default([[location_type]], [Location])]) b4_percent_define_default([[init_throws]], [])
m4_define([b4_init_throws], [b4_percent_define_get([[init_throws]])])
b4_percent_define_default([[location_type]], [Location])
m4_define([b4_location_type], [b4_percent_define_get([[location_type]])]) m4_define([b4_location_type], [b4_percent_define_get([[location_type]])])
b4_percent_define_default([[position_type]], [Position])]) b4_percent_define_default([[position_type]], [Position])
m4_define([b4_position_type], [b4_percent_define_get([[position_type]])]) m4_define([b4_position_type], [b4_percent_define_get([[position_type]])])
@@ -218,21 +242,21 @@ m4_define([b4_rhs_location],
# it to be single quoted. Same for b4_parse_param. # it to be single quoted. Same for b4_parse_param.
# TODO: should be in bison.m4 # TODO: should be in bison.m4
m4_define_default([b4_lex_param], [[]])) m4_define_default([b4_lex_param], [[]])
m4_define([b4_lex_param], b4_lex_param)) m4_define([b4_lex_param], b4_lex_param)
m4_define([b4_parse_param], b4_parse_param)) m4_define([b4_parse_param], b4_parse_param)
# b4_lex_param_decl # b4_lex_param_decl
# ------------------- # -----------------
# Extra formal arguments of the constructor. # Extra formal arguments of the constructor.
m4_define([b4_lex_param_decl], m4_define([b4_lex_param_decl],
[m4_ifset([b4_lex_param], [m4_ifset([b4_lex_param],
[b4_remove_comma([$1], [b4_remove_comma([$1],
b4_param_decls(b4_lex_param))], b4_param_decls(b4_lex_param))],
[$1])]) [$1])])
m4_define([b4_param_decls], m4_define([b4_param_decls],
[m4_map([b4_param_decl], [$@])]) [m4_map([b4_param_decl], [$@])])
m4_define([b4_param_decl], [, $1]) m4_define([b4_param_decl], [, $1])
m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)]) m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)])
@@ -245,21 +269,21 @@ m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)])
m4_define([b4_parse_param_decl], m4_define([b4_parse_param_decl],
[m4_ifset([b4_parse_param], [m4_ifset([b4_parse_param],
[b4_remove_comma([$1], [b4_remove_comma([$1],
b4_param_decls(b4_parse_param))], b4_param_decls(b4_parse_param))],
[$1])]) [$1])])
# b4_lex_param_call # b4_lex_param_call
# ------------------- # -----------------
# Delegating the lexer parameters to the lexer constructor. # Delegating the lexer parameters to the lexer constructor.
m4_define([b4_lex_param_call], m4_define([b4_lex_param_call],
[m4_ifset([b4_lex_param], [m4_ifset([b4_lex_param],
[b4_remove_comma([$1], [b4_remove_comma([$1],
b4_param_calls(b4_lex_param))], b4_param_calls(b4_lex_param))],
[$1])]) [$1])])
m4_define([b4_param_calls], m4_define([b4_param_calls],
[m4_map([b4_param_call], [$@])]) [m4_map([b4_param_call], [$@])])
m4_define([b4_param_call], [, $2]) m4_define([b4_param_call], [, $2])
@@ -269,13 +293,13 @@ m4_define([b4_param_call], [, $2])
# Extra initialisations of the constructor. # Extra initialisations of the constructor.
m4_define([b4_parse_param_cons], m4_define([b4_parse_param_cons],
[m4_ifset([b4_parse_param], [m4_ifset([b4_parse_param],
[b4_constructor_calls(b4_parse_param)])]) [b4_constructor_calls(b4_parse_param)])])
m4_define([b4_constructor_calls], m4_define([b4_constructor_calls],
[m4_map([b4_constructor_call], [$@])]) [m4_map([b4_constructor_call], [$@])])
m4_define([b4_constructor_call], m4_define([b4_constructor_call],
[this.$2 = $2; [this.$2 = $2;
]) ])
@@ -284,15 +308,15 @@ m4_define([b4_constructor_call],
# Extra instance variables. # Extra instance variables.
m4_define([b4_parse_param_vars], m4_define([b4_parse_param_vars],
[m4_ifset([b4_parse_param], [m4_ifset([b4_parse_param],
[ [
/* User arguments. */ /* User arguments. */
b4_var_decls(b4_parse_param)])]) b4_var_decls(b4_parse_param)])])
m4_define([b4_var_decls], m4_define([b4_var_decls],
[m4_map_sep([b4_var_decl], [ [m4_map_sep([b4_var_decl], [
], [$@])]) ], [$@])])
m4_define([b4_var_decl], m4_define([b4_var_decl],
[ protected final $1;]) [ protected final $1;])
@@ -300,4 +324,4 @@ m4_define([b4_var_decl],
# ----------------------- # -----------------------
# Expand to either an empty string or "throws THROWS". # Expand to either an empty string or "throws THROWS".
m4_define([b4_maybe_throws], m4_define([b4_maybe_throws],
[m4_ifval($1, [throws $1])]) [m4_ifval($1, [throws $1])])
+554 -714
View File
File diff suppressed because it is too large Load Diff
+210 -288
View File
@@ -1,6 +1,6 @@
# Java skeleton for Bison -*- autoconf -*- # Java skeleton for Bison -*- autoconf -*-
# Copyright (C) 2007-2011 Free Software Foundation, Inc. # Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -17,26 +17,36 @@
m4_include(b4_pkgdatadir/[java.m4]) m4_include(b4_pkgdatadir/[java.m4])
b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java], [b4_skeleton])]) b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java],
m4_ifval(m4_defn([b4_symbol_destructors]), [b4_skeleton])])
[b4_fatal([%s: %%destructor does not make sense in Java], [b4_skeleton])],
[]) # We don't depend on %debug in Java, but pacify warnings about non-used flags.
b4_parse_trace_if([0], [0])
m4_define([b4_symbol_no_destructor_assert],
[b4_symbol_if([$1], [has_destructor],
[b4_fatal([%s: %s: %%destructor does not make sense in Java],
[b4_skeleton],
[b4_symbol_action_location([$1], [destructor])])])])
b4_symbol_foreach([b4_symbol_no_destructor_assert])
m4_divert_push(0)dnl m4_divert_push(0)dnl
@output(b4_parser_file_name@)@ @output(b4_parser_file_name@)@
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java], b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
[2007-2011]) [2007, 2008, 2009])
b4_percent_define_ifdef([package], [package b4_percent_define_get([package]); b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);
])[/* First part of user declarations. */ ])[/* First part of user declarations. */
]b4_pre_prologue ]b4_user_pre_prologue
b4_user_post_prologue
b4_percent_code_get([[imports]]) b4_percent_code_get([[imports]])
[/** [/**
* A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>. * A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.
* *
* @@author LALR (1) parser skeleton written by Paolo Bonzini. * @@author LALR (1) parser skeleton written by Paolo Bonzini.
*/ */
]b4_public_if([public ])dnl ]b4_percent_define_get3([annotations], [], [ ])dnl
b4_public_if([public ])dnl
b4_abstract_if([abstract ])dnl b4_abstract_if([abstract ])dnl
b4_final_if([final ])dnl b4_final_if([final ])dnl
b4_strictfp_if([strictfp ])dnl b4_strictfp_if([strictfp ])dnl
@@ -45,9 +55,22 @@ b4_percent_define_get3([extends], [ extends ])dnl
b4_percent_define_get3([implements], [ implements ])[ b4_percent_define_get3([implements], [ implements ])[
{ {
]b4_identification[ ]b4_identification[
]b4_error_verbose_if([[
/** True if verbose error messages are enabled. */ /** True if verbose error messages are enabled. */
public boolean errorVerbose = ]b4_flag_value([error_verbose]); private boolean yyErrorVerbose = true;
/**
* Return whether verbose error messages are enabled.
*/
public final boolean getErrorVerbose() { return yyErrorVerbose; }
/**
* Set the verbosity of error messages.
* @@param verbose True to request verbose error messages.
*/
public final void setErrorVerbose(boolean verbose)
{ yyErrorVerbose = verbose; }
]])
b4_locations_if([[ b4_locations_if([[
/** /**
@@ -93,16 +116,11 @@ b4_locations_if([[
]]) ]])
[ /** Token returned by the scanner to signal the end of its input. */
public static final int EOF = 0;]
b4_token_enums(b4_tokens)
b4_locations_if([[ b4_locations_if([[
private ]b4_location_type[ yylloc (YYStack rhs, int n) private ]b4_location_type[ yylloc (YYStack rhs, int n)
{ {
if (n > 0) if (n > 0)
return new ]b4_location_type[ (rhs.locationAt (n-1).begin, rhs.locationAt (0).end); return new ]b4_location_type[ (rhs.locationAt (1).begin, rhs.locationAt (n).end);
else else
return new ]b4_location_type[ (rhs.locationAt (0).end); return new ]b4_location_type[ (rhs.locationAt (0).end);
}]])[ }]])[
@@ -112,6 +130,11 @@ b4_token_enums(b4_tokens)
* parser <tt>]b4_parser_class_name[</tt>. * parser <tt>]b4_parser_class_name[</tt>.
*/ */
public interface Lexer { public interface Lexer {
/** Token returned by the scanner to signal the end of its input. */
public static final int EOF = 0;
]b4_token_enums(b4_tokens)[
]b4_locations_if([[/** ]b4_locations_if([[/**
* Method to retrieve the beginning position of the last scanned token. * Method to retrieve the beginning position of the last scanned token.
* @@return the position at which the last scanned token starts. */ * @@return the position at which the last scanned token starts. */
@@ -140,8 +163,8 @@ b4_token_enums(b4_tokens)
* *
* ]b4_locations_if([[@@param loc The location of the element to which the * ]b4_locations_if([[@@param loc The location of the element to which the
* error message is related]])[ * error message is related]])[
* @@param s The string for the error message. */ * @@param msg The string for the error message. */
void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String s);] void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String msg);]
} }
b4_lexer_if([[private class YYLexer implements Lexer { b4_lexer_if([[private class YYLexer implements Lexer {
@@ -157,7 +180,9 @@ b4_lexer_if([[
/** /**
* Instantiates the Bison-generated parser. * Instantiates the Bison-generated parser.
*/ */
public ]b4_parser_class_name (b4_parse_param_decl([b4_lex_param_decl])[) { public ]b4_parser_class_name (b4_parse_param_decl([b4_lex_param_decl])[) ]b4_maybe_throws([b4_init_throws])[
{
]b4_percent_code_get([[init]])[
this.yylexer = new YYLexer(]b4_lex_param_call[); this.yylexer = new YYLexer(]b4_lex_param_call[);
]b4_parse_param_cons[ ]b4_parse_param_cons[
} }
@@ -167,7 +192,9 @@ b4_lexer_if([[
* Instantiates the Bison-generated parser. * Instantiates the Bison-generated parser.
* @@param yylexer The scanner that will supply tokens to the parser. * @@param yylexer The scanner that will supply tokens to the parser.
*/ */
b4_lexer_if([[protected]], [[public]]) b4_parser_class_name[ (]b4_parse_param_decl([[Lexer yylexer]])[) { b4_lexer_if([[protected]], [[public]]) b4_parser_class_name[ (]b4_parse_param_decl([[Lexer yylexer]])[) ]b4_maybe_throws([b4_init_throws])[
{
]b4_percent_code_get([[init]])[
this.yylexer = yylexer; this.yylexer = yylexer;
]b4_parse_param_cons[ ]b4_parse_param_cons[
} }
@@ -201,20 +228,35 @@ b4_lexer_if([[
*/ */
public final void setDebugLevel(int level) { yydebug = level; } public final void setDebugLevel(int level) { yydebug = level; }
private final int yylex () ]b4_maybe_throws([b4_lex_throws]) [{ /**
return yylexer.yylex (); * Print an error message via the lexer.
*]b4_locations_if([[ Use a <code>null</code> location.]])[
* @@param msg The error message.
*/
public final void yyerror (String msg)
{
yylexer.yyerror (]b4_locations_if([[(]b4_location_type[)null, ]])[msg);
} }
protected final void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String s) { ]b4_locations_if([[
yylexer.yyerror (]b4_locations_if([loc, ])[s); /**
* Print an error message via the lexer.
* @@param loc The location associated with the message.
* @@param msg The error message.
*/
public final void yyerror (]b4_location_type[ loc, String msg)
{
yylexer.yyerror (loc, msg);
} }
]b4_locations_if([ /**
protected final void yyerror (String s) { * Print an error message via the lexer.
yylexer.yyerror ((]b4_location_type[)null, s); * @@param pos The position associated with the message.
} * @@param msg The error message.
protected final void yyerror (]b4_position_type[ loc, String s) { */
yylexer.yyerror (new ]b4_location_type[ (loc), s); public final void yyerror (]b4_position_type[ pos, String msg)
}]) {
yylexer.yyerror (new ]b4_location_type[ (pos), msg);
}]])
[protected final void yycdebug (String s) { [protected final void yycdebug (String s) {
if (yydebug > 0) if (yydebug > 0)
@@ -230,24 +272,24 @@ b4_lexer_if([[
public int height = -1; public int height = -1;
public final void push (int state, ]b4_yystype[ value]dnl public final void push (int state, ]b4_yystype[ value]dnl
b4_locations_if([, ]b4_location_type[ loc])[) { b4_locations_if([, ]b4_location_type[ loc])[) {
height++; height++;
if (size == height) if (size == height)
{ {
int[] newStateStack = new int[size * 2]; int[] newStateStack = new int[size * 2];
System.arraycopy (stateStack, 0, newStateStack, 0, height); System.arraycopy (stateStack, 0, newStateStack, 0, height);
stateStack = newStateStack; stateStack = newStateStack;
]b4_locations_if([[ ]b4_locations_if([[
]b4_location_type[[] newLocStack = new ]b4_location_type[[size * 2]; ]b4_location_type[[] newLocStack = new ]b4_location_type[[size * 2];
System.arraycopy (locStack, 0, newLocStack, 0, height); System.arraycopy (locStack, 0, newLocStack, 0, height);
locStack = newLocStack;]]) locStack = newLocStack;]])
b4_yystype[[] newValueStack = new ]b4_yystype[[size * 2]; b4_yystype[[] newValueStack = new ]b4_yystype[[size * 2];
System.arraycopy (valueStack, 0, newValueStack, 0, height); System.arraycopy (valueStack, 0, newValueStack, 0, height);
valueStack = newValueStack; valueStack = newValueStack;
size *= 2; size *= 2;
} }
stateStack[height] = state; stateStack[height] = state;
]b4_locations_if([[locStack[height] = loc;]])[ ]b4_locations_if([[locStack[height] = loc;]])[
@@ -255,14 +297,14 @@ b4_lexer_if([[
} }
public final void pop () { public final void pop () {
pop (1); height--;
} }
public final void pop (int num) { public final void pop (int num) {
// Avoid memory leaks... garbage collection is a white lie! // Avoid memory leaks... garbage collection is a white lie!
if (num > 0) { if (num > 0) {
java.util.Arrays.fill (valueStack, height - num + 1, height + 1, null); java.util.Arrays.fill (valueStack, height - num + 1, height, null);
]b4_locations_if([[java.util.Arrays.fill (locStack, height - num + 1, height + 1, null);]])[ ]b4_locations_if([[java.util.Arrays.fill (locStack, height - num + 1, height, null);]])[
} }
height -= num; height -= num;
} }
@@ -284,10 +326,10 @@ b4_lexer_if([[
{ {
out.print ("Stack now"); out.print ("Stack now");
for (int i = 0; i <= height; i++) for (int i = 0; i < height; i++)
{ {
out.print (' '); out.print (' ');
out.print (stateStack[i]); out.print (stateStack[i]);
} }
out.println (); out.println ();
} }
@@ -308,9 +350,11 @@ b4_lexer_if([[
* printing an error message. */ * printing an error message. */
public static final int YYERROR = 2; public static final int YYERROR = 2;
// Internal return codes that are not supported for user semantic /**
// actions. * Returned by a Bison action in order to print an error message and start
private static final int YYERRLAB = 3; * error recovery. */
public static final int YYFAIL = 3;
private static final int YYNEWSTATE = 4; private static final int YYNEWSTATE = 4;
private static final int YYDEFAULT = 5; private static final int YYDEFAULT = 5;
private static final int YYREDUCE = 6; private static final int YYREDUCE = 6;
@@ -348,8 +392,8 @@ b4_lexer_if([[
switch (yyn) switch (yyn)
{ {
]b4_user_actions[ ]b4_user_actions[
default: break; default: break;
} }
yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[); yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);
@@ -361,7 +405,7 @@ b4_lexer_if([[
yyn = yyr1_[yyn]; yyn = yyr1_[yyn];
int yystate = yypgoto_[yyn - yyntokens_] + yystack.stateAt (0); int yystate = yypgoto_[yyn - yyntokens_] + yystack.stateAt (0);
if (0 <= yystate && yystate <= yylast_ if (0 <= yystate && yystate <= yylast_
&& yycheck_[yystate] == yystack.stateAt (0)) && yycheck_[yystate] == yystack.stateAt (0))
yystate = yytable_[yystate]; yystate = yytable_[yystate];
else else
yystate = yydefgoto_[yyn - yyntokens_]; yystate = yydefgoto_[yyn - yyntokens_];
@@ -370,6 +414,7 @@ b4_lexer_if([[
return YYNEWSTATE; return YYNEWSTATE;
} }
]b4_error_verbose_if([[
/* Return YYSTR after stripping away unnecessary quotes and /* Return YYSTR after stripping away unnecessary quotes and
backslashes, so that it's suitable for yyerror. The heuristic is backslashes, so that it's suitable for yyerror. The heuristic is
that double-quoting is unnecessary unless the string contains an that double-quoting is unnecessary unless the string contains an
@@ -388,7 +433,7 @@ b4_lexer_if([[
break strip_quotes; break strip_quotes;
case '\\': case '\\':
if (yystr.charAt(++i) != '\\') if (yystr.charAt(++i) != '\\')
break strip_quotes; break strip_quotes;
/* Fall through. */ /* Fall through. */
default: default:
@@ -404,20 +449,21 @@ b4_lexer_if([[
return yystr; return yystr;
} }
]])[
/*--------------------------------. /*--------------------------------.
| Print this symbol on YYOUTPUT. | | Print this symbol on YYOUTPUT. |
`--------------------------------*/ `--------------------------------*/
private void yy_symbol_print (String s, int yytype, private void yy_symbol_print (String s, int yytype,
]b4_yystype[ yyvaluep]dnl ]b4_yystype[ yyvaluep]dnl
b4_locations_if([, Object yylocationp])[) b4_locations_if([, Object yylocationp])[)
{ {
if (yydebug > 0) if (yydebug > 0)
yycdebug (s + (yytype < yyntokens_ ? " token " : " nterm ") yycdebug (s + (yytype < yyntokens_ ? " token " : " nterm ")
+ yytname_[yytype] + " ("]b4_locations_if([ + yytname_[yytype] + " ("]b4_locations_if([
+ yylocationp + ": "])[ + yylocationp + ": "])[
+ (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")"); + (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")");
} }
/** /**
@@ -475,7 +521,7 @@ m4_popdef([b4_at_dollar])])dnl
switch (label) switch (label)
{ {
/* New state. Unlike in the C/C++ skeletons, the state is already /* New state. Unlike in the C/C++ skeletons, the state is already
pushed when we come here. */ pushed when we come here. */
case YYNEWSTATE: case YYNEWSTATE:
yycdebug ("Entering state " + yystate + "\n"); yycdebug ("Entering state " + yystate + "\n");
if (yydebug > 0) if (yydebug > 0)
@@ -490,31 +536,31 @@ m4_popdef([b4_at_dollar])])dnl
if (yy_pact_value_is_default_ (yyn)) if (yy_pact_value_is_default_ (yyn))
{ {
label = YYDEFAULT; label = YYDEFAULT;
break; break;
} }
/* Read a lookahead token. */ /* Read a lookahead token. */
if (yychar == yyempty_) if (yychar == yyempty_)
{ {
yycdebug ("Reading a token: "); yycdebug ("Reading a token: ");
yychar = yylex ();] yychar = yylexer.yylex ();]
b4_locations_if([[ b4_locations_if([[
yylloc = new ]b4_location_type[(yylexer.getStartPos (), yylloc = new ]b4_location_type[(yylexer.getStartPos (),
yylexer.getEndPos ());]]) yylexer.getEndPos ());]])
yylval = yylexer.getLVal ();[ yylval = yylexer.getLVal ();[
} }
/* Convert token to internal form. */ /* Convert token to internal form. */
if (yychar <= EOF) if (yychar <= Lexer.EOF)
{ {
yychar = yytoken = EOF; yychar = yytoken = Lexer.EOF;
yycdebug ("Now at end of input.\n"); yycdebug ("Now at end of input.\n");
} }
else else
{ {
yytoken = yytranslate_ (yychar); yytoken = yytranslate_ (yychar);
yy_symbol_print ("Next token is", yytoken, yy_symbol_print ("Next token is", yytoken,
yylval]b4_locations_if([, yylloc])[); yylval]b4_locations_if([, yylloc])[);
} }
/* If the proper action on seeing token YYTOKEN is to reduce or to /* If the proper action on seeing token YYTOKEN is to reduce or to
@@ -526,20 +572,20 @@ m4_popdef([b4_at_dollar])])dnl
/* <= 0 means reduce or error. */ /* <= 0 means reduce or error. */
else if ((yyn = yytable_[yyn]) <= 0) else if ((yyn = yytable_[yyn]) <= 0)
{ {
if (yy_table_value_is_error_ (yyn)) if (yy_table_value_is_error_ (yyn))
label = YYERRLAB; label = YYFAIL;
else else
{ {
yyn = -yyn; yyn = -yyn;
label = YYREDUCE; label = YYREDUCE;
} }
} }
else else
{ {
/* Shift the lookahead token. */ /* Shift the lookahead token. */
yy_symbol_print ("Shifting", yytoken, yy_symbol_print ("Shifting", yytoken,
yylval]b4_locations_if([, yylloc])[); yylval]b4_locations_if([, yylloc])[);
/* Discard the token being shifted. */ /* Discard the token being shifted. */
yychar = yyempty_; yychar = yyempty_;
@@ -561,7 +607,7 @@ m4_popdef([b4_at_dollar])])dnl
case YYDEFAULT: case YYDEFAULT:
yyn = yydefact_[yystate]; yyn = yydefact_[yystate];
if (yyn == 0) if (yyn == 0)
label = YYERRLAB; label = YYFAIL;
else else
label = YYREDUCE; label = YYREDUCE;
break; break;
@@ -572,36 +618,34 @@ m4_popdef([b4_at_dollar])])dnl
case YYREDUCE: case YYREDUCE:
yylen = yyr2_[yyn]; yylen = yyr2_[yyn];
label = yyaction (yyn, yystack, yylen); label = yyaction (yyn, yystack, yylen);
yystate = yystack.stateAt (0); yystate = yystack.stateAt (0);
break; break;
/*------------------------------------. /*------------------------------------.
| yyerrlab -- here on detecting error | | yyerrlab -- here on detecting error |
`------------------------------------*/ `------------------------------------*/
case YYERRLAB: case YYFAIL:
/* If not already recovering from an error, report this error. */ /* If not already recovering from an error, report this error. */
if (yyerrstatus_ == 0) if (yyerrstatus_ == 0)
{ {
++yynerrs_; ++yynerrs_;
if (yychar == yyempty_)
yytoken = yyempty_;
yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken)); yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken));
} }
]b4_locations_if([yyerrloc = yylloc;])[ ]b4_locations_if([yyerrloc = yylloc;])[
if (yyerrstatus_ == 3) if (yyerrstatus_ == 3)
{ {
/* If just tried and failed to reuse lookahead token after an /* If just tried and failed to reuse lookahead token after an
error, discard it. */ error, discard it. */
if (yychar <= EOF) if (yychar <= Lexer.EOF)
{ {
/* Return failure if at end of input. */ /* Return failure if at end of input. */
if (yychar == EOF) if (yychar == Lexer.EOF)
return false; return false;
} }
else else
yychar = yyempty_; yychar = yyempty_;
} }
/* Else will try to reuse lookahead token after shifting the error /* Else will try to reuse lookahead token after shifting the error
@@ -627,46 +671,46 @@ m4_popdef([b4_at_dollar])])dnl
| yyerrlab1 -- common code for both syntax error and YYERROR. | | yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/ `-------------------------------------------------------------*/
case YYERRLAB1: case YYERRLAB1:
yyerrstatus_ = 3; /* Each real token shifted decrements this. */ yyerrstatus_ = 3; /* Each real token shifted decrements this. */
for (;;) for (;;)
{ {
yyn = yypact_[yystate]; yyn = yypact_[yystate];
if (!yy_pact_value_is_default_ (yyn)) if (!yy_pact_value_is_default_ (yyn))
{ {
yyn += yyterror_; yyn += yyterror_;
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
{ {
yyn = yytable_[yyn]; yyn = yytable_[yyn];
if (0 < yyn) if (0 < yyn)
break; break;
} }
} }
/* Pop the current state because it cannot handle the error token. */ /* Pop the current state because it cannot handle the error token. */
if (yystack.height == 1) if (yystack.height == 1)
return false; return false;
]b4_locations_if([yyerrloc = yystack.locationAt (0);])[ ]b4_locations_if([yyerrloc = yystack.locationAt (0);])[
yystack.pop (); yystack.pop ();
yystate = yystack.stateAt (0); yystate = yystack.stateAt (0);
if (yydebug > 0) if (yydebug > 0)
yystack.print (yyDebugStream); yystack.print (yyDebugStream);
} }
]b4_locations_if([ ]b4_locations_if([
/* Muck with the stack to setup for yylloc. */ /* Muck with the stack to setup for yylloc. */
yystack.push (0, null, yylloc); yystack.push (0, null, yylloc);
yystack.push (0, null, yyerrloc); yystack.push (0, null, yyerrloc);
yyloc = yylloc (yystack, 2); yyloc = yylloc (yystack, 2);
yystack.pop (2);])[ yystack.pop (2);])[
/* Shift the error token. */ /* Shift the error token. */
yy_symbol_print ("Shifting", yystos_[yyn], yy_symbol_print ("Shifting", yystos_[yyn],
yylval]b4_locations_if([, yyloc])[); yylval]b4_locations_if([, yyloc])[);
yystate = yyn; yystate = yyn;
yystack.push (yyn, yylval]b4_locations_if([, yyloc])[); yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
label = YYNEWSTATE; label = YYNEWSTATE;
break; break;
@@ -682,79 +726,47 @@ m4_popdef([b4_at_dollar])])dnl
// Generate an error message. // Generate an error message.
private String yysyntax_error (int yystate, int tok) private String yysyntax_error (int yystate, int tok)
{ {]b4_error_verbose_if([[
if (errorVerbose) if (yyErrorVerbose)
{ {
/* There are many possibilities here to consider: int yyn = yypact_[yystate];
- Assume YYFAIL is not used. It's too flawed to consider. if (yypact_ninf_ < yyn && yyn <= yylast_)
See
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
for details. YYERROR is fine as it does not invoke this
function.
- If this state is a consistent state with a default action,
then the only way this function was invoked is if the
default action is an error action. In that case, don't
check for expected tokens because there are none.
- The only way there can be no lookahead present (in tok) is
if this state is a consistent state with a default action.
Thus, detecting the absence of a lookahead is sufficient to
determine that there is no unexpected or expected token to
report. In that case, just report a simple "syntax error".
- Don't assume there isn't a lookahead just because this
state is a consistent state with a default action. There
might have been a previous inconsistent state, consistent
state with a non-default action, or user semantic action
that manipulated yychar. (However, yychar is currently out
of scope during semantic actions.)
- Of course, the expected token list depends on states to
have correct lookahead information, and it depends on the
parser not to perform extra reductions after fetching a
lookahead from the scanner and before detecting a syntax
error. Thus, state merging (from LALR or IELR) and default
reductions corrupt the expected token list. However, the
list is correct for canonical LR with one exception: it
will still contain any token that will not be accepted due
to an error action in a later state.
*/
if (tok != yyempty_)
{ {
StringBuffer res;
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for this
state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = yylast_ - yyn + 1;
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
int count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
++count;
// FIXME: This method of building the message is not compatible // FIXME: This method of building the message is not compatible
// with internationalization. // with internationalization.
StringBuffer res = res = new StringBuffer ("syntax error, unexpected ");
new StringBuffer ("syntax error, unexpected ");
res.append (yytnamerr_ (yytname_[tok])); res.append (yytnamerr_ (yytname_[tok]));
int yyn = yypact_[yystate]; if (count < 5)
if (!yy_pact_value_is_default_ (yyn))
{ {
/* Start YYX at -YYN if negative to avoid negative count = 0;
indexes in YYCHECK. In other words, skip the first
-YYN actions for this state because they are default
actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = yylast_ - yyn + 1;
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
int count = 0;
for (int x = yyxbegin; x < yyxend; ++x) for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_ if (yycheck_[x + yyn] == x && x != yyterror_
&& !yy_table_value_is_error_ (yytable_[x + yyn])) && !yy_table_value_is_error_ (yytable_[x + yyn]))
++count; {
if (count < 5) res.append (count++ == 0 ? ", expecting " : " or ");
{ res.append (yytnamerr_ (yytname_[x]));
count = 0; }
for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
{
res.append (count++ == 0 ? ", expecting " : " or ");
res.append (yytnamerr_ (yytname_[x]));
}
}
} }
return res.toString (); return res.toString ();
} }
} }
]])[
return "syntax error"; return "syntax error";
} }
@@ -776,107 +788,20 @@ m4_popdef([b4_at_dollar])])dnl
return yyvalue == yytable_ninf_; return yyvalue == yytable_ninf_;
} }
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
private static final ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[; private static final ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[;
private static final ]b4_int_type_for([b4_pact])[ yypact_[] =
{
]b4_pact[
};
/* YYDEFACT[S] -- default reduction number in state S. Performed when
YYTABLE doesn't specify something else to do. Zero means the
default is an error. */
private static final ]b4_int_type_for([b4_defact])[ yydefact_[] =
{
]b4_defact[
};
/* YYPGOTO[NTERM-NUM]. */
private static final ]b4_int_type_for([b4_pgoto])[ yypgoto_[] =
{
]b4_pgoto[
};
/* YYDEFGOTO[NTERM-NUM]. */
private static final ]b4_int_type_for([b4_defgoto])[
yydefgoto_[] =
{
]b4_defgoto[
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If YYTABLE_NINF_, syntax error. */
private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[; private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[;
private static final ]b4_int_type_for([b4_table])[
yytable_[] =
{
]b4_table[
};
/* YYCHECK. */ ]b4_parser_tables_define[
private static final ]b4_int_type_for([b4_check])[ ]b4_integral_parser_table_define([token_number], [b4_toknum],
yycheck_[] = [TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
{ to YYLEX-NUM.])[
]b4_check[
};
/* STOS_[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
private static final ]b4_int_type_for([b4_stos])[
yystos_[] =
{
]b4_stos[
};
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
to YYLEX-NUM. */
private static final ]b4_int_type_for([b4_toknum])[
yytoken_number_[] =
{
]b4_toknum[
};
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
private static final ]b4_int_type_for([b4_r1])[
yyr1_[] =
{
]b4_r1[
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
private static final ]b4_int_type_for([b4_r2])[
yyr2_[] =
{
]b4_r2[
};
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at \a yyntokens_, nonterminals. */ First, the terminals, then, starting at \a yyntokens_, nonterminals. */
private static final String yytname_[] = ]b4_typed_parser_table_define([String], [tname], [b4_tname])[
{
]b4_tname[
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */ ]b4_integral_parser_table_define([rline], [b4_rline],
private static final ]b4_int_type_for([b4_rhs])[ yyrhs_[] = [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[
{
]b4_rhs[
};
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
YYRHS. */
private static final ]b4_int_type_for([b4_prhs])[ yyprhs_[] =
{
]b4_prhs[
};
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
private static final ]b4_int_type_for([b4_rline])[ yyrline_[] =
{
]b4_rline[
};
// Report on the debug stream that the rule yyrule is going to be reduced. // Report on the debug stream that the rule yyrule is going to be reduced.
private void yy_reduce_print (int yyrule, YYStack yystack) private void yy_reduce_print (int yyrule, YYStack yystack)
@@ -888,21 +813,18 @@ m4_popdef([b4_at_dollar])])dnl
int yynrhs = yyr2_[yyrule]; int yynrhs = yyr2_[yyrule];
/* Print the symbols being reduced, and their result. */ /* Print the symbols being reduced, and their result. */
yycdebug ("Reducing stack by rule " + (yyrule - 1) yycdebug ("Reducing stack by rule " + (yyrule - 1)
+ " (line " + yylno + "), "); + " (line " + yylno + "), ");
/* The symbols being reduced. */ /* The symbols being reduced. */
for (int yyi = 0; yyi < yynrhs; yyi++) for (int yyi = 0; yyi < yynrhs; yyi++)
yy_symbol_print (" $" + (yyi + 1) + " =", yy_symbol_print (" $" + (yyi + 1) + " =",
yyrhs_[yyprhs_[yyrule] + yyi], yystos_[yystack.stateAt(yyi + 1 - yynrhs)],
]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([, ]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,
b4_rhs_location(yynrhs, yyi + 1)])[); b4_rhs_location(yynrhs, yyi + 1)])[);
} }
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
private static final ]b4_int_type_for([b4_translate])[ yytranslate_table_[] = ]b4_integral_parser_table_define([translate_table], [b4_translate])[
{
]b4_translate[
};
private static final ]b4_int_type_for([b4_translate])[ yytranslate_ (int t) private static final ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
{ {
@@ -928,5 +850,5 @@ b4_percent_code_get[]dnl
} }
b4_epilogue b4_epilogue[]dnl
m4_divert_pop(0)dnl m4_divert_pop(0)dnl
+45
View File
@@ -0,0 +1,45 @@
## Copyright (C) 2002, 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
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
dist_pkgdata_DATA = \
data/README \
data/bison.m4 \
data/c++-skel.m4 \
data/c++.m4 \
data/c-skel.m4 \
data/c.m4 \
data/glr.c \
data/glr.cc \
data/java-skel.m4 \
data/java.m4 \
data/lalr1.cc \
data/lalr1.java \
data/location.cc \
data/stack.hh \
data/variant.hh \
data/yacc.c
m4sugardir = $(pkgdatadir)/m4sugar
dist_m4sugar_DATA = \
data/m4sugar/foreach.m4 \
data/m4sugar/m4sugar.m4
xsltdir = $(pkgdatadir)/xslt
dist_xslt_DATA = \
data/xslt/bison.xsl \
data/xslt/xml2dot.xsl \
data/xslt/xml2text.xsl \
data/xslt/xml2xhtml.xsl
+40 -17
View File
@@ -1,6 +1,7 @@
# C++ skeleton for Bison # C++ skeleton for Bison
# Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc. # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -15,12 +16,14 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef([b4_copyright_years],
[2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009])
# We do want M4 expansion after # for CPP macros. # We do want M4 expansion after # for CPP macros.
m4_changecom() m4_changecom()
m4_divert_push(0)dnl m4_divert_push(0)dnl
@output(b4_dir_prefix[]position.hh@)@ @output(b4_dir_prefix[]position.hh@)@
b4_copyright([Positions for Bison parsers in C++], b4_copyright([Positions for Bison parsers in C++])[
[2002-2007, 2009-2011])[
/** /**
** \file position.hh ** \file position.hh
@@ -39,29 +42,33 @@ b4_copyright([Positions for Bison parsers in C++],
class position class position
{ {
public: public:
]m4_ifdef([b4_location_constructors], [ ]m4_ifdef([b4_location_constructors], [[
/// Construct a position. /// Construct a position.
position () explicit position (]b4_percent_define_get([[filename_type]])[* f = 0,
: filename (0), line (]b4_location_initial_line[), column (]b4_location_initial_column[) unsigned int l = ]b4_location_initial_line[u,
unsigned int c = ]b4_location_initial_column[u)
: filename (f)
, line (l)
, column (c)
{ {
} }
])[ ]])[
/// Initialization. /// Initialization.
inline void initialize (]b4_percent_define_get([[filename_type]])[* fn) inline void initialize (]b4_percent_define_get([[filename_type]])[* fn)
{ {
filename = fn; filename = fn;
line = ]b4_location_initial_line[; line = ]b4_location_initial_line[u;
column = ]b4_location_initial_column[; column = ]b4_location_initial_column[u;
} }
/** \name Line and Column related manipulators /** \name Line and Column related manipulators
** \{ */ ** \{ */
public:
/// (line related) Advance to the COUNT next lines. /// (line related) Advance to the COUNT next lines.
/// Set current column to initial value.
inline void lines (int count = 1) inline void lines (int count = 1)
{ {
column = ]b4_location_initial_column[; column = ]b4_location_initial_column[u;
line += count; line += count;
} }
@@ -72,7 +79,6 @@ b4_copyright([Positions for Bison parsers in C++],
} }
/** \} */ /** \} */
public:
/// File name to which this position refers. /// File name to which this position refers.
]b4_percent_define_get([[filename_type]])[* filename; ]b4_percent_define_get([[filename_type]])[* filename;
/// Current line number. /// Current line number.
@@ -144,8 +150,7 @@ b4_copyright([Positions for Bison parsers in C++],
]b4_namespace_close[ ]b4_namespace_close[
#endif // not BISON_POSITION_HH] #endif // not BISON_POSITION_HH]
@output(b4_dir_prefix[]location.hh@)@ @output(b4_dir_prefix[]location.hh@)@
b4_copyright([Locations for Bison parsers in C++], b4_copyright([Locations for Bison parsers in C++])[
[2002-2007, 2009-2011])[
/** /**
** \file location.hh ** \file location.hh
@@ -166,9 +171,26 @@ b4_copyright([Locations for Bison parsers in C++],
{ {
public: public:
]m4_ifdef([b4_location_constructors], [ ]m4_ifdef([b4_location_constructors], [
/// Construct a location. /// Construct a location from \a b to \a e.
location () location (const position& b, const position& e)
: begin (), end () : begin (b)
, end (e)
{
}
/// Construct a 0-width location in \a p.
explicit location (const position& p = position ())
: begin (p)
, end (p)
{
}
/// Construct a 0-width location in \a f, \a l, \a c.
explicit location (]b4_percent_define_get([[filename_type]])[* f,
unsigned int l = ]b4_location_initial_line[u,
unsigned int c = ]b4_location_initial_column[u)
: begin (f, l, c)
, end (f, l, c)
{ {
} }
@@ -272,4 +294,5 @@ b4_copyright([Locations for Bison parsers in C++],
#endif // not BISON_LOCATION_HH] #endif // not BISON_LOCATION_HH]
m4_divert_pop(0) m4_divert_pop(0)
m4_popdef([b4_copyright_years])dnl
m4_changecom([#]) m4_changecom([#])
+135
View File
@@ -0,0 +1,135 @@
# C++ skeleton for Bison
# Copyright (C) 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef([b4_copyright_years],
[2002, 2003, 2004, 2005, 2006, 2007, 2008-2009])
# We do want M4 expansion after # for CPP macros.
m4_changecom()
m4_divert_push(0)dnl
@output(b4_dir_prefix[]stack.hh@)@
b4_copyright([Stack handling for Bison parsers in C++])[
#ifndef BISON_STACK_HH
# define BISON_STACK_HH
#include <deque>
]b4_namespace_open[
template <class T, class S = std::deque<T> >
class stack
{
public:
// Hide our reversed order.
typedef typename S::reverse_iterator iterator;
typedef typename S::const_reverse_iterator const_iterator;
stack ()
: seq_ ()
{
}
stack (unsigned int n)
: seq_ (n)
{
}
inline
T&
operator [] (unsigned int i)
{
return seq_[i];
}
inline
const T&
operator [] (unsigned int i) const
{
return seq_[i];
}
inline
void
push (const T& t)
{
seq_.push_front (t);
}
inline
void
pop (unsigned int n = 1)
{
for (; n; --n)
seq_.pop_front ();
}
inline
typename S::size_type
size () const
{
return seq_.size ();
}
inline
const_iterator
begin () const
{
return seq_.rbegin ();
}
inline
const_iterator
end () const
{
return seq_.rend ();
}
private:
/// The wrapped container.
S seq_;
};
/// Present a slice of the top of a stack.
template <class T, class S = stack<T> >
class slice
{
public:
slice (const S& stack, unsigned int range)
: stack_ (stack),
range_ (range)
{
}
inline
const T&
operator [] (unsigned int i) const
{
return stack_[range_ - i];
}
private:
const S& stack_;
unsigned int range_;
};
]b4_namespace_close[
#endif // not BISON_STACK_HH[]dnl
]
m4_divert_pop(0)
m4_popdef([b4_copyright_years])dnl
m4_changecom([#])
+278
View File
@@ -0,0 +1,278 @@
# C++ skeleton for Bison
# Copyright (C) 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
## --------- ##
## variant. ##
## --------- ##
# b4_symbol_variant(YYTYPE, YYVAL, ACTION, [ARGS])
# ------------------------------------------------
# Run some ACTION ("build", or "destroy") on YYVAL of symbol type
# YYTYPE.
m4_define([b4_symbol_variant],
[m4_pushdef([b4_dollar_dollar],
[$2.$3< $][3 >(m4_shift3($@))])dnl
switch ($1)
{
b4_type_foreach([b4_type_action_])[]dnl
default:
break;
}
m4_popdef([b4_dollar_dollar])dnl
])
# _b4_char_sizeof_counter
# -----------------------
# A counter used by _b4_char_sizeof_dummy to create fresh symbols.
m4_define([_b4_char_sizeof_counter],
[0])
# _b4_char_sizeof_dummy
# ---------------------
# At each call return a new C++ identifier.
m4_define([_b4_char_sizeof_dummy],
[m4_define([_b4_char_sizeof_counter], m4_incr(_b4_char_sizeof_counter))dnl
dummy[]_b4_char_sizeof_counter])
# b4_char_sizeof_(SYMBOL-NUM)
# ---------------------------
# A comment describing this symbol.
m4_define([b4_char_sizeof_],
[ // b4_symbol([$1], [tag])
])
# b4_char_sizeof(SYMBOL-NUMS)
# ---------------------------
# To be mapped on the list of type names to produce:
#
# char dummy1[sizeof(type_name_1)];
# char dummy2[sizeof(type_name_2)];
#
# for defined type names.
m4_define([b4_char_sizeof],
[b4_symbol_if([$1], [has_type],
[
m4_map([b4_char_sizeof_], [$@])dnl
char _b4_char_sizeof_dummy@{sizeof([b4_symbol([$1], [type])])@};
])])
# b4_variant_define
# -----------------
# Define "variant".
m4_define([b4_variant_define],
[[
/// A char[S] buffer to store and retrieve objects.
///
/// Sort of a variant, but does not keep track of the nature
/// of the stored data, since that knowledge is available
/// via the current state.
template <size_t S>
struct variant
{]b4_parse_assert_if([
/// Whether something is contained.
bool built;
])[
/// Empty construction.
inline
variant ()]b4_parse_assert_if([
: built (false)])[
{}
/// Instantiate a \a T in here.
template <typename T>
inline T&
build ()
{]b4_parse_assert_if([
assert (!built);
built = true;])[
return *new (buffer.raw) T;
}
/// Instantiate a \a T in here from \a t.
template <typename T>
inline T&
build (const T& t)
{]b4_parse_assert_if([
assert(!built);
built = true;])[
return *new (buffer.raw) T(t);
}
/// Construct and fill.
template <typename T>
inline
variant (const T& t)]b4_parse_assert_if([
: built (true)])[
{
new (buffer.raw) T(t);
}
/// Accessor to a built \a T.
template <typename T>
inline T&
as ()
{]b4_parse_assert_if([
assert (built);])[
return reinterpret_cast<T&>(buffer.raw);
}
/// Const accessor to a built \a T (for %printer).
template <typename T>
inline const T&
as () const
{]b4_parse_assert_if([
assert(built);])[
return reinterpret_cast<const T&>(buffer.raw);
}
/// Swap the content with \a other.
template <typename T>
inline void
swap (variant<S>& other)
{
std::swap (as<T>(), other.as<T>());
}
/// Assign the content of \a other to this.
/// Destroys \a other.
template <typename T>
inline void
build (variant<S>& other)
{
build<T>();
swap<T>(other);
other.destroy<T>();
}
/// Destroy the stored \a T.
template <typename T>
inline void
destroy ()
{
as<T>().~T();]b4_parse_assert_if([
built = false;])[
}
/// A buffer large enough to store any of the semantic values.
/// Long double is chosen as it has the strongest alignment
/// constraints.
union
{
long double align_me;
char raw[S];
} buffer;
};
]])
## -------------------------- ##
## Adjustments for variants. ##
## -------------------------- ##
# b4_semantic_type_declare
# ------------------------
# Declare semantic_type.
m4_define([b4_semantic_type_declare],
[ /// An auxiliary type to compute the largest semantic type.
union union_type
{]b4_type_foreach([b4_char_sizeof])[};
/// Symbol semantic values.
typedef variant<sizeof(union_type)> semantic_type;])
# How the semantic value is extracted when using variants.
# b4_symbol_value(VAL, [TYPE])
# ----------------------------
m4_define([b4_symbol_value],
[m4_ifval([$2],
[$1.as< $2 >()],
[$1])])
# b4_symbol_value_template(VAL, [TYPE])
# -------------------------------------
# Same as b4_symbol_value, but used in a template method.
m4_define([b4_symbol_value_template],
[m4_ifval([$2],
[$1.template as< $2 >()],
[$1])])
## ------------- ##
## make_SYMBOL. ##
## ------------- ##
# b4_symbol_constructor_declare_(SYMBOL-NUMBER)
# ---------------------------------------------
# Declare the overloaded version of make_symbol for the (common) type of
# these SYMBOL-NUMBERS. Use at class-level.
m4_define([b4_symbol_constructor_declare_],
[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
[ static // inline
symbol_type
make_[]b4_symbol_([$1], [id]) (dnl
b4_args(b4_symbol_if([$1], [has_type],
[const b4_symbol([$1], [type])& v]),
b4_locations_if([const location_type& l])));
])])])
# b4_symbol_constructor_declare
# -----------------------------
# Declare symbol constructors for all the value types.
# Use at class-level.
m4_define([b4_symbol_constructor_declare],
[ // Symbol constructors declarations.
b4_symbol_foreach([b4_symbol_constructor_declare_])])
# b4_symbol_constructor_define_(SYMBOL-NUMBER)
# --------------------------------------------
# Define symbol constructor for this SYMBOL-NUMBER.
m4_define([b4_symbol_constructor_define_],
[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
[ b4_parser_class_name::symbol_type
b4_parser_class_name::make_[]b4_symbol_([$1], [id]) (dnl
b4_args(b4_symbol_if([$1], [has_type],
[const b4_symbol([$1], [type])& v]),
b4_locations_if([const location_type& l])))
{
return symbol_type (b4_args([yytranslate_ (token::b4_symbol([$1], [id]))],
b4_symbol_if([$1], [has_type], [v]),
b4_locations_if([l])));
}
])])])
# b4_symbol_constructor_define
# ----------------------------
# Define the overloaded versions of make_symbol for all the value types.
m4_define([b4_symbol_constructor_define],
[ // Implementation of make_symbol for each symbol type.
b4_symbol_foreach([b4_symbol_constructor_define_])])
+1 -1
View File
@@ -3,7 +3,7 @@
<!-- <!--
bison.xsl - common templates for Bison XSLT. bison.xsl - common templates for Bison XSLT.
Copyright (C) 2007-2011 Free Software Foundation, Inc. Copyright (C) 2007, 2008-2009 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
+3 -19
View File
@@ -3,7 +3,7 @@
<!-- <!--
xml2dot.xsl - transform Bison XML Report into DOT. xml2dot.xsl - transform Bison XML Report into DOT.
Copyright (C) 2007-2011 Free Software Foundation, Inc. Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
@@ -35,27 +35,11 @@
</xsl:template> </xsl:template>
<xsl:template match="bison-xml-report"> <xsl:template match="bison-xml-report">
<xsl:text>// Generated by GNU Bison </xsl:text> <xsl:apply-templates select="automaton"/>
<xsl:value-of select="@version"/>
<xsl:text>.&#10;</xsl:text>
<xsl:text>// Report bugs to &lt;</xsl:text>
<xsl:value-of select="@bug-report"/>
<xsl:text>&gt;.&#10;</xsl:text>
<xsl:text>// Home page: &lt;</xsl:text>
<xsl:value-of select="@url"/>
<xsl:text>&gt;.&#10;&#10;</xsl:text>
<xsl:apply-templates select="automaton">
<xsl:with-param name="filename" select="filename"/>
</xsl:apply-templates>
</xsl:template> </xsl:template>
<xsl:template match="automaton"> <xsl:template match="automaton">
<xsl:param name="filename"/> <xsl:text>digraph Automaton {&#10;</xsl:text>
<xsl:text>digraph "</xsl:text>
<xsl:call-template name="escape">
<xsl:with-param name="subject" select="$filename"/>
</xsl:call-template>
<xsl:text>"&#10;{&#10;</xsl:text>
<xsl:apply-templates select="state"/> <xsl:apply-templates select="state"/>
<xsl:text>}&#10;</xsl:text> <xsl:text>}&#10;</xsl:text>
</xsl:template> </xsl:template>
+1 -1
View File
@@ -3,7 +3,7 @@
<!-- <!--
xml2text.xsl - transform Bison XML Report into plain text. xml2text.xsl - transform Bison XML Report into plain text.
Copyright (C) 2007-2011 Free Software Foundation, Inc. Copyright (C) 2007, 2008-2009 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
+1 -1
View File
@@ -3,7 +3,7 @@
<!-- <!--
xml2html.xsl - transform Bison XML Report into XHTML. xml2html.xsl - transform Bison XML Report into XHTML.
Copyright (C) 2007-2011 Free Software Foundation, Inc. Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
+328 -788
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -1,7 +1,8 @@
# DJGPP Maintainer's Makefile -*-Makefile-*- # DJGPP Maintainer's Makefile -*-Makefile-*-
# Requires GNU sed # Requires GNU sed
## Copyright (C) 2005-2011 Free Software Foundation, Inc. ## Copyright (C) 2005, 2006, 2007, 2008-2009 Free Software Foundation,
## Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
This is a port of GNU Bison @VERSION@ to MSDOS/DJGPP. This is a port of GNU Bison @VERSION@ to MSDOS/DJGPP.
Copyright (C) 2005-2011 Free Software Foundation, Inc. Copyright (C) 2005, 2006, 2007, 2008-2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
+2 -1
View File
@@ -4,7 +4,8 @@ Rem Configure Bison for DJGPP.
Rem WARNING WARNING WARNING: This file needs to have DOS CRLF end-of-line Rem WARNING WARNING WARNING: This file needs to have DOS CRLF end-of-line
Rem format, or else stock DOS/Windows shells will refuse to run it. Rem format, or else stock DOS/Windows shells will refuse to run it.
Rem Copyright (C) 2005-2011 Free Software Foundation, Inc. Rem Copyright (C) 2005, 2006, 2007, 2008-2009 Free Software Foundation,
Rem Inc.
Rem This program is free software: you can redistribute it and/or modify Rem This program is free software: you can redistribute it and/or modify
Rem it under the terms of the GNU General Public License as published by Rem it under the terms of the GNU General Public License as published by
+3 -1
View File
@@ -2,7 +2,9 @@
# Sed script for additional DJGPP specific editing # Sed script for additional DJGPP specific editing
# of the configure script generated by autoconf 2.62. # of the configure script generated by autoconf 2.62.
# Copyright (C) 2005-2011 Free Software Foundation, Inc.
# Copyright (C) 2005, 2006, 2007, 2008-2009 Free Software Foundation,
# Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
+2 -1
View File
@@ -3,7 +3,8 @@
# This is the config.site file for configuring GNU packages # This is the config.site file for configuring GNU packages
# which are to be built with DJGPP tools. # which are to be built with DJGPP tools.
# Copyright (C) 2005-2011 Free Software Foundation, Inc. # Copyright (C) 2005, 2006, 2007, 2008-2009 Free Software Foundation,
# Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
+2 -1
View File
@@ -1,6 +1,7 @@
# sed script for DJGPP specific editing of config.hin # sed script for DJGPP specific editing of config.hin
# Copyright (C) 2005-2011 Free Software Foundation, Inc. # Copyright (C) 2005, 2006, 2007, 2008-2009 Free Software Foundation,
# Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
+2 -1
View File
@@ -7,7 +7,8 @@ Rem This batch file unpacks the Bison distribution while simultaneously
Rem renaming some of the files whose names are invalid on DOS or conflict Rem renaming some of the files whose names are invalid on DOS or conflict
Rem with other file names after truncation to DOS 8+3 namespace. Rem with other file names after truncation to DOS 8+3 namespace.
Rem Rem
Rem Copyright (C) 2005-2011 Free Software Foundation, Inc. Rem Copyright (C) 2005, 2006, 2007, 2008-2009 Free Software Foundation,
Rem Inc.
Rem Rem
Rem This program is free software: you can redistribute it and/or modify Rem This program is free software: you can redistribute it and/or modify
Rem it under the terms of the GNU General Public License as published by Rem it under the terms of the GNU General Public License as published by
+27
View File
@@ -0,0 +1,27 @@
## Copyright (C) 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
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
EXTRA_DIST += \
djgpp/Makefile.maint \
djgpp/README.in \
djgpp/config.bat \
djgpp/config.sed \
djgpp/config.site \
djgpp/config_h.sed \
djgpp/djunpack.bat \
djgpp/fnchange.lst \
djgpp/subpipe.c \
djgpp/subpipe.h \
djgpp/testsuite.sed
+2 -1
View File
@@ -1,6 +1,7 @@
/* Subprocesses with pipes. /* Subprocesses with pipes.
Copyright (C) 2005-2011 Free Software Foundation, Inc. Copyright (C) 2005, 2006, 2007, 2008-2009 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
+2 -2
View File
@@ -1,6 +1,6 @@
/* Subprocesses with pipes. /* Subprocesses with pipes.
Copyright (C) 2005, 2006, 2007, 2008-2009 Free Software Foundation,
Copyright (C) 2005-2011 Free Software Foundation, Inc. Inc.
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
+2 -1
View File
@@ -2,7 +2,8 @@
# Sed script for additional DJGPP specific editing # Sed script for additional DJGPP specific editing
# of the testsuite script generated by autoconf 2.61. # of the testsuite script generated by autoconf 2.61.
# Copyright (C) 2007-2011 Free Software Foundation, Inc.
# Copyright (C) 2007, 2008-2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
+25
View File
@@ -0,0 +1,25 @@
*.info*
bison.1
bison.aux
bison.cp
bison.cps
bison.dvi
bison.fn
bison.help
bison.html
bison.ky
bison.log
bison.pdf
bison.pg
bison.ps
bison.toc
bison.tp
bison.vr
cross-options.texi
gendocs_template
refcard.dvi
refcard.log
refcard.ps
stamp-vti
version.texi
yacc.1
+1 -6
View File
@@ -1,15 +1,11 @@
/*.info* /*.info*
/*~
/.dirstamp
/Makefile
/Makefile.in
/bison.1 /bison.1
/bison.aux /bison.aux
/bison.cp /bison.cp
/bison.cps /bison.cps
/bison.dvi /bison.dvi
/bison.fn /bison.fn
/bison.help
/bison.html /bison.html
/bison.ky /bison.ky
/bison.log /bison.log
@@ -27,4 +23,3 @@
/stamp-vti /stamp-vti
/version.texi /version.texi
/yacc.1 /yacc.1
-125
View File
@@ -1,125 +0,0 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-
## Copyright (C) 2001-2003, 2005-2011 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AM_MAKEINFOFLAGS = --no-split
info_TEXINFOS = bison.texinfo
bison_TEXINFOS = $(srcdir)/cross-options.texi gpl-3.0.texi fdl.texi
CLEANFILES = bison.fns
CLEANDIRS = *.t2d
clean-local:
rm -rf $(CLEANDIRS)
CROSS_OPTIONS_PL = $(top_srcdir)/build-aux/cross-options.pl
$(srcdir)/cross-options.texi: $(top_srcdir)/src/getargs.c $(CROSS_OPTIONS_PL)
mv -f $@ $@~ || : >$@~
-rm -f $@.tmp
cd $(top_builddir)/src && $(MAKE) $(AM_MAKEFLAGS) bison
$(top_builddir)/src/bison --help \
| perl $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp
diff -u $@~ $@.tmp || true
mv $@.tmp $@
MAINTAINERCLEANFILES = $(srcdir)/cross-options.texi
## ---------- ##
## Ref card. ##
## ---------- ##
EXTRA_DIST = refcard.tex
CLEANFILES += refcard.dvi refcard.log refcard.ps
refcard.dvi: refcard.tex
tex refcard.tex
refcard.ps: refcard.dvi
## ----------- ##
## Man Pages. ##
## ----------- ##
dist_man_MANS = $(srcdir)/bison.1
EXTRA_DIST += $(dist_man_MANS:.1=.x) common.x
MAINTAINERCLEANFILES += $(dist_man_MANS)
# Depend on configure to get version number changes.
common_dep = $(top_srcdir)/configure $(srcdir)/common.x
srcsrcdir = $(top_srcdir)/bin
$(srcdir)/bison.1: $(common_dep) $(top_srcdir)/src/getargs.c
# Differences to ignore when comparing the man page (the date).
remove_time_stamp = \
sed 's/^\(\.TH[^"]*"[^"]*"[^"]*\)"[^"]*"/\1/'
MOSTLYCLEANFILES = $(srcdir)/*.t
SUFFIXES = .x .1
PREPATH = $(top_builddir)/src
.x.1:
@program=`expr "/$*" : '.*/\(.*\)'` && \
save_IFS=$IFS; \
IFS=$(PATH_SEPARATOR); \
for dir in $(PREPATH); do \
IFS=$save_IFS; \
echo cd $$dir '&&' $(MAKE) $(AM_MAKEFLAGS) $$program && \
(cd $$dir && $(MAKE) $(AM_MAKEFLAGS) $$program) || exit; \
done
@echo "Updating man page $@"
PATH="$(PREPATH)$(PATH_SEPARATOR)$$PATH"; \
export PATH; \
$(HELP2MAN) \
--include=$*.x \
--include=$(srcdir)/common.x \
--output=$@.t `echo '$*' | sed 's,.*/,,'`
if $(remove_time_stamp) $@ >$@a.t 2>/dev/null && \
$(remove_time_stamp) $@.t | cmp $@a.t - >/dev/null 2>&1; then \
touch $@; \
else \
mv $@.t $@; \
fi
rm -f $@*.t
nodist_man_MANS = yacc.1
## -------------- ##
## Doxygenation. ##
## -------------- ##
DOXYGEN = doxygen
.PHONY: doc html
doc: html
html-local: Doxyfile
$(DOXYGEN)
edit = sed -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
-e 's,@top_builddir\@,$(top_builddir),g' \
-e 's,@top_srcdir\@,$(top_srcdir),g'
EXTRA_DIST += Doxyfile.in
CLEANFILES += Doxyfile
# Sed is used to generate Doxyfile from Doxyfile.in instead of
# configure, because the former is way faster than the latter.
Doxyfile: $(srcdir)/Doxyfile.in
$(edit) $(srcdir)/Doxyfile.in >Doxyfile
CLEANDIRS += html latex
+1355 -1690
View File
File diff suppressed because it is too large Load Diff
+5
View File
@@ -53,3 +53,8 @@ are unique. When a long option takes an argument, like
.BR \-\-file-prefix , .BR \-\-file-prefix ,
connect the option name and the argument with connect the option name and the argument with
.BR = . .BR = .
[see also]
.BR lex (1),
.BR flex (1),
.BR yacc (1).
-4
View File
@@ -1,4 +0,0 @@
[see also]
.BR lex (1),
.BR flex (1),
.BR yacc (1).
+13 -68
View File
@@ -1,12 +1,12 @@
@c The GNU Free Documentation License. @c The GNU Free Documentation License.
@center Version 1.3, 3 November 2008 @center Version 1.2, November 2002
@c This file is intended to be included within another document, @c This file is intended to be included within another document,
@c hence no sectioning command or @node. @c hence no sectioning command or @node.
@display @display
Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc.
@uref{http://fsf.org/} 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
@@ -111,9 +111,6 @@ formats which do not have any title page as such, ``Title Page'' means
the text near the most prominent appearance of the work's title, the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text. preceding the beginning of the body of the text.
The ``publisher'' means any person or entity that distributes copies
of the Document to the public.
A section ``Entitled XYZ'' means a named subunit of the Document whose A section ``Entitled XYZ'' means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a text that translates XYZ in another language. (Here XYZ stands for a
@@ -382,30 +379,13 @@ title.
@item @item
TERMINATION TERMINATION
You may not copy, modify, sublicense, or distribute the Document You may not copy, modify, sublicense, or distribute the Document except
except as expressly provided under this License. Any attempt as expressly provided for under this License. Any other attempt to
otherwise to copy, modify, sublicense, or distribute it is void, and copy, modify, sublicense or distribute the Document is void, and will
will automatically terminate your rights under this License. automatically terminate your rights under this License. However,
parties who have received copies, or rights, from you under this
However, if you cease all violation of this License, then your license License will not have their licenses terminated so long as such
from a particular copyright holder is reinstated (a) provisionally, parties remain in full compliance.
unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to
60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, receipt of a copy of some or all of the same material does
not give you any rights to use it.
@item @item
FUTURE REVISIONS OF THIS LICENSE FUTURE REVISIONS OF THIS LICENSE
@@ -423,42 +403,7 @@ following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation. If the Document as a draft) by the Free Software Foundation.
specifies that a proxy can decide which future versions of this
License can be used, that proxy's public statement of acceptance of a
version permanently authorizes you to choose that version for the
Document.
@item
RELICENSING
``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any
World Wide Web server that publishes copyrightable works and also
provides prominent facilities for anybody to edit those works. A
public wiki that anybody can edit is an example of such a server. A
``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the
site means any set of copyrightable works thus published on the MMC
site.
``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0
license published by Creative Commons Corporation, a not-for-profit
corporation with a principal place of business in San Francisco,
California, as well as future copyleft versions of that license
published by that same organization.
``Incorporate'' means to publish or republish a Document, in whole or
in part, as part of another Document.
An MMC is ``eligible for relicensing'' if it is licensed under this
License, and if all works that were first published under this License
somewhere other than this MMC, and subsequently incorporated in whole
or in part into the MMC, (1) had no cover texts or invariant sections,
and (2) were thus incorporated prior to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the site
under CC-BY-SA on the same site at any time before August 1, 2009,
provided the MMC is eligible for relicensing.
@end enumerate @end enumerate
@page @page
@@ -472,7 +417,7 @@ license notices just after the title page:
@group @group
Copyright (C) @var{year} @var{your name}. Copyright (C) @var{year} @var{your name}.
Permission is granted to copy, distribute and/or modify this document Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation; or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled ``GNU Texts. A copy of the license is included in the section entitled ``GNU
+143
View File
@@ -0,0 +1,143 @@
## Copyright (C) 2001, 2002, 2003, 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
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
AM_MAKEINFOFLAGS = --no-split
info_TEXINFOS = doc/bison.texinfo
doc_bison_TEXINFOS = \
$(CROSS_OPTIONS_TEXI) \
doc/fdl.texi \
doc/gpl-3.0.texi
CLEANFILES = doc/bison.fns
CLEANDIRS = doc/*.t2d
clean-local:
rm -rf $(CLEANDIRS)
MOSTLYCLEANFILES += $(top_srcdir)/doc/*.t
CROSS_OPTIONS_PL = $(top_srcdir)/build-aux/cross-options.pl
CROSS_OPTIONS_TEXI = $(top_srcdir)/doc/cross-options.texi
$(CROSS_OPTIONS_TEXI): doc/bison.help $(CROSS_OPTIONS_PL)
# Create $@~ which is the previous contents. Don't use `mv' here so
# that even if we are interrupted, the file is still available for
# diff in the next run. Note that $@ might not exist yet.
{ test ! -f $@ || cat $@; } >$@~
test ! -f $@.tmp || rm -f $@.tmp
src/bison$(EXEEXT) --help | \
perl $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp
diff -u $@~ $@.tmp || true
mv $@.tmp $@
MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI)
## ---------- ##
## Ref card. ##
## ---------- ##
EXTRA_DIST += doc/refcard.tex
CLEANFILES += doc/refcard.dvi doc/refcard.log doc/refcard.ps
doc/refcard.dvi: doc/refcard.tex
cd doc && tex refcard.tex
doc/refcard.ps: doc/refcard.dvi
## ---------------- ##
## doc/bison.help. ##
## ---------------- ##
# Some of our targets (cross-option.texi, bison.1) use "bison --help".
# Since we want to ship the generated file to avoid additional
# requirements over the user environment, we used not depend on
# src/bison itself, but on src/getargs.c and other files. Yet, we
# need "bison --help" to work to make help2man happy, so we used to
# include "make src/bison" in the commands. Then we may have a
# problem with concurrent builds, since one make might be aiming one
# of its jobs at compiling src/bison, and another job at generating
# the man page. If the latter is faster than the former, then we have
# two makes that concurrently try to compile src/bison. Doomed to
# failure.
#
# As a simple scheme to get our way out, make a stamp file,
# bison.help, which contains --version then --help. This file can
# depend on bison, which ensures its correctness. But update it
# *only* if needed (content changes). This way, we avoid useless
# compilations of cross-option.texi and bison.1. At the cost of
# repeated builds of bison.help.
EXTRA_DIST += $(top_srcdir)/doc/bison.help
MAINTAINERCLEANFILES += $(top_srcdir)/doc/bison.help
$(top_srcdir)/doc/bison.help: src/bison$(EXEEXT)
$< --version >doc/bison.help.t
$< --help >>doc/bison.help.t
$(top_srcdir)/build-aux/move-if-change doc/bison.help.t $@
## ----------- ##
## Man Pages. ##
## ----------- ##
dist_man_MANS = $(top_srcdir)/doc/bison.1
EXTRA_DIST += $(dist_man_MANS:.1=.x)
MAINTAINERCLEANFILES += $(dist_man_MANS)
# Differences to ignore when comparing the man page (the date).
remove_time_stamp = \
sed 's/^\(\.TH[^"]*"[^"]*"[^"]*\)"[^"]*"/\1/'
# Depend on configure to get version number changes.
$(top_srcdir)/doc/bison.1: doc/bison.help doc/bison.x $(top_srcdir)/configure
@echo "Updating man page $@"
$(HELP2MAN) \
--include=$(top_srcdir)/doc/bison.x \
--output=$@.t src/bison$(EXEEXT)
if $(remove_time_stamp) $@ >$@a.t 2>/dev/null && \
$(remove_time_stamp) $@.t | cmp $@a.t - >/dev/null 2>&1; then \
touch $@; \
else \
mv $@.t $@; \
fi
rm -f $@*.t
nodist_man_MANS = doc/yacc.1
## -------------- ##
## Doxygenation. ##
## -------------- ##
DOXYGEN = doxygen
.PHONY: doc html
doc: html
html-local: doc/Doxyfile
cd doc && $(DOXYGEN)
edit = sed -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
-e 's,@top_builddir\@,$(top_builddir),g' \
-e 's,@top_srcdir\@,$(top_srcdir),g'
EXTRA_DIST += doc/Doxyfile.in
CLEANFILES += doc/Doxyfile
# Sed is used to generate Doxyfile from Doxyfile.in instead of
# configure, because the former is way faster than the latter.
doc/Doxyfile: $(top_srcdir)/doc/Doxyfile.in
$(edit) $(top_srcdir)/doc/Doxyfile.in >doc/Doxyfile
CLEANDIRS += html latex
+1 -1
View File
@@ -19,7 +19,7 @@
\def\finalout{\overfullrule=0pt} \def\finalout{\overfullrule=0pt}
%\finalout %\finalout
% Copyright (c) 1998, 2001, 2009-2011 Free Software Foundation, Inc. % Copyright (c) 1998, 2001, 2009 Free Software Foundation, Inc.
% %
% This file is part of Bison. % This file is part of Bison.
% %
+1
View File
@@ -0,0 +1 @@
bench.pl
-2
View File
@@ -1,3 +1 @@
/Makefile
/Makefile.in
/bench.pl /bench.pl
-16
View File
@@ -1,16 +0,0 @@
## Copyright (C) 2006, 2009-2011 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
nodist_noinst_SCRIPTS = bench.pl
+1 -1
View File
@@ -19,7 +19,7 @@ straightforward use of _build/src/bison would.)
-- --
Copyright (C) 2006, 2009-2011 Free Software Foundation, Inc. Copyright (C) 2006, 2009 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
+785 -33
View File
@@ -1,6 +1,6 @@
#! /usr/bin/perl -w #! /usr/bin/perl -w
# Copyright (C) 2006, 2008-2011 Free Software Foundation, Inc. # Copyright (C) 2006, 2008, 2009 Free Software Foundation, Inc.
# #
# This file is part of Bison, the GNU Compiler Compiler. # This file is part of Bison, the GNU Compiler Compiler.
# #
@@ -17,17 +17,230 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
use IO::File; =head1 NAME
use Benchmark qw (:all);
my $bison = $ENV{'BISON'} || '@abs_top_builddir@/tests/bison'; bench.pl - bench marks for Bison parsers.
my $cc = $ENV{'CC'} || 'gcc';
=head1 SYNOPSIS
./bench.pl [OPTIONS]... DIRECTIVES
=head1 DIRECTIVES
Specify the set of benches to run. The following grammar defines the
I<directives>:
directives ::=
directives | directives -- Alternation
| directives & directives -- Concatenation
| [ directives> ] -- Optional
| ( directives> ) -- Parentheses
| #d NAME[=VALUE] -- %code { #define NAME [VALUE] }
| %d NAME[=VALUE] -- %define NAME ["VALUE"]
| %s skeleton -- %skeleton "skeleton"
| directive
Parentheses only group to override precedence. For instance:
[ %debug ] & [ %error-verbose ] & [ %define variant ]
will generate eight different cases.
=head1 OPTIONS
=over 4
=item B<-b>, B<--bench>
Predefined benches, that is, combimation between a grammar and a I<directives>
request.
=over 4
=item I<push>
Test the push parser vs. the pull interface. Use the C parser.
=item I<variant>
Test the use of variants instead of union in the C++ parser.
=back
=item B<-c>, B<--cflags>=I<flags>
Flags to pass to the C or C++ compiler. Defaults to -O2.
=item B<-d>, B<--directive>=I<directives>
Add a set of Bison directives to bench against each other.
=item B<-g>, B<--grammar>=I<grammar>
Select the base I<grammar> to use. Defaults to I<calc>.
=over 4
=item I<calc>
Traditional calculator.
=item I<list>
C++ grammar that uses std::string and std::list. Can be used with
or without %define variant.
=item I<triangular>
Artificial grammar with very long rules.
=back
=item B<-h>, B<--help>
Display this message and exit succesfully. The more verbose, the more
details.
=item B<-i>, B<--iterations>=I<integer>
Say how many times a single test of the bench must be run. If
negative, specify the minimum number of CPU seconds to run. Defaults
to -1.
=item B<-q>, B<--quiet>
Decrease the verbosity level (defaults to 1).
=item B<-v>, B<--verbose>
Raise the verbosity level (defaults to 1).
=back
=cut
use strict;
use IO::File;
################################################################## ##################################################################
sub triangular_grammar ($$$) =head1 VARIABLES
=over 4
=item C<@bench>
The list of benches to run.
=item C<$bison>
The Bison program to use to compile the grammar.
=item C<$cc>
The C compiler.
=item C<$cxx>
The C++ compiler.
=item C<$cflags>
Compiler flags (C or C++).
=item C<@directive>
A list of directive sets to measure against each other.
=item C<$iterations>
The number of times the parser is run for a bench.
=item C<$verbose>
Verbosity level.
=back
=cut
my $bench;
my $bison = $ENV{'BISON'} || '@abs_top_builddir@/tests/bison';
my $cc = $ENV{'CC'} || 'gcc';
my $cxx = $ENV{'CXX'} || 'g++';
my $cflags = '-O2';
my @directive = ();
my $grammar = 'calc';
my $iterations = -1;
my $verbose = 1;
=head1 FUNCTIONS
=over 4
=item C<verbose($level, $message)>
Report the C<$message> is C<$level> E<lt>= C<$verbose>.
=cut
sub verbose($$)
{ {
my ($base, $max, $directives) = @_; my ($level, $message) = @_;
print STDERR $message
if $level <= $verbose;
}
######################################################################
=item C<directives($bench, @directive)>
Format the list of directives for Bison for bench named C<$bench>.
=cut
sub directives($@)
{
my ($bench, @directive) = @_;
my $res = "/* Directives for bench `$bench'. */\n";
$res .= join ("\n", @directive) . "\n";
$res .= "/* End of directives for bench `$bench'. */\n";
return $res;
}
######################################################################
=item C<generate_grammar_triangular ($base, $max, @directive)>
Create a large triangular grammar which looks like :
input:
exp { if ($1 != 0) abort (); $$ = $1; }
| input exp { if ($2 != $1 + 1) abort (); $$ = $2; }
;
exp:
END { $$ = 0; }
| "1" END { $$ = 1; }
| "1" "2" END { $$ = 2; }
| "1" "2" "3" END { $$ = 3; }
| "1" "2" "3" "4" END { $$ = 4; }
| "1" "2" "3" "4" "5" END { $$ = 5; }
;
C<$base> is the base name for the file to create (F<$base.y>).
C<$max> is the number of such rules (here, 5). You may pass
additional Bison C<@directive>.
The created parser is self contained: it includes its scanner, and
source of input.
=cut
sub generate_grammar_triangular ($$@)
{
my ($base, $max, @directive) = @_;
my $directives = directives ($base, @directive);
my $out = new IO::File ">$base.y" my $out = new IO::File ">$base.y"
or die; or die;
@@ -41,6 +254,7 @@ sub triangular_grammar ($$$)
static int yylex (void); static int yylex (void);
static void yyerror (const char *msg); static void yyerror (const char *msg);
%} %}
$directives
%union %union
{ {
int val; int val;
@@ -112,6 +326,15 @@ EOF
################################################################## ##################################################################
=item C<calc_input ($base, $max)>
Generate the input file F<$base.input> for the calc parser. The input
is composed of two expressions. The first one is using left recursion
only and consumes no stack. The second one requires a deep stack.
These two expressions are repeated C<$max> times in the output file.
=cut
sub calc_input ($$) sub calc_input ($$)
{ {
my ($base, $max) = @_; my ($base, $max) = @_;
@@ -126,9 +349,22 @@ sub calc_input ($$)
################################################################## ##################################################################
sub calc_grammar ($$$) =item C<generate_grammar_calc ($base, $max, @directive)>
Generate a Bison file F<$base.y> for a calculator parser in C. Pass
the additional Bison C<@directive>. C<$max> is ignored, but left to
have the same interface as C<triangular_grammar>.
=cut
sub generate_grammar_calc ($$@)
{ {
my ($base, $max, $directives) = @_; my ($base, $max, @directive) = @_;
my $directives = directives ($base, @directive);
# Putting this request here is stupid, since the input will be
# generated each time we generate a grammar.
calc_input ('calc', 200);
my $out = new IO::File ">$base.y" my $out = new IO::File ">$base.y"
or die; or die;
@@ -148,9 +384,9 @@ static semantic_value global_result = 0;
static int global_count = 0; static int global_count = 0;
%} %}
/* Exercise %union. */
$directives $directives
%error-verbose %error-verbose
/* Exercise %union. */
%union %union
{ {
semantic_value ival; semantic_value ival;
@@ -327,44 +563,560 @@ EOF
################################################################## ##################################################################
=item C<generate_grammar_list ($base, $max, @directive)>
Generate a Bison file F<$base.y> for a C++ parser that uses C++
objects (std::string, std::list). Tailored for using %define variant.
=cut
sub generate_grammar_list ($$@)
{
my ($base, $max, @directive) = @_;
my $directives = directives ($base, @directive);
my $variant = grep { /%define "?variant"?/ } @directive;
my $lex_symbol = grep { /%define "?lex_symbol"?/ } @directive;
my $out = new IO::File ">$base.y"
or die;
print $out <<EOF;
%language "C++"
%defines
%locations
$directives
%code requires // *.h
{
#include <string>
}
%code // *.c
{
#include <algorithm>
#include <iostream>
#include <sstream>
#define STAGE_MAX ($max * 10) // max = $max
#define USE_LEX_SYMBOL $lex_symbol
#define USE_VARIANTS $variant
// Prototype of the yylex function providing subsequent tokens.
static
#if USE_LEX_SYMBOL
yy::parser::symbol_type yylex();
#else
yy::parser::token_type yylex(yy::parser::semantic_type* yylval,
yy::parser::location_type* yylloc);
#endif
// Conversion to string.
template <typename T>
inline
std::string
string_cast (const T& t)
{
std::ostringstream o;
o << t;
return o.str ();
}
}
%token END_OF_FILE 0
EOF
if ($variant)
{
print $out <<'EOF';
%token <std::string> TEXT
%token <int> NUMBER
%printer { std::cerr << "Number: " << $$; } <int>
%printer { std::cerr << "Text: " << $$; } <std::string>
%type <std::string> text result
%%
result:
text { /* Throw away the result. */ }
;
text:
/* nothing */ { /* This will generate an empty string */ }
| text TEXT { std::swap ($$, $2); }
| text NUMBER { $$ = string_cast($2); }
;
EOF
}
else
{
# Not using Bison variants.
print $out <<'EOF';
%union {int ival; std::string* sval;}
%token <sval> TEXT
%token <ival> NUMBER
%printer { std::cerr << "Number: " << $$; } <ival>
%printer { std::cerr << "Text: " << *$$; } <sval>
%type <sval> text result
%%
result:
text { delete $1; }
;
text:
/* nothing */ { $$ = new std::string; }
| text TEXT { delete $1; $$ = $2; }
| text NUMBER { delete $1; $$ = new std::string (string_cast ($2)); }
;
EOF
}
print $out <<'EOF';
%%
#
static
#if USE_LEX_SYMBOL
yy::parser::symbol_type yylex()
#else
yy::parser::token_type yylex(yy::parser::semantic_type* yylval,
yy::parser::location_type* yylloc)
#endif
{
typedef yy::parser::location_type location_type;
typedef yy::parser::token token;
static int stage = -1;
++stage;
if (stage == STAGE_MAX)
{
#if USE_LEX_SYMBOL
return yy::parser::make_END_OF_FILE (location_type ());
#else
*yylloc = location_type ();
return token::END_OF_FILE;
#endif
}
else if (stage % 2)
{
#if USE_LEX_SYMBOL
return yy::parser::make_NUMBER (stage, location_type ());
#else
# if defined ONE_STAGE_BUILD
yylval->build(stage);
# elif USE_VARIANTS
yylval->build<int>() = stage;
# else
yylval->ival = stage;
# endif
*yylloc = location_type ();
return token::NUMBER;
#endif
}
else
{
#if USE_LEX_SYMBOL
return yy::parser::make_TEXT ("A string.", location_type ());
#else
# if defined ONE_STAGE_BUILD
yylval->build(std::string("A string."));
# elif USE_VARIANTS
yylval->build<std::string>() = std::string("A string.");
# else
yylval->sval = new std::string("A string.");
# endif
*yylloc = location_type ();
return token::TEXT;
#endif
}
abort();
}
// Mandatory error function
void
yy::parser::error(const yy::parser::location_type& loc, const std::string& msg)
{
std::cerr << loc << ": " << msg << std::endl;
}
int main(int argc, char *argv[])
{
yy::parser p;
#if YYDEBUG
p.set_debug_level(!!getenv("YYDEBUG"));
#endif
p.parse();
return 0;
}
EOF
}
##################################################################
=item C<generate_grammar ($name, $base, @directive)>
Generate F<$base.y> by calling C<&generate_grammar_$name>.
=cut
sub generate_grammar ($$@)
{
my ($name, $base, @directive) = @_;
verbose 3, "Generating $base.y\n";
my %generator =
(
"calc" => \&generate_grammar_calc,
"list" => \&generate_grammar_list,
"triangular" => \&generate_grammar_triangular,
);
&{$generator{$name}}($base, 200, @directive);
}
##################################################################
=item C<run ($command)>
Run, possibly verbosely, the shell C<$command>.
=cut
sub run ($)
{
my ($command) = @_;
verbose 3, "$command\n";
system ("$command") == 0
or die "$command failed";
}
##################################################################
=item C<compile ($base)>
Compile C<$base.y> to an executable C, Using the C or C++ compiler
depending on the %language specification in C<$base.y>.
=cut
sub compile ($) sub compile ($)
{ {
my ($base) = @_; my ($base) = @_;
system ("$bison $base.y -o $base.c") == 0 my $language = `sed -ne '/%language "\\(.*\\)"/{s//\\1/;p;q;}' $base.y`;
or die; chomp $language;
system ("$cc -o $base $base.c") == 0
or die; my $compiler = $language eq 'C++' ? $cxx : $cc;
run "$bison $base.y -o $base.c";
run "$compiler -o $base $cflags $base.c";
} }
sub bench_grammar ($) ######################################################################
{
my ($gram) = @_;
my %test =
(
"pull-impure" => '',
"pull-pure" => '%define api.pure',
"push-impure" => '%define api.push-pull "both"',
"push-pure" => '%define api.push-pull "both" %define api.pure',
);
=item C<bench ($grammar, @token)>
Generate benches for the C<$grammar> and the directive specification
given in the list of C<@token>.
=cut
sub bench ($@)
{
my ($grammar, @token) = @_;
use Benchmark qw (:all :hireswallclock);
my @directive = parse (@token);
# Set up the benches as expected by timethese.
my %bench; my %bench;
while (my ($name, $directives) = each %test) # A counter of directive sets.
my $count = 1;
for my $d (@directive)
{ {
print STDERR "$name\n"; $bench{$count} = $d;
my $generator = "$gram" . "_grammar"; printf " %2d. %s\n", $count, join (' ', split ("\n", $d));
&$generator ($name, 200, $directives); $count++;
};
# For each bench, capture the size.
my %size;
while (my ($name, $directives) = each %bench)
{
generate_grammar ($grammar, $name, $directives);
# Compile the executable.
compile ($name); compile ($name);
$bench{$name} = "system ('./$name');"; $bench{$name} = "system ('./$name');";
chop($size{$name} = `wc -c <$name`);
} }
print "$gram:\n"; # Run the benches.
my $res = timethese (50, \%bench, 'nop'); #
# STYLE can be any of 'all', 'none', 'noc', 'nop' or 'auto'. 'all'
# shows each of the 5 times available ('wallclock' time, user time,
# system time, user time of children, and system time of
# children). 'noc' shows all except the two children times. 'nop'
# shows only wallclock and the two children times. 'auto' (the
# default) will act as 'all' unless the children times are both
# zero, in which case it acts as 'noc'. 'none' prevents output.
verbose 3, "Running the benches for $grammar\n";
my $res = timethese ($iterations, \%bench, 'nop');
# Output the speed result.
cmpthese ($res, 'nop'); cmpthese ($res, 'nop');
# Display the sizes.
print "Sizes (decreasing):\n";
my $width = 10;
for my $bench (keys %size)
{
$width = length $bench
if $width < length $bench;
}
# Benches sorted by decreasing size.
my @benches_per_size = sort {$size{$b} <=> $size{$a}} keys %size;
for my $bench (@benches_per_size)
{
printf "%${width}s: %5.2fkB\n", $bench, $size{$bench} / 1024;
}
} }
print STDERR "Using $bison, $cc.\n"; ######################################################################
calc_input ('calc', 200);
bench_grammar ('calc'); =item C<bench_push_parser ()>
Bench the C push parser against the pull parser, pure and impure
interfaces.
=cut
sub bench_push_parser ()
{
bench ('calc',
qw(
[ %d api.pure ]
&
[ %d api.push-pull=both ]
));
}
######################################################################
=item C<bench_variant_parser ()>
Bench the C++ lalr1.cc parser using variants or %union.
=cut
sub bench_variant_parser ()
{
bench ('list',
qw(
[
%d variant
&
[ #d ONE_STAGE_BUILD | %d lex_symbol ]
]
)
);
}
############################################################################
sub help ($)
{
my ($verbose) = @_;
use Pod::Usage;
# See <URL:http://perldoc.perl.org/pod2man.html#NOTES>.
pod2usage( { -message => "Bench Bison parsers",
-exitval => 0,
-verbose => $verbose,
-output => \*STDOUT });
}
######################################################################
# The end of the directives to parse.
my $eod = "end of directives";
# The list of tokens parsed by the following functions.
my @token;
# eat ($EXPECTED)
# ---------------
# Check that the current token is $EXPECTED, and move to the next.
sub eat ($)
{
my ($expected) = @_;
die "expected $expected, unexpected: $token[0] (@token)\n"
unless $token[0] eq $expected;
shift @token;
}
# Parse directive specifications:
# expr: term (| term)*
# term: fact (& fact)*
# fact: ( expr ) | [ expr ] | dirs
# dirs: %s SKELETON | #d NAME[=VALUE] | %d NAME[=VALUE] | directive
sub parse (@)
{
@token = (@_, $eod);
verbose 3, "Parsing: @token\n";
my @res = parse_expr ();
eat ($eod);
return @res;
}
sub parse_expr ()
{
my @res = parse_term ();
while ($token[0] eq '|')
{
eat ('|');
# Alternation.
push @res, parse_term ();
}
return @res;
}
sub parse_term ()
{
my @res = parse_fact ();
while ($token[0] eq '&')
{
eat ('&');
# Cartesian product.
my @lhs = @res;
@res = ();
for my $rhs (parse_fact ())
{
for my $lhs (@lhs)
{
push @res, $lhs . ($lhs && $rhs ? "\n" : "") . $rhs;
}
}
}
return @res;
}
sub parse_fact ()
{
my @res;
die "unexpected end of expression"
unless defined $token[0];
if ($token[0] eq '(')
{
eat ('(');
@res = parse_expr ();
eat (')');
}
elsif ($token[0] eq '[')
{
eat ('[');
@res = (parse_expr (), '');
eat (']');
}
else
{
@res = parse_dirs ();
}
return @res;
}
sub parse_dirs ()
{
my @res;
die "unexpected end of expression"
unless defined $token[0];
if ($token[0] eq '#d')
{
eat ('#d');
$token[0] =~ s/(.*?)=(.*)/$1 $2/;
@res = ("%code {\n#define $token[0]\n}");
shift @token;
}
elsif ($token[0] eq '%d')
{
shift @token;
$token[0] =~ s/(.*?)=(.*)/$1 "$2"/;
@res = ("%define $token[0]");
shift @token;
}
elsif ($token[0] eq '%s')
{
shift @token;
@res = ("%skeleton \"$token[0]\"");
shift @token;
}
else
{
@res = $token[0];
shift @token;
}
return @res;
}
######################################################################
sub getopt ()
{
use Getopt::Long;
my %option = (
"b|bench=s" => \$bench,
"c|cflags=s" => \$cflags,
"d|directive=s" => \@directive,
"g|grammar=s" => \$grammar,
"h|help" => sub { help ($verbose) },
"i|iterations=i" => \$iterations,
"q|quiet" => sub { --$verbose },
"v|verbose" => sub { ++$verbose },
);
Getopt::Long::Configure ("bundling", "pass_through");
GetOptions (%option)
or exit 1;
}
######################################################################
getopt;
# Create the directory we work in.
mkdir "benches" or die "cannot create benches"
unless -d "benches";
my $count = 1;
++$count
while -d "benches/$count";
my $dir = "benches/$count";
mkdir $dir
or die "cannot create $dir";
chdir $dir
or die "cannot chdir $dir";
# The following message is tailored to please Emacs' compilation-mode.
verbose 1, "Entering directory `$dir'\n";
verbose 1, "Using bison=$bison.\n";
verbose 2, "Using cc=$cc.\n";
verbose 2, "Using cxx=$cxx.\n";
verbose 2, "Using cflags=$cflags.\n";
verbose 2, "Grammar: $grammar\n";
# Support -b: predefined benches.
my %bench =
(
"push" => \&bench_push_parser,
"variant" => \&bench_variant_parser,
);
if (defined $bench)
{
die "invalid argument for --bench: $bench"
unless defined $bench{$bench};
&{$bench{$bench}}();
exit 0;
}
else
{
# Launch the bench marking.
bench ($grammar, @ARGV);
}
### Setup "GNU" style for perl-mode and cperl-mode. ### Setup "GNU" style for perl-mode and cperl-mode.
## Local Variables: ## Local Variables:
+16
View File
@@ -0,0 +1,16 @@
## Copyright (C) 2006, 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
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
nodist_noinst_SCRIPTS = etc/bench.pl
+152
View File
@@ -0,0 +1,152 @@
#! /usr/bin/perl -w
use strict;
use IO::File;
my $prefix = "lib/";
# contents ($FILE_NAME)
# ---------------------
sub contents ($)
{
my ($file) = @_;
local $/; # Turn on slurp-mode.
my $f = new IO::File "< $file" or die "$file";
my $contents = $f->getline or die "$file";
$f->close;
return $contents;
}
# prefix_word ($WORD)
# -------------------
# Do not prefix special words such as variable dereferences. Also,
# "Makefile" is really "Makefile", since precisely there is no
# lib/Makefile.
sub prefix_word ($)
{
local ($_) = @_;
$_ = $prefix . $_
unless m{^\$\(\w+\)} || $_ eq "Makefile";
return $_;
}
# prefix_words ($TEXT)
# --------------------
sub prefix_words ($)
{
local ($_) = @_;
s{(\S+)}{prefix_word($1)}gem;
return $_;
}
# prefix_assignment ($LHS-AND-ASSIGN-OP, $RHS)
# --------------------------------------------
sub prefix_assignment ($$)
{
my ($lhs_and_assign_op, $rhs) = @_;
my $res;
# Some variables are initialized by gnulib.mk, and we don't want
# that. Change '=' to '+='.
if ($lhs_and_assign_op =~ /^(SUBDIRS|EXTRA_DIST|BUILT_SOURCES|SUFFIXES|MOSTLYCLEANFILES|CLEANFILES|DISTCLEANFILES|MAINTAINERCLEANFILES|AM_CFLAGS|AM_CPPFLAGS|AM_GNU_GETTEXT) =/)
{
$lhs_and_assign_op =~ s/=/+=/;
}
# We don't want to inherit gnulib's AUTOMAKE_OPTIONS, comment them.
elsif ($lhs_and_assign_op =~ /^AUTOMAKE_OPTIONS =/)
{
$lhs_and_assign_op =~ s/^/# /;
}
# Don't touch suffixes.
elsif ($lhs_and_assign_op =~ /^SUFFIXES /)
{
}
# The words are (probably) paths to files in lib/: prefix them.
else
{
$rhs = prefix_words($rhs)
}
# Variables which name depend on the location: libbison_a_SOURCES =>
# lib_libbison_a_SOURCES.
$lhs_and_assign_op =~ s/(libbison)/lib_$1/g;
return $lhs_and_assign_op . $rhs;
}
# prefix $CONTENTS
# ----------------
# $CONTENTS is a Makefile content. Post-process it so that each file-name
# is prefixed with $prefix (e.g., "lib/").
#
# Relies heavily on the regularity of the file generated by gnulib-tool.
sub prefix ($)
{
# Work on $_.
local ($_) = @_;
# Prefix all the occurrence of files in rules. If there is nothing
# after in the :, it's probably a phony target, or a suffix rule.
# Don't touch it.
s{^([\w./]+ *: *\w.*)$}
{prefix_words($1)}gem;
# Prefix files in variables.
s{^([\w.]+\s*\+?=)(.*)$}
{prefix_assignment($1, $2)}gem;
# These three guys escape all the other regular rules.
s{(charset\.alias|ref-add\.sed|ref-del\.sed)}{$prefix$1}g;
# Unfortunately, as a result we sometimes have lib/lib.
s{($prefix){2}}{$1}g;
# $(srcdir) is actually $(top_srcdir)/lib.
s{\$\(srcdir\)}{\$(top_srcdir)/lib}g;
# Sometimes, t-$@ is used instead of $@-t, which, of course, does
# not work when we have a $@ with a directory in it.
s{t-\$\@}{\$\@-t}g;
# Some AC_SUBST patterns remain and would better be Make macros.
s{\@(MKDIR_P)\@}{\$($1)}g;
# Adjust paths in mkdir.
s{(\$\(MKDIR_P\))\s*(\w+)}{$1 $prefix$2}g;
return $_;
}
# process ($IN)
# -------------
sub process ($)
{
my ($file) = @_;
my ($bak) = "$file.bak";
rename ($file, $bak) or die;
my $contents = contents ($bak);
$contents = prefix ($contents);
my $out = new IO::File(">$file") or die;
print $out $contents;
}
process ("${prefix}gnulib.mk")
### Setup "GNU" style for perl-mode and cperl-mode.
## Local Variables:
## perl-indent-level: 2
## perl-continued-statement-offset: 2
## perl-continued-brace-offset: 0
## perl-brace-offset: 0
## perl-brace-imaginary-offset: 0
## perl-label-offset: -2
## cperl-indent-level: 2
## cperl-brace-offset: 0
## cperl-continued-brace-offset: 0
## cperl-label-offset: -2
## cperl-extra-newline-before-brace: t
## cperl-merge-trailing-else: nil
## cperl-continued-statement-offset: 2
## End:
-2
View File
@@ -1,2 +0,0 @@
Makefile
Makefile.in
-2
View File
@@ -1,2 +0,0 @@
/Makefile
/Makefile.in
-21
View File
@@ -1,21 +0,0 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-
## Copyright (C) 2005, 2009-2011 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if BISON_CXX_WORKS
SUBDIRS = calc++
endif
dist_noinst_SCRIPTS = extexi
+11
View File
@@ -0,0 +1,11 @@
*.cc
*.hh
*.ll
*.output
*.stamp
*.tmp
*.yy
.deps
Makefile
Makefile.in
calc++
+3 -3
View File
@@ -1,5 +1,5 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*- ## Process this file with automake to produce Makefile.in -*-Makefile-*-
## Copyright (C) 2005-2006, 2009-2011 Free Software Foundation, Inc. ## Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@ BISON = $(top_builddir)/tests/bison
BISON_IN = $(top_srcdir)/tests/bison.in BISON_IN = $(top_srcdir)/tests/bison.in
$(BISON): $(BISON_IN) $(BISON): $(BISON_IN)
cd $(top_builddir)/tests && $(MAKE) $(AM_MAKEFLAGS) bison cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) tests/bison
## ------------ ## ## ------------ ##
## Extracting. ## ## Extracting. ##
@@ -63,7 +63,7 @@ EXTRA_DIST = \
$(srcdir)/calc++-parser.stamp: $(srcdir)/calc++-parser.yy $(BISON_IN) $(srcdir)/calc++-parser.stamp: $(srcdir)/calc++-parser.yy $(BISON_IN)
@rm -f calc++-parser.tmp @rm -f calc++-parser.tmp
@touch calc++-parser.tmp @touch calc++-parser.tmp
$(BISON) -d -ra -S lalr1.cc -o $(srcdir)/calc++-parser.cc \ $(BISON) -d -ra -o $(srcdir)/calc++-parser.cc \
$(srcdir)/calc++-parser.yy $(srcdir)/calc++-parser.yy
@mv -f calc++-parser.tmp $@ @mv -f calc++-parser.tmp $@
+53 -5
View File
@@ -5,6 +5,42 @@ test -z "$VERBOSE" && {
set -x set -x
} }
me=`basename $0`
# Number of the current test.
number=1
# Exit status of this script.
exit=true
# run EXPECTED-EXIT-STATUS EXPECTED-OUTPUT [PARSER-OPTIONS]
# ---------------------------------------------------------
run ()
{
# Effective and expected exit status.
local sta_exp=$1
shift
local out_exp=$1
shift
./calc++ "$@" input >out_eff
local sta_eff=$?
local out_eff=`cat out_eff`
if test $sta_eff -eq $sta_exp; then
if test "$out_eff" = "$out_exp"; then
printf "$me: PASS: %2d\n" $number
else
printf "$me: FAIL: %2d (expected output: %s, effective: %s\n" \
$number "$out_exp" "$out_eff"
exit=false
fi
else
printf "$me: FAIL: %2d (expected status: %d, effective: %d\n" \
$number $sta_exp $sta_eff
exit=false
fi
number=`expr $number + 1`
}
cat >input <<EOF cat >input <<EOF
a := 1 a := 1
b := 2 b := 2
@@ -12,20 +48,32 @@ c := 3
d := a + b * c d := a + b * c
d d
EOF EOF
run 0 7
run 0 7 -p
cat >input <<EOF
a := 1
b := 2
c := 3
d := (a + b) * c
d
EOF
run 0 9
./calc++ input
./calc++ -p input
cat >input <<EOF cat >input <<EOF
a := 1 a := 1
d := a + b * c d := a + b * c
EOF EOF
./calc++ input run 1 '' input
cat >input <<EOF cat >input <<EOF
toto := 1 toto := 1
toto toto
EOF EOF
./calc++ -s input run 0 1 -s
rm input rm input out_eff
$exit
+1 -2
View File
@@ -1,8 +1,7 @@
# Extract all examples from the manual source. -*- AWK -*- # Extract all examples from the manual source. -*- AWK -*-
# This file is part of GNU Bison # This file is part of GNU Bison
# Copyright (C) 1992, 2000, 2001, 2005, 2006, 2009 Free Software
# Copyright (C) 1992, 2000-2001, 2005-2006, 2009-2011 Free Software
# Foundation, Inc. # Foundation, Inc.
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
+16
View File
@@ -0,0 +1,16 @@
## Copyright (C) 2005, 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
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
dist_noinst_SCRIPTS = examples/extexi
+124
View File
@@ -0,0 +1,124 @@
%skeleton "lalr1.cc"
%defines
%define parse.assert
%define parse.trace
%define variant
%define lex_symbol
%locations
%code requires // *.hh
{
#include <list>
#include <string>
typedef std::list<std::string> strings_type;
}
%code // *.cc
{
#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
// Prototype of the yylex function providing subsequent tokens.
static yy::parser::symbol_type yylex ();
// Printing a list of strings.
// Koening look up will look into std, since that's an std::list.
namespace std
{
std::ostream&
operator<< (std::ostream& o, const strings_type& s)
{
std::copy (s.begin (), s.end (),
std::ostream_iterator<strings_type::value_type> (o, "\n"));
return o;
}
}
// Conversion to string.
template <typename T>
inline
std::string
string_cast (const T& t)
{
std::ostringstream o;
o << t;
return o.str ();
}
}
%token <::std::string> TEXT;
%token <int> NUMBER;
%printer { debug_stream () << $$; }
<int> <::std::string> <::std::list<std::string>>;
%token END_OF_FILE 0;
%type <::std::string> item;
%type <::std::list<std::string>> list;
%%
result:
list { std::cout << $1 << std::endl; }
;
list:
/* nothing */ { /* Generates an empty string list */ }
| list item { std::swap ($$, $1); $$.push_back ($2); }
;
item:
TEXT { std::swap ($$, $1); }
| NUMBER { $$ = string_cast ($1); }
;
%%
// The yylex function providing subsequent tokens:
// TEXT "I have three numbers for you:"
// NUMBER 1
// NUMBER 2
// NUMBER 3
// TEXT " and that's all!"
// END_OF_FILE
static
yy::parser::symbol_type
yylex ()
{
static int stage = -1;
++stage;
yy::parser::location_type loc(0, stage + 1, stage + 1);
switch (stage)
{
case 0:
return yy::parser::make_TEXT ("I have three numbers for you.", loc);
case 1:
case 2:
case 3:
return yy::parser::make_NUMBER (stage, loc);
case 4:
return yy::parser::make_TEXT ("And that's all!", loc);
default:
return yy::parser::make_END_OF_FILE (loc);
}
}
// Mandatory error function
void
yy::parser::error (const yy::parser::location_type& loc, const std::string& msg)
{
std::cerr << loc << ": " << msg << std::endl;
}
int
main ()
{
yy::parser p;
p.set_debug_level (!!getenv ("YYDEBUG"));
return p.parse ();
}
// Local Variables:
// mode: C++
// End:
+1 -1
Submodule gnulib updated: eff4c0360a...3ef64012bf
+112
View File
@@ -0,0 +1,112 @@
.deps
Makefile
Makefile.in
argmatch.c
argmatch.h
basename.c
bitrotate.h
c-ctype.c
c-ctype.h
c-strcase.h
c-strcasecmp.c
c-strncasecmp.c
charset.alias
config.charset
config.h
config.hin
configmake.h
dirname.c
dirname.h
dup-safer.c
errno.in.h
error.c
error.h
exitfail.c
exitfail.h
fd-safer.c
fopen-safer.c
getopt.c
getopt.h
getopt.in.h
getopt1.c
getopt_.h
getopt_int.h
getpagesize.c
gettext.h
gnulib.mk
hash.c
hash.h
intprops.h
inttypes.h
inttypes.in.h
inttypes_.h
localcharset.c
localcharset.h
malloc.c
mbrtowc.c
mbsinit.c
mbswidth.c
mbswidth.h
memchr.c
memchr.valgrind
obstack.c
obstack.h
pipe-safer.c
quote.c
quote.h
quotearg.c
quotearg.h
ref-add.sed
ref-add.sin
ref-del.sed
ref-del.sin
stamp-h1
stdbool.h
stdbool.in.h
stdbool_.h
stddef.in.h
stdint.h
stdint.in.h
stdint_.h
stdio--.h
stdio-safer.h
stdlib.h
stdlib.in.h
stdlib_.h
stpcpy.c
streq.h
strerror.c
string.h
string.in.h
string_.h
stripslash.c
strndup.c
strnlen.c
strtol.c
strtoul.c
strverscmp.c
strverscmp.h
unistd--.h
unistd-safer.h
unistd.h
unistd.in.h
unistd_.h
unitypes.h
uniwidth
uniwidth.h
unlocked-io.h
unsetenv.c
verify.h
wchar.h
wchar.in.h
wchar_.h
wctype.h
wctype.in.h
wctype_.h
wcwidth.c
wcwidth.h
xalloc-die.c
xalloc.h
xmalloc.c
xstrndup.c
xstrndup.h
+12 -142
View File
@@ -1,78 +1,40 @@
/*.a /*.a
/*.bak
/*.o /*.o
/*~ /*~
/.deps /.deps
/.dirstamp
/Makefile /Makefile
/Makefile.in /Makefile.in
/alignof.h
/alloca.h
/alloca.in.h
/arg-nonnull.h
/argmatch.c /argmatch.c
/argmatch.h /argmatch.h
/asnprintf.c
/basename-lgpl.c
/basename.c /basename.c
/binary-io.h
/bitrotate.h /bitrotate.h
/c++defs.h
/c-ctype.c /c-ctype.c
/c-ctype.h /c-ctype.h
/c-strcase.h /c-strcase.h
/c-strcasecmp.c /c-strcasecmp.c
/c-strncasecmp.c /c-strncasecmp.c
/calloc.c
/charset.alias /charset.alias
/cloexec.c
/cloexec.h
/close-hook.c
/close-hook.h
/close.c
/config.charset /config.charset
/config.h /config.h
/config.hin /config.hin
/configmake.h /configmake.h
/dirname-lgpl.c
/dirname.c /dirname.c
/dirname.h /dirname.h
/dosname.h
/dup-safer-flag.c
/dup-safer.c /dup-safer.c
/dup2.c
/errno.h
/errno.in.h /errno.in.h
/error.c /error.c
/error.h /error.h
/exitfail.c /exitfail.c
/exitfail.h /exitfail.h
/fatal-signal.c
/fatal-signal.h
/fclose.c
/fcntl.c
/fcntl.h
/fcntl.in.h
/fd-safer-flag.c
/fd-safer.c /fd-safer.c
/float+.h
/float.h
/float.in.h
/fopen-safer.c /fopen-safer.c
/fopen.c
/fprintf.c
/fpucw.h
/frexp.c
/frexpl.c
/fseterr.c
/fseterr.h
/getdtablesize.c
/getopt.c /getopt.c
/getopt.h /getopt.h
/getopt.in.h /getopt.in.h
/getopt1.c /getopt1.c
/getopt_.h
/getopt_int.h /getopt_int.h
/getpagesize.c
/gettext.h /gettext.h
/gnulib.mk /gnulib.mk
/hash.c /hash.c
@@ -80,166 +42,74 @@
/intprops.h /intprops.h
/inttypes.h /inttypes.h
/inttypes.in.h /inttypes.in.h
/ioctl.c /inttypes_.h
/isnan.c
/isnand-nolibm.h
/isnand.c
/isnanf-nolibm.h
/isnanf.c
/isnanl-nolibm.h
/isnanl.c
/iswblank.c
/ldexpl.c
/localcharset.c /localcharset.c
/localcharset.h /localcharset.h
/malloc.c /malloc.c
/math.h
/math.in.h
/mbchar.c
/mbchar.h
/mbrtowc.c /mbrtowc.c
/mbschr.c
/mbsinit.c /mbsinit.c
/mbsrchr.c
/mbswidth.c /mbswidth.c
/mbswidth.h /mbswidth.h
/mbuiter.h
/memchr.c /memchr.c
/memchr.valgrind /memchr.valgrind
/nonblocking.c
/nonblocking.h
/obstack.c /obstack.c
/obstack.h /obstack.h
/open.c
/perror.c
/pipe-safer.c /pipe-safer.c
/pipe.c
/pipe2-safer.c
/pipe2.c
/printf-args.c
/printf-args.h
/printf-frexp.c
/printf-frexp.h
/printf-frexpl.c
/printf-frexpl.h
/printf-parse.c
/printf-parse.h
/printf.c
/quote.c /quote.c
/quote.h /quote.h
/quotearg.c /quotearg.c
/quotearg.h /quotearg.h
/rawmemchr.c
/rawmemchr.valgrind
/realloc.c
/ref-add.sed /ref-add.sed
/ref-add.sin /ref-add.sin
/ref-del.sed /ref-del.sed
/ref-del.sin /ref-del.sin
/sched.h
/sched.in.h
/sig-handler.h
/sigaction.c
/signal.h
/signal.in.h
/signbitd.c
/signbitf.c
/signbitl.c
/sigprocmask.c
/size_max.h
/snprintf.c
/spawn-pipe.c
/spawn-pipe.h
/spawn.h
/spawn.in.h
/spawn_faction_addclose.c
/spawn_faction_adddup2.c
/spawn_faction_addopen.c
/spawn_faction_destroy.c
/spawn_faction_init.c
/spawn_int.h
/spawnattr_destroy.c
/spawnattr_init.c
/spawnattr_setflags.c
/spawnattr_setsigmask.c
/spawni.c
/spawnp.c
/sprintf.c
/stamp-h1 /stamp-h1
/stat.c
/stdbool.h /stdbool.h
/stdbool.in.h /stdbool.in.h
/stddef.h /stdbool_.h
/stddef.in.h /stddef.in.h
/stdint.h /stdint.h
/stdint.in.h /stdint.in.h
/stdint_.h
/stdio--.h /stdio--.h
/stdio-impl.h
/stdio-safer.h /stdio-safer.h
/stdio-write.c
/stdio.h
/stdio.in.h
/stdlib.h /stdlib.h
/stdlib.in.h /stdlib.in.h
/stdlib_.h
/stpcpy.c /stpcpy.c
/strchrnul.c
/strchrnul.valgrind
/strdup.c
/streq.h /streq.h
/strerror.c /strerror.c
/string.h /string.h
/string.in.h /string.in.h
/string_.h
/stripslash.c /stripslash.c
/strndup.c /strndup.c
/strnlen.c /strnlen.c
/strnlen1.c
/strnlen1.h
/strtol.c /strtol.c
/strtoul.c /strtoul.c
/strverscmp.c /strverscmp.c
/sys /strverscmp.h
/sys_ioctl.h
/sys_ioctl.in.h
/sys_socket.h
/sys_socket.in.h
/sys_stat.h
/sys_stat.in.h
/sys_wait.h
/sys_wait.in.h
/time.h
/time.in.h
/unistd--.h /unistd--.h
/unistd-safer.h /unistd-safer.h
/unistd.h /unistd.h
/unistd.in.h /unistd.in.h
/unistd_.h
/unitypes.h /unitypes.h
/unitypes.in.h
/uniwidth /uniwidth
/uniwidth.h /uniwidth.h
/uniwidth.in.h
/unlocked-io.h /unlocked-io.h
/unsetenv.c /unsetenv.c
/vasnprintf.c
/vasnprintf.h
/verify.h /verify.h
/vfprintf.c
/vsnprintf.c
/vsprintf.c
/w32sock.h
/w32spawn.h
/wait-process.c
/wait-process.h
/waitpid.c
/warn-on-use.h
/wchar.h /wchar.h
/wchar.in.h /wchar.in.h
/wchar_.h
/wctype.h /wctype.h
/wctype.in.h /wctype.in.h
/wctype_.h
/wcwidth.c /wcwidth.c
/wcwidth.h
/xalloc-die.c /xalloc-die.c
/xalloc.h /xalloc.h
/xmalloc.c /xmalloc.c
/xsize.h
/xstrndup.c /xstrndup.c
/xstrndup.h /xstrndup.h
-45
View File
@@ -1,45 +0,0 @@
# Make bison/lib.
# Copyright (C) 2001-2004, 2006, 2008-2011 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
include gnulib.mk
AM_CFLAGS += $(WARN_CFLAGS)
# Implementation of bitsets.
bitsets_sources = \
abitset.c abitset.h bbitset.h bitset.c bitset.h bitset_stats.c \
bitset_stats.h bitsetv.c bitsetv.h ebitset.c ebitset.h lbitset.c \
lbitset.h libiberty.h vbitset.c vbitset.h
# Additional bitset operations.
additional_bitsets_sources = \
bitsetv-print.h bitsetv-print.c
# timevars, stolen from GCC.
timevars_sources = \
timevar.h timevar.c timevar.def
# Non-gnulib sources in Bison's internal library.
libbison_a_SOURCES += \
get-errno.h get-errno.c \
$(bitsets_sources) $(additional_bitsets_sources) $(timevars_sources)
# The Yacc compatibility library.
lib_LIBRARIES = $(YACC_LIBRARY)
EXTRA_LIBRARIES = liby.a
liby_a_SOURCES = main.c yyerror.c
+1 -4
View File
@@ -1,8 +1,5 @@
/* Array bitsets. /* Array bitsets.
Copyright (C) 2002, 2003, 2006, 2009 Free Software Foundation, Inc.
Copyright (C) 2002-2003, 2006, 2009-2011 Free Software Foundation,
Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
+1 -3
View File
@@ -1,7 +1,5 @@
/* Functions to support abitsets. /* Functions to support abitsets.
Copyright (C) 2002, 2004, 2009 Free Software Foundation, Inc.
Copyright (C) 2002, 2004, 2009-2011 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
+1 -3
View File
@@ -1,8 +1,6 @@
/* Base bitset stuff. /* Base bitset stuff.
Copyright (C) 2002, 2003, 2004, 2006, 2009 Free Software Foundation,
Copyright (C) 2002-2004, 2006, 2009-2011 Free Software Foundation,
Inc. Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
+2 -3
View File
@@ -1,7 +1,6 @@
/* General bitsets. /* General bitsets.
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2009 Free Software
Copyright (C) 2002-2006, 2009-2011 Free Software Foundation, Inc. Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
+1 -3
View File
@@ -1,7 +1,5 @@
/* Generic bitsets. /* Generic bitsets.
Copyright (C) 2002, 2003, 2004, 2009 Free Software Foundation, Inc.
Copyright (C) 2002-2004, 2009-2011 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
+2 -3
View File
@@ -1,7 +1,6 @@
/* Bitset statistics. /* Bitset statistics.
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2009 Free Software
Copyright (C) 2002-2006, 2009-2011 Free Software Foundation, Inc. Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
+1 -3
View File
@@ -1,7 +1,5 @@
/* Functions to support bitset statistics. /* Functions to support bitset statistics.
Copyright (C) 2002, 2003, 2004, 2009 Free Software Foundation, Inc.
Copyright (C) 2002-2004, 2009-2011 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
+2 -3
View File
@@ -1,7 +1,6 @@
/* Bitset vectors. /* Bitset vectors.
Copyright (C) 2001, 2002, 2004, 2006, 2009 Free Software Foundation,
Copyright (C) 2001-2002, 2004, 2006, 2009-2011 Free Software Inc.
Foundation, Inc.
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
+1 -3
View File
@@ -1,7 +1,5 @@
/* Bitset vectors. /* Bitset vectors.
Copyright (C) 2002, 2004, 2009 Free Software Foundation, Inc.
Copyright (C) 2002, 2004, 2009-2011 Free Software Foundation, Inc.
Contributed by Akim Demaille (akim@freefriends.org). Contributed by Akim Demaille (akim@freefriends.org).
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
+1 -2
View File
@@ -1,6 +1,5 @@
/* Bitset vectors. /* Bitset vectors.
Copyright (C) 2001, 2002, 2004, 2005, 2006, 2009 Free Software
Copyright (C) 2001-2002, 2004-2006, 2009-2011 Free Software
Foundation, Inc. Foundation, Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
+1 -3
View File
@@ -1,7 +1,5 @@
/* Bitset vectors. /* Bitset vectors.
Copyright (C) 2002, 2004, 2009 Free Software Foundation, Inc.
Copyright (C) 2002, 2004, 2009-2011 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
+2 -3
View File
@@ -1,7 +1,6 @@
/* Functions to support expandable bitsets. /* Functions to support expandable bitsets.
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2009 Free Software
Copyright (C) 2002-2006, 2009-2011 Free Software Foundation, Inc. Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
+1 -3
View File
@@ -1,7 +1,5 @@
/* Functions to support ebitsets. /* Functions to support ebitsets.
Copyright (C) 2002, 2004, 2009 Free Software Foundation, Inc.
Copyright (C) 2002, 2004, 2009-2011 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify

Some files were not shown because too many files have changed in this diff Show More