Commit Graph

6662 Commits

Author SHA1 Message Date
Akim Demaille
b92f064e9b doc: more details about the test suite
* README-hacking.md: here.
2019-11-22 09:02:06 +01:00
Akim Demaille
98f19578aa maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-11-20 07:49:44 +01:00
Akim Demaille
7d9839c4a8 version 3.4.91
* NEWS: Record release date.
v3.4.91
2019-11-20 07:13:38 +01:00
Akim Demaille
ad32ec64c8 style: pacify syntax-check
* cfg.mk: No need to translate *.md files.
* data/skeletons/glr.c, data/skeletons/yacc.c: Fix space issues.
2019-11-20 07:10:27 +01:00
Akim Demaille
44cdc0f001 gnulib: update 2019-11-19 21:15:00 +01:00
Akim Demaille
ca796220ec doc: don't promote dangling aliases
String literals as tokens serve two distinct purposes: freeing from
having to implement the keyword matching in the scanner, and improving
error messages.  Most of the time both can be achieved at the same
time, but on occasions, it does not work so well.

We promote their use for error messages.  We will also still support
the former case, but it is _not_ the recommended approach.

* doc/bison.texi (Tokens from Literals): Clearly state that we don't
recommend looking up the token types in the list of token names.
2019-11-18 09:15:35 +01:00
Akim Demaille
8a910107b3 diagnostics: complain about undeclared string tokens
String literals, which allow for better error messages, are (too)
liberally accepted by Bison, which might result in silent errors.  For
instance

    %type <exVal> cond "condition"

does not define “condition” as a string alias to 'cond' (nonterminal
symbols do not have string aliases).  It is rather equivalent to

    %nterm <exVal> cond
    %token <exVal> "condition"

i.e., it gives the type 'exVal' to the "condition" token, which was
clearly not the intention.

Introduce -Wdangling-alias to catch this.

* src/complain.h, src/complain.c: Add support for -Wdangling-alias.
(argmatch_warning_args): Sort.
* src/symtab.c (symbol_check_defined): Complain about dangling
aliases.
* doc/bison.texi: Document it.
* tests/input.at (Dangling aliases): New test.
2019-11-17 18:27:42 +01:00
Akim Demaille
28d1ca8f48 diagnostics: yacc reserves %type to nonterminals
On

    %token TOKEN1
    %type  <ival> TOKEN1 TOKEN2 't'
    %token TOKEN2
    %%
    expr:

bison -Wyacc gives

    input.y:2.15-20: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
        2 | %type  <ival> TOKEN1 TOKEN2 't'
          |               ^~~~~~
    input.y:2.29-31: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
        2 | %type  <ival> TOKEN1 TOKEN2 't'
          |                             ^~~
    input.y:2.22-27: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
        2 | %type  <ival> TOKEN1 TOKEN2 't'
          |                      ^~~~~~

The messages appear to be out of order, but they are emitted when the
error is found.

