Commit Graph

7132 Commits

Author SHA1 Message Date
Akim Demaille
73ac8ff409 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2020-05-03 13:07:08 +02:00
Akim Demaille
0e0fb0efc9 version 3.5.92
* NEWS: Record release date.
v3.5.92
2020-05-03 12:48:16 +02:00
Akim Demaille
bb1d776be0 news: update for 3.5.92 2020-05-03 12:47:21 +02:00
Akim Demaille
d7e1abe656 gnulib: update 2020-05-03 12:43:55 +02:00
Akim Demaille
13a1537dba java: demonstrate push parsers
* data/skeletons/lalr1.java (Location): Make it a static class.
(Lexer.yylex, Lexer.getLVal, Lexer.getStartPos, Lexer.getEndPos):
These are not needed in push parsers.
* examples/java/calc/Calc.y: Demonstrate push parsers in the Java.
* doc/bison.texi: Push parsers have been supported for a long time,
remove incorrect statements stating the opposite.
2020-05-03 11:28:36 +02:00
Akim Demaille
ac2ba46053 doc: clarify what a location is
Reported by Arthur Schwarz <aschwarz1309@att.net>
https://lists.gnu.org/r/help-bison/2013-12/msg00009.html

* doc/bison.texi (Location Type): here.
2020-05-03 11:28:36 +02:00
Akim Demaille
2a7a2c1d3a tests: beware of mbswidth portability issues
Shy away from these issues on Cygwin.
Reported Denis Excoffier.
https://lists.gnu.org/r/bug-bison/2020-05/msg00003.html

* tests/diagnostics.at (Tabulations and multibyte characters): Split
in two.
2020-05-03 11:28:36 +02:00
Akim Demaille
c9b5b68c73 examples: beware of intl portability issues
Reported by Horst von Brand.
https://lists.gnu.org/r/bug-bison/2020-04/msg00033.html

* examples/c/bistromathic/Makefile: libintl might not be needed, but
libm probably is.
* examples/c/bistromathic/parse.y: Include locale.h.
2020-05-03 10:32:33 +02:00
Akim Demaille
26aef31552 examples: beware of portability issues with readline
On OpenBSD 6.5, the prompt is repeated, but not the actual command
line...  Don't try to cope with that.
Reported by Bruno Haible.
https://lists.gnu.org/r/bug-bison/2020-05/msg00015.html

* examples/c/bistromathic/bistromathic.test: Skip when readline behave
this way.
2020-05-03 10:32:33 +02:00
Akim Demaille
392f3caef6 examples: beware of the portability of flex --header-file
The option --header was introduced in version 2.5.6.
The option --header-file was introduced in version 2.6.4.
Reported by Bruno Haible.
https://lists.gnu.org/r/bug-bison/2020-05/msg00013.html

So use --header, and do bother with versions that don't support it.

* m4/flex.m4: Check whether flex supports --header.
* configure.ac (FLEX_WORKS, FLEX_CXX_WORKS): Set to false if it doesn't.
* * examples/c/reccalc/local.mk, examples/c/reccalc/Makefile:
Use --header rather than --header-file.
2020-05-03 10:32:32 +02:00
Akim Demaille
ccaa8e29f9 c++: provide backward compatibility on by_type
To write unit tests for their scanners, some users depended on
symbol_type::token():

    Lexer lex("12345");
    symbol_type t = lex.nextToken();
    assert(t.token() == token::INTLIT);
    assert(t.value.as<int>() == 12345);

But symbol_type::token() was removed in Bison 3.5 because it relied on
a conversion table.  So users had to find other patterns, such as

    assert(t.type_get() == by_type(token::INTLIT).type_get());

which relies on several private implementation details.

As part of transitioning from "token type" to "token kind", and making
this a public and documented interface, "by_type" was renamed
"by_kind" and "type_get()" was renamed as "kind()".  The latter had
backward compatibility mechanisms, not the former.

In Bison 3.6 none of this should be used, but rather

    assert(t.kind() == symbol_kind::S_INTLIT);

