Commit Graph

7828 Commits

Author SHA1 Message Date
Akim Demaille
e1caae6b48 Merge 3.7.6 into master
* maint:
  maint: post-release administrivia
  version 3.7.6
  yacc: fix push parser
  tables: fix again the handling of useless tokens
2021-03-10 06:41:59 +01:00
Akim Demaille
c4cf4cc2f5 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2021-03-08 06:36:36 +01:00
Akim Demaille
b458b34f94 version 3.7.6
* NEWS: Record release date.
v3.7.6
2021-03-08 06:15:53 +01:00
Akim Demaille
09a22da8c8 doc: don't mention YY_LOCATION_PRINT
* doc/bison.texi (Syntax Error Reporting Function): Don't refer to
YY_LOCATION_PRINT, it is a private internal detail.
2021-03-07 18:41:38 +01:00
Akim Demaille
cf899f7a7c yacc: fix push parser
When a pstate is used for multiple successive parses, some state may
leak from one run into the following one.  That was introduced in
330552ea49 "yacc.c: push: don't clear
the parser state when accepting/rejecting".

Reported by Ryan <dev@splintermail.com>
https://lists.gnu.org/r/bug-bison/2021-03/msg00000.html

* data/skeletons/yacc.c (yypush_parse): We reusing a pstate from a
previous run, do behave as if it were the first run.
* tests/push.at (Pstate reuse): Check this.
2021-03-07 18:41:38 +01:00
Akim Demaille
a774839ca8 tables: fix again the handling of useless tokens
The right-shift added in c22902e360
("tables: fix handling for useless tokens") is incorrect.  In
particular, we need to reset the "new" bits.

Reported by Balázs Scheidler.
https://github.com/akimd/bison/issues/74

* src/tables.c (pos_set_set): Fix the right-shift.
2021-03-07 11:56:30 +01:00
Akim Demaille
15c61fb712 html: fix memory leak
* src/print-xml.c (print_html): Free allocated memory.
2021-02-26 07:36:11 +01:00
Akim Demaille
f6eb1ac87b output: cache the mapped file names
Don't repeatedly call malloc/free for each call to map_file_name.

* bootstrap.conf: We need hash-map.
* src/files.h, src/files.c (map_file_name): The caller must not free
the result.
Adjust callers.
(mapped_dir_prefix, spec_mapped_header_file): Remove.
* src/files.c
(map_file_name): Rename as...
(map_file_name_alloc): this.
(mapped_files, map_file_name, string_equals, string_hash, string_free):
New.
2021-02-26 07:16:57 +01:00
Joshua Watt
b96528b48c output: use mapped file name for symbols
Applies the file name mapping before exporting it as a symbol. This
allows the symbols to correctly respect the --file-prefix-map command
line option.

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
2021-02-26 07:16:57 +01:00
Akim Demaille
4511e43245 style: formatting changes
* src/files.c, src/files.h: Save horizontal space.
Prefer `res` for returned values.
Put the doc into the header.
2021-02-26 07:16:35 +01:00
Akim Demaille
306fc3ec00 gnulib: update 2021-02-26 07:04:43 +01:00
Joshua Watt
f08110cb50 doc: fix documented function name
* data/README.md: Fix the name of a referenced function to match the
name in code.
2021-02-25 06:55:22 +01:00
Akim Demaille
c61b282d77 regen 2021-02-25 06:55:08 +01:00
Akim Demaille
2d1d2f87f9 doc: printing locations
Document YYLOCATION_PRINT.

* doc/bison.texi (Printing Locations): New node.
2021-02-09 07:05:08 +01:00
Akim Demaille
f50fff58d1 examples: improve some function prototypes
* examples/c/bistromathic/parse.y, examples/c/glr/c++-types.y,
* examples/c/lexcalc/parse.y: Use const where appropriate.
Avoid `yy` prefixes where it does not make sense.
Avoid the `p` prefix for pointers.
2021-02-09 07:04:05 +01:00
Akim Demaille
e0ab5c324a examples: use YYLOCATION_PRINT
* examples/c/bistromathic/parse.y, examples/c/glr/c++-types.y,
* examples/c/lexcalc/parse.y: Don't use the private internal detail
`YY_LOCATION_PRINT`, use `YYLOCATION_PRINT`.
2021-02-09 06:59:50 +01:00
Akim Demaille
c80b404dfa c: rename YY_LOCATION_PRINT as YYLOCATION_PRINT and make it public
It is very helpful to be able to look at the locations in the debug
traces, let's provide the users with (i) a means to do that for their
location types, and (ii) a public macro to print locations when debug
traces are enabled.

