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