Files
bison/examples/c++
Akim Demaille 85d303b713 examples: sort them per language and complete them
Convert some of the READMEs to Markdown, which is now more common, and
nicely displayed in some git hosting services.

Add missing READMEs and Makefiles.  Generate XML, HTML and Dot files.  Be
sure to ship the test files.  Complete CLEANFILES to remove all generated
files.

* examples/calc++: Move into...
* examples/c++: here.
* examples/mfcalc, examples/rpcalc: Move into...
* examples/c: here.

* examples/README.md, examples/c++/calc++/Makefile, examples/c/local.mk,
* examples/c/mfcalc/Makefile, examples/c/rpcalc/Makefile,
* examples/d/README.md, examples/java/README.md:
New files.

* examples/test (medir): Be robust to deeper directory nesting.
2018-12-09 13:55:05 +01:00
..
2018-11-13 06:53:21 +01:00

Examples in C++

This directory contains examples of Bison grammar files in C++.

You can run make to compile these examples. And make clean to tidy afterwards.

simple.yy - Simple example in C++14

A very simple example in C++, based on variants and symbol constructors. Variants allow to use any C++ type as semantic value type, and symbol constructors ensure consistency between declared token type and effective semantic value.

Run as ./simple.

Extracted from the documentation: "A Simple C++ Example". https://www.gnu.org/software/bison/manual/html_node/A-Simple-C_002b_002b-Example.html

variant.yy - Self-contained example in C++98

A variation of simple.yy, in C++98.

Run as ./variant.

variant-11.yy - Self-contained example in modern C++

Another variation of simple.yy, closely related to the previous one, but exhibiting support for C++11's move semantics.

Run as ./variant or ./variant NUMBER.

calc++ - A Complete C++ Example

A fully featured C++ version of the canonical example for parsers: a calculator. Also uses Flex for the scanner.

Don't look at this example first: it is fully featured and can serve as a starting point for a clean parser in C++. The previous examples are better introductory examples, and the C examples are also useful introductory examples.

Extracted from the documentation: "A Complete C++ Example". https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html