Files
bison/examples
Akim Demaille 01898726e2 generate the default semantic action
Currently, in C, the default semantic action is implemented by being
always run before running the actual user semantic action.  As a
consequence, when the user action is run, $$ is already set as $1.

In C++ with variants, we don't do that, since we cannot manipulate the
semantic value without knowing its exact type.  When variants are
enabled, the only guarantee is that $$ is default contructed and ready
to the used.

Some users still would like the default action to be run with
variants.  Frank Heckenbach's parser in
C++17 (http://lists.gnu.org/archive/html/bug-bison/2018-04/msg00011.html)
provides this feature, but relying on std::variant's dynamic typing,
which we forbid in lalr1.cc.

The simplest seems to be actually generating the default semantic
action (in all languages/skeletons).  This makes the pre-action (that
sets $$ to $1) useless.  But...  maybe some users depend on this, in
spite of the comments that clearly warn againt this.  So let's not
turn this off just yet.

* src/reader.c (grammar_rule_check_and_complete): Rename as...
(grammar_rule_check_and_complete): this.
Install the default semantic action when applicable.
* examples/variant-11.yy, examples/variant.yy, tests/calc.at:
Exercise the default semantic action, even with variants.
2018-10-14 18:53:21 +02:00
..
2018-10-07 10:41:40 +02:00
2018-10-07 10:41:40 +02:00
2018-10-07 10:41:40 +02:00
2018-10-07 10:41:40 +02:00
2018-09-13 19:01:33 +02:00
2018-10-05 07:01:04 +02:00

This directory contains examples of Bison grammar files.

* mfcalc
A C example of a multi-function calculator.  Extracted from the
documentation.

* calc++
A C++ version of the canonical example for parsers: a calculator.  Also uses
Flex for the scanner.  Extracted from the documentation.

* variant.yy
A C++ example that uses variants (they allow to use any C++ type as semantic
value type) and symbol constructors (they ensure consistency between
declared token type and effective semantic value).

* variant-11.yy
Another C++ example, closely related to the previous one, but exhibiting
support for C++11's move semantics.

-----

Local Variables:
mode: outline
fill-column: 76
End:

Copyright (C) 2018 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts.  A copy of the license is included in the "GNU Free
Documentation License" file as part of this distribution.

# LocalWords:  mfcalc calc parsers yy