Commit Graph

6351 Commits

Author SHA1 Message Date
Akim Demaille
ab3eaff7c4 doc: use colors for diagnostics in TeX too
Thanks to Gavin Smith and Patrice Dumas.
http://lists.gnu.org/archive/html/help-texinfo/2019-04/msg00015.html

* doc/bison.texi (@colorWarning, @colorError, @colorNotice)
(@colorOff): Define for TeX and HTML.
(@dwarning, @derror, @dnotice): Use them.
2019-05-09 19:21:02 +02:00
Akim Demaille
85e83ea968 gnulib: update to fix location tracking in UTF-8 on Solaris
This update contains Bruno Haible's fix for the location tracking
issue reported by Kiyoshi Kanazawa.

https://lists.gnu.org/archive/html/bug-gnulib/2019-05/msg00020.html
https://lists.gnu.org/archive/html/bug-bison/2019-04/msg00020.html
2019-05-08 16:34:31 +02:00
Akim Demaille
0269c6fb03 diagnostics: rename --style=debug as --color=debug
It is more consistent with --color=html, --color=test, etc.

* src/getargs.h, src/getargs.c (style_debug): Rename as...
(color_debug): this.
(getargs_colors): Rename --style=debug as --color=debug.
Adjust dependencies.
2019-05-08 13:36:47 +02:00
Akim Demaille
23e536af49 diagnostics: support --color=html
Based on a message from Bruno Haible.
https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=commitdiff;h=fe18e92743b7226791a5f28d7c786941a1bf8cc9

This does not generate proper HTML: special characters are not escaped
for instance.  This is a hidden feature meant for Bison developers,
not end users.

* src/complain.c (complain_init_color): Support --color=html.
2019-05-08 13:36:47 +02:00
Akim Demaille
cd56929097 tests: use %empty instead of comments
* tests/c++.at, tests/glr-regression.at: here.
2019-05-08 09:11:37 +02:00
Akim Demaille
7aa38561f7 fixits: sort them before applying them
An experimental commit introduced a fix-it hint that changes comments
such as "/* empty */" into %empty.  But in some case, because
diagnostics are not necessarily emitted in order, the fixits also come
in disorder, which must never happen, as the fixes are installed in
one pass.

* src/fixits.c (fixits_register): Insert them in order.
2019-05-08 09:10:28 +02:00
Akim Demaille
22a00cfbf2 style: use warning_is_enabled instead of duplicating it
* src/complain.c (deprecated_directive): Here.
2019-05-04 17:50:57 +02:00
Akim Demaille
8c06cb9130 fixits: be sure to preserve the action when adding %empty
Currently we remove the rhs to install %empty instead.

* src/reader.c (grammar_rule_check_and_complete): Insert the missing
%empty in front of the rhs, not in replacement thereof.
* tests/actions.at (Add missing %empty): Check that.
2019-05-03 16:28:28 +02:00
Akim Demaille
b5233ba323 tests: don't duplicate the portability prologue
* tests/actions.at, tests/input.at: Don't repeat the prologue, skip it.
* tests/diagnostics.at, tests/local.at: Comment changes.
2019-05-03 16:28:28 +02:00
Akim Demaille
013720f0e7 style: use consistently *_loc for locations
Some members are called foo_location, others are foo_loc.  Stick to
the latter.

* src/gram.h, src/location.h, src/location.c, src/output.c,
* src/parse-gram.y, src/reader.h, src/reader.c, src/reduce.c,
* src/scan-gram.l, src/symlist.h, src/symlist.c, src/symtab.h,
* src/symtab.c:
Use _loc consistently, not _location.
2019-05-03 16:28:28 +02:00
Akim Demaille
365b4d95a4 style: clarify the use of symbol_lists' locations
symbol_list features a 'location' and a 'sym_loc' member.  The former
is expected to be set only for symbol_lists that denote a symbol (not
a type name), and the latter should only denote the location of the
symbol/type name.  Yet both are set, and the name "location" is too
unprecise.

* src/symlist.h, src/symlist.c (symbol_list::location): Rename as
rhs_loc for clarity.  Move it to the "section" of data valid only
for rules.
* src/reader.c, src/scan-code.l: Adjust.
2019-05-03 16:28:28 +02:00
Akim Demaille
5bb44cca81 maint: update gnulib-po/.gitignore 2019-05-03 16:28:28 +02:00
Akim Demaille
15f9f8c853 tests: don't require a D compiler
Reported by Kiyoshi Kanazawa.
http://lists.gnu.org/archive/html/bug-bison/2019-04/msg00018.html

