Commit Graph

6174 Commits

Author SHA1 Message Date
Akim Demaille
9cd7bd4d5f add -fsyntax-only
When debugging Bison itself, this is very handy, especially when
tweaking the frontend badly enough to break the backends. It can also
be used to check a grammar.

* src/getargs.h, src/getargs.c (feature_syntax_only): New.
(feature_args, feature_types): Adjust.
* src/main.c (main): Use it.
2019-01-28 06:47:07 +01:00
Akim Demaille
a108d84f88 style: beware of collisions on status
* src/symtab.h (status): Rename as...
(declaration_status): this, to avoid colliding with status, the
argument of 'usage'.
'status' seems a tad too general to be used only here.
2019-01-27 20:07:08 +01:00
Akim Demaille
1e83dd2229 gnulib: update 2019-01-27 19:48:09 +01:00
Akim Demaille
d02ca923e2 usage: document -ffixit
* src/getargs.c (usage): Document -ffixit.
Document the aliases of -f.
2019-01-27 18:08:55 +01:00
Akim Demaille
f82f7eb1d8 style: reduce scopes in state.c and ielr.c 2019-01-27 18:08:47 +01:00
Akim Demaille
0d472b29ec Merge branch 'maint'
* maint:
  maint: post-release administrivia
  version 3.3.1
  yacc: issue warnings, not errors, for Bison extensions
  style: formatting changes in NEWS and complain.c
  tests: don't depend on the user's definition of SHELL
2019-01-27 16:44:56 +01:00
Akim Demaille
7a21067bb9 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-27 16:17:28 +01:00
Akim Demaille
ed02d34fbc version 3.3.1
* NEWS: Record release date.
v3.3.1
2019-01-27 16:03:23 +01:00
Akim Demaille
8b0b295569 yacc: issue warnings, not errors, for Bison extensions
Reported by Kiyoshi Kanazawa.
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00029.html

* src/getargs.c (getargs): Let --yacc imply -Wyacc, not -Werror=yacc.
* tests/input.at: Adjust.
* doc/bison.tex (Bison Options): Document.
2019-01-27 15:53:28 +01:00
Akim Demaille
59a108c0a6 style: formatting changes in NEWS and complain.c 2019-01-27 15:51:44 +01:00
Kiyoshi Kanazawa
83ebc8bdb6 tests: don't depend on the user's definition of SHELL
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00031.html

* examples/test (SHELL): Set it to /bin/sh.
2019-01-27 07:06:44 +01:00
Akim Demaille
21a7fa8063 traces: always print the reduced grammar and fix it
* src/gram.c (grammar_dump): Print the effective number first instead
of last.  And fix it (remove the incorrect "+1").
Use t/f for Booleans.
* src/reduce.c: When asked, always print the reduced grammar, even if
there was nothing useless.
* tests/sets.at (Reduced Grammar): Check that.
2019-01-26 16:21:35 +01:00
Akim Demaille
83463dfbee style: rename LR0.* as lr0.*
Let's stick to lower case for file names.

* src/LR0.h, src/LR0.c: Rename as...
* src/lr0.h, src/lr0.c: these.
2019-01-26 16:21:35 +01:00
Akim Demaille
c3c50c0030 style: rename print_graph.* as print-graph.*
These are the only files with _.

* src/print_graph.h, src/print_graph.c: Rename as...
* src/print-graph.h, src/print-graph.c: these.
2019-01-26 16:16:47 +01:00
Akim Demaille
e85ab7ac9b style: various fixes
* src/gram.c: Use consistent variable names.
Prefix prefix unary operators.
(grammar_dump): Use rule_rhs_length instead of duplicating it.
* src/reduce.c: Avoid useless variables.
2019-01-26 16:16:47 +01:00
Akim Demaille
a11463a02f style: comment changes in gram.h
* src/gram.h: Shorten comments.
2019-01-26 16:16:47 +01:00
Akim Demaille
8023b3153a 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-26 11:45:20 +01:00
Akim Demaille
b23ca37ed2 version 3.3
* NEWS: Record release date.
v3.3
2019-01-26 11:32:11 +01:00
Akim Demaille
bb5e4b659b NEWS: update 2019-01-26 11:31:01 +01:00
Akim Demaille
bc8ec1d7bf c++: fix comment
* data/skeletons/c++.m4: here.
2019-01-26 10:46:33 +01:00
Akim Demaille
665c5d688c style: formatting changes
* data/skeletons/lalr1.cc: Add dnl.
* data/skeletons/bison.m4: Comment the use of dnl.
2019-01-26 10:46:33 +01:00
Akim Demaille
53d379b905 tests: run the printer/destructor test on glr.cc
* tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Adjust for
glr.cc, and use it.
2019-01-26 10:46:33 +01:00
Akim Demaille
aa85bfe3a7 gnulib: update 2019-01-24 07:40:05 +01:00
Akim Demaille
5ec9c99662 --update: when used, do not generate the output files
It is inconvenient that we also generate the output files when we
update the grammar file, and it's somewhat unexpected.  Let's not do
that.

