Cut-over to expand2

This commit is contained in:
Justin Ethier 2015-09-02 01:41:30 -04:00
parent 9a3d370de4
commit e177410706
3 changed files with 9 additions and 13 deletions

View file

@ -102,7 +102,7 @@
;(set! input-program (add-libs input-program)) ;(set! input-program (add-libs input-program))
;; JAE DEBUG code, remove (or refactor) once working ;; JAE DEBUG code, remove (or refactor) once working
(trace:info "JAE DEBUG - compiled macros") ;(trace:info "JAE DEBUG - compiled macros")
;(trace:info ;(trace:info
; (filter ; (filter
; (lambda (v) ; (lambda (v)
@ -124,8 +124,8 @@
*defined-macros*))) *defined-macros*)))
(macro:load-env! *defined-macros* (create-environment '() '())) (macro:load-env! *defined-macros* (create-environment '() '()))
;TODO: try this again, make sure macro is loaded: ;TODO: try this again, make sure macro is loaded:
(trace:info (list 'defined-macros *defined-macros*)) ;(trace:info (list 'defined-macros *defined-macros*))
(trace:info (list 'macro-env (macro:get-env))) ;(trace:info (list 'macro-env (macro:get-env)))
;; END JAE DEBUG ;; END JAE DEBUG
(set! input-program (expand input-program (macro:get-env))) (set! input-program (expand input-program (macro:get-env)))

View file

@ -87,10 +87,10 @@
(define (macro:expand2 exp macro mac-env) (define (macro:expand2 exp macro mac-env)
(let* ((compiled-macro? (or (macro? (Cyc-get-cvar (cadr macro))) (let* ((compiled-macro? (or (macro? (Cyc-get-cvar (cadr macro)))
(procedure? (cadr macro))))) (procedure? (cadr macro)))))
(newline) ;(newline)
(display "/* ") ;(display "/* ")
(display (list 'macro:expand2 exp macro compiled-macro?)) ;(display (list 'macro:expand2 exp macro compiled-macro?))
(display "*/ ") ;(display "*/ ")
;; Invoke ER macro ;; Invoke ER macro
(cond (cond
@ -108,10 +108,6 @@
(list 'quote exp) (list 'quote exp)
(Cyc-er-rename mac-env) (Cyc-er-rename mac-env)
Cyc-er-compare?) Cyc-er-compare?)
; TODO: this is broken because mac-env only contains macros, but
; we need global-env to handle functions (like null?, caddr, etc).
; not sure what the answer is yet... might need to base macro-env
; on global-env, and ensure symbol is a macro before expanding
mac-env))))) mac-env)))))
; TODO: get macro name, transformer ; TODO: get macro name, transformer

View file

@ -793,8 +793,8 @@
(let ((val (env:lookup (car exp) env #f))) (let ((val (env:lookup (car exp) env #f)))
(if (tagged-list? 'macro val) (if (tagged-list? 'macro val)
(expand ; Could expand into another macro (expand ; Could expand into another macro
(macro:expand 'val exp env *defined-macros*) ;(macro:expand 'val exp env *defined-macros*)
;(macro:expand2 exp val env) (macro:expand2 exp val env)
env) env)
(map (map
(lambda (expr) (expand expr env)) (lambda (expr) (expand expr env))