Reported by Pramod Kumbhar.
https://lists.gnu.org/r/bug-bison/2020-05/msg00012.html

* data/skeletons/c++.m4 (by_type): Make it an alias to by_kind.
2020-05-03 09:20:08 +02:00
Akim Demaille
76c3bccf40 yacc.c: improve formatting of the generated code
* data/skeletons/yacc.c (yy_reduce_print): here.
2020-05-02 10:17:01 +02:00
Akim Demaille
6275137378 doc: java supports push parsers since 3.0 (2013-07-25)
* doc/bison.texi: Clarify this.
2020-05-02 09:29:05 +02:00
Akim Demaille
d0571c846f java: fix coding style
I don't plan to fix everything in one go.  But this was in the way of
the next commit.

* data/skeletons/lalr1.java: Avoid space before parens.
* tests/java.at: Adjust.
2020-05-02 09:27:16 +02:00
Akim Demaille
8c1002e4b7 style: comment changes
* tests/java.at: here.
2020-05-02 09:08:26 +02:00
Akim Demaille
dbd8fd71ba todo: more 2020-05-02 08:18:20 +02:00
Akim Demaille
95bac741c3 style: more documentation about errs
Suggested by Angelo Borsotti.
https://lists.gnu.org/r/bug-bison/2014-02/msg00003.html

* src/state.h: here.
2020-05-02 08:18:20 +02:00
Akim Demaille
f8ab4d81c0 doc: document the exit status
Suggested by Alexandre Duret-Lutz.
https://lists.gnu.org/r/bug-bison/2013-09/msg00015.html

* doc/bison.texi (Invocation): Here.
2020-05-01 10:48:44 +02:00
Akim Demaille
d55c9b001a java: add missing i18n requests
* data/skeletons/lalr1.java (reportSyntaxError): Here.
2020-05-01 10:36:05 +02:00
Akim Demaille
611495999f java: style: fix coding style of yyerror/reportSyntaxError
* data/skeletons/lalr1.java: here.
2020-05-01 10:36:05 +02:00
Akim Demaille
01d5f232a9 java: avoid useless work
* data/skeletons/lalr1.java (yySymbolPrint): Avoid the computation of
the argument if useless.
While at it, fix Java coding style.
2020-05-01 10:36:05 +02:00
Akim Demaille
0407acbc59 java: comment changes
* data/skeletons/lalr1.java, examples/java/calc/Calc.y: here.
2020-05-01 10:36:05 +02:00
Akim Demaille
0c0e778bd1 news: make it more consistent
* NEWS: Use the same pattern for titles.
2020-05-01 10:36:05 +02:00
Akim Demaille
30357ae942 c++: use modern idioms to make classes non-copyable
Reported by Don Macpherson.
https://lists.gnu.org/r/bug-bison/2019-05/msg00015.html
https://github.com/akimd/bison/issues/36

* data/skeletons/lalr1.cc, data/skeletons/stack.hh,
* data/skeletons/variant.hh: Delete the copy-ctor and the copy operator.
2020-05-01 06:52:04 +02:00
Akim Demaille
fb1d76d9a9 yacc.c: avoid the use of a temporary
* data/skeletons/yacc.c: Use YYLLOC_DEFAULT directly with the final
destination.
2020-04-30 08:07:55 +02:00
Akim Demaille
a61bc3f9f8 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2020-04-29 09:07:50 +02:00
Akim Demaille
f0942df01a version 3.5.91
* NEWS: Record release date.
v3.5.91
2020-04-29 08:47:35 +02:00
Akim Demaille
52ababbc89 build: fix syntax-check issues
* cfg.mk: We do want to gettextize the examples.
* po/POTFILES.in: Adjust.
2020-04-29 08:47:04 +02:00
Akim Demaille
8e11933e41 gnulib: update 2020-04-29 08:32:25 +02:00
Akim Demaille
99efa35369 doc: document YYEOF, YYUNDEF and YYerror
* doc/bison.texi (Special Tokens): New.
* examples/c/bistromathic/parse.y: Formatting changes.
2020-04-29 08:23:55 +02:00
Akim Demaille
547545a795 package: fix distcheck
Bison emits strings to translate in the generated code, for builtin
tokens.  So they appear only in generated parsers, which are not
shipped, so they are not in the src tree, so we cannot use them in our
POTFILE.

