| 1 |
Here is how to compile and run the parser file: |
| 2 |
verb( |
| 3 |
# List files (recursively) in the (current) examples/rpn directory. |
| 4 |
% ls -R |
| 5 |
.: |
| 6 |
build* main.cc parser/ rpn.ih |
| 7 |
|
| 8 |
./parser: |
| 9 |
grammar lex.cc Parser.ih |
| 10 |
|
| 11 |
# Create `rpn' using the `build' script: |
| 12 |
% ./build program |
| 13 |
|
| 14 |
# List files again, ./rpn is the constructed program |
| 15 |
% ls -R |
| 16 |
.: |
| 17 |
build* main.cc parser/ program* rpn.ih |
| 18 |
|
| 19 |
./parser: |
| 20 |
grammar grammar.output lex.cc parse.cc Parserbase.h Parser.h Parser.ih |
| 21 |
) |
| 22 |
|
| 23 |
Here is an example session using the calculator: |
| 24 |
verb( |
| 25 |
% program |
| 26 |
4 9 + |
| 27 |
13 |
| 28 |
3 7 + 3 4 5 *+- |
| 29 |
-13 |
| 30 |
3 7 + 3 4 5 * + - n Note the unary minus, `n' |
| 31 |
13 |
| 32 |
5 6 / 4 n + |
| 33 |
-3.16667 |
| 34 |
3 4 ^ Exponentiation |
| 35 |
81 |
| 36 |
^D End-of-file indicator |
| 37 |
% |
| 38 |
) |
| 39 |
|
| 40 |
|