Commit Graph

7872 Commits

Author SHA1 Message Date
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
Akim Demaille
a83202a436 doc: avoid #define YYDEBUG in C++
* doc/bison.texi (Enabling Traces): here.
2021-08-07 07:57:58 +02:00
Akim Demaille
9de593aba7 tests: extract AT_LOCATION_PRINT_DECLARE and AT_LOCATION_PRINT_DEFINE
* tests/local.at (AT_LOCATION_PRINT_DECLARE)
(AT_LOCATION_PRINT_DEFINE): New.
2021-08-06 18:02:23 +02:00
Akim Demaille
6fc9f13aef tests: rename AT_YACC_IF as AT_YACC_C_IF
In data/, b4_yacc_if refers to %yacc, not yacc.c.

* tests/local.at (AT_YACC_IF): Rename as...
(AT_YACC_C_IF): this.
2021-08-06 18:02:23 +02:00
Akim Demaille
d4b195ece6 doc: more pointers to the examples
* doc/bison.texi (Infix Calc): Here.
2021-08-06 18:02:23 +02:00
Akim Demaille
85032e9630 git: add diff patterns for Autotest and Texinfo 2021-08-06 18:02:19 +02:00
Akim Demaille
7e16706f7b CI: fix the GCC 9 build 2021-08-06 18:01:15 +02:00
Akim Demaille
b7d2b854be todo: d: push and token ctors are done 2021-08-04 21:42:31 +02:00
Akim Demaille
93f9e527ca doc: refer to the examples
* doc/bison.texi: Point to rpcalc, mfcalc, simple.y, calc++, c/glr and
c++/glr.
2021-08-04 21:36:41 +02:00
Akim Demaille
0c0cf6f5a4 examples: modernize the example Makefiles
* examples/c++/Makefile, examples/c++/calc++/Makefile,
* examples/c++/glr/Makefile, examples/c/bistromathic/Makefile,
* examples/c/calc/Makefile, examples/c/glr/Makefile,
* examples/c/lexcalc/Makefile, examples/c/mfcalc/Makefile,
* examples/c/pushcalc/Makefile, examples/c/reccalc/Makefile,
* examples/c/rpcalc/Makefile, examples/d/calc/Makefile,
* examples/d/simple/Makefile, examples/java/calc/Makefile,
* examples/java/simple/Makefile:
Use --html to generate *.html directly.
No longer demonstrate --xml.
No longer show rules for xml to html.
Use --header, not --defines.
Use --graph without specifying the output file now that we
generate *.gv by default.
2021-08-04 10:07:48 +02:00
Akim Demaille
413d318940 doc: glr: document typed mergers
See <https://lists.gnu.org/r/help-bison/2020-12/msg00016.html>.

* doc/bison.texi (Merging GLR Parses): document typed mergers.
And avoid #define YYSTYPE.
2021-08-04 09:14:49 +02:00
Akim Demaille
cb7bdc251d style: tests: rebox comments
* tests/glr-regression.at: here.
2021-08-04 09:14:49 +02:00
Akim Demaille
e814ddc92f news: update
In particular, announce lalr1.d.
2021-08-04 07:01:07 +02:00
Akim Demaille
b293d4fbca doc: fix spello
* doc/bison.texi (Multiple start-symbols): here.
2021-08-03 12:22:52 +02:00
Akim Demaille
952479fca7 scan: fix typo in UTF-8 escape
We had:

```
-mbchar    ...|\xF0[\x\90-\xBF]([\x80-\xBF]{2})|...
+mbchar    ...|\xF0[\x90-\xBF]([\x80-\xBF]{2})|...
```

so a precise sequence that matches the incorrect regex can let NUL
bytes pass through, which triggers an assertion violation downstream.
It is a pity that Flex does not report an error for such input.

Reported by Ahcheong Lee <ahcheong.lee@gmail.com>.
<https://lists.gnu.org/r/bug-bison/2021-04/msg00003.html>

