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

View file

@ -483,13 +483,18 @@
(let ((renamed (gensym identifier))) (let ((renamed (gensym identifier)))
(env:define-variable! renamed val mac-env) (env:define-variable! renamed val mac-env)
renamed)) renamed))
(else #;((not (eq? val 'not-defined))
;; Unrenamed variable identifier ;; Unrenamed variable identifier
(let ((renamed (gensym identifier))) (let ((renamed (gensym identifier)))
(env:define-variable! renamed identifier use-env) (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) renamed)
identifier ;; TESTING! ;identifier ;; TESTING!
))) )
(else
identifier)))
; ;
;(gensym identifier) ;(gensym identifier)
; gensym not good enough, need to also preserve ref trans. ; gensym not good enough, need to also preserve ref trans.