; In the Replace all comments with code. Add a top-level comment here describing your ; general approach to the solution. Also add explanatory comments above each ; function that you implement, describing your implementation. (defmacro comment (&rest l) ()) ; The static pool holds all global variable bindings. Global variables are ; defined as all variables that are not declared as function parameters. The ; static pool also holds function bindings, that is functions that are declared ; with xdefun. (defvar static-pool) ; The stack holds activation records of parameter bindings. (defvar stack) ; Evaluate the given sexpr in the context of the given alist. (defun xeval (sexpr alist) (cond ( (eq sexpr ':dump) (pprint alist) (list nil alist) ) ;-- :dump is for debugging purposes only ( (numberp sexpr) (comment -- return numbers as is) ) ( (stringp sexpr) (comment -- ditto for strings) ) ( (eq sexpr t) (comment -- ditto for t) ) ( (null sexpr) (comment -- and ditto for nil) ) ( (atom sexpr) (cond ( (comment -- check if atomic sexpr is on the alist) (comment -- and if so use that value) ) ( t (comment -- otherwise print an "Unbound Variable" error) ) ) ) ( (atom (car sexpr)) (cond ( (eq (car sexpr) 'xquote) (comment -- return quotes as is) ) ( (eq (car sexpr) 'xsetq) (comment -- call eval-xsetq with appropriate args) ) ( (eq (car sexpr) 'xcond) (comment -- call eval-xcond with appropriate args) ) ( (eq (car sexpr) 'xdefun) (comment -- call eval-xdefun with appropriate args) ) ( (comment -- if alist value of (car sexpr) is a function body) (comment -- then call xapply to evaluate it) ) ( t (comment -- call eval-with-gcl for the rest) ) ) ) ( t (comment -- what if (car sexpr) is not an atom?) ) ) ) (defun eval-xsetq (atom-name value alist) (comment -- bind name to value in the static pool or stack, as appropriate)) (defun eval-xcond (sexpr alist) (comment -- evaluate a conditional)) (defun eval-xdefun (fn-name formals fn-body alist) (comment -- add fn-name to along with its formal parms and body)) (defun xapply (fn-body formals actuals alist) (comment -- bind args and xeval fn-body)) (defun xbind (formals actuals alist) (comment -- extend the alist with new bindings (called from xapply))) (defun xeval-list (sexpr-list alist) (comment -- x-evaluate a list of sexprs returning the value of the last (called from eval-xcond and xapply)) ) (defun eval-with-gcl (sexpr alist) (comment -- if sexpr is a function\, xevaluate each arg\, and then use gcl to eval. If sexpr is not a function\, send sexpr directly to gcl.) ) (defun xeval-list-list (sexpr-list alist) (comment -- x-evaluate a list of sexprs returning a list of quoted values (called from eval-with-gcl)) ) (comment -- add additional auxiliary function you may need)