Except src/parse-gram.c, which is in the source tree.  And even in the
git repo.  But to avoid useless diffs in the repo, we do not keep the
src/parse-gram.c _with_ the #lines.  This is done in a dist-hook which
regenerates src/parse-gram.c when we run "make dist".

Unfortunately, then, update-po traverses the whole tree and sees that
the location of the strings to translate in src/parse-gram.c have
changed, so the bison.pot is to be updated.  And that is not possible
in the "make dist" which is run within "make distcheck"
(not the one preparing the dist for distcheck, the one run by
distcheck to check that a distributed tarball can build a tarball)
because then the src tree is read-only.

So let's not put src/parse-gram.c in the POTFILE, and expose these
strings to gettextize by hand.

* src/i18n-strings.c: New.
* po/POTFILES.in: Add it, and remove src/parse-gram.c.
2020-04-29 07:01:22 +02:00
Akim Demaille
1b5cf80e32 style: avoid gettextize warnings
* src/scan-gram.l, src/scan-skel.l: Help it see the start and end of
"character literals".
2020-04-29 07:01:22 +02:00
Akim Demaille
4c641c5189 tests: beware of portability of readline
* examples/test: here.
2020-04-29 07:01:22 +02:00
Akim Demaille
3b05de2d05 yacc.c: install backward compatibility for YYERRCODE
Some people have been using that symbol.  Some even have #defined it
themselves.
https://lists.gnu.org/r/bison-patches/2020-04/msg00138.html

Let's provide backward compatibility, having it point to YYUNDEF, so
that an error message is generated.

* data/skeletons/yacc.c (YYERRCODE): New, at the exact same location
it was defined before.
2020-04-28 08:26:49 +02:00
Akim Demaille
902a235ad3 style: c++: s/type/kind/ where appropriate
These are internal details.  `type_get ()` is still there to ensure
backward compatibility, `kind ()` being the modern way.

