summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* cex: check -Dcex.timeoutAkim Demaille2022-09-201-0/+36
| | | | | | | * src/counterexample.c (counterexample_init): Remove stray debug trace. Complain about invalid values. * tests/input.at (-Dcex.timeout): New.
* d: fix interface syntax errorAdela Vais2022-09-201-0/+7
| | | | | | | | | | | Fix syntax error regarding interface inheritance of the Lexer. It appeared when the `%code lexer` option was used. Reported by ledaniel2. <https://github.com/akimd/bison/issues/84> * data/skeletons/lalr1.d: Fix syntax. * tests/d.at: Test it.
* cex: provide the user with a means to change the timeoutAkim Demaille2022-09-161-1/+1
| | | | | | | | | | | | | 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.
* reader: reject rules on YYEOFAkim Demaille2022-09-101-0/+32
| | | | | | | | | | 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-0/+15
| | | | | | | | | | | | | | | 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.
* maint: don’t use \] in BREs and EREsPaul Eggert2022-07-312-5/+5
| | | | | | | | | * .travis.yml (jobs): * doc/local.mk ($(top_srcdir)/%D%/bison.help): * tests/regression.at (Web2c Actions, Useless Tokens): * tests/scanner.at (Token numbers: $1): Use plain ], not \], in a POSIX regular expression, as POSIX says the interpretation of \] is undefined.
* style: enforce GNU-style variable namesAkim Demaille2022-07-311-11/+11
| | | | | | * examples/c/glr/c++-types.y, tests/cxx-type.at (lineNum, colNum): Rename as... (line_num, col_num): these.
* tests: avoid useless variablesAkim Demaille2022-07-311-14/+14
| | | | | | | | Reported by clang's -Wunused-but-set-variable warning. * configure.ac (warn_common): Add -Wunused-but-set-variable. * tests/cxx-type.at: Don't emit location track code when we don't use locations.
* package: bump copyrights to 2022Paul Eggert2022-01-1533-33/+33
| | | | Run "make update-copyright".
* warnings: don't complain about m4_foo and b4_foo when from the userAkim Demaille2021-11-071-9/+15
| | | | | | | | | | | | | | | | | | | | | | 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-0/+41
| | | | | | | | 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.
* tests: address portability issues about strdupAkim Demaille2021-11-062-3/+6
| | | | | | | | | | | | | Reported by Dennis Clarke <https://lists.gnu.org/r/bug-bison/2021-10/msg00005.html>. In particular <https://lists.gnu.org/r/bug-bison/2021-10/msg00023.html>. * doc/bison.texi, examples/c/glr/c++-types.y, * examples/c/bistromathic/parse.y tests/testsuite.h: Define _XOPEN_SOURCE to 600, to get a strdup that works on Solaris. * tests/glr-regression.at: Use strdup freely.
* tests: fix coding styleAkim Demaille2021-11-062-44/+40
| | | | | | * tests/cxx-type.at, tests/glr-regression.at: Prefer strdup to malloc+strcpy. Use snake_case.
* tests: Apple clang issues warning on C++11 featuresAkim Demaille2021-09-252-1/+11
| | | | | | | | | | | | | | | | | | | | $ cat /tmp/foo.cc using foo = int; foo f; $ clang++ -Wc++11-extensions -c /tmp/foo.cc /tmp/foo.cc:1:13: warning: alias declarations are a C++11 extension [-Wc++11-extensions] using foo = int; ^ 1 warning generated. $ clang++ --version Apple clang version 11.0.0 (clang-1100.0.33.17) Target: x86_64-apple-darwin18.7.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin * tests/local.at (AT_COMPILE_CXX): Make sure -std=c++11 is passed when running glr2.cc. It may be overridden by another flag in CXXFLAGS afterwards.
* glr2.cc: check linking conflictsAkim Demaille2021-09-121-1/+6
| | | | * tests/headers.at (Several Headers): Link two glr2.cc parsers.
* glr2.cc: don't publish YY_EXCEPTIONSAkim Demaille2021-09-121-2/+6
| | | | | | | | We don't need them in the header file. * data/skeletons/glr2.cc (YY_EXCEPTIONS): Define only in the implementation file. * tests/headers.at (Several Parsers): Also check glr2.cc.
* c++: demonstrate custom error messages in the examplesAkim Demaille2021-09-121-5/+2
| | | | | | | | | | | Let's use c++/glr to demonstrate custom error messages in C++ (not just in glr2.cc). * examples/c++/glr/c++-types.yy (report_syntax_error): New. * examples/c++/glr/c++-types.test: Adjust. * examples/c/bistromathic/parse.y: Comment changes. * tests/local.at (AT_YYERROR_DEFINE(c++)): Use a nicer way to print the lookakead's name.
* glr2.cc: custom error messagesAkim Demaille2021-09-121-0/+5
| | | | | | | | | | Reported by Tom Shields <thomas.evans.shields@icloud.com>. <https://lists.gnu.org/r/bug-bison/2021-08/msg00003.html> * data/skeletons/glr2.cc (context): New. Use it to generate the error messages. Add support for custom error messages. * tests/calc.at: Check support for custom error messages.
* glr2.cc: start the transition to using symbol_typeAkim Demaille2021-09-123-11/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently glr2.cc uses three variables/struct members to denote the symbols' kind (or state), value and location. lalr1.cc has two types for "complete" symbols: symbol_type and stack_symbol_type. Let's use that model in glr2.cc too. For a start use yyla (a symbol_type) to denote the lookahead, instead of the triple yytoken, yylval and yylloc. This will make easier the introduction of the "context" subclass, used in parse.error=custom. It simplifies the code in several places. For instance from: symbol_kind_type yytoken_current = this->yytoken;]b4_variant_if([[ value_type yylval_current; ]b4_symbol_variant([this->yytoken], [yylval_current], [move], [this->yylval])], [[ value_type yylval_current = this->yylval;]])[]b4_locations_if([ location_type yylloc_current = this->yylloc;])[ to: symbol_type yyla_current = std::move (this->yyla); * data/skeletons/glr2.cc (yytoken, yylval, yylloc): Replace by... (yyla): this. Adjust all dependencies. (yyloc_default): Remove, unused. * tests/c++.at, tests/glr-regression.at, tests/types.at: C++11 is required for glr2.cc. Adjust to changes in glr2.cc.
* c++: avoid using the obsolete namesAkim Demaille2021-09-122-3/+3
| | | | | | | | * data/skeletons/c++.m4: Don't define obsolete identifiers in the case of glr2.cc. Let's not start with technical debt. * data/skeletons/glr2.cc, data/skeletons/lalr1.cc, * data/skeletons/variant.hh: Use token_kind_type, not token_type. * tests/c++.at, tests/local.at: Use value_type, not semantic_type.
* yacc: declare yyerror/yylex only when POSIXLY_CORRECTAkim Demaille2021-09-112-4/+16
| | | | | | | | | | | | | | | | | | | | 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: disable "Multistart reports"Akim Demaille2021-09-021-1595/+1598
| | | | | | | | | For some reason this test fails on Solaris/x86. But multistart is not part of 3.8, so we can postpone the debugging of this issue. Reported by Dagobert Michelsen. <https://lists.gnu.org/r/bug-bison/2021-08/msg00027.html> * tests/report.at (Multistart reports): Comment out.
* style: rename stmtMerge as stmt_mergeAkim Demaille2021-08-291-9/+9
| | | | | | | Follow the GNU Coding Style. * doc/bison.texi, examples/c++/glr/c++-types.yy, * examples/c/glr/c++-types.y, tests/cxx-type.at: s/stmtMerge/stmt_merge/g.
* tests: don't postprocess stderr with sedAkim Demaille2021-08-291-19/+5
| | | | | | | | | | | | | | | 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.
* tests: grep -E is not portableAkim Demaille2021-08-191-1/+1
| | | | | | | Reported by Dagobert Michelsen. <https://lists.gnu.org/r/bug-bison/2021-08/msg00008.html> * tests/calc.at: Use $EGREP.
* glr2.cc: require C++11Akim Demaille2021-08-192-1/+4
| | | | | | | | | | | | | | Reported by Dagobert Michelsen. https://lists.gnu.org/r/bug-bison/2021-08/msg00006.html * m4/bison-cxx-std.m4 (_BISON_CXXSTD_98_snippet): We don't need vector::data, it was only for glr2.cc, which is C++11 anyway. (_BISON_CXXSTD_11_snippet): We need vector::data and std::swap on arrays. * m4/cxx.m4 (BISON_TEST_FOR_WORKING_CXX_COMPILER): We don't need vector::data. * tests/local.at (AT_COMPILE_CXX): Skip when glr2.cc and no support for C++11.
* tests: fix incorrect test caseAkim Demaille2021-08-121-2/+2
| | | | | | | | In c2ba260487927a4cdf061fae10fdd1b387ca3d95 ("glr.c: fix signature when using custom error messages"), I meant to add a test case for C, not C++. It does not work in C++. * tests/calc.at: Run for glr.c, not glr.cc.
* build: check for C++ 20 and 2bAkim Demaille2021-08-122-3/+6
| | | | | | | C++20 is released. * configure.ac, m4/bison-cxx-std.m4, tests/atlocal.in, * tests/local.at: Replace 2a with 20, and add support for 2b.
* tests: remove obsolete checksAkim Demaille2021-08-121-26/+0
| | | | | | | * tests/atlocal.in: It was an error for tests to depend on gnulib: they must not, as gnulib would hide portability issues that we want to catch. So this piece of code is no longer useful, and must not be useful.
* tests: be robust to old versions of xlstprocAkim Demaille2021-08-122-3/+17
| | | | | | | | Reported by Christopher Nielsen <mascguy@github.com>. <https://trac.macports.org/raw-attachment/ticket/59927/bison-test-results-20210811-95b72.log.xz> * tests/report.at (AT_CHECK_HTML): New. Use it.
* glr.c: fix signature when using custom error messagesAkim Demaille2021-08-111-0/+2
| | | | | | | Reported by Tom Shields <thomas.evans.shields@icloud.com>. * data/skeletons/glr.c (yypcontext_location): Fix return type. * tests/calc.at: Check the case pure, location, custom error messages.
* tests: check symbol/token renumberingAkim Demaille2021-08-111-1/+297
| | | | | | | | | In some extreme situations, with lots of useless tokens, Bison was numbering them incorrectly, which resulted in a broken grammar. <https://lists.gnu.org/r/bison-patches/2021-03/msg00001.html> commit a774839ca873d1082f79ba3c4eecc1e242a28ce1. * tests/regression.at (Useless Tokens): New.
* yacc: comply with recent POSIX updates: declare yyerror and yylexAkim Demaille2021-08-093-4/+9
| | | | | | | | | | | | | | | | | | | | | In POSIX Yacc mode, declare yyerror and yylex unless already #defined, or if YYERROR_IS_DECLARED/YYLEX_IS_DECLARED are defined (for consistency with Bison's YYSTYPE_IS_DECLARED/YYLTYPE_IS_DECLARED). See <https://austingroupbugs.net/view.php?id=1388#c5220>. * data/skeletons/c.m4 (b4_function_declare): Resurect. (b4_lex_formals): Since we will possibly expose this prototype in the header, take the prefix into account. * data/skeletons/yacc.c (b4_declare_yyerror_and_yylex): New. (b4_shared_declarations): Use it. * tests/local.at (AT_YACC_IF): New. When in Yacc mode, set the `yacc` Autotest keyword. (AT_YYERROR_DECLARE(c)): Don't declare in Yacc mode, to avoid clashes (since this signature is static). (AT_YYERROR_DEFINE(c)): Don't define as static in Yacc mode. * tests/regression.at (Early token definitions with --yacc): Specify that we are in Yacc mode.
* d: prepare to be able to run LAC testsAkim Demaille2021-08-072-1/+29
| | | | | | | | | | Unfortunately it seems to be quite difficult to have "LAC: Exploratory stack" run for D. * data/skeletons/lalr1.d: We need File when traces are enabled. * tests/local.at (AT_YYLEX_DEFINE(d)): New. * tests/regression.at: Prepare for D, but don't run it, it does not work.
* tests: factor iterating over skeletonsAkim Demaille2021-08-073-5/+13
| | | | | | | * tests/local.at (AT_FOR_EACH_SKEL): New. Use where appropriate. * data/skeletons/lalr1.d: Reject -d. * tests/input.at, tests/scanner.at: Also check D.
* m4: catch suspicions of unevaluated macrosAkim Demaille2021-08-071-19/+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.
* tests: extract AT_LOCATION_PRINT_DECLARE and AT_LOCATION_PRINT_DEFINEAkim Demaille2021-08-061-19/+31
| | | | | * tests/local.at (AT_LOCATION_PRINT_DECLARE) (AT_LOCATION_PRINT_DEFINE): New.
* tests: rename AT_YACC_IF as AT_YACC_C_IFAkim Demaille2021-08-064-7/+7
| | | | | | | In data/, b4_yacc_if refers to %yacc, not yacc.c. * tests/local.at (AT_YACC_IF): Rename as... (AT_YACC_C_IF): this.
* style: tests: rebox commentsAkim Demaille2021-08-041-31/+31
| | | | * tests/glr-regression.at: here.
* scan: fix typo in UTF-8 escapeAkim Demaille2021-08-031-23/+28
| | | | | | | | | | | | | | | | | | | 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.
* d: add push parser supportAdela Vais2021-04-111-1/+3
| | | | | | | | | | Support the push-pull directive with the options pull, push and both. Pull remains the default option. * data/skeletons/d.m4: Add user aliases for the push parser's return values: PUSH_MORE, ABORT, ACCEPT. * data/skeletons/lalr1.d: Add push parser support. * tests/calc.at: Test it.
* d: add token constructors supportAdela Vais2021-03-261-16/+26
| | | | | | | | | | | The user can return from yylex() by calling the Symbol method of the same name as the TokenKind reported, and adding the parameters for value and location if necessary. These methods generate compile-time errors if the parameters are not correlated. Token constructors work with both %union and api.value.type union. * data/skeletons/d.m4: Here. * tests/calc.at: Test it.
* d: add api.value.type union supportAkim Demaille2021-03-262-5/+8
| | | | | | | | | The union of the values is handled by the backend. In D, unions can hold classes, structs, etc., so this is more similar to the C++ api.value.type variant. * data/skeletons/d.m4, data/skeletons/lalr1.d: Here. * tests/calc.at, tests/local.at: Test it.
* Merge 3.7.6 into masterAkim Demaille2021-03-101-2/+125
|\ | | | | | | | | | | | | | | * maint: maint: post-release administrivia version 3.7.6 yacc: fix push parser tables: fix again the handling of useless tokens
| * yacc: fix push parserAkim Demaille2021-03-071-2/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When a pstate is used for multiple successive parses, some state may leak from one run into the following one. That was introduced in 330552ea499ca474f65967160e9d4e50265f9631 "yacc.c: push: don't clear the parser state when accepting/rejecting". Reported by Ryan <dev@splintermail.com> https://lists.gnu.org/r/bug-bison/2021-03/msg00000.html * data/skeletons/yacc.c (yypush_parse): We reusing a pstate from a previous run, do behave as if it were the first run. * tests/push.at (Pstate reuse): Check this.
| * Update URLs to prefer https: to http:Paul Eggert2021-01-3031-62/+62
| | | | | | | | Also, fix a few http: URLs that were no longer working.
| * package: bump copyrights to 2021Akim Demaille2021-01-2332-32/+32
| | | | | | | | Run 'make update-copyright'.
| * %merge: associate it to its first definition, not the latestAkim Demaille2021-01-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: clearer tests on diagnosticsAkim Demaille2021-01-231-1/+9
| | | | | | | | * tests/glr-regression.at: Use caret errors.
| * style: YYUSE is private, make it YY_USEAkim Demaille2021-01-234-11/+11
| | | | | | | | | | | | | | | | | | | | 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.