* src/main.c (main): Skip generation when --update is passed.
* src/getargs.c (usage): Update the help message.
* doc/bison.texi (Bison Options): Likewise.
* tests/input.at: Check that we don't generate the output.
2019-01-22 06:54:31 +01:00
Akim Demaille
36cae8e752 diagnostics: let redundant definitions be only warnings
After all, this is clearly harmless.

* src/muscle-tab.c (muscle_percent_define_insert): Let equal
definitions of a %define variable be only a warning.
Adjust test cases.
2019-01-22 06:54:28 +01:00
Akim Demaille
7498ede3ab tests: improve check for updated variable names
* tests/input.at ("%define" backward compatibility): Don't define
twice "api.namespace", so that we don't get an error, which stops the
process too soon to see an error about the value given to
'lr.keep-unreachable-state'.
2019-01-22 06:52:33 +01:00
Akim Demaille
27104acdbe diagnostics: remove redundancy
Don't repeat the name of the warning in the sub messages.  E.g.,
remove the second "[-Wother]" in the following message

    foo.y:2.1-27: warning: %define variable 'parse.error' redefined [-Wother]
     %define parse.error verbose
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    foo.y:1.1-27:     previous definition [-Wother]
     %define parse.error verbose
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~

* src/complain.c (error_message): Don't print the warning type when
it's indented.
Adjust test cases.
2019-01-21 20:30:36 +01:00
Akim Demaille
7b3368a155 c++: better "scope" a workaround for GCC
* data/skeletons/lalr1.cc: Enable it only for GCC 4.8 and before.
2019-01-20 18:46:44 +01:00
Akim Demaille
ec08b369ec c++: address -Wweak-vtables warnings
Reported by Derek Clegg
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00021.html

    aux/parser-internal.h:429:12: error: 'syntax_error' has no out-of-line virtual
         method definitions; its vtable will be emitted in every translation unit
         [-Werror,-Wweak-vtables]
       struct syntax_error : std::runtime_error

To avoid this warning, we need syntax_error to have a virtual function
defined in a compilation unit.  Let it be the destructor.  To comply
with C++98, this dtor should be 'throw()'.  Merely making YY_NOEXCEPT
be 'throw()' in C++98 triggers
errors (http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00022.html),
so let's introduce YY_NOTHROW and flag only ~syntax_error with it.

Also, since we now have an explicit dtor, we need to provide an copy
ctor.

* configure.ac (warn_cxx): Add -Wweak-vtables.
* data/skeletons/c++.m4 (YY_NOTHROW): New.
(syntax_error): Declare the dtor, and define the copy ctor.
* data/skeletons/glr.cc, data/skeletons/lalr1.cc (~syntax_error):
Define.
2019-01-20 18:46:44 +01:00
Akim Demaille
05b70f47e8 style: prefer bool to char
* src/state.h, src/state.c (state::consistent): Make it a bool.
Adjust dependencies.
2019-01-20 18:31:41 +01:00
Akim Demaille
626d2f2dca glr.cc: be more alike lalr1.cc 2019-01-20 17:35:15 +01:00
Akim Demaille
5c797b1627 style: formatting changes
* data/skeletons/c++.m4: Un-remove an end-of-line.
2019-01-20 08:56:14 +01:00
Akim Demaille
ac692b572a NEWS: fixes 2019-01-20 08:25:31 +01:00
Akim Demaille
2f208ee43a 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-19 07:38:00 +01:00
Akim Demaille
013a695add version 3.2.91
* NEWS: Record release date.
v3.2.91
2019-01-19 07:25:25 +01:00
Akim Demaille
54ed577da0 style: various fixes
Some reported by syntax-check.

* po/POTFILES.in: Add fixits.cc.
* src/muscle-tab.c: Don't cast for free.
* src/files.c: Reduce scopes.
* cfg.mk: We need the cast for free in muscle_percent_define_insert.
2019-01-18 08:43:06 +01:00
Akim Demaille
4a690d3d19 doc: document -ffixit and --update
* doc/bison.texi (Bison Options): here.
2019-01-18 06:55:01 +01:00
Akim Demaille
cd1a9f076c doc: style fixes
* doc/bison.texi: Use @kbd where appropriate.
Update ^~~~ marks for caret-errors.
* build-aux/cross-options.pl: Do not add quotes to %define's argument.
2019-01-18 06:55:01 +01:00
Akim Demaille
7a0f681cb8 NEWS: update for fixits and --update 2019-01-18 06:55:01 +01:00
Akim Demaille
eb0f3e79e0 fixits: handle duplicates of %name-prefix
The test case "Deprecated directives" (currently 56) no longer emits
warnings after 'bison -u'!

