This commit is contained in:
Justin Ethier 2015-08-13 02:18:03 -04:00
parent 42a7790a29
commit 3608c2aeda
2 changed files with 27 additions and 26 deletions

View file

@ -143,7 +143,7 @@
(car vals))))
(else (scan (cdr vars) (cdr vals)))))
(if (eq? env the-empty-environment)
(error "Unbound variable" var)
(not-found)
(let ((frame (first-frame env)))
(scan (frame-variables frame)
(frame-values frame)))))
@ -466,30 +466,30 @@
(loop (car procs) (cdr procs))))
(define (pre-analyze-application exp a-env)
; (let* ((op (operator exp))
; (var (if (symbol? op)
; (_lookup-variable-value op a-env
; (lambda () #f)) ; Not found
; #f)))
; (cond
; ((macro? var)
;; look up symbol in env, and expand if it is a macro
;; Adds some extra overhead into eval, which is not ideal. may need to
;; reduce that overhead later...
;(write (list 'JAE-DEBUG 'expanding exp)) ;; DEBUG-only
; ;; TODO: need to use common rename/compare functions
; ;; instead of fudging them here. maybe keep common
; ;; functions in the macros module and hook into them???
;
; ;; see macro-expand in that module. believe these are the only
; ;; two places so far that introduce instances of rename/compare?
; (analyze (apply op
; (list (cons op (operands exp))
; (lambda (sym) sym)
; (lambda (a b) (eq? a b))))
; a-env))
; (else
(analyze-application exp a-env)) ;)))
(let* ((op (operator exp))
(var (if (symbol? op)
(_lookup-variable-value op a-env
(lambda () #f)) ; Not found
#f)))
(cond
((macro? var)
; look up symbol in env, and expand if it is a macro
; Adds some extra overhead into eval, which is not ideal. may need to
; reduce that overhead later...
(write (list 'JAE-DEBUG 'expanding exp)) ;; DEBUG-only
;; TODO: need to use common rename/compare functions
;; instead of fudging them here. maybe keep common
;; functions in the macros module and hook into them???
;; see macro-expand in that module. believe these are the only
;; two places so far that introduce instances of rename/compare?
(analyze (apply var
(list (cons var (operands exp))
(lambda (sym) sym)
(lambda (a b) (eq? a b))))
a-env))
(else
(analyze-application exp a-env)))))
(define (analyze-application exp a-env)
(let ((fproc (analyze (operator exp) a-env))

View file

@ -48,4 +48,5 @@
(write x)
(write
(eval 'or))
;(eval '(or 1 2 x)))
(write
(eval '(or 1 2 x)))