Newer
Older
# Disclaimer
The contents of this directory are taken from the Bison Manual.
See the URL below for the relevant portion of the manual (and then follow the "Up" links for the rest of the manual).
The major changes are the Makefile and the test.sh shell script.
Changes made by Prof. Ronald Moore for his students at the h_da.
See https://fbi.h-da.de/personen/ronald-moore/
or mail ronald.moore@h-da.de
## Quick Start
To build the software, simply run `make`.
To run the test script, either enter `make tests` or `test.sh`.
To make the output of the test script more readable, try:
```
./test.sh 2>&1 | less
```
## Build Requirements
This will only work if you have flex and bison and either gcc or clang installed.
(The Makefile will have to be changed to use gcc instead of clang -- see the Makefile).
This version of this code was most recently tested with the following versions (no guarantee that it will work for other versions):
* bison 3.7.6 (in 2021, and 3.5.4 in 2020)
* flex 2.6.4 (in 2021 and 2020)
* clang 11.1.0 (in 2021 and 10.0.0 in 2020)
* gcc 10.2.0 (in 2021 and 9.3.0 in 2020)
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
The remainder of this file is taken *verbatim* from the README from the Bison source code distribution. Please look at the end of this file in a normal text editor to see the invisible copyright information (among other things, otherwise hidden in comments).
# calc++ - A Flex+Bison calculator
This directory contains calc++, a Bison grammar file in C++. If you never
saw the traditional implementation in C, please first read
examples/c/lexcalc, which can be seen as a C precursor of this example.
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 <Ctrl-d>, 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.
<!---
Local Variables:
fill-column: 76
ispell-dictionary: "american"
End:
Copyright (C) 2018-2019 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
# LocalWords: calc parsers yy MERCHANTABILITY Ctrl ispell american
--->