Commit Graph

6747 Commits

Author SHA1 Message Date
Akim Demaille
e3812bb8c3 yacc.c: make sure we properly propagated the user's number for error
* data/skeletons/yacc.c (YYERRCODE): Be truthful.
* tests/input.at (Redefining the error token): Check that.
2020-03-08 08:10:11 +01:00
Akim Demaille
cfcd823e16 diagnostics: don't crash because of repeated definitions of error
According to https://www.unix.com/man-page/POSIX/1posix/yacc/, the
user is allowed to specify her user number for the error token:

    The token error shall be reserved for error handling. The name
    error can be used in grammar rules. It indicates places where the
    parser can recover from a syntax error. The default value of error
    shall be 256. Its value can be changed using a %token
    declaration. The lexical analyzer should not return the value of
    error.

I think this feature is useless, the user should not have to deal with
that.  The intend is probably to give the user a means to use 256 if
she wants to, but provided "error" cleared the path first by being
assigned another number.  In the case of Bison, 256 is assigned to
"error" at the end if the user did not use it for a token of hers.  So
this feature is useless.

Yet it is valid, and if the user assigns twice a token number to
"error", then the second time we want to complain about it and want to
show the original definition.  At this point, we try to display the
built-in definition of "error", whose location is NULL, and we crash.

Rather, the location of the first user definition of "error" should
become its defining location.

Reported byg Ahcheong Lee.
https://lists.gnu.org/r/bug-bison/2020-03/msg00007.html

* src/symtab.c (symbol_class_set): If this is a declaration and the
symbol was not declared yet, keep this as defining location.
* tests/input.at (Redefining the error token): New.
2020-03-08 08:10:11 +01:00
Akim Demaille
2f02d9beae style: initialize some struct members
* src/symtab.c (sym_content_new): Initialize all the location members.
Not needed by the code, but disturbing values when using a debugger.
2020-03-08 08:10:11 +01:00
Akim Demaille
b638603477 diagnostics: beware of zero-width characters
Currenly we rely on (visual) width of the characters to decide where
to open and close the styling of the quoted lines.  This breaks when
we deal with zero-width characters: we cannot just rely on (visual)
columns, we need to know whether we are before, inside, or after the
highlighted portion.

* src/location.c (location_caret): col_end: no longer add 1, "regular"
characters have a width of 1, only 0-width characters have 0-width.
opened: replace with 'state', a three-valued enum.
Don't reopen the style if we already did.
* tests/diagnostics.at (Zero-width characters): New.
2020-03-08 08:10:11 +01:00
Akim Demaille
e21ff47f5d diagnostics: be sure to close the styling when lines are too short
bar.y:4.12-17: <error>error:</error> redefining user token number of foo
    -    4 | %token foo <error>123
    +    4 | %token foo <error>123</error>
           |            <error>^~~~~~</error>

* src/location.c (location_caret): Be sure to close.
* tests/diagnostics.at (Line is too short, and then you die): New.
2020-03-07 10:01:52 +01:00
Akim Demaille
b82b387da9 muscles: fix incorrect decoding of $
Bug introduced in 458171e6df.
https://lists.gnu.org/archive/html/bison-patches/2013-11/msg00009.html

Reported by Ahcheong Lee.
https://lists.gnu.org/r/bug-bison/2020-03/msg00010.html

* src/muscle-tab.c (COMMON_DECODE): "$" is coded as "$][", not "$[][".
* tests/input.at ("%define" enum variables): Check that case.
2020-03-07 07:45:10 +01:00
Akim Demaille
641e326303 code: be robust to reference with invalid tags
Because we want to support $<a->b>$, we must accept -> in type tags,
and reject $<->$, as it is unfinished.
Reported by Ahcheong Lee.

