previous | index | next

The evaluate Procedure

     (define evaluate
       (lambda (expression-string)
	 (let ((expr-stack (make-ra-stack)))
	   (push! expr-stack '$)
	   (define process
	     (lambda (rest-of-expr)
	       ... scan the expression and take
		   action according to the action
		   table ...
	       ))
	   (process
	     (tokenize expression-string)))))
"Tokenizing" the Expression:
  • tokenize takes the input expression string and makes it into a Scheme list with special tokens for parentheses.
  • It also puts the end-of-expression indicator $ at the end.
  • Example:
         (tokenize "(3+2)*4-40/5")
         ⇒ (lparen 3 + 2 rparen * 4 - 40 / 5 $)
    

previous | index | next