* src/symtab.h (symbol_class): Add pct_type_sym, used to denote
symbols appearing in %type.
* src/symtab.c (complain_pct_type_on_token): New.
(symbol_class_set): Check that %type is not applied to tokens.
(symbol_check_defined): pct_type_sym also means undefined.
* src/parse-gram.y (symbol_decl.1): Set the class to pct_type_sym.
* src/reader.c (grammar_current_rule_begin): pct_type_sym also means
undefined.
* tests/input.at (Yacc's %type): New.
2019-11-17 09:45:25 +01:00
Akim Demaille
1817b475a6 doc: promote %nterm over %type
As an extension to POSIX Yacc, Bison's %type accepts tokens.
Unfortunately with string literals as implicit tokens, this is
misleading, and led some users to write

    %type <exVal> cond "condition"

believing that "condition" would be associated to the 'cond'
nonterminal (see https://github.com/apache/httpd/pull/72).

* doc/bison.texi: Promote %nterm rather than %type to declare the type
of nonterminals.
2019-11-16 12:54:44 +01:00
Akim Demaille
22ca07defa doc: formatting changes
* doc/bison.texi: No visible changes.
2019-11-16 12:54:44 +01:00
Akim Demaille
dbd6975b5c doc: work around warnings when Flex C output is compiled in C++
* doc/bison.texi (calc++/scanner.ll): here.
While at it, clarify clang vs. warnings.
2019-11-16 12:54:44 +01:00
Akim Demaille
cd726fdc4d tests: be robust to old Perl versions on Cygwin
Reported by Denis Excoffier.
https://lists.gnu.org/archive/html/bug-bison/2019-11/msg00008.html.

* tests/output.at: Be sure to remove back up files.
2019-11-16 12:54:44 +01:00
Akim Demaille
60ebd8e210 regen 2019-11-16 12:54:44 +01:00
kaneko y
3765e3e790 gram.c: Fix condition of aver
* src/gram.c (grammar_dump): Fix condition of aver.
What we want to check is that rhs is followed by its rule.
2019-11-12 08:39:28 +01:00
Akim Demaille
c313360deb doc: clarify build instructions
* README: A few fixes.
Explain how to install color support.
* README-hacking: Rename as...
* README-hacking.md: this, and convert to Markdown.
Improve typography.
Improve explanations about update-test.
2019-11-11 15:59:53 +01:00
Akim Demaille
25698b58c0 gnulib: update 2019-11-11 15:41:29 +01:00
Yuichiro Kaneko
17d34c231b gram.c: also print terminals in grammar_dump
* src/gram.c (grammar_dump): Print terminals likewise non terminals.
* tests/sets.at (Reduced Grammar): Update test case to catch up the
change and add a test case where prec and assoc are used.
2019-11-11 10:37:30 +01:00
Akim Demaille
af000bab11 doc: work around Texinfo 6.7 bug
When @code is used in a @deftype... definition, it issues quotes.
Remove them.
See https://lists.gnu.org/archive/html/help-texinfo/2019-11/msg00004.html.

* doc/local.mk: here.
2019-11-10 14:59:11 +01:00
Akim Demaille
b2347a3c3e doc: formatting changes
* doc/bison.texi: Wrap lines.
No semantical difference.
2019-11-09 07:57:05 +01:00
Akim Demaille
008d927f71 doc: use upper case for tokens
* doc/bison.texi: here.
2019-11-09 07:54:32 +01:00
Akim Demaille
1650c729d9 doc: type-face fixes
* doc/bison.texi: Use @code for types in function definitions.
2019-11-07 07:13:40 +01:00
Akim Demaille
7bdf7246fb c++: expose the type used to store line and column numbers
* data/skeletons/location.cc (position::counter_type)
(location::counter_type): New.
Use them.
* doc/bison.texi (C++ position, C++ location): Adjust.
2019-11-06 18:20:15 +01:00
Akim Demaille
583c193ffa tests: fix comment and adjust to locale names on GNU/Linux
Reported by Denis Excoffier.

* tests/diagnostics.at: here.
2019-11-03 10:32:22 +01:00
Akim Demaille
47b9ada6fa tests: really check complaints from m4
* tests/diagnostics.at (Locations from M4, Tabulations and multibyte
characters from M4): These tests are actually checking a message
coming from C, not from M4.  Replace with...
(Complaints from M4): This.
2019-11-03 10:32:22 +01:00
Akim Demaille
dcd5bb26e3 tests: simplify prologue
* tests/testsuite.h: We no longer load gnulib in the tests.
2019-11-03 10:32:22 +01:00
Akim Demaille
cce6c998b6 diagnostics: add missing translation
* src/muscle-tab.c (muscle_percent_define_check_kind): Here.
2019-11-03 09:24:12 +01:00
Akim Demaille
3398b0fa90 c++: fix old cast warnings
We still have a few old C casts in lalr1.cc, let's get rid of them.
Reported by Frank Heckenbach.

Actually, let's monitor all our casts using easy to grep macros.
Let's use these macros to use the C++ standard casts when we are in
C++.

* data/skeletons/c.m4 (b4_cast_define): New.
* data/skeletons/glr.c, data/skeletons/glr.cc,
* data/skeletons/lalr1.cc, data/skeletons/stack.hh,
* data/skeletons/yacc.c:
Use it and/or its casts.

* tests/actions.at, tests/cxx-type.at,
* tests/glr-regression.at, tests/headers.at, tests/torture.at,
* tests/types.at:
Use YY_CAST instead of C casts.

* configure.ac (warn_cxx): Add -Wold-style-cast.
* doc/bison.texi: Disable it.
2019-11-02 16:40:50 +01:00
Akim Demaille
2bd1d9e20f tests: be robust to tput errors
Reported by Denis Excoffier.

* tests/bison.in: here.
2019-11-01 12:04:13 +01:00
Akim Demaille
1f2546396e git: update ignores
I don't understand what happened in
10acc148bb.
2019-11-01 12:04:13 +01:00
Akim Demaille
809268c1a4 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-10-29 21:58:53 +01:00
Akim Demaille
10acc148bb version 3.4.90
* NEWS: Record release date.
v3.4.90
2019-10-29 21:41:00 +01:00
Akim Demaille
28f1e1546c C++: finish propagating the unsigned->signed conversion in locations
* data/skeletons/location.cc: Remove the u (for unsigned) suffix from
the initial line and column.
* NEWS: AFAICT, only C++ backends have their location types changed.
2019-10-29 09:15:25 +01:00
Akim Demaille
c53b379784 style: fix cpp indentation
Reported by syntax-check.

* src/system.h: here.
2019-10-29 09:00:46 +01:00
Akim Demaille
fead28d9e3 style: glr.c: comment changes
* data/skeletons/glr.c: here.
2019-10-29 08:59:18 +01:00
Akim Demaille
7e0b50c524 CI: pass -O1 to GCC8 with sanitizers
This build never finishes in the 50min credit given by Travis.  See if
with optimizations it works better.

* .travis.yml: here.
2019-10-26 10:39:01 +02:00
Akim Demaille
8228d96d33 reader: reduce the "scope" of global variables
We have too many global variables, adding structure would help.  For a
start, let's hide some of the variables closer to their usage.

* src/getargs.c, src/files.h (current_file): Move to...
* src/scan-gram.c: here.
* src/scan-gram.h (gram_in, gram__flex_debug): Remove, make them
private to the scanner.
* src/reader.h, src/reader.c (reader): Take a grammar file as argument.
Move the handling of scanner variables to...
* src/scan-gram.l (gram_scanner_open, gram_scanner_close): here.
(gram_scanner_initialize): Remove, replaced by gram_scanner_open.
* src/main.c: Adjust.
2019-10-26 10:39:01 +02:00
Akim Demaille
a5fc4e3b44 regen 2019-10-26 10:39:01 +02:00
Akim Demaille
3be912e4af parser: use grammar_file instead of current_file
* src/parse-gram (%initial-action): here.
(handle_skeleton): Don't depend on the current file name to look for
"local" skeletons (subject to changes coming from "#lines"): depend
only on the initial file name, the one given on the command line.
2019-10-26 10:38:39 +02:00
Akim Demaille
4b4e532748 diagnostics: use grammar_file instead of current_file
Currently there are two globals denoting the input file: grammar_file
is the one from the command line, and current_file which might change
because of #line.  Use only the former.

* src/complain.c (error_message): here.
* tests/diagnostics.at: Adjust.
2019-10-26 09:11:40 +02:00
Akim Demaille
6e7d8ba6a7 reader: let symtab deal with the symbols
* src/reader.c (reader): Move the setting up of the builtin symbols to...
* src/symtab.c (symbols_new): here.
2019-10-25 07:48:07 +02:00
Akim Demaille
c680300a29 style: remove incorrect comment
Reported by Paul Eggert.

* src/system.h: here.
2019-10-25 07:41:38 +02:00
Akim Demaille
0cbefb71e8 lalr1.cc: fix previous commit: printing of state numbers
* data/skeletons/lalr1.cc: Printing a char prints... a char.
Print ints instead.
2019-10-24 23:02:26 +02:00
Akim Demaille
402332c4b6 lalr1.cc: use computed state types
This skeleton uses a single stack of state structures, so it is less
likely to benefit from a stack size reduction than yacc.c (which uses
several stacks: state number, value and location).  But it will reduce
the size of the LAC stack.

This skeleton was already using int for state numbers, so, contrary to
yacc.c, this brings nothing for large automata.

Overall, it is still nicer to make the skeletons alike.

* data/skeletons/lalr1.cc (state_type): Here.
2019-10-24 18:16:01 +02:00
kaneko y
aa244fc5fe README: Fix a typo
* README: Fix a typo. Git command name is submodule.
2019-10-24 18:13:17 +02:00
Akim Demaille
719395c9cd examples: fix missing dependencies
Reported by Thomas Petazzoni.
https://lists.gnu.org/archive/html/bug-bison/2019-08/msg00000.html

* examples/c/reccalc/local.mk: Complete dependencies, including for
earlier versions of Automake (for sake of our CI, on top of Ubuntu
Xenial/Bionic, which feature only Automake 1.15).
(%D%/scan.c %D%/scan.h): Upgrade to the full version provided in
Automake's documentation.
2019-10-24 18:01:53 +02:00
Akim Demaille
fa9871a2fb diagnostics: simplify location handling
Locations start at line 1.  Don't accept line 0.

* src/location.c (location_print): Don't print locations with line 0.
(location_caret): Simplify.
2019-10-24 18:00:43 +02:00
Akim Demaille
76597d01f3 build: reenable -Wtype-limits
See https://lists.gnu.org/archive/html/bug-bison/2019-10/msg00061.html
to https://lists.gnu.org/archive/html/bug-bison/2019-10/msg00073.html.

Paul Eggert's changes in gnulib do fix the issue for modern GCCs (7,
8, 9) on macOS.  Unfortunately these warnings are back on the
CI (GNU/Linux) with GCC 4.6, 4.7, (not 4.8) and 4.9.

Disable the warning locally.

* configure.ac (warn_common, warn_tests): Remove -Wtype-limits.
* src/system.h (IGNORE_TYPE_LIMITS_BEGIN, IGNORE_TYPE_LIMITS_END): New.
* src/InadequacyList.c, src/parse-gram.c, src/parse-gram.y,
* src/symtab.c: Use it.
2019-10-24 08:50:14 +02:00
Akim Demaille
bc5efb558d build: remove dmalloc support
Today sanitizers are a better alternative.

* m4/dmalloc.m4: Remove.
* configure.ac, src/system.h: Adjust.
2019-10-24 07:22:17 +02:00
Akim Demaille
17e21f6158 gitignore: update 2019-10-23 23:09:56 +02:00
Paul Eggert
6ef8513e7c build: update gnulib submodule to latest 2019-10-23 13:44:58 -07:00