mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
WIP
This commit is contained in:
parent
cd1c5eb99d
commit
fcfa5bda2f
2 changed files with 20 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue