Commit Graph

336 Commits

Author SHA1 Message Date
Akim Demaille
6687da3425 output: no longer use b4_tokens.
* data/glr.c, data/glr.cc, data/lalr1.cc, data/lalr1.java, data/yacc.c:
Since the previous commit, b4_tokens_define and the like no longer need
b4_tokens.
* src/output.c (token_definitions_output): Remove.
2012-07-22 17:01:15 +02:00
Akim Demaille
60aa04a236 Merge remote-tracking branch 'origin/maint'
* origin/maint:
  maint: update release instructions
  maint: post-release administrivia
  version 2.5.90
  build: fix gen-ChangeLog call.
  gnulib: update.
  tests: fix SKIP_IF for Java.
  api.prefix: incompatible with %name-prefix.
  api.prefix: strengthen the tests and fix push-parsers.
  skeletons: style changes.
  NEWS: minor changes.
  api.prefix: improve the documentation for YYDEBUG.
  gnulib: update.

Conflicts:
	NEWS
	cfg.mk
	data/bison.m4
	doc/bison.texi
	m4/.gitignore
	tests/calc.at
	tests/headers.at
2012-07-06 11:00:57 +02:00
Akim Demaille
ad60e80f3d api.prefix: strengthen the tests and fix push-parsers.
* tests/calc.at: Check api.prefix in addition to %name-prefix.
* tests/headers.at: Check push parsers and pure interface.
* tests/local.at: Use YYLTYPE renamed.
* data/yacc.c (b4_declare_yyparse_push_): Handle api.prefix.
* doc/bison.texi: Style changes.
2012-07-05 12:41:15 +02:00
Akim Demaille
ccdc1577ef Merge remote-tracking branch 'origin/maint'
* origin/maint:
  tests: headers.at: strengthen.
  glr.cc: do not override C++ definitions by C macros.
  YYLLOC_DEFAULT: factor, and don't export it in headers.
  api.prefix: do not use #define to handle YYSTYPE_IS_TRIVIAL etc.
  tests: portability fixes.
  c++: fewer #includes in the headers.
  glr.cc: formatting changes.
  tests: more logs.
  api.prefix: also rename YYDEBUG.

Conflicts:
	data/c.m4
	data/glr.c
	data/glr.cc
	data/lalr1.cc
	data/yacc.c
2012-07-04 17:34:57 +02:00
Akim Demaille
426903aa75 YYLLOC_DEFAULT: factor, and don't export it in headers.
* data/c++.m4, data/c.m4 (b4_yylloc_default_define): New.
* data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c: Use it.
* data/glr.cc: Do not define YYLLOC_DEFAULT in the header file,
but in the implementation one.
2012-07-04 12:24:13 +02:00
Akim Demaille
9104636b03 api.prefix: do not use #define to handle YYSTYPE_IS_TRIVIAL etc.
The following mixture is insane:

  #define YYSTYPE_IS_TRIVIAL PREFIX_STYPE_IS_TRIVIAL
  #if (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)

since, of course YYSTYPE_IS_TRIVIAL is defined.  Instead we could
define YYSTYPE_IS_TRIVIAL as PREFIX_STYPE_IS_TRIVIAL only when the
later is defined, but let's avoid stacking CPP on top of M4: rather, use

  #if (defined PREFIX_STYPE_IS_TRIVIAL && PREFIX_STYPE_IS_TRIVIAL)

* data/glr.c, data/yacc.c: Use YYSTYPE_IS_TRIVIAL, YYSTYPE_IS_DECLARED,
YYLTYPE_IS_TRIVIAL and YYLTYPE_IS_DECLARED under their api.prefix-renamed
name.
2012-07-04 12:24:13 +02:00
Akim Demaille
5f108727a1 api.prefix: also rename YYDEBUG.
The testsuite in master has shown weird errors for the "Mulitple
Parsers" tests: the caller of p5.parse() received some apparently
random value, while tracing p5.parse() showed that the function was
consistently returning 0.

It happens when mixing several parser headers, some generated without
%debug, others with.  In particular the C++ parser was generated with
%debug, i.e., with:

  #ifndef YYDEBUG
  # define YYDEBUG 1
  #endif

and compiled separatedly.  Yet, its header was included after the one
of another parser, this time without %debug, i.e., with

  #ifndef YYDEBUG
  # define YYDEBUG 0
  #endif

