README.md
1# calc++ - A Flex+Bison calculator
2
3This directory contains calc++, a Bison grammar file in C++. If you never
4saw the traditional implementation in C, please first read
5examples/c/lexcalc, which can be seen as a C precursor of this example.
6
7Read the corresponding chapter in the documentation: "A Complete C++
8Example". It is also available [on
9line](https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html)
10(maybe with a different version of Bison).
11
12To use it, copy this directory into some work directory, and run `make` to
13compile the executable, and try it. It is a simple calculator which accepts
14several variable definitions, one per line, and then a single expression to
15evaluate.
16
17The program calc++ expects the file to parse as argument; pass `-` to read
18the standard input (and then hit <Ctrl-d>, control-d, to end your input).
19
20```
21$ ./calc++ -
22one := 1
23two := 2
24three := 3
25(one + two * three) * two * three
26<Ctrl-d>
2742
28```
29
30You may pass `-p` to activate the parser debug traces, and `-s` to activate
31the scanner's.
32
33<!---
34Local Variables:
35fill-column: 76
36ispell-dictionary: "american"
37End:
38
39Copyright (C) 2018-2021 Free Software Foundation, Inc.
40
41Permission is granted to copy, distribute and/or modify this document
42under the terms of the GNU Free Documentation License, Version 1.3 or
43any later version published by the Free Software Foundation; with no
44Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
45Texts. A copy of the license is included in the "GNU Free
46Documentation License" file as part of this distribution.
47
48LocalWords: calc parsers yy MERCHANTABILITY Ctrl ispell american
49--->
50