* data/skeletons/c.m4 (b4_yy_location_print_define): Rename as...
(b4_yylocation_print_define): this.
Define YYLOCATION_PRINT instead of YY_LOCATION_PRINT.
Ensure backward compatibility for those who might have defined/used
YY_LOCATION_PRINT in spite the warnings.
Adjust dependencies.
* data/skeletons/glr2.cc: We don't use YYLOCATION_PRINT here.
2021-02-09 06:48:02 +01:00
Akim Demaille
96b881094b examples: do not rely on YY_LOCATION_PRINT
* examples/c/bistromathic/parse.y (location_print): New.
Use it.
2021-02-09 06:48:00 +01:00
Akim Demaille
fdba54a961 c: stop defining YY_LOCATION_PRINT when locations are not enabled
* data/skeletons/c.m4 (b4_yy_location_print_define): here.
2021-02-02 06:53:53 +01:00
Akim Demaille
d50a3e450e graph: output foo.gv by default, instead of *.dot
That change was started in Bison 3.4.  The announcement for 3.7 stated
that in Bison 3.8 we would use *.gv by default.

* src/files.c (compute_output_file_names): spec_graph_file defaults
too *.gv.
* doc/bison.texi, examples/c++/calc++/local.mk, tests/output.at:
Adjust.
2021-02-02 06:51:39 +01:00
Akim Demaille
47186ec460 tests: adjust to the removal of YYPRINT
* tests/regression.at: here.
2021-02-01 08:34:49 +01:00
Akim Demaille
1efe31185f yacc: remove support for YYPRINT
Its removal was annonced several times in NEWS (for Bison 3.5, 3.6, 3.7).

* data/skeletons/c.m4, data/skeletons/yacc.c: Remove support for YYPRINT.
* NEWS: Fix the mess introduced by the merge.
Document the removal of YYPRINT.
* doc/bison.texi (The YYPRINT Macro): Remove.
2021-02-01 06:51:15 +01:00
Akim Demaille
9acc9d2aee c++: issue a compile-time warning when #define YYSTYPE is used
Using #define YYSTYPE has always been strongly discouraged in C++.
Macros are dangerous and can result in subtle bugs.
https://lists.gnu.org/r/bug-bison/2020-12/msg00007.html

Maybe some people are currently using #define YYSTYPE.  Instead of
dropping support right now, first issue a warning.  Bison can "see" if
YYDEBUG is defined (it could even be on the command line), only the
compiler knows.  Unfortunately `#warning` is non-portable, and
actually GCC even dies on it when `-pedantic` is enabled.  So we need
to use `#pragma message`.  We must make it conditional as some
compilers might not support it, but it doesn't matter if only _some_
compilers emit the warning: it should be enough to catch the attention
of the developers.

* data/skeletons/c++.m4: Issue a warning when the user defined
YYSTYPE.
* tests/actions.at: Don't #define YYSTYPE.
* tests/headers.at (Several parsers): Ignore the YYSTYPE in the
warning.
2021-02-01 05:54:06 +01:00
Akim Demaille
dc8fe0678a c++: make it clear that #define YYSTYPE is not supported
We have been accepting this for years, but it is deprecated: people
are expecting to define api.value.type instead.

* doc/bison.texi: Make it clear that YYSTYPE and YYLTYPE are for C
only.
2021-02-01 05:54:06 +01:00
Akim Demaille
a70e21215a c++: stop referring to YYSTYPE in yylex
* data/skeletons/glr2.cc, data/skeletons/lalr1.cc (b4_lex): Don't
refer to YYSTYPE, but to value_type.
Note that this is "symbolic" in the sense that these values are never
used by b4_function_call.
2021-02-01 05:54:06 +01:00
Akim Demaille
638de51289 CI: try GCC 11 and Clang 11 2021-02-01 05:54:06 +01:00
Akim Demaille
b46afca5be gnulib: update 2021-02-01 05:34:53 +01:00
Akim Demaille
0dc20612c0 glr2.cc: no longer be part of b4_glr_cc_if
We are fully independant of glr.c/glr.cc, we no longer need to pretend
we are glr.cc.

