previous | index | next

Adding Parentheses to the Evaluation Method

Example:
     (evaluate "(3+2)*4-40/5")
Note that the expression is represented as a string because of the special meaning that parentheses have in Scheme.

A parenthesized (sub-)expression must be fully reduced before continuing the left-to-right scan.

This is accomplished by:

  1. If a ( is encountered, simply shift it onto the stack.

  2. If a ) is encountered:


previous | index | next