in its header.  As a result, the parser was compiled with YYDEBUG set,
but its header was used without.  Since the layout of the objects are
then completely different, boom.

Therefore, do not change the value of YYDEBUG.  Rather, use it as a
default value for <API.PREFIX>DEBUG.

* data/c.m4 (b4_YYDEBUG_define): New.
(b4_declare_yydebug): Rename as...
(b4_yydebug_declare): this, for consistency.
* data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c: Use it.
* NEWS: Document it.
2012-07-04 12:24:12 +02:00
Akim Demaille
5458913aba Merge remote-tracking branch 'origin/maint'
* origin/maint:
  NEWS: spell check.
  api.prefix.

Conflicts:
	data/c.m4
	data/glr.cc
	data/lalr1.cc
	doc/bison.texi
2012-07-02 09:56:01 +02:00
Akim Demaille
4b3847c3c0 api.prefix.
* data/c.m4 (b4_api_prefix, b4_api_PREFIX): New.
(b4_prefix, b4_union_name, b4_token_enums, b4_declare_yylstype): Use them.
* data/glr.c, data/yacc.c, data/glr.cc, data/lalr1.cc: Use them to change
the prefix of exported preprocessor symbols.
* src/getargs.c (usage): Ditto.
* tests/headers.at (Several parsers): New.
* tests/local.at (AT_API_PREFIX): New.
AT_YYSTYPE, AT_YYLTYPE): Adjust.
* doc/bison.texi (Multiple Parsers): Move documentation of %name-prefix to...
(Table of Symbols): here.
(Multiple Parsers): Document api.prefix.
(%define Summary): Point to it.
Use @code for variable names.
(Bison Options): -p/--name-prefix are obsoleted.
* NEWS: Announce api.prefix.
2012-06-29 17:40:42 +02:00
Akim Demaille
7aaaad6c6d Merge remote-tracking branch 'origin/maint'
* origin/maint:
  tests: use the generalized default yylex.
  tests: AT_YYERROR_DEFINE: prepare for list of ints.
  skeletons: no longer define YYLSP_NEEDED.
  c++: do not export YYTOKEN_TABLE and YYERROR_VERBOSE.

Conflicts:
	data/c.m4
	data/glr.cc
	data/lalr1.cc
	doc/bison.texi
	tests/regression.at
2012-06-28 15:42:00 +02:00
Akim Demaille
258cddbc36 c++: do not export YYTOKEN_TABLE and YYERROR_VERBOSE.
* src/output.c (prepare_symbols): Do not define b4_token_table.
(prepare): Define b4_token_table_flag.
* data/bison.m4 (b4_token_table_if): New.
Arm it when error-verbose.
* data/glr.c, data/yacc.c (YYTOKEN_TABLE): Remove.
Use m4.
* data/lalr1.cc: Likewise.
(YYERROR_VERBOSE): Remove.
* NEWS, doc/bison.texi: Document this.
2012-06-27 10:03:21 +02:00
Akim Demaille
297e263a00 Merge remote-tracking branch 'origin/maint'
* origin/maint:
  tests: do not output m4 set up.
  tests: use the generic yyerror function.
  tests: use assert instead of plain abort.
  tests: improve the generic yylex implementation.
  tests: generalize the compilation macros.
  tests: fix confusion between api.prefix and name-prefix.
  maint: gitignores.
  yacc: work around the ylwrap limitation.

Conflicts:
	NEWS
	tests/local.at
2012-06-26 16:44:59 +02:00
Akim Demaille
55d1006fce yacc: work around the ylwrap limitation.
* data/yacc.c (b4_shared_declarations): Include the header guards.
Do not include the header in the *.c file, duplicate it.
* NEWS (Future Changes): Extend, and announce the forthcoming change
about the use of the parser header.
2012-06-25 10:20:56 +02:00
Akim Demaille
6cf3716c31 Merge remote-tracking branch 'origin/maint'
* origin/maint:
  tests: more uniformity.
  tests: handle locations in a more generic way.
  tests: handle locations in the generic yyerror functions.
  tests: fix AT_CHECK_CALC.
  tests: improve infrastructure
  tests: factor.
  skeletons: minor style changes
  tests: AT_LANG.
  c skeletons: factor the declaration of yylloc and yylval.
  news: condemn YYPARSE_PARAM and YYLEX_PARAM.
  maint: regen.