* src/scan-code.l (yylex): Make sure "tag" does not end with -, since
-> does not close the tag.
* tests/input.at (Stray $ or @): Check this.
2020-03-06 17:29:26 +01:00
Akimn Demaille
192e9fdf77 build: fix typo
* build-aux/cross-options.pl: here.
2020-03-06 08:32:26 +01:00
Akim Demaille
a4a3f08c11 doc: update recommandation for libtextstyle
* README: here.
2020-03-06 08:32:18 +01:00
Akim Demaille
666df338a7 style: comment changes
* src/symtab.h, src/lr0.c: here.
2020-03-06 08:32:03 +01:00
Akim Demaille
b437b16603 examples: use consistently the GFDL header for readmes
* examples/c++/README.md, examples/c++/calc++/README.md,
* examples/c/calc/README.md, examples/c/lexcalc/README.md,
* examples/c/reccalc/README.md:
Prefer the GFDL banner to the GPL one.
2020-03-06 08:31:34 +01:00
Akim Demaille
b493c173c9 style: remove useless declarations
* src/reader.h: Don't duplicate what parse-gram.h already exposes.
* src/lr0.h: Remove useless include.
2020-03-06 08:30:21 +01:00
Adrian Vogelsgesang
aab3feb5a1 typo: succesful -> successful
* data/skeletons/lalr1.cc: here
* etc/bench.pl.in: here
* src/location.c: and here.
2020-03-06 08:29:58 +01:00
Akim Demaille
b7942f2661 README: point to tests/bison, and document --trace
Reported by Victor Morales Cayuela.

* README, README-hacking.md: here.
2020-03-06 08:28:23 +01:00
Akim Demaille
cefb538ab0 gnulib: update 2020-03-06 08:25:52 +01:00
Akim Demaille
26c5f48c1c maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2020-02-13 19:11:16 +01:00
Akim Demaille
7f921d18dd version 3.5.2
* NEWS: Record release date.
v3.5.2
2020-02-13 18:25:21 +01:00
Akim Demaille
cc3760ef51 news: 3.5.2
* NEWS: Update.
2020-02-13 18:25:11 +01:00
Akim Demaille
2f23ca6f65 gnulib: update 2020-02-13 08:18:12 +01:00
Akim Demaille
468b68c5cd doc: update Doxygen template
* Doxyfile.in: Run doxygen -u on it.
2020-02-13 08:18:12 +01:00
Akim Demaille
9ed802a026 java: avoid trailing white spaces
* data/skeletons/java.m4 (b4_maybe_throws): Issue a space before when needed.
* data/skeletons/lalr1.java: Avoid trailing spaces.
2020-02-13 08:18:12 +01:00
Akim Demaille
fb554c2804 m4: fix b4_token_format
We used to emit:

    /** Token number,to be returned by the scanner.  */
    static final int NUM = 258;
    /** Token number,to be returned by the scanner.  */
    static final int NEG = 259;

with no space after the comma.  Fix that.

* data/skeletons/bison.m4 (b4_token_format): Quote where appropriate.
2020-02-13 08:18:11 +01:00
Akim Demaille
47850d4f58 doc: clearly state that %yacc only makes sense with yacc.c
* doc/bison.texi: here.
2020-02-13 08:18:11 +01:00
Akim Demaille
57b035a242 doc: spell check
* doc/bison.texi: here.
2020-02-13 08:18:11 +01:00
Akim Demaille
1587a5ea9b examples: be more robust to spaces in paths
Reported by Nikki Valen.
https://lists.gnu.org/r/bug-bison/2020-01/msg00032.html

* examples/test ($prog): Remove, replaced by...
(prog): This new function, which pays attention to quoting shell
variables.
2020-01-21 07:01:34 +01:00
Adrian Vogelsgesang
4ab2cf7450 larlr1.cc: Reject unsupported values for parse.lac
Just as the yacc.c skeleton, the lalr1.cc skeleton should reject
invalid values for parse.lac.

* data/skeletons/lalr1.cc: check validity of parse.lac
* tests/input.at: new test cases
2020-01-21 06:57:21 +01:00
Akim Demaille
7e3a513d88 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2020-01-19 14:35:50 +01:00
Akim Demaille
57f64ebbf8 version 3.5.1
* NEWS: Record release date.
v3.5.1
2020-01-19 14:17:48 +01:00
Akim Demaille
c8d997cb5f news: update 2020-01-19 14:10:46 +01:00
Akim Demaille
61b8a8def5 CI: use ICC again
See https://github.com/nemequ/icc-travis/issues/15.
Thanks to Jeff Hammond and Evan Nemerson for their help.

* configure.ac (warn_common): Disable dubious warnings.
* .travis.yml: Use ICC again.
2020-01-19 11:36:47 +01:00
Akim Demaille
6990c5bde9 warnings: pacify ICC in lalr1.cc
See 139d065594.

* data/skeletons/yacc.c: If I might be a char, write a[+I] instead of
a[I], so that ICC does not complain.
2020-01-19 11:35:26 +01:00
Jim Meyering
27e822abfd test: report.at: avoid tiny new failure
Be robust to newer versions of Autoconf where the package URL defaults
to https instead of http.

