Commit Graph

7851 Commits

Author SHA1 Message Date
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
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