summaryrefslogtreecommitdiff
path: root/data
Commit message (Collapse)AuthorAgeFilesLines
* yacc.c, lalr1.cc: fix warnings about yynerrsAkim Demaille2022-08-022-2/+2
| | | | | | | | | | | | | | | | | | | | Most often yynerrs is not used. Clang 15 now complains about such variables. Bison itself does not compile: ``` src/parse-gram.c:1797:9: error: variable 'gram_nerrs' set but not used [-Werror,-Wunused-but-set-variable] int yynerrs = 0; ^ src/parse-gram.c:79:25: note: expanded from macro 'yynerrs' ^ 1 error generated. ``` Reported by Nikita Popov. Fixes https://github.com/akimd/bison/issues/89. * data/skeletons/yacc.c (yynerrs): Flag with YY_ATTRIBUTE_UNUSED. * data/skeletons/lalr1.cc (yynerrs_): Likewise.
* glr2.cc: fix -Wnoexcept issuesAkim Demaille2022-08-011-2/+2
| | | | | | | | | | | | | | | | | | | | 440-453 and 685 failed with GCC 12.1: ``` test.cc:1814:21: required from here /opt/local/include/gcc12/c++/bits/stl_construct.h:95:14: error: noexcept-expression evaluates to 'false' because of a call to '{anonymous}::glr_stack_item::glr_stack_item(bool)' [-Werror=noexcept] 95 | noexcept(noexcept(::new((void*)0) _Tp(std::declval<_Args>()...))) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test.cc:1486:5: note: but '{anonymous}::glr_stack_item::glr_stack_item(bool)' does not throw; perhaps it should be declared 'noexcept' 1486 | glr_stack_item (bool state = true) | ^~~~~~~~~~~~~~ ``` Reported by Paul Eggert. <https://lists.gnu.org/r/bison-patches/2022-07/msg00008.html> * data/skeletons/glr2.cc (glr_state, glr_stack_item): Declare the default ctors noexcept.
* lalr1.cc: declare stack_symbol_type as noexceptAkim Demaille2022-08-011-2/+2
| | | | | | | | | | | | | | | | | | | | | Many C++ tests (400-25, 440-53, 664-5, 667-76, 679-80, 682-3, 685-9, 692) failed with GCC 12.1: ``` test.cc:843:28: required from here /opt/local/include/gcc12/c++/bits/stl_construct.h:95:14: error: noexcept-expression evaluates to 'false' because of a call to 'yy::parser::stack_symbol_type::stack_symbol_type()' [-Werror=noexcept] 95 | noexcept(noexcept(::new((void*)0) _Tp(std::declval<_Args>()...))) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test.cc:990:3: note: but 'yy::parser::stack_symbol_type::stack_symbol_type()' does not throw; perhaps it should be declared 'noexcept' 990 | parser::stack_symbol_type::stack_symbol_type () | ^~~~~~ ``` Reported by Paul Eggert. <https://lists.gnu.org/r/bison-patches/2022-07/msg00008.html> * data/skeletons/lalr1.cc (stack_symbol_type::stack_symbol_type()): Declare noexcept.
* package: bump copyrights to 2022Paul Eggert2022-01-1527-34/+34
| | | | Run "make update-copyright".
* c++: use YY_NOEXCEPT where it helpsAkim Demaille2021-09-184-28/+28
| | | | | | | | | Suggested by Don Macpherson. <https://github.com/akimd/bison/issues/80> * data/skeletons/c++.m4, data/skeletons/glr2.cc, * data/skeletons/lalr1.cc, data/skeletons/stack.hh: Use YY_NOEXCEPT where it helps constructors.
* glr2.cc: semantic_option: use a symbolAkim Demaille2021-09-132-39/+35
| | | | | | * data/skeletons/c++.m4 (basic_symbol): Add assignment operators. * data/skeletons/glr2.cc (semantic_option): Replace yytoken, yyvalue and yylocation by yyla.
* glr2.cc: don't publish move ctor to lalr1.ccAkim Demaille2021-09-131-6/+6
| | | | | | | These operators were introduced in "c++: add move assignments to the symbol type" (fdaedc780af0dd678a4f4fa3175a201a553be20a) for glr2.cc. * data/skeletons/c++.m4: Define them for glr2.cc only.
* glr2.cc: simplify semantic_optionAkim Demaille2021-09-121-3/+3
| | | | | | * data/skeletons/glr2.cc (semantic_option): Simplify the rule-based constructor. This shows that it should be easy to use a symbol_kind, instead of the kind/value/location triple.
* glr2.cc: we require C++11Akim Demaille2021-09-121-4/+0
| | | | * data/skeletons/glr2.cc: So no need for C++98 compatibility.
* glr2.cc: introduse b4_glr2_cc_ifAkim Demaille2021-09-122-9/+13
| | | | | * data/skeletons/bison.m4 (b4_glr2_cc_if): Intro. * data/skeletons/c++.m4: use.
* glr2.cc: don't pass %parse-param to destroyAkim Demaille2021-09-121-6/+6
| | | | | | | | | | | | | | | | | | | | I regret that %destructor and %printer give access to the %parse-param in lalr1.cc, since that prevents them from being implemented as a simple destructor and operator<<. Let's not repeat the mistake in glr2.cc. In addition, fixes a name conflict we have currently in tests 566 568 570 657: calc.cc:1395:85: error: declaration shadows a field of 'calc::parser' [-Werror,-Wshadow] void glr_state::destroy (char const* yymsg, calc::parser& yyparser, semantic_value *result, int *count, int *nerrs) ^ calc.hh:441:21: note: previous declaration is here semantic_value *result; ^ With this commit, the whole test suite passes for glr2.cc. * data/skeletons/glr2.cc (glr_state::destroy): Don't take the user arguments.
* glr2.cc: kill trailing white spacesAkim Demaille2021-09-121-15/+14
| | | | | | | | | | | | | | | | Fixes several calc tests. Tests 566 568 570 657 still fail because of a name clash when using %parse-param: calc.cc:1395:85: error: declaration shadows a field of 'calc::parser' [-Werror,-Wshadow] void glr_state::destroy (char const* yymsg, calc::parser& yyparser, semantic_value *result, int *count, int *nerrs) ^ calc.hh:441:21: note: previous declaration is here semantic_value *result; ^ * data/skeletons/glr2.cc: Fix indentation/trailing spaces.
* glr2.cc: move strong_index_alias into the unnamed namespaceAkim Demaille2021-09-121-82/+82
| | | | * data/skeletons/glr2.cc: here.
* glr2.cc: use only symbol_kind_type, not yysymbol_kind_tAkim Demaille2021-09-121-22/+23
| | | | | * data/skeletons/glr2.cc: here. And prefer the unnamed namespace to static.
* glr2.cc: prefer using, and remove useless type aliasesAkim Demaille2021-09-121-30/+15
| | | | * data/skeletons/glr2.cc: here.
* glr2.cc: put glr_state_set and glr_stack_item in unnamed namespaceAkim Demaille2021-09-121-239/+248
| | | | * data/skeletons/glr2.cc: here.
* glr2.cc: move state_stack into the unnamed namespaceAkim Demaille2021-09-121-352/+354
| | | | | | * data/skeletons/glr2.cc: here. Prefer `using` to `typedef`, this is C++11. Use the type alias we introduced.
* glr2.cc: style: clarify control flowAkim Demaille2021-09-121-6/+7
| | | | * data/skeletons/glr2.cc (yypreference): Be more functional-style.
* glr2.cc: move glr_stack and glr_state into the parser classAkim Demaille2021-09-121-1238/+1244
| | | | | | | | | | | In order to be able to link several glr2.cc parser together, we cannot have glr_stack and glr_state be in no namespace. Putting them in the unnamed namespace is not doable, since we need to fwd declare them in the parser. Putting them in the specified namespace is not enough either, since some users would like to be able to put several parsers in the same name, only differing by the class name. * data/skeletons/glr2.cc (glr_state, glr_stack): Move into yy::parser.
* glr2.cc: put create_state_set_index in unnamed namespaceAkim Demaille2021-09-121-2/+5
| | | | * data/skeletons/glr2.cc: here.
* glr2.cc: prefer unnamed namespace to 'static'Akim Demaille2021-09-121-45/+69
| | | | * data/skeletons/glr2.cc: here.
* glr2.cc: put semantic_option into an unnamed namespaceAkim Demaille2021-09-121-231/+237
| | | | | | | | If we link several glr2.cc parsers together, we get linking failures because of duplicate symbols. * data/skeletons/glr2.cc (semantic_option::indexIn) (semantic_option::next): Remove the useless overloads.
* glr2.cc: don't publish YY_EXCEPTIONSAkim Demaille2021-09-121-9/+9
| | | | | | | | 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.
* glr2.cc: custom error messagesAkim Demaille2021-09-121-96/+167
| | | | | | | | | | 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-121-109/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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++: add move assignments to the symbol typeAkim Demaille2021-09-121-0/+28
| | | | | | This will be used in glr2.cc, which requires C++11. * data/skeletons/c++.m4 (basic_symbol, by_kind): Add move assignment.
* c++: avoid using the obsolete namesAkim Demaille2021-09-124-18/+25
| | | | | | | | * 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-1/+2
| | | | | | | | | | | | | | | | | | | | 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.
* style: c++: formatting changesAkim Demaille2021-08-292-13/+12
| | | | | * data/skeletons/variant.hh, data/skeletons/glr2.cc: Fix space before paren issue.
* c++: beware of Visual C++ limitationsAkim Demaille2021-08-291-0/+2
| | | | | | | | | | | | | | Contrary to what commit d8cc6b073e2802d871a16dc62418a7eb62ed2216 "c++: shorten the assertions that check whether tokens are correct" believed, MS Visual C++'s preprocessor limitation is not on the input line length, but on the size of the line holding the full C++ statement. Reported by Vince Huffaker <vince@vincejulie.com> <https://lists.gnu.org/r/help-bison/2021-08/msg00003.html> * data/skeletons/variant.hh (_b4_symbol_constructor_define): Hide the assertion from Visual C++.
* glr2.cc: require C++11Akim Demaille2021-08-191-1/+0
| | | | | | | | | | | | | | 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.
* c: fix _Noreturn support detectionAkim Demaille2021-08-111-1/+1
| | | | | | | | Reported by Christopher Nielsen <mascguy@github.com>. <https://trac.macports.org/ticket/59927#comment:59> and <https://trac.macports.org/ticket/59927#comment:62>. * data/skeletons/c.m4: Fix typo.
* lalr1.cc: style changesAkim Demaille2021-08-111-8/+11
| | | | | * data/skeletons/lalr1.cc: Formatting changes. Use more `const`, as in glr2.cc.
* glr.c: fix signature when using custom error messagesAkim Demaille2021-08-111-2/+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.
* style: rename b4_lex as b4_yylexAkim Demaille2021-08-096-22/+31
| | | | | | | | | | | | For consistency with b4_yyerror_formals, etc. * data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/d.m4, * data/skeletons/glr.c, data/skeletons/glr2.cc, * data/skeletons/java.m4, data/skeletons/lalr1.cc, * data/skeletons/lalr1.d, data/skeletons/lalr1.java, * data/skeletons/yacc.c (b4_lex, b4_lex_formals): Rename as... (b4_yylex, b4_yylex_formals): these.
* yacc: comply with recent POSIX updates: declare yyerror and yylexAkim Demaille2021-08-092-4/+37
| | | | | | | | | | | | | | | | | | | | | 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-071-0/+1
| | | | | | | | | | 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-071-0/+2
| | | | | | | * 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-074-16/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* all: fix confusion between token ctor and symbol ctorAkim Demaille2021-08-013-13/+14
| | | | | The symbol constructors are genuine constructors. Token constructors are plain functions that construct tokens.
* d: add push parser supportAdela Vais2021-04-112-47/+195
| | | | | | | | | | 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-0/+27
| | | | | | | | | | | 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-6/+116
| | | | | | | | | 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.
* d: rewrite Symbol's constructors in M4Adela Vais2021-03-261-14/+18
| | | | | | | The D code was becoming too complex. M4 is easier to maintain in the long run. * data/skeletons/d.m4: Here.
* Merge 3.7.6 into masterAkim Demaille2021-03-101-5/+7
|\ | | | | | | | | | | | | | | * 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-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-3025-31/+31
| | | | | | | | Also, fix a few http: URLs that were no longer working.
* | doc: fix documented function nameJoshua Watt2021-02-251-1/+1
| | | | | | | | | | * data/README.md: Fix the name of a referenced function to match the name in code.
* | c: rename YY_LOCATION_PRINT as YYLOCATION_PRINT and make it publicAkim Demaille2021-02-094-16/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is very helpful to be able to look at the locations in the debug traces, let's provide the users with (i) a means to do that for their location types, and (ii) a public macro to print locations when debug traces are enabled. * data/skeletons/c.m4 (b4_yy_location_print_define): Rename as... (b4_yylocation_print_define): this. Define YYLOCATION_PRINT instead of YY_LOCATION_PRINT. Ensure backward compatibility for those who might have defined/used YY_LOCATION_PRINT in spite the warnings. Adjust dependencies. * data/skeletons/glr2.cc: We don't use YYLOCATION_PRINT here.
* | c: stop defining YY_LOCATION_PRINT when locations are not enabledAkim Demaille2021-02-021-6/+2
| | | | | | | | * data/skeletons/c.m4 (b4_yy_location_print_define): here.