Previous: Rpcalc Generate, Up: RPN Calc [Contents][Index]
Here is how to compile and run the parser implementation file:
# List files in current directory.
$ ls
rpcalc.tab.c rpcalc.y
# Compile the Bison parser.
# ‘-lm’ tells compiler to search math library for pow
.
$ cc -lm -o rpcalc rpcalc.tab.c
# List files again.
$ ls
rpcalc rpcalc.tab.c rpcalc.y
The file rpcalc now contains the executable code. Here is an
example session using rpcalc
.
$ rpcalc 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.166666667 3 4 ^ Exponentiation ⇒ 81 ^D End-of-file indicator $