* data/skeletons/bison.m4: here.
2021-01-31 18:44:30 +01:00
Akim Demaille
6dc09317fb m4: provide macros for api.value.type=union
* data/skeletons/bison.m4 (b4_union_if): New.
Remove support for "%define variant", which was deprecated long ago.
* tests/local.at (AT_UNION_IF): New.
2021-01-31 07:27:41 +01:00
Akim Demaille
fc0dbb3bba traces: display the Bison version
* src/main.c (main): When traces are enabled, display the Bison
version.
* tests/conflicts.at, tests/report.at, tests/sets.at:
Use AT_PACKAGE_VERSION (for package.m4) instead of post-processing the
output.
2021-01-30 14:32:00 +01:00
Akim Demaille
de93a0728b tests: run the main test suite on "make check"
Automake appears to not recognize "check-local" when it is not a
isolated target.  Fixes 77a8b84fc8.

* tests/local.mk (check-local): Make it visible to Automake.
2021-01-30 09:06:36 +01:00
Adela Vais
689b184983 d: tests: various style fixes
* tests/calc.at, tests/scanner.at: Here.
(yylex): Report values directly, without storing them to the union
first.
2021-01-30 08:49:22 +01:00
Paul Eggert
ef3adfa0fb Update URLs to prefer https: to http:
Also, fix a few http: URLs that were no longer working.
2021-01-30 07:32:03 +01:00
Paul Eggert
b4582f1918 Update URLs to prefer https: to http:
Also, fix a few http: URLs that were no longer working.
2021-01-29 13:48:43 -08:00
Akim Demaille
77a8b84fc8 tests: provide check-examples and check-tests
* examples/local.mk (check-examples): New.
* tests/local.mk (check-tests): New.
* README-hacking.md: Document them.
2021-01-27 20:48:38 +01:00
Akim Demaille
b27bba5ced bistromathic: use gettext for all the messages
* examples/c/bistromathic/parse.y: Add missing calls to _.
2021-01-27 20:48:38 +01:00
Adela Vais
7a525fa06f d: tests: avoid mixing output from reportSyntaxError and getExpectedTokens
Function reportSyntaxError buffers and prints the message at the end.

* tests/local.at: Here.
2021-01-24 10:27:17 +01:00
Akim Demaille
c7037bfcb0 glr2.cc: fix destructor support
Currently glr2.cc does not use 'symbol's everywhere, in various places
it also uses yykind, yyval and yyloc "by hand".  So we need two
different calls for user-defined constructors: once for ~symbol,
another for yy_destroy_.  Both need to call the user destructors with
different calling conventions.

* data/skeletons/glr2.cc (b4_symbol_action): Rename as...
(b4_symbol_action_for_yyval): this.
(b4_symbol_action): New, taken from lalr1.cc.
(yy_destroy_, yy_symbol_value_print_): Use b4_symbol_action_for_yyval.
2021-01-24 09:56:07 +01:00
Akim Demaille
874e75975b glr2.cc: beware of types with angle brackets
For C++98, avoid "yyval.as<std::list<int>>".

* data/skeletons/glr2.cc (b4_call_merger): Add spaces within "<...>".
2021-01-24 09:56:02 +01:00
Akim Demaille
51f12cffd2 package: fix details after merge with 3.7.5
* TODO, cfg.mk: Update.
* src/parse-gram.c, src/parse-gram.h: Regen.
2021-01-24 09:30:02 +01:00
Akim Demaille
c94456986d Merge tag 'v3.7.5'
Three new commits:

commit 8358090292
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Wed Jan 20 18:30:16 2021 -0800

    c: port to HP-UX 11.23

commit 2c294c1325
Author: Vincent Imbimbo <vmi6@cornell.edu>
Date:   Sat Jan 23 13:25:18 2021 -0500

    cex: fix state-item pruning

commit c22902e360
Author: Akim Demaille <akim.demaille@gmail.com>
Date:   Sat Jan 23 18:40:15 2021 +0100

    tables: fix handling for useless tokens
2021-01-24 09:22:49 +01:00
Akim Demaille
4083ee52b5 doc: fix typo
Reported by Kaz Kylheku.
https://lists.gnu.org/r/bison-patches/2020-11/msg00019.html

