glr2.cc: style: clarify control flow
[bison.git] / examples / c++ / README.md
blobdff3783e5aba396a4ac6952f753175d8cb0e6b1a
1 # Examples in C++
3 This directory contains examples of Bison grammar files in C++.
5 You can run `make` to compile these examples.  And `make clean` to tidy
6 afterwards.
8 ## simple.yy - Simple example in C++14
9 A very simple example in C++, based on variants and symbol constructors.
10 Variants allow to use any C++ type as semantic value type, and symbol
11 constructors ensure consistency between declared token kind and effective
12 semantic value.
14 Run as `./simple`.
16 Extracted from the documentation: [A Simple C++
17 Example](https://www.gnu.org/software/bison/manual/html_node/A-Simple-C_002b_002b-Example.html).
19 ## variant.yy - Self-contained example in C++98
20 A variation of simple.yy, in C++98.
22 Run as `./variant`.
24 ## variant-11.yy - Self-contained example in modern C++
25 Another variation of simple.yy, closely related to the previous one, but
26 exhibiting support for C++11's move semantics.
28 Run as `./variant` or `./variant NUMBER`.
30 ## calc++ - A Complete C++ Example
31 A fully featured C++ version of the canonical example for parsers: a
32 calculator.  Also uses Flex for the scanner.
34 Don't look at this example first: it is fully featured and can serve as a
35 starting point for a clean parser in C++.  The previous examples are better
36 introductory examples, and the C examples are also useful introductory
37 examples.
39 Extracted from the documentation: [A Complete C++
40 Example](https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html).
42 ## glr
44 This example demonstrates the use of GLR parsers to handle (local)
45 ambiguities in the C++ language.  See the node "Merging GLR Parses" in
46 Bison's documentation.
48 It uses (Bison) variants to store objects as semantic values.  It also
49 demonstrates custom error messages in C++.
51 <!---
53 Local Variables:
54 fill-column: 76
55 ispell-dictionary: "american"
56 End:
58 Copyright (C) 2018-2021 Free Software Foundation, Inc.
60 Permission is granted to copy, distribute and/or modify this document
61 under the terms of the GNU Free Documentation License, Version 1.3 or
62 any later version published by the Free Software Foundation; with no
63 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
64 Texts.  A copy of the license is included in the "GNU Free
65 Documentation License" file as part of this distribution.
67 LocalWords:  mfcalc calc parsers yy ispell american
68 --->