summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* diagnostics: document the change of formatAkim Demaille2019-04-232-41/+63
| | | | | | * doc/bison.texiL Adjust output. Also, Graphviz has no uppercsae V. * NEWS: Explain the format change.
* diagnostics: copy GCC9's formatAkim Demaille2019-04-2311-502/+502
| | | | | | | | | | | | | | | | | | | | | | | 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.
* diagnostics: fix the handling of multibyte charactersAkim Demaille2019-04-232-12/+52
| | | | | | | | | | | | | | 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.
* diagnostics: check the handling of tabulationsAkim Demaille2019-04-231-1/+26
| | | | * tests/diagnostics.at (Tabulations): here.
* diagnostics: fix styling issuesAkim Demaille2019-04-238-28/+85
| | | | | | | | | | | | | | | | | | | 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.
* diagnostics: check the stylingAkim Demaille2019-04-236-6/+98
| | | | | | | | | 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.
* TODO: updateAkim Demaille2019-04-231-64/+56
| | | | | Let's prepare 3.4 with more or less what we have. Schedule some features for 3.5 and 3.6. Remove obsolete stuff.
* doc: sort the warning categoriesAkim Demaille2019-04-192-22/+22
| | | | * doc/bison.texi, src/getargs.c: here.
* style: formatting changesAkim Demaille2019-04-193-1/+5
| | | | * tests/actions.at, tests/calc.at, tests/input.at: here.
* graphviz: move constant computation out of a loopAkim Demaille2019-04-191-5/+3
| | | | * src/graphviz.c (output_red): here.
* diagnostics: fix memory leak in libtextstyleAkim Demaille2019-04-183-2/+11
| | | | | * src/complain.h, src/complain.c (complain_free): New. * src/main.c: Use it.
* tests: remove useless featureAkim Demaille2019-04-171-12/+5
| | | | | | * tests/calc.at (read_signed_integer): Rename as... (read_integer): this. We never read signs here.
* traces: make closure() less verboseAkim Demaille2019-04-143-2/+5
| | | | | * src/getargs.h, src/getargs.c (trace_closure): New. * src/closure.c (closure): Use it.
* build: also generate the graph reportsAkim Demaille2019-04-141-1/+1
| | | | * Makefile.am (AM_YFLAGS_WITH_LINES): here.
* yacc.c: minor style changeAkim Demaille2019-04-121-2/+2
| | | | | * data/skeletons/yacc.c: To improve consistency with other similar pieces of code.
* style: scope reduction in lalr.cAkim Demaille2019-04-121-2/+2
| | | | * src/lalr.c (initialize_goto_follows): here.
* style: comment changesAkim Demaille2019-04-124-11/+60
| | | | * src/closure.h, src/closure.c, src/lalr.c: here.
* traces: improve logsAkim Demaille2019-04-122-6/+9
| | | | | | | * src/lalr.c: Move logs to a better place to understand the chronology of events. * src/symlist.c (symbol_list_syms_print): Don't dump core on type elements.
* doc: minor fixesAkim Demaille2019-04-071-27/+26
| | | | | | * doc/bison.texi: Use consistently $ and @kbd in shell examples. Prefer sticking to English words: output and file instead of outfile and infile.
* regenAkim Demaille2019-04-032-314/+7
|
* bison: use no-linesAkim Demaille2019-04-031-1/+3
| | | | | | | | | | | The 'regen' commit in Bison's history are a nuisance. They are especially big because of the #lines. Let's generate our parse without these lines in the repository, but generate them in the tarball. * Makefile.am (AM_YFLAGS_WITH_LINES): New. (AM_YFLAGS): Use it. (dist-hook): Regenerate the parser with #lines.
* no-lines: avoid leaving an empty line instead of the synclineAkim Demaille2019-04-0311-37/+71
| | | | | | | | | | | | | | | Currently, with --no-lines, instead of "#line file line\n", we emit "\n". Let's emit nothing. * data/skeletons/bison.m4 (b4_syncline): Emit at end-of-line when enabled. * data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/glr.cc, * data/skeletons/lalr1.cc, src/output.c: Use dnl after b4_syncline to avoid spurious empty lines. * tests/synclines.at (Sync Lines): Make sure that --no-lines is like grep -v #line. * tests/calc.at: Make sure that a rich grammar file behaves properly with %no-lines.
* java: use full locations for diagnostics about destructorsAkim Demaille2019-04-037-20/+18
| | | | | | | | | | | | | | | | | | | Currently we use the syncline to report errors about a symbol's destructor/printer. This is not accurate (only file and line), and this is incorrect: the file name is double quotes (a recent change, needed to make sure we escape properly double quotes in it). And worst of all: with --no-line, b4_syncline expands to nothing. Rather, push the locations into the backend, and use them. * src/muscle-tab.h, src/muscle-tab.c (muscle_location_grow): Make it public. * src/output.c (prepare_symbol_definitions): Use it to pubish the location of the printer and destructor. * data/skeletons/lalr1.java: Use complain_at instead of complain. * tests/java.at (Java invalid directives): Adjust expectations. * data/skeletons/bison.m4 (b4_symbol_action_location): Remove. We should not use b4_syncline this way.
* java: prefer errors to fatal errorsAkim Demaille2019-04-032-2/+24
| | | | | | | | | | Fatal errors are inconvenient, and should be reserved to cases where we cannot continue. Here, it could even be warnings actually: these directives will simply be ignored. * data/skeletons/lalr1.java: Prefer error (b4_complain) to fatal errors (b4_fatal). * tests/java.at (Java invalid directives): New.
* tests: formatting changesAkim Demaille2019-04-031-48/+45
| | | | * tests/javapush.at: here.
* lalr: offer more flexibility in debugging routinesAkim Demaille2019-04-032-11/+19
| | | | | | * src/state.h, src/state.c (state_transitions_print): New, extracted from... (state_transitions_set): here.
* lalr: don't overbook memoryAkim Demaille2019-03-311-5/+5
| | | | | | | | | | | | | | | | | I never understood why we book ngotos+1 slots for relations between gotos: there are at most ngotos images, not ngotos+1 (and "includes" does have cases where a goto is in relation with itself, so it's not ngotos-1). Maybe bbf37f2534a8e5a6b4e28047f0a10903e6dc73f9 explains the +1: a bug left us register a goto several times on occasion, and the +1 might have been a means to avoid this problem in most cases. Now that this bug is addressed, we should no longer overbook memory, if only for the clarity of the code ("why ngotos+1 instead of ngotos?"). * src/lalr.c: A goto has at most ngotos images, not ngotos+1. While at it, avoid useless repeated call to map_goto introduced in bbf37f2534a8e5a6b4e28047f0a10903e6dc73f9.
* lalr: show lookback for debugAkim Demaille2019-03-301-1/+73
| | | | | | * src/lalr.c (lookback_print): New. (build_relations): Use it. Also show edges.
* diagnostics: don't crash when declaring the error token as an ntermAkim Demaille2019-03-302-4/+11
| | | | | | | | | | | | | Reported by wcventure. http://lists.gnu.org/archive/html/bug-bison/2019-03/msg00008.html * src/symtab.c (complain_class_redeclared): Don't print empty locations. There can only be empty locations for predefined symbols. And the only symbol that is lexically available is the error token. So this appears to be the only possible way to have an error involving an empty location. * tests/input.at (Symbol class redefinition): Check it.
* lalr: fix segmentation violationAkim Demaille2019-03-303-2/+58
| | | | | | | | | | | | | | | | | | | The "includes" relation [DeRemer 1982] is between gotos, so of course, for a given goto, there cannot be more that ngotos (number of gotos) images. But we manipulate the set of images of a goto as a list, without checking that an image was not already introduced. So we can "register" way more images than ngotos, leading to a crash (heap buffer overflow). Reported by wcventure. http://lists.gnu.org/archive/html/bug-bison/2019-03/msg00007.html For the records, this bug is present in the first committed version of Bison. * src/lalr.c (build_relations): Don't insert the same goto several times. * tests/sets.at (Build Relations): New.
* state: more debug tracesAkim Demaille2019-03-301-0/+13
| | | | * src/state.c (state_transitions_set): Show the transitions.
* style: rename variables for consistencyAkim Demaille2019-03-302-21/+24
| | | | | | * src/lalr.c: Use trans for transitions, and reds for reductions, as elsewhere in the code. * src/state.h: Comment changes.
* gram: fix and improve log messageAkim Demaille2019-03-303-25/+30
| | | | | | | | | | | | It seems that not many people read these logs: the error was introduced in 2001 (3067fbef531832df1e43bbd28787655808361eed), * src/gram.c (grammar_dump): Fix the headers of the table: remove duplicate display of "Ritem Range". While at it, remove duplicate display of the rule number (and remove an incorrect comment about it: these numbers _are_ equal). * tests/sets.at (Reduced Grammar): Use useless rule, nterm and token in the example.
* tests: add a tool for mass updatesAkim Demaille2019-03-302-0/+98
| | | | | | | | When we update some output format, too many adjustements must be made by hand. This script updates most tests based on the actual output made during the tests. * build-aux/update-test: New.
* style: remove now useless _GL_UNUSEDAkim Demaille2019-03-251-1/+1
| | | | | * src/getargs.c (getargs_colors): Here. Useless since 4d34b06fb3a38eb050439084476a6b3e292c5680.
* tables: use bitsets for a performance boostTheophile Ranquet2019-03-241-15/+24
| | | | | | | | | | | | | | | | | | | Suggested by Yuri at <http://lists.gnu.org/archive/html/bison-patches/2012-01/msg00000.html>. The improvement is marginal for most grammars, but notable for large grammars (e.g., PosgreSQL's postgre.y), and very large for the sample.y grammar submitted by Yuri in http://lists.gnu.org/archive/html/bison-patches/2012-01/msg00012.html. Measured with --trace=time -fsyntax-only. parser action tables postgre.y sample.y Before 0,129 (44%) 37,095 (99%) After 0,117 (42%) 5,046 (93%) * src/tables.c (pos): Replace this set of integer coded as an unsorted array or integers with... (pos_set): this bitset.
* yacc.c: don't suggest api.header.include when --defines is not usedAkim Demaille2019-03-241-2/+3
| | | | | | | | See 4e19ab9fcd28c9361ff08f46e5e353effb0a0520: the suggestion to include the header file should not be emitted when the header is not generated. * data/skeletons/yacc.c: Here.
* reader: clarify variable namesAkim Demaille2019-03-244-16/+19
| | | | | | | | | * src/reader.c (grammar_rule_check_and_complete): When 'p' and 'lhs' are aliases, prefer the latter, for clarity and consistency. (grammar_current_rule_begin): Avoid 'p', current_rule suffices. * src/gram.h, src/gram.c: Comment changes. ptdr# calc.tab.c
* diagnostics: style changesAkim Demaille2019-03-241-10/+11
| | | | * src/location.c (location_caret): Clarify a bit.
* diagnostics: use gnulib's libtextstyle-optionalAkim Demaille2019-03-248-49/+71
| | | | | | | | | | Bruno Haible just added a default implementation of libtextstyle's interface when the library is not available. https://lists.gnu.org/archive/html/bison-patches/2019-03/msg00025.html * gnulib: Update. * bootstrap.conf: Replace libtextstyle with libtextstyle-optional. * src/complain.c, src/getargs.c: Remove now useless cpp guards.
* diagnostics: fix handling of style in limit casesAkim Demaille2019-03-231-2/+7
| | | | | * src/location.c (location_caret): Beware of the cases where the start and end columns are the same, or when the location is multilines.
* warnings: don't use _Noreturn with G++ 4.7 in C++98 modeAkim Demaille2019-03-233-11/+34
| | | | | | | | | | | | | | The timevar and bitset modules now use the c99 module which causes $CXX to now include -std=gnu++11 when possible. Unfortunately, G++ 4.7 does not implement [[noreturn]] in C++11 mode, so our tests of glr.cc (which uses _Noreturn) fail with input.cc:954:1: error: expected unqualified-id before '[' token right before [[noreturn]]. 4.8 works fine. * data/skeletons/c.m4 (b4_attribute_define): Do not use [[noreturn]] with GCC 4.7.
* d: tests: use more a natural approach for the scannerAkim Demaille2019-03-171-74/+51
| | | | | | | | | See f8408562f8439654261418406296e4108d2a995f. * tests/calc.at: Stop imitating the C API. Prepare more tests to run in the future. %verbose works as expected (what a surprise, it's unrelated to the skeleton...).
* regenAkim Demaille2019-03-172-549/+329
|
* style: rename spec_defines_file as spec_header_fileAkim Demaille2019-03-1710-28/+28
| | | | | | | | | | | | | | The variable spec_defines_file denotes the name of the generated header. Its name is derived from --defines/%defines, whose name in turn is derived from the fact that the header, in Yacc, contained the Not only does the header now contain a lot more than just the token definitions, but we no longer even generate macros, but an enum... Let's modernize our vocabulary. * src/files.h, src/files.c (spec_defines_file): Rename as... (spec_header_file): this.
* yacc.c: provide a means to include the header in the implementationAkim Demaille2019-03-174-5/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently when --defines is used, we generate a header, and paste an exact copy of it into the generated parser implementation file. Let's provide a means to #include it instead. We don't do it by default because of the Autotools' ylwrap. This program wraps invocations of yacc (that uses a fixed output name: y.tab.c, y.tab.h, y.output) to support a more modern naming scheme (dir/foo.y -> dir/foo.tab.c, dir/foo.tab.h, etc.). It does that by renaming the generated files, and then by running sed to propagate these renamings inside the files themselves. Unfortunately Automake's Makefiles uses Bison as if it were Yacc (with --yacc or with -o y.tab.c) and invoke bison via ylwrap. As a consequence, as far as Bison is concerned, the output files are y.tab.c and y.tab.h, so it emits '#include "y.tab.h"'. So far, so good. But now ylwrap processes this '#include "y.tab.h"' into '#include "dir/foo.tab.h"', which is not guaranteed to always work. So, let's do the Right Thing when the output file is not y.tab.c, in which case the user should %define api.header.include. Binding this behavior to --yacc is tempting, but we recently told people to stop using --yacc (as it also enables the Yacc warnings), but rather to use -o y.tab.c. Yacc.c is the only skeleton concerned: all the others do include their header. * data/skeletons/yacc.c (b4_header_include_if): New. (api.header.include): Provide a default value when the output is not y.tab.c. * src/parse-gram.y (api.header.include): Define.
* d: don't link against LIBSAkim Demaille2019-03-171-2/+1
| | | | | * tests/local.at (AT_COMPILE_D): Don't pass LIBS, dmd does not like being given -lintl.
* address warnings from GCC's UB sanitizerAkim Demaille2019-03-172-17/+9
| | | | | | | | | | | | | Running with CC='gcc-mp-8 -fsanitize=undefined' revealed Undefined Behaviors. https://lists.gnu.org/archive/html/bison-patches/2019-03/msg00008.html * src/state.c (errs_new): Don't call memcpy with NULL as source. * src/location.c (add_column_width): Don't assume that the column argument is nonnegative: the scanner sometimes "backtracks" (e.g., see ROLLBACK_CURRENT_TOKEN and DEPRECATED) in which case we can have negative column numbers (temporarily). Found in test 3 (Invalid inputs).
* diagnostics: use libtextstyle for colored outputAkim Demaille2019-03-1613-25/+203
| | | | | | | | | | | | | | | | | | | | | | | | | | | Bruno Haible released libtextstyle, a library for colored output based on CSS. Let's use it to generate colored diagnostics, provided libtextstyle is available. See https://lists.gnu.org/archive/html/bug-gnulib/2019-01/msg00176.html https://lists.gnu.org/archive/html/bison-patches/2019-02/msg00073.html https://lists.gnu.org/archive/html/bison-patches/2019-02/msg00084.html https://lists.gnu.org/archive/html/bison-patches/2019-03/msg00007.html * bootstrap.conf (gnulib_modules): Use libtextstyle when possible. * data/diagnostics.css: New. * src/complain.c (begin_use_class, end_use_class, flush) (severity_style, complain_init_color): New. Use them. * src/getargs.c (getargs_colors): New. (getargs): Use it. Skip --color and --style. * src/location.h, src/location.c (location_print): Use a style. * tests/bison.in: Force --color=yes when stderr is a tty. * tests/local.at: Disable colors during the test suite. * tests/input.at: Adjust expectations to the extra options passed on the command line.
* style: clean up complain.cAkim Demaille2019-03-161-12/+28
| | | | | * src/complain.c (severity_prefix): New. (error_message): Take the severity as argument, instead of the prefix.