Refactoring

This commit is contained in:
Justin Ethier 2016-04-30 02:16:22 -04:00
parent e2d158bdd6
commit 6ed5d735f6

View file

@ -782,13 +782,8 @@
;; FUTURE: append the empty (unprinted) value
;; instead of #f
#f)))
((app? exp)
(cond
;; TODO: could check for a define-syntax here and load into memory
;; if found. would then want to continue expanding. may need to
;; return some value such as #t or NULL as a placeholder, since the
;; define-syntax form would not be carried forward in the compiled code
((define-syntax? exp) ;; TODO: not good enough, should do error checking, and make sure list is big enough for cadr
((define-c? exp) exp)
((define-syntax? exp)
;(trace:info `(define-syntax ,exp))
(let* ((name (cadr exp))
(trans (caddr exp))
@ -816,7 +811,8 @@
;; (alpha, cps, closure, etc). otherwise code has to be interpreted during expansion
;;
`(define ,name ,(expand body env))))))
((define-c? exp) exp)
((app? exp)
(cond
((symbol? (car exp))
(let ((val (env:lookup (car exp) env #f)))
(if (tagged-list? 'macro val)
@ -826,7 +822,6 @@
(map
(lambda (expr) (expand expr env))
exp))))
(else
(map
(lambda (expr) (expand expr env))
@ -885,10 +880,10 @@
((or (const? this-exp)
(prim? this-exp)
(ref? this-exp)
(quote? this-exp))
(quote? this-exp)
(define-c? this-exp))
(expand-body (cons this-exp result) (cdr exp) env))
((or (define? this-exp)
(define-c? this-exp)
(define-syntax? this-exp)
(lambda? this-exp)
(set!? this-exp)