Commit Graph

7923 Commits

Author SHA1 Message Date
Akim Demaille
157e91dcc6 glr2.cc: introduse b4_glr2_cc_if
* data/skeletons/bison.m4 (b4_glr2_cc_if): Intro.
* data/skeletons/c++.m4: use.
2021-09-12 20:04:44 +02:00
Akim Demaille
b820718adf glr2.cc: don't pass %parse-param to destroy
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.
2021-09-12 14:00:55 +02:00
Akim Demaille
6e6e11795c glr2.cc: kill trailing white spaces
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.
2021-09-12 14:00:55 +02:00
Akim Demaille
6bfdf22c50 glr2.cc: check linking conflicts
* tests/headers.at (Several Headers): Link two glr2.cc parsers.
2021-09-12 14:00:55 +02:00
Akim Demaille
d432079f8a glr2.cc: move strong_index_alias into the unnamed namespace
* data/skeletons/glr2.cc: here.
2021-09-12 14:00:55 +02:00
Akim Demaille
b6ac175a1c glr2.cc: use only symbol_kind_type, not yysymbol_kind_t
* data/skeletons/glr2.cc: here.
And prefer the unnamed namespace to static.
2021-09-12 14:00:55 +02:00
Akim Demaille
5f90ef59a4 glr2.cc: prefer using, and remove useless type aliases
* data/skeletons/glr2.cc: here.
2021-09-12 14:00:55 +02:00
Akim Demaille
10ee04479f glr2.cc: put glr_state_set and glr_stack_item in unnamed namespace
* data/skeletons/glr2.cc: here.
2021-09-12 14:00:55 +02:00
Akim Demaille
c09524cf8f glr2.cc: move state_stack into the unnamed namespace
* data/skeletons/glr2.cc: here.
Prefer `using` to `typedef`, this is C++11.
Use the type alias we introduced.
2021-09-12 14:00:55 +02:00
Akim Demaille
28152fc10a glr2.cc: style: clarify control flow
* data/skeletons/glr2.cc (yypreference): Be more functional-style.
2021-09-12 14:00:55 +02:00
Akim Demaille
9babd05a90 glr2.cc: move glr_stack and glr_state into the parser class
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.
2021-09-12 14:00:55 +02:00
Akim Demaille
3e94b12ddd glr2.cc: put create_state_set_index in unnamed namespace
* data/skeletons/glr2.cc: here.
2021-09-12 14:00:55 +02:00
Akim Demaille
7cb6de2533 glr2.cc: prefer unnamed namespace to 'static'
* data/skeletons/glr2.cc: here.
2021-09-12 14:00:55 +02:00
Akim Demaille
4ec4309cce glr2.cc: put semantic_option into an unnamed namespace
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.
2021-09-12 14:00:50 +02:00
Akim Demaille
ca96df89b2 glr2.cc: don't publish YY_EXCEPTIONS
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.
2021-09-12 12:03:58 +02:00
Akim Demaille
2142e59155 c++: demonstrate custom error messages in the examples
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.
2021-09-12 12:03:58 +02:00
Akim Demaille
a75072476e glr2.cc: custom error messages
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.
2021-09-12 12:03:58 +02:00
Akim Demaille
7c47598d4f glr2.cc: start the transition to using symbol_type
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.
2021-09-12 12:03:58 +02:00
Akim Demaille
fdaedc780a c++: add move assignments to the symbol type
This will be used in glr2.cc, which requires C++11.

