Files
bison/examples/c++/calc++
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
..

This directory contains calc++, a simple Bison grammar file in C++.

Please, read the corresponding chapter in the documentation: "A Complete C++ Example". It is also available on line (maybe with a different version of Bison): https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html

To use it, copy this directory into some work directory, and run make to compile the executable, and try it. It is a simple calculator which accepts several variable definitions, one per line, and then a single expression to evaluate.

The program calc++ expects the file to parse as argument; pass - to read the standard input (and then hit , control-d, to end your input).

$ ./calc++ -
one := 1
two := 2
three := 3
(one + two * three) * two * three
<Ctrl-d>
42

You may pass -p to activate the parser debug traces, and -s to activate the scanner's.