Up: Provided Examples



6.3.4.1 incubcalc

The calculator has already been described in The Incubator Calculator Example earlier. We show here how to use the implementation provided in the source code. The executable incubcalc is located in the examples/incubcalc/ directory. The only command line options are given in Command-line Arguments.

From the examples/incubcalc/ directory, run ./incubcalc. The program will come up with a prompt:

     mathieu% ./incubcalc
     Please enter a string to evaluate:
     #

Type in an arithmetic expression and press return:

     mathieu% ./incubcalc
     Please enter a string to evaluate:
     # (2 + 2) * (3 + 2 * 6 + 5) <return>

The program will calculate the answer, print it, and loop to the beginning:

     Done
     The result is 80
     Please enter a string to evaluate:
     #

If you enter an invalid expression, it will stall (FIXME: Fix that soon!). Currently, no division is allowed (FIXME: Fix that soon!).