Conflicts:
	tests/calc.at
	tests/local.at
	tests/regression.at
2012-06-25 09:46:34 +02:00
Akim Demaille
6e2d7b0974 skeletons: minor style changes
* data/glr.c, data/yacc.c: here.
2012-06-21 17:08:11 +02:00
Akim Demaille
756257ee86 c skeletons: factor the declaration of yylloc and yylval.
There is one difference: now, even without --defines, we generate
extern declarations for these variables.  The factoring is worth it.
* data/c.m4 (b4_declare_yylstype): Declare them.
* data/glr.c, data/yacc.c: Adjust.
2012-06-21 15:19:43 +02:00
Akim Demaille
e436fa677c Merge remote-tracking branch 'origin/maint'
* origin/maint:
  maint: formatting changes.
  tests: support api.prefix.
  tests: pacify font-lock-mode.
  tests: remove test covered elsewhere.
  tests: factor the declaration/definition of yyerror and yylex.
  regen.
  tests: portability issues.
  tests: call the parser from another compilation unit.
  glr.c, yacc.c: declare yydebug in the header.
  skeletons: use header guards.
  tests: improve AT_FULL_COMPILE.
  tests: reorder.
  tests: strengthen the test on generated headers inclusion
  yacc.c: instead of duplicating y.tab.h inside y.tac.c, include it.
  yacc.c: factor.

Conflicts:
	NEWS
	data/glr.c
	data/yacc.c
	src/parse-gram.c
	src/parse-gram.h
	tests/conflicts.at
	tests/regression.at
2012-06-19 18:17:09 +02:00
Akim Demaille
56ca3d8fce glr.c, yacc.c: declare yydebug in the header.
* data/c.m4 (b4_declare_yydebug): New.
* data/glr.c, data/yacc.c (b4_shared_declarations): Use it.
Remove the corresponding code from the parser body.
* NEWS: Doc this.
2012-06-15 15:33:14 +02:00
Akim Demaille
c3e9f08f93 skeletons: use header guards.
* data/glr.c, data/glr.cc, data/yacc.c: here.
* NEWS: Document it.
2012-06-15 15:33:14 +02:00
Akim Demaille
0f11eec272 yacc.c: instead of duplicating y.tab.h inside y.tac.c, include it.
This is already what glr.c and lalr1.cc do.

* data/yacc.c: here.
2012-06-15 13:31:34 +02:00
Akim Demaille
ae6bdabbf6 yacc.c: factor.
yacc.c used to include two almost identical sections: one for the *.h
file, and another for the *.c file.  The main difference is that in
the *.c file we used the yy* names (as %name-prefix is handled by
"#define yy* <prefix>*" before), while the *.hh used <prefix>* names.
Keep only the later.  If this is troublesome, b4_shared_declarations
can easily take the desired prefix as argument.

* data/yacc.c (b4_shared_declarations): New.
Use it to factor duplicated declarations.
2012-06-13 21:52:38 +02:00
Akim Demaille
9ce27ab013 Merge remote-tracking branch 'origin/maint'
* origin/maint:
  skeletons: factor yacc.c and glr.c.
  glr.c: minor refactoring.
  tests: remove all the -On flags.
  maint: fix spello.
  maint: improve release procedure instructions.
  gnulib: update readme-release.
  maint: cfg.mk: manual title.
  maint: cfg.mk: simplify
  maint: post-release administrivia

Conflicts:
	NEWS
	bootstrap.conf
