Commit Graph

6108 Commits

Author SHA1 Message Date
Akim Demaille
8c3a7687e4 regen 2019-01-14 19:57:37 +01:00
Akim Demaille
72c488aa62 diagnostics: improve them for %name-prefix
Currently the diagnostics for %name-prefix are not precise enough.  In
particular, they does not show that braces must be used instead of
quotes.

Before:

    foo.y:3.1-14: warning: deprecated directive, use '%define api.prefix' [-Wdeprecated]
     %name-prefix = "foo"
     ^^^^^^^^^^^^^^

After:

    foo.y:3.1-20: warning: deprecated directive, use '%define api.prefix {foo}' [-Wdeprecated]
     %name-prefix = "foo"
     ^^^^^^^^^^^^^^^^^^^^

To do this we need the value passed to %name-prefix, so move the
warning from the scanner to the parser.

Accuracy will be very important for the forthcoming changes.

* src/parse-gram.y (do_name_prefix): New.
(PERCENT_NAME_PREFIX): Have a semantic value: the raw source, with
possibly underscores, equal sign, and spaces.  This is used to provide
a more accurate message.  It does not take comments into account,
but...
* src/scan-gram.l (%name-prefix): Delegate the warnings to the parser.

* tests/headers.at, tests/input.at: Adjust expectations.
2019-01-14 19:57:37 +01:00
Akim Demaille
a88f8117b0 diagnostics: style: avoid allocating memory when not needed
* src/muscle-tab.c (muscle_percent_variable_update): Avoid allocating
memory when it is not needed, which should be most of the time (when
there's no update to perform).
Adjust callers.
2019-01-14 19:57:37 +01:00
Akim Demaille
3551d51dd9 c++: avoid warnings about extraneous semi-colons
Reported by Derek Clegg.
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00005.html

* configure.ac (warn_cxx): Add -Wextra-semi.
* data/skeletons/c++.m4: Remove extraneous semi-colon.
2019-01-14 19:45:01 +01:00
Akim Demaille
38b17c36da style: minor changes
* src/muscle-tab.c: Sort alphabetically.
* src/scan-gram.l: Reduce scopes.
Initialize variables.
2019-01-13 12:48:42 +01:00
Akim Demaille
f9db426de6 c++: beware of -Wshadow
This line:

    slice<stack_symbol_type, stack_type> slice (yystack_, yylen);

triggers warnings:

    parse.h:1790:11: note: shadowed declaration is here

Reported by Frank Heckenbach.
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00002.html

* configure.ac (warn_c): Move -Wshadow to...
(warn_common): here.
* data/skeletons/stack.hh (slice): Define as an inner class of stack.
* data/skeletons/lalr1.cc: Adjust.
Rename the variable as 'range' instead of 'slice'.
2019-01-13 12:26:58 +01:00
Akim Demaille
c927c955c8 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-01-12 10:59:57 +01:00
Akim Demaille
475fd79c8e version 3.2.90
* NEWS: Record release date.
v3.2.90
2019-01-12 10:46:43 +01:00
Akim Demaille
586e2ab0c8 yacc: fix relocatability
* src/yacc.in (prefix): Define it, as it's typically needed for
exec_prefix.
2019-01-12 10:45:21 +01:00
Akim Demaille
7e617dd847 syntax-check: adjust paths
* cfg.mk: here.
(require_config_h): New.
2019-01-12 09:41:15 +01:00
Akim Demaille
3355ee32f0 style: formatting clean up
* data/skeletons/d.m4, examples/d/calc.y, src/output.c,
* src/parse-gram.y:
No tab, no trailing spaces.
Reported by syntax-check.
2019-01-12 09:41:10 +01:00
Akim Demaille
7d545fd23f po: remove bitset/stats.c
* po/POTFILES.in: here.
2019-01-12 09:38:57 +01:00
Akim Demaille
70a4b97daf tests: fix usage of AT_PARSER_CHECK
The parser must be the first command.  Caught by syntax-check.

* tests/c++.at: here.
2019-01-12 09:38:57 +01:00
Akim Demaille
c314b5509f gnulib: update 2019-01-12 09:38:57 +01:00
Akim Demaille
f0d7f71a64 NEWS: update 2019-01-12 08:19:46 +01:00
Akim Demaille
c8ee05c2b2 style: isolate the creation of tname in a function
* src/output.c (prepare_symbol_names): New.
Use it.
2019-01-12 07:34:50 +01:00
Akim Demaille
d3801ad2d1 tests: formatting changes
* tests/input.at, tests/regression.at: here.
2019-01-12 07:34:50 +01:00
Akim Demaille
8b717ca5ae doc: use @option consistently
* doc/bison.texi: Use @option, not @code, for options.
2019-01-05 15:43:39 +01:00
Akim Demaille
b7ddb1f224 yacc.c: avoid negated if
* data/skeletons/yacc.c: Prefer a "direct" conditional.
2019-01-05 15:09:28 +01:00
Akim Demaille
2471733f1a package: bump copyrights to 2019 2019-01-05 14:58:05 +01:00
Akim Demaille
c0c45cfa38 java/d: rename some %define variables for consistency
See 890ee8a1fd and
https://lists.gnu.org/archive/html/bison-patches/2019-01/msg00024.html.

* data/skeletons/d.m4, data/skeletons/java.m4
(abstract, annotations, extends, final, implements, public, strictfp):
Rename as...
(api.parser.abstract, api.parser.annotations, api.parser.extends)
(api.parser.final, api.parser.implements, api.parser.public)
(api.parser.strictfp):
these.

* src/muscle-tab.c (muscle_percent_variable_update): Ensure backward
compatibility.

* doc/bison.texi, examples/d/calc.y, examples/java/Calc.y,
tests/input.at: Adjust.
2019-01-05 12:28:55 +01:00
Akim Demaille
230d6c5160 java/d: remove useless macros
There are many macros that are defined and used just
once (b4_public_if, b4_abstract_if, etc.).  That's overkill.  Rather,
let's define a macro to build the "public class YYParser" line.

It appears that the same syntax with "extends", "abstract", etc. is
implemented in the D parser, which looks very fishy...

* data/skeletons/d.m4, data/skeletons/java.m4 (b4_public_if)
(b4_abstract_if, b4_final_if, b4_strictfp_if): Replace with
(b4_parser_class_declaration): this.
* data/skeletons/lalr1.d, data/skeletons/lalr1.java: Adjust.
2019-01-05 12:28:28 +01:00
Akim Demaille
eb2b5aef0a style: clean tests
* tests/named-refs.at: here.
2019-01-05 10:15:33 +01:00
Akim Demaille
df732955ff gnulib: update
In particular, report uninitialized submodules instead of breaking
symlinks.

For reports, see
https://lists.gnu.org/archive/html/bug-bison/2011-05/msg00012.html
https://lists.gnu.org/archive/html/help-bison/2018-12/msg00034.html

For a fix, see
https://lists.gnu.org/archive/html/bug-gnulib/2019-01/msg00024.html
2019-01-05 10:15:33 +01:00
Akim Demaille
84276bc3d5 glr.cc: fix the handling of syntax_error from the scanner
Commit 90a8537e62 was right, but issued
two error messages.  Commit 80ef7e7639
tried to address that by mapping yychar and yytoken to empty, but that
completely breaks the invariants of glr.c.  In particular, yygetToken
can be called repeatedly and is expected to return the latest result,
unless yytoken is YYEMPTY.  Since the previous attempt was "recording"
that the token was coming from an exception by setting it to YYEMPTY,
instead of getting again the faulty token, we fetched another one.

Rather, revert to the first approach: map yytoken to "invalid token",
but record in yychar the fact that we come from an exception thrown in
the scanner.

* data/skeletons/glr.c (YYFAULTYTOK): New.
(yygetToken): Use it to record syntax errors from the scanner.
* tests/c++.at (Syntax error as exception): In addition to checking
syntax_error with error recovery, make sure it also behaves as
expected without.
2019-01-05 10:15:33 +01:00
Akim Demaille
b90675e67a clearly deprecate %name-prefix
* src/scan-gram.l (%name-prefix): Issue a deprecation warning.

* tests/calc.at, tests/headers.at, tests/input.at, tests/java.at,
* tests/javapush.at, tests/local.at: Adjust expectations.
Or disable -Wdeprecated.

* doc/bison.texi: Document that %name-prefix is replaced by %define
api.prefix.
2019-01-03 09:03:33 +01:00
Akim Demaille
9ec93d4e34 examples: clean up the Java/D examples
* examples/java/Calc.y: Fix indentation.
Sort.
Don't use %name-prefix, since api.parser.class is already defined.
* examples/d/calc.y: Likewise.
2019-01-03 09:02:37 +01:00
Akim Demaille
9f81497a0c doc: formatting changes
* doc/bison.texi: here.
2019-01-03 09:02:22 +01:00
Akim Demaille
890ee8a1fd rename parser_class_name as api.parser.class
The previous name was historical and inconsistent.

* src/muscle-tab.c (define_directive): Use the proper value passing
syntax, based on the muscle kind.
(muscle_percent_variable_update): Use the right value passing syntax.
Migrate from parser_class_name to api.parser.class.

* data/skeletons: Migrate from parser_class_name to api.parser.class.

* doc/bison.texi (%define Summary): Document both parser_class_name
and api.parser.class.
Promote the latter over the former.
2019-01-02 19:14:32 +01:00
Akim Demaille
092b787198 style: formatting changes
* src/scan-gram.l: Here.
2019-01-02 19:14:32 +01:00
Akim Demaille
6d9818b0cf style: glr.c: prefer returning a value rather than passing pointers
This is very debatable.  This function is not pure at all, so it could
stick to returning void: that's a common coding style to tell the
difference between "real" (pure) functions and side-effecting
subroutines.  However, we already have this style elsewhere (e.g.,
yylex), and I feel the callers are somewhat nice to read this way.

* data/skeletons/glr.c (yygetLRActions): Return the action rather than
passing by pointer.
While at it, fix type of yytoken.
Adjust callers.
2019-01-02 12:08:04 +01:00
Akim Demaille
80ef7e7639 glr.cc: don't issue two error messages when syntax_error is thrown
Reported by Askar Safin.
https://lists.gnu.org/archive/html/bison-patches/2019-01/msg00000.html

* data/skeletons/glr.c (yygetToken): Return YYEMPTY when an exception
is thrown.
* data/skeletons/lalr1.cc: Log when an exception is caught.
* tests/c++.at (Syntax error as exception): Be sure to recover from
error before triggering another error.
2019-01-02 12:08:04 +01:00
Akim Demaille
5be47a73e8 skeletons: shorten b4_parser_class_name to b4_parser_class
* skeletons/c++.m4, skeletons/d.m4, skeletons/glr.c, skeletons/glr.cc,
* skeletons/java.m4, skeletons/lalr1.cc, skeletons/lalr1.d,
* skeletons/lalr1.java: Here.
2019-01-02 08:02:23 +01:00
Akim Demaille
0dfad676e3 glr.cc: remove duplicate definition of YYLLOC_DEFAULT
It's already provided by glr.c.

* data/skeletons/glr.cc (b4_post_prologue): Here.
2019-01-02 08:02:23 +01:00
Akim Demaille
d05b8f181e style: sort includes in scanners
* src/scan-code.l, src/scan-gram.l, src/scan-skel.l: Reorder includes.
2019-01-02 08:02:23 +01:00
Akim Demaille
86cb2e72fd style: formatting changes in the doc
* doc/bison.texi: here.
2019-01-02 08:02:23 +01:00
Akim Demaille
d07564af63 style: remove stray empty lines
* data/skeletons/glr.c, data/skeletons/glr.cc: here.
* data/skeletons/bison.m4 (b4_glr_cc_if): Move it here.
2019-01-02 08:01:48 +01:00
Akim Demaille
90a8537e62 glr.cc: support syntax_error exceptions
Kindly requested by Аскар Сафин (Askar Safin).
http://lists.gnu.org/archive/html/bug-bison/2018-12/msg00033.html

* data/skeletons/glr.c (b4_glr_cc_if): New.
Use it.
(yygetToken): Catch syntax_errors.
* data/skeletons/glr.cc (YY_EXCEPTIONS): New.
* tests/c++.at: Check it.
2018-12-31 07:48:09 +01:00
Akim Demaille
6653c912da glr.c: factor the calls to yylex
The call protocol of yylex is quite complex, and repeated three
times.  Let's factor it.

* data/skeletons/glr.c (yygetToken): New.
Use it.
2018-12-31 07:31:27 +01:00
Akim Demaille
5bcd4292bb style: reduce scopes in glr.c
* data/skeletons/glr.c (yyrecoverSyntaxError): here.
2018-12-31 07:29:50 +01:00
Akim Demaille
9a110873a0 tests: refactor 2018-12-30 14:02:59 +01:00
Akim Demaille
7ff7ef678c c++: inline the implementation of syntax_error in its definition
This way, it is easier to make sure its implementation is available in
glr.cc too, which is not the case currently.

* data/skeletons/c++.m4 (b4_public_types_define): Move the
implementation of syntax_error...
(b4_public_types_declare): here.
2018-12-30 10:16:03 +01:00
Akim Demaille
597600fd83 style: formatting changes
* tests/input.at: here.
2018-12-29 09:23:09 +01:00
Akim Demaille
4d7df9aec7 symbol: don't crash on symbol without content
When running with --trace=parse, we may crash.

* src/symtab.c (symbol_print): Avoid that.
2018-12-29 09:23:09 +01:00
Akim Demaille
7c25df547e README-hacking: update 2018-12-28 18:49:26 +01:00
Akim Demaille
f773e6ead5 reader: get rid of a useless function
Useless since 58d7a1a1c7 (2006).

* src/parse-gram.y, src/reader.h (token_name): Remove, unused.
2018-12-28 18:48:07 +01:00
Akim Demaille
0dc44adbf6 parsers: fix minor stylistic issues
* data/skeletons/variant.hh (b4_token_constructor_declare): Remove,
unused since the previous commit.
Fix indentation issues.
* data/skeletons/c++.m4: Fix indentation issues.
2018-12-27 18:23:49 +01:00
Akim Demaille
7938ab53ff c++: check several parsers in the same program
* tests/local.at (AT_LOCATION_TYPE_IF): Turn into...
(AT_LOCATION_TYPE_SPAN_IF): this.
Adjust dependencies.
* tests/headers.at (Several parsers): Add another C++ parser,
which uses the first C++ parser's locations.
2018-12-27 18:22:33 +01:00
Akim Demaille
5fb0d276b3 c++: variants: fuse declarations and definitions
We used to create a short definition of yy::parser with all the
implementations of its member functions outside.  But yy::parser is no
longer short and simple to read.  Maintaining each function twice is
painful: a lot of redundancy but different indentation levels, output
which depends on whether we are in a header or not (see
d132c2d545), etc.

Let's simplify this and put the implementations into the class
definition itself.

Discussed in this monologue:
https://lists.gnu.org/archive/html/bison-patches/2018-12/msg00058.html.

* data/skeletons/c++.m4, data/skeletons/lalr1.cc,
* data/skeletons/variant.hh (b4_basic_symbol_constructor_define)
(_b4_token_constructor_declare, b4_token_constructor_declare)
Merge into...
(b4_basic_symbol_constructor_define, _b4_token_constructor_define)
(b4_token_constructor_define): these.
2018-12-26 09:12:25 +01:00
Akim Demaille
50285ff066 examples: fix dependencies
Commit 112ccb5ed7 moved the skeletons
from dist_pkgdata_DATA to dist_skeletons_DATA, hence broke the dependencies.

* Makefile.am (dependencies): New.
Use it where appropriate.
2018-12-26 08:44:01 +01:00