* data/skeletons/c++.m4 (basic_symbol, by_kind): Add move assignment.
2021-09-12 12:03:58 +02:00
Akim Demaille
85f5e3b9d5 c++: avoid using the obsolete names
* 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.
2021-09-12 12:03:58 +02:00
Akim Demaille
c3a4686a03 regen 2021-09-12 12:03:58 +02:00
Akim Demaille
9cdfd86cbb maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2021-09-11 08:55:22 +02:00
Akim Demaille
659376b590 version 3.8.1
* NEWS: Record release date.
v3.8.1
2021-09-11 08:26:40 +02:00
Akim Demaille
0343acbe89 portability: don't use strtof
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.
2021-09-11 08:26:10 +02:00
Akim Demaille
5d9ccd5a87 yacc: declare yyerror/yylex only when POSIXLY_CORRECT
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.
2021-09-11 08:26:10 +02:00
Akim Demaille
ad9b8a069f maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2021-09-07 20:56:23 +02:00
Akim Demaille
ec3375ab4e version 3.8
* NEWS: Record release date.
v3.8
2021-09-07 20:28:49 +02:00
Akim Demaille
12c8e427c7 news: update 2021-09-07 20:28:36 +02:00
Akim Demaille
9f8f3d2e77 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2021-09-02 07:56:44 +02:00
Akim Demaille
108724c2e7 version 3.7.91
* NEWS: Record release date.
v3.7.91
2021-09-02 07:31:20 +02:00
Akim Demaille
da0f993fb9 tests: disable "Multistart reports"
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.
2021-09-02 07:27:42 +02:00
Akim Demaille
075a879052 style: c++: formatting changes
* data/skeletons/variant.hh, data/skeletons/glr2.cc: Fix space before
paren issue.
2021-08-29 18:36:07 +02:00
Akim Demaille
a7ded4284e style: rename stmtMerge as stmt_merge
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.
2021-08-29 16:25:38 +02:00
Akim Demaille
a5c55bb758 c++: beware of Visual C++ limitations
Contrary to what commit d8cc6b073e "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++.
2021-08-29 10:10:56 +02:00
Akim Demaille
bc5aa8e274 tests: don't postprocess stderr with sed
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.
2021-08-29 09:50:02 +02:00
Akim Demaille
0a82bf5c07 CI: don't require Autoconf 2.71 2021-08-19 10:07:51 +02:00
Akim Demaille
a70e75b8a4 examples: don't demonstrate multistart, which is not part of 3.8
Besides, for mysterious reasons, this fails on some environment.
Reported by Dagobert Michelsen.
<https://lists.gnu.org/archive/html/bug-bison/2021-08/msg00008.html>

* examples/c/lexcalc/lexcalc.test, examples/c/lexcalc/parse.y,
* examples/c/lexcalc/scan.l: Revert to a single-start example.
2021-08-19 09:19:07 +02:00
Akim Demaille
3afa9757da tests: grep -E is not portable
Reported by Dagobert Michelsen.
<https://lists.gnu.org/r/bug-bison/2021-08/msg00008.html>

* tests/calc.at: Use $EGREP.
2021-08-19 08:21:23 +02:00
Akim Demaille
36f37568ba glr2.cc: require C++11
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.
2021-08-19 08:21:22 +02:00
Akim Demaille
f2c568d3ef readme: add D 2021-08-13 09:06:34 +02:00
Akim Demaille
bb7860d208 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2021-08-13 08:47:37 +02:00
Akim Demaille
8bb81e2048 version 3.7.90
* NEWS: Record release date.
v3.7.90
2021-08-13 08:20:06 +02:00
Akim Demaille
84059ea508 build: ignore syntax-check's file_system check on Doxyfile
* cfg.mk: Here.
2021-08-13 08:15:31 +02:00
Akim Demaille
024f00fd11 tests: fix incorrect test case
In c2ba260487 ("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.
2021-08-12 10:13:38 +02:00
Akim Demaille
0af06e091b gnulib: update 2021-08-12 10:13:38 +02:00
Akim Demaille
1d291901b4 news: be clear that glr2.cc is C++11 2021-08-12 10:13:38 +02:00
Akim Demaille
f387ffc1d3 build: modernize to newer Autoconf releases
* configure.ac: here.
2021-08-12 10:13:38 +02:00
Akim Demaille
9307c173c7 build: reject C++ compilers that don't support std::vector::data
GCC 4.2 on macOS claims to support C++98, but does not feature it.

input.cc: In member function 'void state_stack::yycompressStack()':
input.cc:1774: error: 'class std::vector<glr_stack_item, std::allocator<glr_stack_item> >' has no member named 'data'

Reported by Christopher Nielsen <mascguy@github.com>.
<https://trac.macports.org/raw-attachment/ticket/59927/bison-test-results-20210811-95b72.log.xz>.

* m4/bison-cxx-std.m4 (_BISON_CXXSTD_98_snippet): Check for it.
* m4/cxx.m4 (BISON_TEST_FOR_WORKING_CXX_COMPILER): Ditto.
2021-08-12 10:13:26 +02:00
Akim Demaille
15ba35a51b build: check for C++ 20 and 2b
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.
2021-08-12 09:07:36 +02:00
Akim Demaille
db66acc5d0 tests: remove obsolete checks
* 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.
2021-08-12 08:24:13 +02:00