2012-06-13 21:03:29 +02:00
Akim Demaille
c0828abf9d skeletons: factor yacc.c and glr.c.
yacc.c and glr.c share common declarations.  Their YYLTYPE are exactly
equal, and their YYSTYPE are sufficiently alike to be fused (its
declaration was protected by YYSTYPE_IS_DECLARED in yacc.c, but not in
glr.c).  Besides, yacc.c duplicated the definitions of YYLTYPE and
YYSTYPE (*.h/*.c).

* data/c.m4 (b4_declare_yylstype): New.
* data/yacc.c, data/glr.c: Use it.
2012-06-12 14:49:48 +02:00
Akim Demaille
527187137a Merge remote-tracking branch 'origin/maint'
* origin/maint:
  version 2.5.1
  NEWS: prepare for 2.5.1.
  maint: update release procedure
  maint: fix comment typos
  maint: post-release administrivia

Conflicts:
	NEWS
2012-06-05 14:07:43 +02:00
Jim Meyering
cbdb6d9145 maint: fix comment typos
Using http://github.com/lyda/misspell-check, massage its
output into sed commands to perform the suggested changes.
Initially, I filtered out the THRU->Through changes, because
that failed to retain capitalization in the grammar token.
Instead, do this manually, beforehand:

sed -i s/THRU/THROUGH/ tests/existing.at
git ls-files|misspellings -f -|perl -nl \
  -e '/^(.*?)\[(\d+)\]: (\w+) -> "(.*?)"$/ or next;' \
  -e '($file,$n,$l,$r)=($1,$2,$3,$4); $q="'\''"; $r=~s/$q/$q\\$q$q/g;'\
  -e 'print "sed -i $q${n}s!$l!$r!$q $file"'|bash
2012-06-05 09:17:43 +02:00
Akim Demaille
6557bcce8b c++: more YY_NULL
Caught by maintainer-check-g++.
* data/glr.c, data/lalr1.cc, data/yacc.c, tests/cxx-type.at,
* tests/glr-regression.at, tests/push.at:
When simple to do, avoid expliciting the null ptr.
Otherwise use YY_NULL.
(cherry picked from commit eeaf1dc646)

Conflicts:

	data/glr.c
	data/lalr1.cc
	tests/cxx-type.at
2012-04-01 14:02:27 +02:00
Akim Demaille
eeaf1dc646 c++: more YY_NULL
Caught by maintainer-check-g++.
* data/glr.c, data/lalr1.cc, data/yacc.c, tests/cxx-type.at,
* tests/glr-regression.at, tests/push.at:
When simple to do, avoid expliciting the null ptr.
Otherwise use YY_NULL.
2012-04-01 13:42:46 +02:00
Akim Demaille
3e75a2c92b Merge remote-tracking branch 'origin/maint'
* origin/maint:
  bump to 2012 in skeletons.
  build: remove ancient Autoconf tests.
  doc: c++: complete the location documentation.
  c++: locations: provide convenience constructors.
  c++: locations: remove useless "inline".
  glr: do not use locations when they are not requested
  c++: use nullptr for C++11.
  build: simplify and improve the compiler warnings for tests.
  gnulib: update.
  maint: formatting changes.
  NEWS: update.
  Java: Fix syntax error handling without error token.
  tests: beware of -pedantic on large #line numbers.
  tests: when using the C++ compiler, use its flags too.

Conflicts:
	data/glr.c
	data/glr.cc
	data/lalr1.cc
	data/location.cc
	data/yacc.c
	tests/Makefile.am
2012-04-01 13:14:34 +02:00
Akim Demaille
681dda24ba bump to 2012 in skeletons.
* data/glr.c, data/glr.cc, data/lalr1.cc, data/lalr1.java,
* data/location.cc, data/yacc.c: Bump copyright year ranges.
2012-04-01 12:16:46 +02:00
Akim Demaille
ef51bfa744 c++: use nullptr for C++11.
C++11 introduces "nullptr" which plays the role of C's NULL, in
replacement of "0".  Fix the C++ skeletons to avoid warnings about
uses of "0" in place of "nullptr", and improve C skeletons to also use
this "nullptr" when compiled with a C++11 compiler.

* configure.ac: More C++ warnings.
* NEWS (2.5.1): Document this.
* data/c++.m4, data/c.m4 (b4_null_define): New.
(b4_null): Use YY_NULL instead of 0.
* data/glr.c, data/lalr1.cc, data/location.cc, data/yacc.c:
Call b4_null_define/b4_null where appropriate.
Use YY_NULL instead of NULL.
* data/location.cc (initialize): Accept a default argument,
YY_NULL.
* tests/actions.at, tests/calc.at: Adjust.

* data/glr.c, lib/libiberty.h, src/system.h (__attribute__):
Do not disable it when __STRICT_ANSI__ is defined, as, for
instance, it disables the __attribute__((unused)) which
protects us from some compiler warnings.
This was already done elsewhere in Bison, in 2001, see
4a0d893695.
* tests/regression.at: Adjust output.
2012-03-31 11:12:28 +02:00
Akim Demaille
14f4455e43 maint: address sc_prohibit_doubled_word.
* data/yacc.c, doc/bison.texinfo: Reword to avoid having to
	disable that check.
	* cfg.mk: No longer skip this test.
(cherry picked from commit 762caaf639)

Conflicts:

	data/yacc.c
2012-02-19 18:26:01 +01:00
Akim Demaille
43e9e2a113 maint: address sc_prohibit_always-defined_macros.
* cfg.mk: No longer skip it, except where EXIT_SUCCESS is used
	as a witness for stdlib.h.
	Skip this test when appropriate.
	* data/yacc.c: Drop a note about why EXIT_SUCCESS is defined here.

Conflicts:

	cfg.mk
2012-02-19 18:25:24 +01:00
Akim Demaille
762caaf639 maint: address sc_prohibit_doubled_word.
* data/yacc.c, doc/bison.texinfo: Reword to avoid having to
	disable that check.
	* cfg.mk: No longer skip this test.
2012-02-19 12:54:09 +01:00
Akim Demaille
db3458d6ea maint: address sc_prohibit_always-defined_macros.
* cfg.mk: No longer skip it, except where EXIT_SUCCESS is used
	as a witness for stdlib.h.
	Skip this test when appropriate.
	* data/yacc.c: Drop a note about why EXIT_SUCCESS is defined here.
2012-02-19 12:54:06 +01:00
Akim Demaille
24bb5f8fb7 maint: fix some syntax-check issues.
* cfg.mk (local-checks-to-skip): Remove
	sc_prohibit_quotearg_without_use, sc_prohibit_strcmp,
	sc_unmarked_diagnostics, sc_useless_cpp_parens.
	(sc_unmarked_diagnostics): Skip DJGPP.
	* data/yacc.c, src/LR0.c, src/closure.c,
	* src/flex-scanner.h, src/gram.c, src/lalr.c,
	* src/print-xml.c, src/print.c, src/print_graph.c,
	* src/reader.c, src/reduce.c, src/tables.c:
	Don't use parens with cpp's defined.
	Remove useless includes.
2012-02-19 10:21:06 +01:00
Akim Demaille
eff97eb54a maint: fix some syntax-check issues.
* cfg.mk (local-checks-to-skip): Remove
	sc_prohibit_quotearg_without_use, sc_prohibit_strcmp,
	sc_unmarked_diagnostics, sc_useless_cpp_parens.
	(sc_unmarked_diagnostics): Skip DJGPP.
	* data/yacc.c, src/LR0.c, src/closure.c,
	* src/flex-scanner.h, src/gram.c, src/lalr.c,
	* src/print-xml.c, src/print.c, src/print_graph.c,
	* src/reader.c, src/reduce.c, src/tables.c:
	Don't use parens with cpp's defined.
	Remove useless includes.
2012-02-18 18:48:33 +01:00
Akim Demaille
94556574b5 yacc: fix YYBACKUP.
Reported by David Kastrup:
https://lists.gnu.org/archive/html/bug-bison/2011-10/msg00002.html.

	* data/yacc.c (YYBACKUP): Accept rhs size.
	Restore the proper state value.
	* TODO (YYBACKUP): Make it...
	* tests/actions.at: a new test case.
	* NEWS, THANKS: Update.
(cherry picked from commit d115aad911)

Conflicts:

	TODO
	data/yacc.c
2012-01-26 21:36:35 +01:00
Akim Demaille
d115aad911 yacc: fix YYBACKUP.
Reported by David Kastrup:
https://lists.gnu.org/archive/html/bug-bison/2011-10/msg00002.html.

	* data/yacc.c (YYBACKUP): Accept rhs size.
	Restore the proper state value.
	* TODO (YYBACKUP): Make it...
	* tests/actions.at: a new test case.
	* NEWS, THANKS: Update.
2012-01-26 21:18:24 +01:00
Akim Demaille
c932d6135c maint: run "make update-copyright". 2012-01-13 11:48:14 +01:00
Jim Meyering
34136e65fc maint: run "make update-copyright". 2012-01-13 10:09:44 +01:00
Joel E. Denny
e969014232 global: remove unnecessary horizontal tabs.
This change was made by applying emacs' untabify function to
nearly all files in Bison's repository.  Required tabs in make
files, ChangeLog, regexps, and test code were manually skipped.
Other notable exceptions and changes are listed below.
* bootstrap: Skip because we sync this with gnulib.
* data/m4sugar/foreach.m4
* data/m4sugar/m4sugar.m4: Skip because we sync these with
Autoconf.
* djgpp: Skip because I don't know how to test djgpp properly, and
this code appears to be unmaintained anyway.
* README-hacking (Hacking): Specify that tabs should be avoided
where not required.
2011-07-24 18:13:05 -04:00
Joel E. Denny
fe3cae17a1 * data/yacc.c: Fix last apostrophe warning from xgettext.
(cherry picked from commit 448dc38bc4)

Conflicts:

	data/yacc.c
	src/parse-gram.c
	src/parse-gram.h
2011-01-24 21:46:45 -05:00
Joel E. Denny
448dc38bc4 * data/yacc.c: Fix last apostrophe warning from xgettext. 2011-01-24 21:14:46 -05:00
Paul Eggert
7e5ef70679 Fix minor problems encountered by a fresh bootstrap.
* data/glr.c, data/yacc.c: Do not use apostrophes in '#' comments,
as they confuse xgettext, which tries to parse them as C character
constants in a preprocessor directive.
* data/yacc.c (yy_lac): Don't use printf %d format on *yyesp, as
that expression might not promote to int on some platforms.
* src/parse-gram.c, src/parse-gram.h: Regenerate.
(cherry picked from commit 3c9b20ff5a)

Conflicts:

	data/yacc.c
	src/parse-gram.c
	src/parse-gram.h
2011-01-24 20:53:51 -05:00
Paul Eggert
3c9b20ff5a Fix minor problems encountered by a fresh bootstrap.
* data/glr.c, data/yacc.c: Do not use apostrophes in '#' comments,
as they confuse xgettext, which tries to parse them as C character
constants in a preprocessor directive.
* data/yacc.c (yy_lac): Don't use printf %d format on *yyesp, as
that expression might not promote to int on some platforms.
* src/parse-gram.c, src/parse-gram.h: Regenerate.
2011-01-09 17:09:03 -08:00
Joel E. Denny
575619af5e maint: run "make update-copyright". 2011-01-02 10:02:43 -05:00
Joel E. Denny
ea0a767697 maint: run "make update-copyright". 2011-01-02 09:56:16 -05:00
Joel E. Denny
723fe7d18a parse.lac: implement exploratory stack reallocations.
* data/yacc.c: Rename %define variable parse.lac.es-capacity to
parse.lac.es-capacity-initial.  Accept parse.lac.memory-trace
with values of "failures" (default) or "full".
(b4_declare_parser_state_variables): Add yyesa, yyes, and
yyes_capacity variables.
(YYSTACK_USE_ALLOCA): Ignore it if LAC requested.
(YYSTACK_ALLOC, YYSTACK_FREE, YYSTACK_ALLOC_MAXIMUM): Define if
LAC requested.
(YYCOPY_NEEDED): New cpp macro.
(YYCOPY): Define if LAC requested.
(yy_lac_stack_realloc): New function implementing stack
reallocations.  Use YYMAXDEPTH for maximum stack size given that
the stack should never need to grow larger than the main state
stack needs to grow without LAC.
(YY_LAC_ESTABLISH): Update yy_lac invocation.
(yy_lac): Add arguments for exploratory stack memory data
recorded in the main parser.  Invoke yy_lac_stack_realloc when
reallocation is necessary.
(yysyntax_error): Add the same new arguments and pass them to
yy_lac.
(yypstate_delete): Free yyes if necessary.
(yyesa, yyes, yyes_capacity): #define these to yypstate members
in the case of push parsing.
(yyparse, yypush_parse): Initialize yyes and yyes_capacity.
Update yysyntax_error invocations.  At yyreturn, free yyes if
necessary.
* src/parse-gram.y: %define parse.lac full.
* tests/input.at (LAC: errors for %define): Extend for
parse.lac-memory-trace.
* tests/regression.at (LAC: Exploratory stack): Extend to check
that stack reallocs happen when expected.
(LAC: Memory exhaustion): Update to use YYMAXDEPTH and
parse.lac.es-capacity-initial.
(cherry picked from commit 107844a3ee)

Conflicts:

	src/parse-gram.c
	src/parse-gram.h
	src/parse-gram.y
2010-12-23 21:27:42 -05:00
Joel E. Denny
ea13bea8ab parse.lac: implement as %define variable.
LAC = lookahead correction.  See discussion at
<http://lists.gnu.org/archive/html/bison-patches/2009-09/msg00034.html>.
However, one point there must be corrected: because of %nonassoc,
LAC is *not* always redundant for lr.type=canonical-lr.
* data/yacc.c: Accept values of "none" (default) or "full" for
parse.lac.  Accept %define parse.lac.es-capacity to specify
capacity of LAC's temporary exploratory stack.  It defaults to 20
and, for now, will not grow dynamically.
(b4_lac_flag, b4_lac_if): New m4 macros.  Evaluate as true for
parse.lac!=none.
(YYBACKUP): Invoke YY_LAC_DISCARD.
(YY_LAC_ESTABLISH, YY_LAC_DISCARD): New cpp macros that invoke
yy_lac and track when it needs to be invoked
(yy_lac): New function that, given the current stack, determines
whether a token can eventually be shifted.  Return status mimics
yyparse return status.
(yysyntax_error): Change yystate argument to yyssp so stack top
can be passed to yy_lac.  If LAC is requested, build expected
token list by invoking yy_lac for every token instead of just
checking the current state for lookaheads.  Return 2 if yy_lac
exhausts memory.
(yyparse, yypush_parse): Use local variable yy_lac_established and
cpp macros YY_LAC_ESTABLISH and YY_LAC_DISCARD to implement LAC.
Update yysyntax_error invocation.  Add yyexhaustedlab code if LAC
is requested.
* tests/conflicts.at (%nonassoc and eof): Extend to check the
effect of each of -Dlr.type=canonical-lr and -Dparse.lac=full.
(%error-verbose and consistent errors): Likewise.
(LAC: %nonassoc requires splitting canonical LR states): New test
group demonstrating how LAC can fix canonical LR.
* tests/input.at (LAC: Errors for %define): New test group.
* tests/regression.at (LAC: Exploratory stack): New test group.
(LAC: Memory exhaustion): New test group.
(cherry picked from commit bf35c71c58)

Conflicts:

	src/parse-gram.c
	src/parse-gram.h
2010-12-23 21:13:58 -05:00
Joel E. Denny
107844a3ee parse.lac: implement exploratory stack reallocations.
* data/yacc.c: Rename %define variable parse.lac.es-capacity to
parse.lac.es-capacity-initial.  Accept parse.lac.memory-trace
with values of "failures" (default) or "full".
(b4_declare_parser_state_variables): Add yyesa, yyes, and
yyes_capacity variables.
(YYSTACK_USE_ALLOCA): Ignore it if LAC requested.
(YYSTACK_ALLOC, YYSTACK_FREE, YYSTACK_ALLOC_MAXIMUM): Define if
LAC requested.
(YYCOPY_NEEDED): New cpp macro.
(YYCOPY): Define if LAC requested.
(yy_lac_stack_realloc): New function implementing stack
reallocations.  Use YYMAXDEPTH for maximum stack size given that
the stack should never need to grow larger than the main state
stack needs to grow without LAC.
(YY_LAC_ESTABLISH): Update yy_lac invocation.
(yy_lac): Add arguments for exploratory stack memory data
recorded in the main parser.  Invoke yy_lac_stack_realloc when
reallocation is necessary.
(yysyntax_error): Add the same new arguments and pass them to
yy_lac.
(yypstate_delete): Free yyes if necessary.
(yyesa, yyes, yyes_capacity): #define these to yypstate members
in the case of push parsing.
(yyparse, yypush_parse): Initialize yyes and yyes_capacity.
Update yysyntax_error invocations.  At yyreturn, free yyes if
necessary.
* src/parse-gram.y: %define parse.lac full.
* tests/input.at (LAC: errors for %define): Extend for
parse.lac-memory-trace.
* tests/regression.at (LAC: Exploratory stack): Extend to check
that stack reallocs happen when expected.
(LAC: Memory exhaustion): Update to use YYMAXDEPTH and
parse.lac.es-capacity-initial.
2010-12-11 15:33:41 -05:00