This commit is contained in:
Justin Ethier 2016-09-16 03:29:27 -04:00
parent cd1c5eb99d
commit fcfa5bda2f
2 changed files with 20 additions and 6 deletions

View file

@ -8,7 +8,7 @@
;;;;
(define-library (scheme cyclone macros)
(import (scheme base)
;(scheme write) ;; Debug only
(scheme write) ;; Debug only
(scheme eval)
(scheme cyclone util)
)
@ -54,13 +54,15 @@
(define (macro:expand exp macro mac-env)
(let* ((use-env (env:extend-environment '() '() '()))
(compiled-macro? (or (Cyc-macro? (Cyc-get-cvar (cadr macro)))
(procedure? (cadr macro)))))
(procedure? (cadr macro))))
(result #f))
;(newline)
;(display "/* ")
;(display (list 'macro:expand exp macro compiled-macro?))
;(display "*/ ")
;; Invoke ER macro
(set! result
(cond
((not macro)
(error "macro not found" exp))
@ -76,7 +78,14 @@
(list 'quote exp)
(Cyc-er-rename use-env mac-env)
(Cyc-er-compare? use-env))
mac-env)))))
mac-env))))
; (newline)
; (display "/* ")
; (display (list 'macro:expand exp macro compiled-macro?))
; (newline)
; (display (list result))
; (display "*/ ")
result))
; TODO: get macro name, transformer
; TODO: let-syntax forms

View file

@ -483,13 +483,18 @@
(let ((renamed (gensym identifier)))
(env:define-variable! renamed val mac-env)
renamed))
(else
#;((not (eq? val 'not-defined))
;; Unrenamed variable identifier
(let ((renamed (gensym identifier)))
(env:define-variable! renamed identifier use-env)
; (env:define-variable! renamed identifier mac-env) ;; TODO: renamed val?
(Cyc-write `(ER rename ,identifier to ,renamed) (current-output-port))
(Cyc-display "\n" (current-output-port))
renamed)
identifier ;; TESTING!
)))
;identifier ;; TESTING!
)
(else
identifier)))
;
;(gensym identifier)
; gensym not good enough, need to also preserve ref trans.