Commit Graph

7909 Commits

Author SHA1 Message Date
Akim Demaille
ca96df89b2 glr2.cc: don't publish YY_EXCEPTIONS
We don't need them in the header file.

* data/skeletons/glr2.cc (YY_EXCEPTIONS): Define only in the
implementation file.
* tests/headers.at (Several Parsers): Also check glr2.cc.
2021-09-12 12:03:58 +02:00
Akim Demaille
2142e59155 c++: demonstrate custom error messages in the examples
Let's use c++/glr to demonstrate custom error messages in C++ (not
just in glr2.cc).

* examples/c++/glr/c++-types.yy (report_syntax_error): New.
* examples/c++/glr/c++-types.test: Adjust.
* examples/c/bistromathic/parse.y: Comment changes.
* tests/local.at (AT_YYERROR_DEFINE(c++)): Use a nicer way to print
the lookakead's name.
2021-09-12 12:03:58 +02:00
Akim Demaille
a75072476e glr2.cc: custom error messages
Reported by Tom Shields <thomas.evans.shields@icloud.com>.
<https://lists.gnu.org/r/bug-bison/2021-08/msg00003.html>

* data/skeletons/glr2.cc (context): New.
Use it to generate the error messages.
Add support for custom error messages.
* tests/calc.at: Check support for custom error messages.
2021-09-12 12:03:58 +02:00
Akim Demaille
7c47598d4f glr2.cc: start the transition to using symbol_type
Currently glr2.cc uses three variables/struct members to denote the
symbols' kind (or state), value and location.  lalr1.cc has two types
for "complete" symbols: symbol_type and stack_symbol_type.  Let's use
that model in glr2.cc too.

For a start use yyla (a symbol_type) to denote the lookahead, instead
of the triple yytoken, yylval and yylloc.  This will make easier the
introduction of the "context" subclass, used in parse.error=custom.