* data/skeletons/c++.m4 (by_type, by_type::type): Rename as...
(by_kind, by_kind::kind_): this.
Adjust dependencies.
2020-04-28 08:16:05 +02:00
Akim Demaille
11027558c8 java: clean up the definition of token kinds
From

    public interface Lexer {
      /* Token kinds.  */
      /** Token number, to be returned by the scanner.  */
      static final int YYEOF = 0;
      /** Token number, to be returned by the scanner.  */
      static final int YYERRCODE = 256;
      /** Token number, to be returned by the scanner.  */
      static final int YYUNDEF = 257;
      /** Token number, to be returned by the scanner.  */
      static final int BANG = 258;
    ...
      /** Deprecated, use b4_symbol(0, id) instead.  */
      public static final int EOF = YYEOF;

to

    public interface Lexer {
      /* Token kinds.  */
      /** Token "end of file", to be returned by the scanner.  */
      static final int YYEOF = 0;
      /** Token error, to be returned by the scanner.  */
      static final int YYerror = 256;
      /** Token "invalid token", to be returned by the scanner.  */
      static final int YYUNDEF = 257;
      /** Token "!", to be returned by the scanner.  */
      static final int BANG = 258;
    ...
      /** Deprecated, use YYEOF instead.  */
      public static final int EOF = YYEOF;

* data/skeletons/java.m4 (b4_token_enum): Display the symbol's tag in
comment.
* data/skeletons/lalr1.java: Address overquotation issue.
* examples/java/calc/Calc.y, examples/java/simple/Calc.y: Use YYEOF,
not EOF.
2020-04-28 07:56:00 +02:00
Akim Demaille
cd4e799da4 error: rename the error token from YYERRCODE to YYerror
See https://lists.gnu.org/r/bison-patches/2020-04/msg00162.html.

* data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/glr.cc,
* data/skeletons/lalr1.java, doc/bison.texi,
* examples/c/bistromathic/parse.y, src/scan-gram.l, src/symtab.c
(YYERRCODE): Rename as...
(YYerror): this.
Adjust dependencies.
2020-04-28 07:54:07 +02:00
Akim Demaille
7346163840 dogfooding: use YYERRCODE in our scanner
* src/scan-gram.l: Use it.
* tests/input.at: Adjust.
2020-04-27 08:21:50 +02:00
Akim Demaille
89c4e1becf scanner: avoid spurious errors about empty character literals
On an invalid character literal such as "'\777'" we used to produce
two errors:

    input.y:2.9-12: error: invalid number after \-escape: 777
    input.y:2.8-13: error: empty character literal

Get rid of the second one.

* src/scan-gram.l (STRING_GROW_ESCAPE): New.
* tests/input.at: Adjust.
2020-04-27 08:06:49 +02:00
Akim Demaille
3262747c5b scanner: bad character literals are errors
* src/scan-gram.l: These are errors, not warnings.
* tests/input.at: Adjust.
2020-04-27 07:17:04 +02:00
Akim Demaille
5f3cd49acc regen 2020-04-27 07:08:55 +02:00
Akim Demaille
e6d928c4e8 todo: update 2020-04-26 19:55:52 +02:00
Akim Demaille
b254b36db8 all: don't emit an error message when the scanner returns YYERRCODE
I'm quite pleased to see that the tricky case of glr.c was already
prepared by the changes to support syntax_error exceptions.  Better
yet, it is actually syntax_error that becomes a special case of the
general pattern: make yytoken be YYERRCODE.

* data/skeletons/glr.c (YYFAULTYTOK): Remove the now useless (Basil)
Faulty token.
Instead, use the error token.
* data/skeletons/lalr1.d, data/skeletons/lalr1.java: When computing
the action, first check the case of the error token.

* tests/calc.at: Check cases for the error token symbols before and
after it.
2020-04-26 19:55:52 +02:00
Akim Demaille
58e79539fc c: don't emit an error message when the scanner returns YYERRCODE
* data/skeletons/yacc.c (yyparse): When the scanner returns YYERRCODE,
go directly to error recovery (yyerrlab1).
However, don't keep the error token as lookahead, that token is too
special.
* data/skeletons/lalr1.cc: Likewise.

* examples/c/bistromathic/parse.y (yylex): Use that feature to report
nicely invalid characters.
* examples/c/bistromathic/bistromathic.test: Check that.
* examples/test: Neutralize gratuitous differences such as rule
position.

* tests/calc.at: Check that case in C only.
The other case seem to be working, but that's an illusion that the
next commit will address (in fact, they can enter endless loops, and
report the error several times anyway).
2020-04-26 18:05:30 +02:00
Akim Demaille
60366b152b examples: bistromathic: demonstrate error recovery
* examples/c/bistromathic/parse.y: here.
* examples/c/bistromathic/bistromathic.test: Check it.
Included a stupid case where the error is actually ignored.
2020-04-26 16:08:47 +02:00
Akim Demaille
c90110efd3 examples: bistromathic: when quitting, close the current line
When the user ctrl-d the line, we left the cursor not at col 0.
Let's fix that.
This revealed a few short-comings in the testing framework.

* examples/test (run): Also display the diffs.
And support -n.
* examples/c/bistromathic/bistromathic.test
* examples/c/bistromathic/parse.y
2020-04-26 16:08:47 +02:00
Akim Demaille
3b50adf7f4 examples: bistromathic: comment changes
* examples/c/bistromathic/parse.y: here.
2020-04-26 16:08:47 +02:00
Akim Demaille
3aaa971096 doc: hacking tricks
* README-hacking.md: Here.
2020-04-26 16:08:42 +02:00
Akim Demaille
7eabe1c70b c++: make valid to print the empty symbol
* data/skeletons/lalr1.cc (yy_print_): here.
2020-04-26 15:09:52 +02:00
Akim Demaille
7fec669e42 c++: always define symbol_name
* data/skeletons/lalr1.cc (symbol_name): Always define it, even when
it's actually yytname which is used.
2020-04-26 15:09:52 +02:00