mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 08:47:35 +02:00
Restructuring
This commit is contained in:
parent
cc27e2b355
commit
5a27727c4f
1 changed files with 29 additions and 18 deletions
|
@ -27,12 +27,25 @@
|
||||||
|
|
||||||
(define (macro:macro? exp defined-macros) (assoc (car exp) defined-macros))
|
(define (macro:macro? exp defined-macros) (assoc (car exp) defined-macros))
|
||||||
(define (macro:expand exp defined-macros)
|
(define (macro:expand exp defined-macros)
|
||||||
|
(let ((rename (lambda (sym) ;; TODO: not good enough, need to actually rename, and keep same results if
|
||||||
|
sym)) ;; the same symbol is renamed more than once
|
||||||
|
(compare? (lambda (sym-a sym-b) ;; TODO: the compare function from exrename.
|
||||||
|
(eq? sym-a sym-b))) ;; this may need to be more sophisticated
|
||||||
|
)
|
||||||
|
;(cond
|
||||||
|
; ;; compiled macro
|
||||||
|
; ;((macro? (car exp))
|
||||||
|
; ; ((car exp)
|
||||||
|
; ; exp
|
||||||
|
; ; rename
|
||||||
|
; ; compare?))
|
||||||
|
; (else
|
||||||
(let ((macro (assoc (car exp) defined-macros)))
|
(let ((macro (assoc (car exp) defined-macros)))
|
||||||
|
|
||||||
TODO: restructure this to use eval if the macro is not a proc.
|
;TODO: restructure this to use eval if the macro is not a proc.
|
||||||
then can try passing in an environment with create-environment.
|
; then can try passing in an environment with create-environment.
|
||||||
once eval is extended to work with macros, this could allow it to
|
; once eval is extended to work with macros, this could allow it to
|
||||||
expand a macro contained within another
|
; expand a macro contained within another
|
||||||
|
|
||||||
;; assumes ER macro
|
;; assumes ER macro
|
||||||
(if macro
|
(if macro
|
||||||
|
@ -42,11 +55,9 @@ TODO: restructure this to use eval if the macro is not a proc.
|
||||||
(if (procedure? (cdr macro))
|
(if (procedure? (cdr macro))
|
||||||
exp
|
exp
|
||||||
(list 'quote exp))
|
(list 'quote exp))
|
||||||
(lambda (sym) ;; TODO: not good enough, need to actually rename, and keep same results if
|
rename
|
||||||
sym) ;; the same symbol is renamed more than once
|
compare?)
|
||||||
(lambda (sym-a sym-b) ;; TODO: the compare function from exrename.
|
exp))));)) ;; TODO: error instead??
|
||||||
(eq? sym-a sym-b))) ;; this may need to be more sophisticated
|
|
||||||
exp))) ;; TODO: error instead??
|
|
||||||
|
|
||||||
; TODO: get macro name, transformer
|
; TODO: get macro name, transformer
|
||||||
; TODO: base off of syntactic closures instead of ER macros??
|
; TODO: base off of syntactic closures instead of ER macros??
|
||||||
|
|
Loading…
Add table
Reference in a new issue