* configure.ac (AC_INIT): Use https.
* tests/report.at: Adjust expected output s/http/https/
to match updated URL.
2020-01-19 10:03:01 +01:00
Akim Demaille
21ba496083 git: update ignores 2020-01-19 10:02:55 +01:00
Akim Demaille
9cf0a97aa9 gnulib: update 2020-01-11 06:03:51 +01:00
Akim Demaille
3dec8a4caf lalr1.cc: avoid static_cast
Reported by donmac703.
Fixes https://github.com/akimd/bison/issues/20.

* data/skeletons/lalr1.cc: here.
2020-01-10 19:31:00 +01:00
Akim Demaille
2cb52c5a91 glr.c: add missing cast
Reported by psjo.
Fixes https://github.com/akimd/bison/issues/19.

* data/skeletons/glr.c (yyprocessOneStack): Here.
2020-01-10 19:30:54 +01:00
Akim Demaille
04f3bfc596 regen 2020-01-10 19:21:35 +01:00
Akim Demaille
c67daa9a97 package: bump copyrights to 2020
Run 'make update-copyright'.
2020-01-10 19:16:23 +01:00
Akim Demaille
2ca8e86f83 gitignore: update 2020-01-10 19:16:16 +01:00
Akim Demaille
78bb152a63 tests: also check -Wchar-subscripts
GCC's -Wchar-subscripts may report issues on platforms where char is
unsigned.  Unfortunately the current CI does not reproduce the
problem.  But that would allow contributors to report issues if the
warning appears somewhere.

See 139d065594.
Problem reported by Andy Fiddaman in:
https://lists.gnu.org/r/bug-bison/2019-12/msg00021.html

* configure.ac (warn_common): Add -Wchar-subscripts.
2019-12-31 12:00:02 +01:00
Akim Demaille
4d6ff4c5e5 CI: do not specify the language
When we give travis the langugage, it overrides our envvars.  Instead
of the MATRIX_EVAL trick, just stop specifying the language.
2019-12-30 15:28:15 +01:00
Akim Demaille
9bb5087ad1 CI: remove ICC support, we can no longer use it
https://github.com/nemequ/icc-travis/issues/15
2019-12-30 08:56:46 +01:00
Akim Demaille
d29e40a047 doc: clean up the description of YYDEBUG
* doc/bison.texi: Make it clearer that %define parse.trace is the
preferred options.
Fix a typo about api.prefix.
2019-12-29 11:13:00 +01:00
Akim Demaille
b10366f296 glr.cc: avoid compiler warnings
381. types.at:366: testing glr.cc api.value.type={double} ...
    test.cc:207:57: error: "__clang_major__" is not defined, evaluates to 0 [-Werror=undef]
      207 | #if defined __APPLE__ && YY_CPLUSPLUS < 201103L && 4 <= __clang_major__
          |                                                         ^~~~~~~~~~~~~~~

* data/skeletons/glr.cc: Check __clang_major__ before using it.
2019-12-29 11:13:00 +01:00
Paul Eggert
139d065594 warnings: pacify ‘gcc -Wchar-subscripts’ in yacc.c
Problem reported by Andy Fiddaman in:
https://lists.gnu.org/r/bug-bison/2019-12/msg00021.html
* data/skeletons/yacc.c (yy_reduce_print, yy_lac, yysyntax_error)
(yyreturn): If I might be a char, write a[+I] instead of a[I],
so that ‘gcc -Wchar-subscripts’ does not complain.
2019-12-18 13:35:28 -08:00
Akim Demaille
0d73c39bb7 doc: formatting changes
* doc/bison.texi: No output changes.
2019-12-14 17:19:53 +01:00
Akim Demaille
7f01adced9 tests: don't fail if seq is no available
As is the case on Solaris.
Reported by Dennis Clarke.
https://lists.gnu.org/archive/html/bug-bison/2019-12/msg00011.html

* examples/c/reccalc/reccalc.test: Skip if there is no seq.
2019-12-14 17:19:53 +01:00
Akim Demaille
3bad20352c maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-12-11 07:57:45 +01:00
Akim Demaille
cb3bf6493d version 3.5
* NEWS: Record release date.
v3.5
2019-12-11 07:41:51 +01:00
Akim Demaille
57503e2165 news: prepare for 3.5 2019-12-10 07:06:04 +01:00