* tests/atlocal.in (BISON_DC_WORKS): New.
* tests/local.at (AT_COMPILE_D): Use it.
2019-04-29 22:27:01 +02:00
Akim Demaille
04676a5085 doc: use svg instead of png
* doc/bison.texi, doc/local.mk: here.
2019-04-29 07:44:19 +02:00
Akim Demaille
cf44351dd7 doc: use colors
* doc/bison.texi (dwarning, derror, dnotice): New.
Use them in the diagnostics.
* doc/local.mk (AM_MAKEINFOFLAGS): Pass customization variables.
2019-04-29 07:44:19 +02:00
Akim Demaille
614e0bbe23 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-04-28 12:02:35 +02:00
Akim Demaille
3eb7b0ee78 version 3.3.90
* NEWS: Record release date.
v3.3.90
2019-04-28 11:45:38 +02:00
Akim Demaille
02a1600994 package: add missing CLEANFILES
* examples: here.
2019-04-28 11:39:10 +02:00
Akim Demaille
f6868c5a77 build: don't generate the graph reports
Revert "build: also generate the graph
reports" (4ec413da32).  The problem is
Automake's ylwrap which does not rename y.dot with the appropriate
name.  We should completely stop using Automake's support for Yacc,
which is not something I will do right now.  So step back.

* Makefile.am (AM_YFLAGS_WITH_LINES): Don't pass --graph.
2019-04-28 11:39:10 +02:00
Akim Demaille
f92f2f8afe package: don't regen the parser during dist if unneeded
* Makefile.am (gen-synclines): New.
2019-04-28 11:39:10 +02:00
Akim Demaille
0cc04eaa2a package: don't ship the sources generated from the parser
Because some of our examples use

    %C%_reccalc_SOURCES = %D%/parse.y

Automake ships parse.y and parse.c, and possibly parse.h when it
"understands" that there is one.  This is not what we want: ship only
parser.y.  Yet we still want to use Automake to compile the sources
from parser.y.  The easiest seems to use

    nodist_%C%_reccalc_SOURCES = %D%/parse.y

together with

    dist_reccalc_DATA = %D%/parse.y %D%/scan.l %D%/Makefile %D%/README.md

which guarantees that parse.y is indeed shipped.

* examples/c/calc/local.mk, examples/c/lexcalc/local.mk,
* examples/c/reccalc/local.mk: Always use nodist_*SOURCES for parsers,
let the dist_*_DATA rules do their job.
2019-04-28 11:39:10 +02:00
Akim Demaille
57290d63fd package: various fixes for syntax-check
* cfg.mk: Disable checks where needed (e.g., we do want to check the
behavior with tabs).
(sc_at_parser_check): Remove.  Unfortunately since
a11c144609 we no longer use the './'
prefix to run programs in the current directory.  That was so that we
could run Java programs like the other, although they are no run with
the `./` prefix (see 967a59d2c0).
As a consequence this sc check no longer makes sense.
However, since now AT_PARSER_CHECK passes the `./` prefix itself, this
sc-check was superfluous.
* examples/c/reccalc/scan.l: Use memcpy, not strncpy.
* src/ielr.c, src/reader.c: Obfuscate "lr(0)" so that the sc-check for
"space before paren" does not fire.
* tests/diagnostics.at: Avoid space-tab, use tab-tab.
2019-04-28 08:24:31 +02:00
Akim Demaille
33b246a624 doc: clarify -fsyntax-error
* NEWS, doc/bison.texi: here.
2019-04-27 18:27:04 +02:00
Akim Demaille
dc5ce5989f regen 2019-04-27 18:27:04 +02:00
Akim Demaille
7ea108fa67 traces: use colors for the semantic values
This makes reading the trace slightly easier.  It would be very nice
to highlight the "big steps", especially reductions.  But this is a
private experiment: do not use it.

* data/diagnostics.css (value): New.
* src/parse-gram.y: Use no delimiters and no c quotation for strings
to facilitate debugging.
(tron, troff, TRACE): New.
Not very elegant, but until there is support for printf-formats in
libtextstyle, it shall be enough.
2019-04-27 18:27:04 +02:00
Akim Demaille
386cf25088 diagnostics: give m4 precise locations
Currently we pass only the columns based on the screen-width, which is
important for the carets.  But we don't pass the bytes-based columns,
which is important for the colors.  Pass both.

* src/muscle-tab.c (muscle_boundary_grow): Also pass the byte-based column.
* src/location.c (location_caret): Clarify.
(boundary_set_from_string): Adjust to the new format.
* tests/diagnostics.at (Tabulations and multibyte characters from M4): New.
2019-04-27 18:27:04 +02:00
Akim Demaille
a514c51e55 diagnostics: fix locations coming from M4
Locations issued from M4 need the byte-based column for the
diagnostics to work properly.  Currently they were unassigned, which
typically resulted in partially non-colored diagnostics.