* src/files.h, src/files.c (spec_name_prefix_loc): New.
* src/parse-gram.y (handle_name_prefix): Emit fixits for duplicate
%name-prefix.
* tests/input.at (Deprecated directives): Adjust.
2019-01-17 18:09:38 +01:00
Akim Demaille
25b7421c40 regen 2019-01-17 18:09:38 +01:00
Akim Demaille
e86adac52d fixits: handle %file-prefix
* src/files.h, src/files.c (spec_file_prefix_loc): New.
* src/scan-gram.l (%file-prefix): Delegate diagnostics to...
* src/parse-gram.y (handle_file_prefix): here.
* src/complain.c (duplicate_directive): Quote the directive.
* tests/input.at: Adjust.
2019-01-17 18:09:38 +01:00
Akim Demaille
5879c8dc5a fixits: handle per-rule duplicates
* src/complain.c (duplicate_rule_directive): Here.
* tests/actions.at (Invalid uses of %empty): Check it.
2019-01-17 18:09:38 +01:00
Akim Demaille
d5d148630a fixits: fix warnings about duplicates
* src/complain.c (duplicate_directive): Fix the complaint level.
* tests/input.at: Adjust.
2019-01-17 18:09:32 +01:00
Akim Demaille
b443932991 diagnostics: properly indent the "previous declaration" message
* src/complain.c (duplicate_directive, duplicate_rule_directive):
Here.
2019-01-16 08:40:47 +01:00
Akim Demaille
f5a646c390 regen 2019-01-16 08:40:47 +01:00
Akim Demaille
f038f0b12f style: rename some functions for consistency
"handle_" is the prefix used in scan-code.l for instance.

* src/parse-gram.y (do_error_verbose, do_name_prefix, do_require)
(do_skeleton, do_yacc):
Rename as...
(handle_error_verbose, handle_name_prefix, handle_require)
(handle_skeleton, handle_yacc):
these.
2019-01-16 08:40:47 +01:00
Akim Demaille
b6b397b7f0 fixits: report duplicate %yacc directives
We should use -ffixit and --update to clean files with duplicate
directives.  And we should complain only once about duplicate obsolete
directives: keep only the "duplicate" warning.  Let's start with %yacc.

For instance on:

    %fixed-output_files
    %fixed-output-files
    %yacc
    %%
    exp:

This run of bison:

    $ bison /tmp/foo.y -u
    foo.y:1.1-19: warning: deprecated directive, use '%fixed-output-files' [-Wdeprecated]
     %fixed-output_files
     ^~~~~~~~~~~~~~~~~~~
    foo.y:2.1-19: warning: duplicate directive [-Wother]
     %fixed-output-files
     ^~~~~~~~~~~~~~~~~~~
    foo.y:1.1-19: previous declaration
     %fixed-output_files
     ^~~~~~~~~~~~~~~~~~~
    foo.y:3.1-5: warning: duplicate directive [-Wother]
     %yacc
     ^~~~~
    foo.y:1.1-19: previous declaration
     %fixed-output_files
     ^~~~~~~~~~~~~~~~~~~
    bison: file 'foo.y' was updated (backup: 'foo.y~')

gives:

    %fixed-output-files
    %%
    exp:

* src/location.h, src/location.c (location_empty): New.
* src/complain.h, src/complain.c (duplicate_directive): New.

* src/getargs.h, src/getargs.c (yacc_flag): Instead of a Boolean, be
the location of the definition.
Update dependencies.

* src/scan-gram.l (%yacc, %fixed-output-files): Move the handling of
its warnings to...
* src/parse-gram.y (do_yacc): This new function.

* tests/input.at (Deprecated Directives): Adjust expectations.
2019-01-16 08:40:39 +01:00
Akim Demaille
2c8fb4d126 style: rename duplicate_directive as duplicate_rule_directive
* src/complain.h, src/complain.c: here.
Adjust callers.
2019-01-16 07:59:25 +01:00
Akim Demaille
169fe80c7f fixits: suggest running --update if there are fixits
* src/fixits.h, src/fixits.c (fixits_empty): New.
* src/complain.c (deprecated_directive): Register the Wdeprecated
fixits only if -Wdeprecated was enabled, so that we don't apply
updates if the user didn't ask for them.
* src/main.c (main): If there were fixits, issue a warning suggesting
running with --update.
Free uniqstrs after the fixits, since the latter use the former.
* tests/headers.at, tests/input.at: Update expectations.
2019-01-16 07:59:16 +01:00