It simplifies the code in several places.  For instance from:

    symbol_kind_type yytoken_current = this->yytoken;]b4_variant_if([[
    value_type yylval_current;
    ]b4_symbol_variant([this->yytoken],
                       [yylval_current], [move], [this->yylval])], [[
    value_type yylval_current = this->yylval;]])[]b4_locations_if([
    location_type yylloc_current = this->yylloc;])[

to:

    symbol_type yyla_current = std::move (this->yyla);

* data/skeletons/glr2.cc (yytoken, yylval, yylloc): Replace by...
(yyla): this.
Adjust all dependencies.
(yyloc_default): Remove, unused.
* tests/c++.at, tests/glr-regression.at, tests/types.at: C++11 is
required for glr2.cc.
Adjust to changes in glr2.cc.
2021-09-12 12:03:58 +02:00
Akim Demaille
fdaedc780a c++: add move assignments to the symbol type
This will be used in glr2.cc, which requires C++11.

* data/skeletons/c++.m4 (basic_symbol, by_kind): Add move assignment.
2021-09-12 12:03:58 +02:00
Akim Demaille
85f5e3b9d5 c++: avoid using the obsolete names
* data/skeletons/c++.m4: Don't define obsolete identifiers in the case
of glr2.cc.  Let's not start with technical debt.
* data/skeletons/glr2.cc, data/skeletons/lalr1.cc,
* data/skeletons/variant.hh: Use token_kind_type, not token_type.
* tests/c++.at, tests/local.at: Use value_type, not semantic_type.
2021-09-12 12:03:58 +02:00
Akim Demaille
c3a4686a03 regen 2021-09-12 12:03:58 +02:00
Akim Demaille
9cdfd86cbb maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2021-09-11 08:55:22 +02:00
Akim Demaille
659376b590 version 3.8.1
* NEWS: Record release date.
v3.8.1
2021-09-11 08:26:40 +02:00
Akim Demaille
0343acbe89 portability: don't use strtof
It is not available on HP-UX 11i.
Reported by Larkin Nickle <me@larbob.org>.
<https://lists.gnu.org/r/bug-bison/2021-09/msg00012.html>

Gnulib provides no replacement, but anyway we should be using doubles,
since difftime uses doubles.

* bootstrap.conf: We want portability on stdtod.
* src/counterexample.c: Use double, not float, for time measurements.
2021-09-11 08:26:10 +02:00
Akim Demaille
5d9ccd5a87 yacc: declare yyerror/yylex only when POSIXLY_CORRECT
The recent changes to comply with POSIX are breaking Automake's test
suite.
Reported by Kiyoshi Kanazawa.
<https://lists.gnu.org/r/bug-bison/2021-09/msg00005.html>

To limit the impact of POSIX changes, bind them to $POSIXLY_CORRECT.
Suggested by Karl Berry.
<https://lists.gnu.org/r/bug-bison/2021-09/msg00009.html>

The existing `maintainer-check-posix` Make target checks these
changes.

* src/getargs.h, src/getargs.c (set_yacc): New.
Use it.
* data/skeletons/bison.m4 (b4_posix_if): New.
* data/skeletons/yacc.c (b4_declare_yyerror_and_yylex): Use it.
* doc/bison.texi, tests/local.at: Adjust.
2021-09-11 08:26:10 +02:00
Akim Demaille
ad9b8a069f maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2021-09-07 20:56:23 +02:00
Akim Demaille
ec3375ab4e version 3.8
* NEWS: Record release date.
v3.8
2021-09-07 20:28:49 +02:00
Akim Demaille
12c8e427c7 news: update 2021-09-07 20:28:36 +02:00
Akim Demaille
9f8f3d2e77 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2021-09-02 07:56:44 +02:00
Akim Demaille
108724c2e7 version 3.7.91
* NEWS: Record release date.
v3.7.91
2021-09-02 07:31:20 +02:00
Akim Demaille
da0f993fb9 tests: disable "Multistart reports"
For some reason this test fails on Solaris/x86.  But multistart is not
part of 3.8, so we can postpone the debugging of this issue.
Reported by Dagobert Michelsen.
<https://lists.gnu.org/r/bug-bison/2021-08/msg00027.html>

* tests/report.at (Multistart reports): Comment out.
2021-09-02 07:27:42 +02:00
Akim Demaille
075a879052 style: c++: formatting changes
* data/skeletons/variant.hh, data/skeletons/glr2.cc: Fix space before
paren issue.
2021-08-29 18:36:07 +02:00
Akim Demaille
a7ded4284e style: rename stmtMerge as stmt_merge
Follow the GNU Coding Style.

* doc/bison.texi, examples/c++/glr/c++-types.yy,
* examples/c/glr/c++-types.y, tests/cxx-type.at: s/stmtMerge/stmt_merge/g.
2021-08-29 16:25:38 +02:00
Akim Demaille
a5c55bb758 c++: beware of Visual C++ limitations
Contrary to what commit d8cc6b073e "c++:
shorten the assertions that check whether tokens are correct"
believed, MS Visual C++'s preprocessor limitation is not on the input
line length, but on the size of the line holding the full C++
statement.

Reported by Vince Huffaker <vince@vincejulie.com>
<https://lists.gnu.org/r/help-bison/2021-08/msg00003.html>

* data/skeletons/variant.hh (_b4_symbol_constructor_define): Hide the
assertion from Visual C++.
2021-08-29 10:10:56 +02:00
Akim Demaille
bc5aa8e274 tests: don't postprocess stderr with sed
On Solaris, sed throws away the NUL bytes from the stream, even in C
locale.  So instead of postprocessing bison's stderr to neutralize
changes in value of `argv[0]`, use an envvar to actually neutralize
variations of `argv[0]` during tests.

Reported by Dagobert Michelsen.
<https://lists.gnu.org/r/bug-bison/2021-08/msg00025.html>

* src/main.c (main): Change `argv[0]` if BISON_PROGRAM_NAME is
defined.
* tests/bison.in: No longer mess with stderr, just pass
the expected BISON_PROGRAM_NAME value.
2021-08-29 09:50:02 +02:00
Akim Demaille
0a82bf5c07 CI: don't require Autoconf 2.71 2021-08-19 10:07:51 +02:00
Akim Demaille
a70e75b8a4 examples: don't demonstrate multistart, which is not part of 3.8
Besides, for mysterious reasons, this fails on some environment.
Reported by Dagobert Michelsen.
<https://lists.gnu.org/archive/html/bug-bison/2021-08/msg00008.html>

* examples/c/lexcalc/lexcalc.test, examples/c/lexcalc/parse.y,
* examples/c/lexcalc/scan.l: Revert to a single-start example.
2021-08-19 09:19:07 +02:00
Akim Demaille
3afa9757da tests: grep -E is not portable
Reported by Dagobert Michelsen.
<https://lists.gnu.org/r/bug-bison/2021-08/msg00008.html>

* tests/calc.at: Use $EGREP.
2021-08-19 08:21:23 +02:00
Akim Demaille
36f37568ba glr2.cc: require C++11
Reported by Dagobert Michelsen.
https://lists.gnu.org/r/bug-bison/2021-08/msg00006.html

* m4/bison-cxx-std.m4 (_BISON_CXXSTD_98_snippet): We don't need
vector::data, it was only for glr2.cc, which is C++11 anyway.
(_BISON_CXXSTD_11_snippet): We need vector::data and std::swap on
arrays.
* m4/cxx.m4 (BISON_TEST_FOR_WORKING_CXX_COMPILER): We don't need
vector::data.
* tests/local.at (AT_COMPILE_CXX): Skip when glr2.cc and no support
for C++11.
2021-08-19 08:21:22 +02:00
Akim Demaille
f2c568d3ef readme: add D 2021-08-13 09:06:34 +02:00
Akim Demaille
bb7860d208 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2021-08-13 08:47:37 +02:00
Akim Demaille
8bb81e2048 version 3.7.90
* NEWS: Record release date.
v3.7.90
2021-08-13 08:20:06 +02:00
Akim Demaille
84059ea508 build: ignore syntax-check's file_system check on Doxyfile
* cfg.mk: Here.
2021-08-13 08:15:31 +02:00
Akim Demaille
024f00fd11 tests: fix incorrect test case
In c2ba260487 ("glr.c: fix signature
when using custom error messages"), I meant to add a test case for C,
not C++.  It does not work in C++.

* tests/calc.at: Run for glr.c, not glr.cc.
2021-08-12 10:13:38 +02:00
Akim Demaille
0af06e091b gnulib: update 2021-08-12 10:13:38 +02:00
Akim Demaille
1d291901b4 news: be clear that glr2.cc is C++11 2021-08-12 10:13:38 +02:00
Akim Demaille
f387ffc1d3 build: modernize to newer Autoconf releases
* configure.ac: here.
2021-08-12 10:13:38 +02:00
Akim Demaille
9307c173c7 build: reject C++ compilers that don't support std::vector::data
GCC 4.2 on macOS claims to support C++98, but does not feature it.

input.cc: In member function 'void state_stack::yycompressStack()':
input.cc:1774: error: 'class std::vector<glr_stack_item, std::allocator<glr_stack_item> >' has no member named 'data'

Reported by Christopher Nielsen <mascguy@github.com>.
<https://trac.macports.org/raw-attachment/ticket/59927/bison-test-results-20210811-95b72.log.xz>.

* m4/bison-cxx-std.m4 (_BISON_CXXSTD_98_snippet): Check for it.
* m4/cxx.m4 (BISON_TEST_FOR_WORKING_CXX_COMPILER): Ditto.
2021-08-12 10:13:26 +02:00
Akim Demaille
15ba35a51b build: check for C++ 20 and 2b
C++20 is released.

* configure.ac, m4/bison-cxx-std.m4, tests/atlocal.in,
* tests/local.at: Replace 2a with 20, and add support for 2b.
2021-08-12 09:07:36 +02:00
Akim Demaille
db66acc5d0 tests: remove obsolete checks
* tests/atlocal.in: It was an error for tests to depend on gnulib:
they must not, as gnulib would hide portability issues that we want to
catch.  So this piece of code is no longer useful, and must not be
useful.
2021-08-12 08:24:13 +02:00
Akim Demaille
3477ced42b tests: be robust to old versions of xlstproc
Reported by Christopher Nielsen <mascguy@github.com>.
<https://trac.macports.org/raw-attachment/ticket/59927/bison-test-results-20210811-95b72.log.xz>

* tests/report.at (AT_CHECK_HTML): New.
Use it.
2021-08-12 08:16:08 +02:00
Akim Demaille
348b5039fd c: fix _Noreturn support detection
Reported by Christopher Nielsen <mascguy@github.com>.
<https://trac.macports.org/ticket/59927#comment:59> and
<https://trac.macports.org/ticket/59927#comment:62>.

* data/skeletons/c.m4: Fix typo.
2021-08-11 18:01:12 +02:00
Akim Demaille
07cdeda9f8 lalr1.cc: style changes
* data/skeletons/lalr1.cc: Formatting changes.
Use more `const`, as in glr2.cc.
2021-08-11 18:01:12 +02:00
Akim Demaille
c2ba260487 glr.c: fix signature when using custom error messages
Reported by Tom Shields <thomas.evans.shields@icloud.com>.

* data/skeletons/glr.c (yypcontext_location): Fix return type.
* tests/calc.at: Check the case pure, location, custom error messages.
2021-08-11 18:01:12 +02:00
Akim Demaille
e4e3cbce77 tests: check symbol/token renumbering
In some extreme situations, with lots of useless tokens, Bison was
numbering them incorrectly, which resulted in a broken grammar.
<https://lists.gnu.org/r/bison-patches/2021-03/msg00001.html>
commit a774839ca8.

* tests/regression.at (Useless Tokens): New.
2021-08-11 18:00:38 +02:00
Akim Demaille
b2a00ed5dd style: rename b4_lex as b4_yylex
For consistency with b4_yyerror_formals, etc.

* data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/d.m4,
* data/skeletons/glr.c, data/skeletons/glr2.cc,
* data/skeletons/java.m4, data/skeletons/lalr1.cc,
* data/skeletons/lalr1.d, data/skeletons/lalr1.java,
* data/skeletons/yacc.c
(b4_lex, b4_lex_formals): Rename as...
(b4_yylex, b4_yylex_formals): these.
2021-08-09 07:17:19 +02:00
Akim Demaille
3c5f73fe51 yacc: comply with recent POSIX updates: declare yyerror and yylex
In POSIX Yacc mode, declare yyerror and yylex unless already #defined,
or if YYERROR_IS_DECLARED/YYLEX_IS_DECLARED are defined (for
consistency with Bison's YYSTYPE_IS_DECLARED/YYLTYPE_IS_DECLARED).
See <https://austingroupbugs.net/view.php?id=1388#c5220>.

* data/skeletons/c.m4 (b4_function_declare): Resurect.
(b4_lex_formals): Since we will possibly expose this prototype
in the header, take the prefix into account.
* data/skeletons/yacc.c (b4_declare_yyerror_and_yylex): New.
(b4_shared_declarations): Use it.

* tests/local.at (AT_YACC_IF): New.
When in Yacc mode, set the `yacc` Autotest keyword.
(AT_YYERROR_DECLARE(c)): Don't declare in Yacc mode,
to avoid clashes (since this signature is static).
(AT_YYERROR_DEFINE(c)): Don't define as static in Yacc mode.
* tests/regression.at (Early token definitions with --yacc): Specify
that we are in Yacc mode.
2021-08-09 07:17:19 +02:00
Akim Demaille
dabde7c560 build: enable -Wmismatched-dealloc
* configure.ac (warn_common): Here.
2021-08-09 07:17:19 +02:00
Akim Demaille
272da17cfd gnulib: update 2021-08-09 07:17:19 +02:00
Akim Demaille
4b802d6417 bistromathic: beware of portability issues with readline
In some cases readline emits a trailing spaces after the last
suggestion, which results in errors such as:

```
-(       -       atan    cos     exp     ln      number  sin     sqrt$
+(       -       atan    cos     exp     ln      number  sin     sqrt    $
```

Reported by Christopher Nielsen <mascguy@github.com>.
<https://trac.macports.org/ticket/59927#comment:48>
<https://trac.macports.org/attachment/ticket/59927/bison-3.7.6-test-10.13.test-suite.log>

* examples/test (run): Add support for -t.
* examples/c/bistromathic/bistromathic.test: Use it.
2021-08-08 08:08:04 +02:00
Akim Demaille
7f1e9249d0 d: prepare to be able to run LAC tests
Unfortunately it seems to be quite difficult to have "LAC: Exploratory
stack" run for D.

* data/skeletons/lalr1.d: We need File when traces are enabled.
* tests/local.at (AT_YYLEX_DEFINE(d)): New.
* tests/regression.at: Prepare for D, but don't run it, it does not
work.
2021-08-07 12:53:19 +02:00
Akim Demaille
6d86d26b33 tests: factor iterating over skeletons
* tests/local.at (AT_FOR_EACH_SKEL): New.
Use where appropriate.
* data/skeletons/lalr1.d: Reject -d.
* tests/input.at, tests/scanner.at: Also check D.
2021-08-07 12:53:19 +02:00
Akim Demaille
80db1029e6 m4: catch suspicions of unevaluated macros
Check in m4's output if there are sequences such as m4_foo or b4_foo,
which are probably resulting from incorrect m4 processing.

It actually already is useful:

- it caught a leaking b4_lac_if leaking from glr.c, where LAC is not
  supported, hence b4_lac_if is not defined.

- it also caught references to location.hh in position.hh when
  location.hh does not exist.

- while making "Code injection" robust to these new warnings (it is
  its very purpose to let b4_canary pass unevaluated), I saw that it
  did not check lalr1.d, and when adding lalr1.d, it revealed it did
  underquote ocurrences of token value types.

* src/scan-skel.l (macro): New abbreviation.
Use it.
* data/skeletons/glr.c: Don't use b4_lac_if, we don't have it.
* data/skeletons/location.cc: Don't generate position.hh when we don't
generate location.hh.
* data/skeletons/d.m4 (b4_basic_symbol_constructor_define): Fix
underquotation.
* data/skeletons/bison.m4 (b4_canary): New.
* tests/input.at (Code injection): Use it, and check lalr1.d too.
2021-08-07 12:53:19 +02:00
Akim Demaille
6118406c3e style: formatting changes in scan-code.l
* src/scan-code.l: Fix indentation.
2021-08-07 12:53:15 +02:00