* src/location.c (boundary_set_from_string): Fix the parsed location.
* src/muscle-tab.c (muscle_percent_define_default): Set the byte values.
* tests/diagnostics.at (Locations from M4): New.
2019-04-27 18:12:23 +02:00
Akim Demaille
91b8f3f171 diagnostics: show locations in full when debugging
This is meant for developers, not end users, that's why I attached it
to --trace.

* src/getargs.h, src/getargs.c (trace_locations): New.
* src/location.c (location_print): Use it.
2019-04-27 18:11:41 +02:00
Akim Demaille
8f5d475079 diagnostics: use flush, not fflush
* src/complain.c: here.
2019-04-27 18:09:52 +02:00
Akim Demaille
f5a4e279bc build: use gettext-h
We were using the gnulib's gettext module with tricks in
bootstrap.conf to avoid useless files.  Instead, use gnulib's
gettext-h module.

* .travis.yml: Force Gettext 0.18.3 on Trusty.
* bootstrap.conf: Use gettext-h instead of gettext.
(excluded_files): Remove.
* configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.19.
2019-04-25 22:09:41 +02:00
Akim Demaille
571447afe8 NEWS: update 2019-04-25 22:09:39 +02:00
Akim Demaille
9260e5ca4f api.location.type: support it in C
Reported by Balázs Scheidler.

* data/skeletons/c.m4 (b4_location_type_define): Use api.location.type
if defined.
* doc/bison.texi: Document it.
* tests/local.at (AT_C_IF, AT_LANG_CASE): New.
Support Span in C.
* tests/calc.at (Span): Convert it to be usable in C and C++.
Check api.location.type with yacc.c and glr.c.
2019-04-25 20:20:59 +02:00
Akim Demaille
971e72514f updates: insert/remove %empty
* src/reader.c (grammar_rule_check_and_complete): Generate fixits for
adding/removing %empty.
* tests/actions.at, tests/diagnostics.at, tests/existing.at: Adjust.
2019-04-24 13:21:24 +02:00
Akim Demaille
0ee5ac5367 regen 2019-04-24 13:08:51 +02:00
Akim Demaille
935d119c82 diagnostics: better rule locations
The "identifier and colon" of a rule is implemented as a single token,
but whose location is only that of the identifier (so that messages
about the lhs of a rule are accurate).  When reducing empty rules, the
default location is the single point location on the end of the
previous symbol.  As a consequence, when Bison parses a grammar, the
location of the right-hand side of an empty rule is based on the
lhs, *independently of the position of the colon*.  And the colon can
be way farther, separated by comments, white spaces, including empty
lines.

As a result, some messages look really bad.  For instance:

    $ cat foo.y
    %%
    foo     : /* empty */
    bar
    : /* empty */

gives

    $ bison -Wall foo.y
    foo.y:2.4: warning: empty rule without %empty [-Wempty-rule]
        2 | foo     : /* empty */
          |    ^
    foo.y:3.4: warning: empty rule without %empty [-Wempty-rule]
        3 | bar
          |    ^

The carets are not at the right column, not even the right line.

This commit passes the colon "again" after the "id colon" token, which
gives more accurate locations for these messages:

    $ bison -Wall foo.y
    foo.y:2.10: warning: empty rule without %empty [-Wempty-rule]
        2 | foo     : /* empty */
          |          ^
    foo.y:4.2: warning: empty rule without %empty [-Wempty-rule]
        4 | : /* empty */
          |  ^

* src/scan-gram.l (SC_AFTER_IDENTIFIER): Rollback the colon, so that
we scan it again afterwards.
(INITIAL): Scan colons.
* src/parse-gram.y (COLON): New.
(rules): Parse the colon after the rule's id_colon (and possible
named reference).
* tests/actions.at, tests/conflicts.at, tests/diagnostics.at,
* tests/existing.at: Adjust.
2019-04-24 13:08:51 +02:00
Akim Demaille
01fe32ee53 fixits: track byte-columns, not character-columns
Because the fix-its were ready the character-based columns, but were
applied on byte-based columns, the result with multibyte characters or
tabs could be "interesting".  For instance

	    %fixed-output_files
            %fixed_output-files
    %fixed-output-files
    %define api.prefix {foo}
    %no-default-prec

would give

         %fixed-%fixed-output-files  %fixed_output-files
    %fixed-orefix= "foo"
    o_default-prec

* src/fixits.c (fixit_print, fixits_run): Work on byte-base columns.
* tests/input.at: Check it.
2019-04-24 07:18:22 +02:00
Akim Demaille
19ea6b1405 diagnostics: expose a means to know whether a warning is enabled
* src/complain.h, src/complain.c (warning_is_enabled): New.
2019-04-24 07:18:22 +02:00
Akim Demaille
a4d33cdf48 gnulib: let it use its own PO domain
See
https://www.gnu.org/software/gnulib/manual/html_node/Localization.html.

