1 (defun make-sum (a1 a2)
3 (defun make-product (m1 m2)
6 (and (consp x) (eql (cadr x) '+)))
12 (and (consp x) (eql (cadr x) '*)))
15 (defun multiplicand (s)
18 (defvar *stream* '() "Token stream")
19 (defun init-stream (stream)
20 "Initialize the stream"
21 (setq *stream* stream))
23 "Returns the next token of the stream"
27 (defvar *stream-stack* '() "Stack of streams")
28 (defun push-stream (stream)
29 "Push the current *stream* on stack, and set this tream as *stream*"
30 (push *stream* *stream-stack*)
33 (init-stream (pop *stream-stack)))
34 (defun parse-factor ()
35 (let ((tok (next-token)))
37 ((or (numberp tok) (sybolp tok))
42 (let ((sum (parse-sum)))
46 (t (error "Bad token in parse-atom -- ~A" tok)))))
48 (let ((lfact (parse-factor)))
49 (if (eq (next-token) '*)
52 (let ((rterm (parse-term)))
53 (list '* lfact rterm)))