summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* maint: remove unnecessary casts before using gnulib functionsHEADmasterEdoardo Sanguineti2022-11-043-5/+5
| | | | | | | | * src/parse-gram.y, src/scan-gram.l: Do not cast c-ctype.h function args to unsigned char unnecessarily. * src/parse-gram.c: Regenerate. Copyright-paperwork-exempt: yes
* cex: check -Dcex.timeoutAkim Demaille2022-09-201-3/+12
| | | | | | | * src/counterexample.c (counterexample_init): Remove stray debug trace. Complain about invalid values. * tests/input.at (-Dcex.timeout): New.
* cex: provide the user with a means to change the timeoutAkim Demaille2022-09-163-15/+20
| | | | | | | | | | | | | Reported by Frank Heckenbach. https://lists.gnu.org/r/bug-bison/2022-07/msg00011.html * bootstrap.conf: Use c_strtod, so that even in French locales "1.5" is accepted, instead of "1,5". * src/counterexample.c, src/state-item.c: Use xtime_t instead of time_t, so that accuracy goes from seconds to nanoseconds. ( counterexample_init): Depend on cex.timeout rather than $TIME_LIMIT. * doc/bison.texi (%define Summary): Document cex.timeout.
* cex: clarify messageAkim Demaille2022-09-101-1/+1
| | | | | | | | Reported by Frank Heckenbach. https://lists.gnu.org/r/bug-bison/2022-07/msg00007.html src/counterexample.c (unifying_example): Prefer "searching for" to "finding", which is somewhat confusing.
* reader: reject rules on YYEOFAkim Demaille2022-09-101-0/+4
| | | | | | | | | | We crashed when rules were given on YYEOF. Reported by Han Zheng. Fixes https://github.com/akimd/bison/issues/92. * src/reader.c (check_and_convert_grammar): Make sure YYEOF is not an nterm. * tests/input.at (Rule for YYEOF): New.
* muscles: fix handling of the "@'" escapeAkim Demaille2022-09-041-4/+5
| | | | | | | | | | | | | | | When we use `b4_` or `m4_` somewhere in the input, it is escaped as `b4@'_`/`m4@'_` so that the warning about unexpanded b4_foo/m4_foo macros does not fire. But in the case of muscles, the `@'` escape was not recognized, and an assertion was triggered. Reported by Han Zheng. <https://github.com/akimd/bison/issues/91> * src/muscle-tab.c (COMMON_DECODE): Handle `@'`. * tests/skeletons.at (Suspicious sequences): Check that case.
* diagnostics: Windows compatibility issuesAkim Demaille2022-09-031-4/+4
| | | | | | | | | | Suggested by Bruno Haible <https://lists.gnu.org/r/bug-bison/2022-08/msg00006.html> following a report from Andrei Malashkin <https://lists.gnu.org/r/bug-bison/2022-08/msg00003.html> * src/location.c (caret_set_file): Read the file in binary. We already deal with CRLF in caret_getc_internal.
* regenAkim Demaille2022-08-022-8/+8
|
* address unused variablesAkim Demaille2022-07-312-10/+4
| | | | | | | Reported by recent versions of clang. * src/counterexample.c (search_state_prepend): Use complexity_cost. * src/print.c: Remove useless variable.
* package: bump copyrights to 2022Paul Eggert2022-01-1590-91/+91
| | | | Run "make update-copyright".
* warnings: don't complain about m4_foo and b4_foo when from the userAkim Demaille2021-11-074-16/+76
| | | | | | | | | | | | | | | | | | | | | | Currently, occurrences of these identifiers in the user's input yield spurious warnings. To tell the difference between a legitimate m4_foo from the user, and a bad m4_foo coming from a non-evaluated macro of a skeleton, escape the user's identifiers as m4@'_foo. We already use @' as a special sequence to be stripped from the skeleton's output. See <https://lists.gnu.org/r/bug-bison/2021-10/msg00026.html> and previous commit ("warnings: be less picky about occurrences of m4_/b4_ in the output"). * src/flex-scanner.h (OBSTACK_SGROW): New. * src/output.c (output_escaped): Escape m4_ and b4_. * src/scan-code.l: Likewise. * src/system.h (obstack_escape): Likewise. And rewrite as a function. * tests/skeletons.at (Suspicious sequences): Make sure the user can use m4_foo/b4_foo without spurious warnings.
* warnings: be less picky about occurrences of m4_/b4_ in the outputAkim Demaille2021-11-061-2/+5
| | | | | | | | Reported by Marko Mäkelä. <https://lists.gnu.org/r/bug-bison/2021-10/msg00026.html> * src/scan-skel.l: It is ok to have foob4_ or foom4_. * tests/skeletons.at (Suspicious sequences): New.
* avoid using atoiAkim Demaille2021-09-253-8/+16
| | | | | | * cfg.mk: Disable sc_indent as auto indent is too invasive for now. Enable sc_prohibit_atoi_atof, except where we don't care. * src/location.c, src/muscle-tab.c: Use strtol instead of atoi.
* regenAkim Demaille2021-09-122-4/+4
|
* maint: post-release administriviaAkim Demaille2021-09-112-4/+4
| | | | | | * NEWS: Add header line for next release. * .prev-version: Record previous version. * cfg.mk (old_NEWS_hash): Auto-update.
* portability: don't use strtofAkim Demaille2021-09-111-5/+5
| | | | | | | | | | | | It is not available on HP-UX 11i. Reported by Larkin Nickle <me@larbob.org>. <https://lists.gnu.org/r/bug-bison/2021-09/msg00012.html> Gnulib provides no replacement, but anyway we should be using doubles, since difftime uses doubles. * bootstrap.conf: We want portability on stdtod. * src/counterexample.c: Use double, not float, for time measurements.
* yacc: declare yyerror/yylex only when POSIXLY_CORRECTAkim Demaille2021-09-115-9/+22
| | | | | | | | | | | | | | | | | | | | The recent changes to comply with POSIX are breaking Automake's test suite. Reported by Kiyoshi Kanazawa. <https://lists.gnu.org/r/bug-bison/2021-09/msg00005.html> To limit the impact of POSIX changes, bind them to $POSIXLY_CORRECT. Suggested by Karl Berry. <https://lists.gnu.org/r/bug-bison/2021-09/msg00009.html> The existing `maintainer-check-posix` Make target checks these changes. * src/getargs.h, src/getargs.c (set_yacc): New. Use it. * data/skeletons/bison.m4 (b4_posix_if): New. * data/skeletons/yacc.c (b4_declare_yyerror_and_yylex): Use it. * doc/bison.texi, tests/local.at: Adjust.
* tests: don't postprocess stderr with sedAkim Demaille2021-08-291-0/+6
| | | | | | | | | | | | | | | On Solaris, sed throws away the NUL bytes from the stream, even in C locale. So instead of postprocessing bison's stderr to neutralize changes in value of `argv[0]`, use an envvar to actually neutralize variations of `argv[0]` during tests. Reported by Dagobert Michelsen. <https://lists.gnu.org/r/bug-bison/2021-08/msg00025.html> * src/main.c (main): Change `argv[0]` if BISON_PROGRAM_NAME is defined. * tests/bison.in: No longer mess with stderr, just pass the expected BISON_PROGRAM_NAME value.
* m4: catch suspicions of unevaluated macrosAkim Demaille2021-08-071-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Check in m4's output if there are sequences such as m4_foo or b4_foo, which are probably resulting from incorrect m4 processing. It actually already is useful: - it caught a leaking b4_lac_if leaking from glr.c, where LAC is not supported, hence b4_lac_if is not defined. - it also caught references to location.hh in position.hh when location.hh does not exist. - while making "Code injection" robust to these new warnings (it is its very purpose to let b4_canary pass unevaluated), I saw that it did not check lalr1.d, and when adding lalr1.d, it revealed it did underquote ocurrences of token value types. * src/scan-skel.l (macro): New abbreviation. Use it. * data/skeletons/glr.c: Don't use b4_lac_if, we don't have it. * data/skeletons/location.cc: Don't generate position.hh when we don't generate location.hh. * data/skeletons/d.m4 (b4_basic_symbol_constructor_define): Fix underquotation. * data/skeletons/bison.m4 (b4_canary): New. * tests/input.at (Code injection): Use it, and check lalr1.d too.
* style: formatting changes in scan-code.lAkim Demaille2021-08-071-3/+3
| | | | * src/scan-code.l: Fix indentation.
* scan: fix typo in UTF-8 escapeAkim Demaille2021-08-031-1/+1
| | | | | | | | | | | | | | | | | | | We had: ``` -mbchar ...|\xF0[\x\90-\xBF]([\x80-\xBF]{2})|... +mbchar ...|\xF0[\x90-\xBF]([\x80-\xBF]{2})|... ``` so a precise sequence that matches the incorrect regex can let NUL bytes pass through, which triggers an assertion violation downstream. It is a pity that Flex does not report an error for such input. Reported by Ahcheong Lee <ahcheong.lee@gmail.com>. <https://lists.gnu.org/r/bug-bison/2021-04/msg00003.html> * src/scan-gram.l (mbchar): Fix the bad regex. * tests/input.at (Invalid inputs): Check that case.
* getargs: don't translate first line of --versionAlyssa Ross2021-08-011-1/+1
| | | | | | <https://lists.gnu.org/r/bison-patches/2021-06/msg00002.html> * src/getargs.c (version): here.
* files: please syntax-checkAkim Demaille2021-03-101-2/+3
| | | | | * src/files.c (string_free): syntax-check does not want us to cast arguments to free.
* Merge 3.7.6 into masterAkim Demaille2021-03-101-5/+10
|\ | | | | | | | | | | | | | | * maint: maint: post-release administrivia version 3.7.6 yacc: fix push parser tables: fix again the handling of useless tokens
| * tables: fix again the handling of useless tokensAkim Demaille2021-03-071-5/+10
| | | | | | | | | | | | | | | | | | | | | | The right-shift added in c22902e360e0fbbe9fd5657dcf107e03166da309 ("tables: fix handling for useless tokens") is incorrect. In particular, we need to reset the "new" bits. Reported by Balázs Scheidler. https://github.com/akimd/bison/issues/74 * src/tables.c (pos_set_set): Fix the right-shift.
| * Update URLs to prefer https: to http:Paul Eggert2021-01-3091-106/+105
| | | | | | | | Also, fix a few http: URLs that were no longer working.
* | html: fix memory leakAkim Demaille2021-02-261-2/+3
| | | | | | | | * src/print-xml.c (print_html): Free allocated memory.
* | output: cache the mapped file namesAkim Demaille2021-02-265-47/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't repeatedly call malloc/free for each call to map_file_name. * bootstrap.conf: We need hash-map. * src/files.h, src/files.c (map_file_name): The caller must not free the result. Adjust callers. (mapped_dir_prefix, spec_mapped_header_file): Remove. * src/files.c (map_file_name): Rename as... (map_file_name_alloc): this. (mapped_files, map_file_name, string_equals, string_hash, string_free): New.
* | output: use mapped file name for symbolsJoshua Watt2021-02-262-3/+9
| | | | | | | | | | | | | | | | Applies the file name mapping before exporting it as a symbol. This allows the symbols to correctly respect the --file-prefix-map command line option. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
* | style: formatting changesAkim Demaille2021-02-262-10/+12
| | | | | | | | | | | | * src/files.c, src/files.h: Save horizontal space. Prefer `res` for returned values. Put the doc into the header.
* | regenAkim Demaille2021-02-251-8/+23
| |
* | graph: output foo.gv by default, instead of *.dotAkim Demaille2021-02-021-2/+1
| | | | | | | | | | | | | | | | | | | | That change was started in Bison 3.4. The announcement for 3.7 stated that in Bison 3.8 we would use *.gv by default. * src/files.c (compute_output_file_names): spec_graph_file defaults too *.gv. * doc/bison.texi, examples/c++/calc++/local.mk, tests/output.at: Adjust.
* | yacc: remove support for YYPRINTAkim Demaille2021-02-012-23/+4
| | | | | | | | | | | | | | | | | | Its removal was annonced several times in NEWS (for Bison 3.5, 3.6, 3.7). * data/skeletons/c.m4, data/skeletons/yacc.c: Remove support for YYPRINT. * NEWS: Fix the mess introduced by the merge. Document the removal of YYPRINT. * doc/bison.texi (The YYPRINT Macro): Remove.
* | traces: display the Bison versionAkim Demaille2021-01-301-0/+3
| | | | | | | | | | | | | | | | * src/main.c (main): When traces are enabled, display the Bison version. * tests/conflicts.at, tests/report.at, tests/sets.at: Use AT_PACKAGE_VERSION (for package.m4) instead of post-processing the output.
* | Update URLs to prefer https: to http:Paul Eggert2021-01-2991-106/+105
| | | | | | | | Also, fix a few http: URLs that were no longer working.
* | package: fix details after merge with 3.7.5Akim Demaille2021-01-242-4/+16
| | | | | | | | | | * TODO, cfg.mk: Update. * src/parse-gram.c, src/parse-gram.h: Regen.
* | Merge tag 'v3.7.5'Akim Demaille2021-01-242-47/+95
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Three new commits: commit 8358090292e21c61a583da542bad9099ad65f355 Author: Paul Eggert <eggert@cs.ucla.edu> Date: Wed Jan 20 18:30:16 2021 -0800 c: port to HP-UX 11.23 commit 2c294c132528ede23d8ae4959783a67e9ff05ac5 Author: Vincent Imbimbo <vmi6@cornell.edu> Date: Sat Jan 23 13:25:18 2021 -0500 cex: fix state-item pruning commit c22902e360e0fbbe9fd5657dcf107e03166da309 Author: Akim Demaille <akim.demaille@gmail.com> Date: Sat Jan 23 18:40:15 2021 +0100 tables: fix handling for useless tokens
| * tables: fix handling for useless tokensAkim Demaille2021-01-241-10/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In some rare conditions, the generated parser can be wrong when there are useless tokens. Reported by Balázs Scheidler. https://github.com/akimd/bison/issues/72 Balázs managed to prove that the bug was introduced in commit af1c6f973a60a51c609903713ff8f7fce0887025 Author: Theophile Ranquet <ranquet@lrde.epita.fr> Date: Tue Nov 13 10:38:49 2012 +0000 tables: use bitsets for a performance boost 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 of integers with... (pos_set): this bitset. which was implemented long ago, but that I installed only recently (March 2019), first published in v3.3.90. That patch introduces a bitset to represent a set of integers. It managed negative integers by using a (fixed) base (the smallest integer to represent). It avoided negative accesses into the bitset by ignoring integers smaller than the base, under the asumption that these cases correspond to useless tokens that are ignored anyway. While it turns out to be true for all the test cases in the test suite (!), Balázs' use case demonstrates that it is not always the case. So we need to be able to accept negative integers that are smaller than the current base. "Amusingly" enough, the aforementioned patch was visibly unsure about itself: /* Store PLACE into POS_SET. PLACE might not belong to the set of possible values for instance with useless tokens. It would be more satisfying to eliminate the need for this 'if'. */ This commit needs several improvements in the future: - support from bitset for bit assignment and shifts - amortized resizing of pos_set - test cases * src/tables.c (pos_set_base, pos_set_dump, pos_set_set, pos_set_test): New. Use them instead of using bitset_set and bitset_test directly.
| * cex: fix state-item pruningVincent Imbimbo2021-01-241-37/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There were several bugs in pruning that would leave the state-item graph in an inconsistent state which could cause crashes later on: - Pruning now happens in one pass instead of two. - Disabled state-items no longer prune the state-items they transition to if that state-item has other states that transition to it. - State-items that transition to disabled state-items are always pruned even if they have productions. Reported by Michal Bartkowiak <michal.bartkowiak@nokia.com> https://lists.gnu.org/r/bug-bison/2021-01/msg00000.html and Zartaj Majeed https://github.com/akimd/bison/issues/71 * src/state-item.c (prune_forward, prune_backward): Fuse into... (prune_state_item): this. Adjust callers.
| * package: bump copyrights to 2021Akim Demaille2021-01-2391-91/+91
| | | | | | | | Run 'make update-copyright'.
| * %merge: associate it to its first definition, not the latestAkim Demaille2021-01-231-11/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently each time we meet %merge we record this location as the defining location (and symbol). Instead, record the first definition. In the generated code we go from yy0->A = merge (*yy0, *yy1); to yy0->S = merge (*yy0, *yy1); where S was indeed the first symbol, and in the diagnostics we go from glr-regr18.y:30.18-24: error: result type clash on merge function 'merge': <type2> != <type1> 30 | sym2: sym3 %merge<merge> { $$ = $1; } ; | ^~~~~~~ glr-regr18.y:29.18-24: note: previous declaration 29 | sym1: sym2 %merge<merge> { $$ = $1; } ; | ^~~~~~~ glr-regr18.y:31.13-19: error: result type clash on merge function 'merge': <type3> != <type2> 31 | sym3: %merge<merge> { $$ = 0; } ; | ^~~~~~~ glr-regr18.y:30.18-24: note: previous declaration 30 | sym2: sym3 %merge<merge> { $$ = $1; } ; | ^~~~~~~ to glr-regr18.y:30.18-24: error: result type clash on merge function 'merge': <type2> != <type1> 30 | sym2: sym3 %merge<merge> { $$ = $1; } ; | ^~~~~~~ glr-regr18.y:29.18-24: note: previous declaration 29 | sym1: sym2 %merge<merge> { $$ = $1; } ; | ^~~~~~~ glr-regr18.y:31.13-19: error: result type clash on merge function 'merge': <type3> != <type1> 31 | sym3: %merge<merge> { $$ = 0; } ; | ^~~~~~~ glr-regr18.y:29.18-24: note: previous declaration 29 | sym1: sym2 %merge<merge> { $$ = $1; } ; | ^~~~~~~ where both duplicates are reported against definition 1, rather than using definition 1 as a reference when diagnosing about definition 2, and then 2 as a reference for 3. * src/reader.c (record_merge_function_type): Keep the first definition. * tests/glr-regression.at: Adjust.
| * %merge: delegate the generation of calls to mergers to m4Akim Demaille2021-01-231-6/+2
| | | | | | | | | | | | | | Don't generate C code from bison, leave that to the skeletons. * src/output.c (merger_output): Emit invocations to b4_call_merger. * data/skeletons/glr.c (b4_call_merger): New.
| * %merge: let mergers record a typing-symbol, rather than a typeAkim Demaille2021-01-233-23/+25
| | | | | | | | | | | | | | | | | | | | | | | | Symbols are richer than types, and in M4 it is my simpler (and more common) to deal with symbols rather than types. So let's associate mergers to a symbol rather than a type name. * src/reader.h (merger_list): Replace the 'type' member by a symbol member. * src/reader.c (record_merge_function_type): Take a symbol as argument, rather than a type name. * src/output.c (merger_output): Adjust.
| * style: YYUSE is private, make it YY_USEAkim Demaille2021-01-232-9/+9
| | | | | | | | | | | | | | | | | | | | This macro is not exposed to users, make start it with 'YY_'. * data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/glr.c, * data/skeletons/glr.cc, data/skeletons/lalr1.cc, * src/parse-gram.c, tests/actions.at, tests/c++.at, tests/headers.at, * tests/local.at (YYUSE): Rename as... (YY_USE): this.
| * package: codespellAkim Demaille2021-01-231-1/+1
| | | | | | | | * src/parse-gram.y: Fix spelling.
| * cex: fix traces: fix display of disabled itemsAkim Demaille2021-01-231-22/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The display of disabled state items is incorrect. The item is stuttered, and lacks on end-of-line. From State 7: 1 exp: exp • "⊕" exp -> 1 exp: exp "⊕" • exp <- 1 exp: • exp "⊕" exp 2 exp: exp • "+" exp 2 exp: exp • "+" exp DISABLED 2 exp: exp "+" exp • <- 2 exp: exp "+" • exp 3 exp: exp • "+" exp 3 exp: exp • "+" exp DISABLED 3 exp: exp "+" exp • <- 3 exp: exp "+" • exp to State 7: 1 exp: exp • "⊕" exp -> 1 exp: exp "⊕" • exp <- 1 exp: • exp "⊕" exp 2 exp: exp • "+" exp DISABLED 2 exp: exp "+" exp • <- 2 exp: exp "+" • exp 3 exp: exp • "+" exp DISABLED 3 exp: exp "+" exp • <- 3 exp: exp "+" • exp * src/state-item.c (state_items_report): Don't issue disabled items twice, and issue two '\n' at their end. * tests/conflicts.at: Check it.
| * cex: fix traces: add missing end-of-linesAkim Demaille2021-01-232-4/+6
| | | | | | | | | | | | | | | | In 430ca0fc632f5e8072fe468b8a99c640985f6926, I completely forgot that `puts` adds a `\n`. * src/lssi.c, src/state-item.c: Restore missing end-of-lines in the output.
| * cex: add support for $TIME_LIMITAkim Demaille2021-01-232-4/+17
| | | | | | | | | | | | | | * src/counterexample.c (TIME_LIMIT): Replace with... (time_limit): this. (counterexample_init): Check $TIME_LIMIT. * src/scan-gram.l: Reorder includes.
| * cex: send traces to stderr, not stdoutAkim Demaille2021-01-232-24/+23
| | | | | | | | | | | | | | When comparing traces from different machines, the mixture of stdout/stderr in the output are making things uselessly difficult. * src/lssi.c, src/state-item.c: Output debug traces on stderr.
| * tables: avoid warnings and save bitsAkim Demaille2021-01-233-9/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The yydefgoto table uses -1 as an invalid for an impossible case (we never use yydefgoto[0], since it corresponds to the reduction to $accept, which never happens). Since yydefgoto is a table of state numbers, this -1 forces a signed type uselessly, which (1) might trigger compiler warnings when storing a value from yydefgoto into a state number (nonnegative), and (2) wastes bits which might result in using a int16 where a uint8 suffices. Reported by Jot Dot <jotdot@shaw.ca>. https://lists.gnu.org/r/bug-bison/2020-11/msg00027.html * src/tables.c (default_goto): Use 0 rather than -1 as invalid value. * tests/regression.at: Adjust.