Files
bison/examples/c++
Akim Demaille d50a3e450e graph: output foo.gv by default, instead of *.dot
That change was started in Bison 3.4.  The announcement for 3.7 stated
that in Bison 3.8 we would use *.gv by default.

* src/files.c (compute_output_file_names): spec_graph_file defaults
too *.gv.
* doc/bison.texi, examples/c++/calc++/local.mk, tests/output.at:
Adjust.
2021-02-02 06:51:39 +01:00
..
2021-01-29 13:48:43 -08:00
2019-09-22 07:48:10 +02:00
2021-01-29 13:48:43 -08:00
2021-01-16 16:11:17 +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 kind and effective semantic value.

Run as ./simple.

Extracted from the documentation: A Simple C++ Example.

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.