* doc/bison.texi (Versioning): here.
2021-01-24 08:55:42 +01:00
Kaz Kylheku
3c47ed0fe6 doc: document best deployment practices.
* doc/bison.texi (Versioning): New node about practices
regarding dealing with multiple versions of Bison.
2021-01-24 08:55:30 +01:00
Akim Demaille
1ff6bcb2f1 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2021-01-24 08:53:16 +01:00
Akim Demaille
2fac23b9dd version 3.7.5
* NEWS: Record release date.
v3.7.5
2021-01-24 08:30:41 +01:00
Akim Demaille
c22902e360 tables: fix handling for useless tokens
In some rare conditions, the generated parser can be wrong when there
are useless tokens.

Reported by Balázs Scheidler.
https://github.com/akimd/bison/issues/72

Balázs managed to prove that the bug was introduced in

    commit af1c6f973a
    Author: Theophile Ranquet <ranquet@lrde.epita.fr>
    Date:   Tue Nov 13 10:38:49 2012 +0000

    tables: use bitsets for a performance boost

    Suggested by Yuri at
    <http://lists.gnu.org/archive/html/bison-patches/2012-01/msg00000.html>.

    The improvement is marginal for most grammars, but notable for large
    grammars (e.g., PosgreSQL's postgre.y), and very large for the
    sample.y grammar submitted by Yuri in
    http://lists.gnu.org/archive/html/bison-patches/2012-01/msg00012.html.
    Measured with --trace=time -fsyntax-only.

    parser action tables    postgre.y     sample.y
    Before                 0,129 (44%)  37,095 (99%)
    After                  0,117 (42%)   5,046 (93%)

    * src/tables.c (pos): Replace this set of integer coded as an unsorted
    array of integers with...
    (pos_set): this bitset.

which was implemented long ago, but that I installed only recently
(March 2019), first published in v3.3.90.

That patch introduces a bitset to represent a set of integers.  It
managed negative integers by using a (fixed) base (the smallest
integer to represent).  It avoided negative accesses into the bitset
by ignoring integers smaller than the base, under the asumption that
these cases correspond to useless tokens that are ignored anyway.
While it turns out to be true for all the test cases in the test suite
(!), Balázs' use case demonstrates that it is not always the case.

So we need to be able to accept negative integers that are smaller
than the current base.

"Amusingly" enough, the aforementioned patch was visibly unsure about
itself:

    /* Store PLACE into POS_SET.  PLACE might not belong to the set
       of possible values for instance with useless tokens.  It
       would be more satisfying to eliminate the need for this
       'if'.  */

This commit needs several improvements in the future:
- support from bitset for bit assignment and shifts
- amortized resizing of pos_set
- test cases

* src/tables.c (pos_set_base, pos_set_dump, pos_set_set, pos_set_test):
New.
Use them instead of using bitset_set and bitset_test directly.
2021-01-24 08:28:45 +01:00
Vincent Imbimbo
2c294c1325 cex: fix state-item pruning
There were several bugs in pruning that would leave the state-item
graph in an inconsistent state which could cause crashes later on:

- Pruning now happens in one pass instead of two.

- Disabled state-items no longer prune the state-items they transition
  to if that state-item has other states that transition to it.

- State-items that transition to disabled state-items are always
  pruned even if they have productions.

Reported by Michal Bartkowiak <michal.bartkowiak@nokia.com>
https://lists.gnu.org/r/bug-bison/2021-01/msg00000.html
and Zartaj Majeed
https://github.com/akimd/bison/issues/71

* src/state-item.c (prune_forward, prune_backward): Fuse into...
(prune_state_item): this.
Adjust callers.
2021-01-24 08:24:56 +01:00
Akim Demaille
236b85dd28 package: pacify syntax-check
* cfg.mk: Currently we cannot update gnulib because of portability
issues with ancient versions of clang
(https://lists.gnu.org/r/bug-gnulib/2021-01/msg00241.html).  So skip
the check about copyright date for gnulib.
2021-01-23 15:08:48 +01:00
Akim Demaille
4109d56aa9 news: update 2021-01-23 15:02:49 +01:00
Akim Demaille
003ca0498d package: bump copyrights to 2021
Run 'make update-copyright'.
2021-01-23 15:02:49 +01:00