* src/scan-gram.l (mbchar): Fix the bad regex.
* tests/input.at (Invalid inputs): Check that case.
2021-08-03 12:22:52 +02:00
Akim Demaille
e14825ecb7 todo: POSIX yacc and prototypes 2021-08-03 09:04:15 +02:00
Akim Demaille
98823ea402 doc: update Doxygen template file
* doc/Doxyfile.in: here.
2021-08-03 09:04:15 +02:00
Akim Demaille
ad40c80a03 doc: a bit of editing
* doc/bison.texi: Use @samp{...}, not "..." for pieces of code.
Use @samp{...}, not @command{...} for command lines.
Promote %header/--header over %defines/--defines.
Spellcheck.
2021-08-03 08:57:35 +02:00
Akim Demaille
3c7cc7dc4f gnulib: update 2021-08-03 08:08:24 +02:00
Alyssa Ross
410d37b994 getargs: don't translate first line of --version
<https://lists.gnu.org/r/bison-patches/2021-06/msg00002.html>

* src/getargs.c (version): here.
2021-08-01 10:04:24 +02:00
Akim Demaille
9b6065303b all: fix confusion between token ctor and symbol ctor
The symbol constructors are genuine constructors.  Token constructors
are plain functions that construct tokens.
2021-08-01 09:55:39 +02:00
Akim Demaille
5325292e5d d: minor clean up
* doc/bison.texi: Use @samp, not "...", around pieces of code.
* examples/d/calc/calc.y: Don't promote %union.
2021-07-25 18:21:12 +02:00
Akim Demaille
ca403f672c gnulib: update 2021-06-23 07:18:30 +02:00
Adela Vais
5c554ea8a3 d: demonstrate the token constructors
* examples/d/calc/calc.y: Use the token constructors in the 'calc' example.
2021-06-06 08:10:46 +02:00
Adela Vais
7eee2ccbd2 d: update documentation
* doc/bison.texi: Various fixes.
(D Push Parser Interface, D Complete Symbols): New sections.
2021-04-11 07:57:50 +02:00
Adela Vais
f99314765b d: demonstrate the push parser
* examples/d/calc/calc.y: Use a parser of type 'push' in the calc
example.
2021-04-11 07:41:39 +02:00
Adela Vais
9ba3c5ceb9 d: add push parser support
Support the push-pull directive with the options pull, push and both.
Pull remains the default option.

* data/skeletons/d.m4: Add user aliases for the push parser's return
values: PUSH_MORE, ABORT, ACCEPT.
* data/skeletons/lalr1.d: Add push parser support.
* tests/calc.at: Test it.
2021-04-11 07:41:39 +02:00
Adela Vais
4bd4cdf377 d: add token constructors support
The user can return from yylex() by calling the Symbol method of the
same name as the TokenKind reported, and adding the parameters for
value and location if necessary.  These methods generate compile-time
errors if the parameters are not correlated.  Token constructors work
with both %union and api.value.type union.

* data/skeletons/d.m4: Here.
* tests/calc.at: Test it.
2021-03-26 07:01:55 +01:00
Akim Demaille
ae0889d805 d: add api.value.type union support
The union of the values is handled by the backend.
In D, unions can hold classes, structs, etc., so this is more similar
to the C++ api.value.type variant.

* data/skeletons/d.m4, data/skeletons/lalr1.d: Here.
* tests/calc.at, tests/local.at: Test it.
2021-03-26 07:01:48 +01:00
Adela Vais
a9c2549c27 d: rewrite Symbol's constructors in M4
The D code was becoming too complex.
M4 is easier to maintain in the long run.

* data/skeletons/d.m4: Here.
2021-03-26 06:49:32 +01:00
Akim Demaille
fb032a28df gnulib: update 2021-03-26 06:42:17 +01:00
Akim Demaille
59a2053c83 files: please syntax-check
* src/files.c (string_free): syntax-check does not want us to cast
arguments to free.
2021-03-10 06:43:00 +01:00
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