* bootstrap.conf: Create gnulib-po.
* Makefile.am, configure.ac: Use it.
* po/POTFILES.in: Remove files now in gnulib.
* src/main.c: Open the bison-gnulib domain.
2019-04-23 19:28:08 +02:00
Akim Demaille
a992a3cb9e diagnostics: don't try to quote special files
Based on a report by Todd Freed.
http://lists.gnu.org/archive/html/bug-bison/2019-04/msg00000.html
See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90034

* src/location.c (caret_info): Also track the file name.
(location_caret): Don't quote special files.
2019-04-23 18:29:10 +02:00
Akim Demaille
95d688957f diagnostics: document the change of format
* doc/bison.texiL Adjust output.
Also, Graphviz has no uppercsae V.
* NEWS: Explain the format change.
2019-04-23 18:29:10 +02:00
Akim Demaille
a9b350fb3a diagnostics: copy GCC9's format
Currently, when we quote the source file, we indent it with one space,
and preserve tabulations, so there is a discrepancy and the visual
rendering is bad.  One way out is to indent with a tab instead of a
space, but then this space can be used for more information.  This is
what GCC9 does.  Let's play copy cats.

See
https://lists.gnu.org/archive/html/bison-patches/2019-04/msg00025.html
https://developers.redhat.com/blog/2019/03/08/usability-improvements-in-gcc-9/
https://gcc.gnu.org/onlinedocs/gccint/Guidelines-for-Diagnostics.html#Guidelines-for-Diagnostics

* src/location.c (location_caret): Prefix quoted lines with the line
number and a pipe, fitting 8 columns.

* tests/actions.at, tests/c++.at, tests/conflicts.at,
* tests/diagnostics.at, tests/input.at, tests/java.at,
* tests/named-refs.at, tests/reduce.at, tests/regression.at,
* tests/sets.at: Adjust expectations.
Partly by "./build-aux/update-test tests/testsuite.dir/*/testsuite.log"
repeatedly, and partly by hand.
2019-04-23 18:29:10 +02:00
Akim Demaille
afe7dfd3b9 diagnostics: fix the handling of multibyte characters
This is a pity: efforts were invested in computing correctly the
number of screen columns consumed by multibyte characters, but the
routines that do that were fed by single-byte inputs...

As a consequence Bison never displayed correctly locations when there
are multibyte characters.

* src/scan-gram.l (mbchar): New.
Use it instead of . in the catch-all clause.
* tests/diagnostics.at (Tabulations): Enhance into...
(Tabulations and multibyte characters): this.
2019-04-23 18:29:10 +02:00
Akim Demaille
6b6c3de2ae diagnostics: check the handling of tabulations
* tests/diagnostics.at (Tabulations): here.
2019-04-23 18:29:10 +02:00
Akim Demaille
1b70f687fa diagnostics: fix styling issues
Single point locations (equal boundaries) are troublesome, and we were
incorrectly ending the style in their case.  Which results in an abort
in libtextstyle.

There is also a confusion between columns as displayed on the
screen (which take into account multibyte characters and tabulations),
and the number of bytes.  Counting the screen-column
incrementally (character by character) is uneasy (because of multibyte
characters), and I don't want to maintain a buffer of the current line
when displaying the diagnostic.  So I believe the simplest solution is
to track the byte number in addition to the screen column.

* src/location.h, src/location.c (boundary): Add the byte-column.
Adjust dependencies.
* src/getargs.c, src/scan-gram.l: Adjust.
* tests/diagnostics.at: Check zero-width locations.
2019-04-23 18:29:10 +02:00
Akim Demaille
520d474ec6 diagnostics: check the styling
Enable checking of styles even when libtextstyle is not installed.

* src/getargs.h, src/getargs.c (style_debug): New.
(getargs_colors): Set it when --style=debug.
* src/complain.c (begin_use_class, end_use_class): Use it.
* tests/diagnostics.at: New.
2019-04-23 18:29:10 +02:00
Akim Demaille
deec7ca65c TODO: update
Let's prepare 3.4 with more or less what we have.  Schedule some
features for 3.5 and 3.6.  Remove obsolete stuff.
2019-04-23 18:25:30 +02:00
Akim Demaille
dff7454371 doc: sort the warning categories
* doc/bison.texi, src/getargs.c: here.
2019-04-19 20:16:32 +02:00
Akim Demaille
e50eedf3c5 style: formatting changes
* tests/actions.at, tests/calc.at, tests/input.at: here.
2019-04-19 20:16:32 +02:00
Akim Demaille
341776b03b graphviz: move constant computation out of a loop
* src/graphviz.c (output_red): here.
2019-04-19 20:16:32 +02:00
Akim Demaille
79f7afb125 diagnostics: fix memory leak in libtextstyle
* src/complain.h, src/complain.c (complain_free): New.
* src/main.c: Use it.
2019-04-18 22:19:18 +02:00