mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-25 13:05:05 +02:00
Relocated functions to macros module
This commit is contained in:
parent
9c447a384a
commit
ab05152163
2 changed files with 2 additions and 16 deletions
|
@ -871,18 +871,6 @@
|
||||||
;;
|
;;
|
||||||
|
|
||||||
;; Macro expansion
|
;; Macro expansion
|
||||||
(define (macro? exp) (assoc (car exp) *defined-macros*))
|
|
||||||
(define (macro-expand exp)
|
|
||||||
(let ((macro (assoc (car exp) *defined-macros*)))
|
|
||||||
;; assumes ER macro
|
|
||||||
(if macro
|
|
||||||
((cdr macro)
|
|
||||||
exp
|
|
||||||
(lambda (sym) ;; TODO: not good enough, need to actually rename, and keep same results if
|
|
||||||
sym) ;; the same symbol is renamed more than once
|
|
||||||
(lambda (sym-a sym-b) ;; TODO: the compare function from exrename.
|
|
||||||
(eq? sym-a sym-b))) ;; this may need to be more sophisticated
|
|
||||||
exp))) ;; TODO: error instead??
|
|
||||||
|
|
||||||
; expand : exp -> exp
|
; expand : exp -> exp
|
||||||
(define (expand exp)
|
(define (expand exp)
|
||||||
|
@ -920,9 +908,9 @@
|
||||||
(body (cadr trans)))
|
(body (cadr trans)))
|
||||||
(set! *defined-macros* (cons (cons name body) *defined-macros*))
|
(set! *defined-macros* (cons (cons name body) *defined-macros*))
|
||||||
#t))
|
#t))
|
||||||
((macro? exp)
|
((macro? exp *defined-macros*)
|
||||||
(expand ;; Could expand into another macro
|
(expand ;; Could expand into another macro
|
||||||
(macro-expand exp)))
|
(macro-expand exp *defined-macros*)))
|
||||||
(else
|
(else
|
||||||
(map expand exp))))
|
(map expand exp))))
|
||||||
(else
|
(else
|
||||||
|
|
|
@ -99,8 +99,6 @@
|
||||||
cell->value
|
cell->value
|
||||||
cell-get?
|
cell-get?
|
||||||
cell-get->cell
|
cell-get->cell
|
||||||
macro?
|
|
||||||
macro-expand
|
|
||||||
expand
|
expand
|
||||||
let=>lambda
|
let=>lambda
|
||||||
letrec=>lets+sets
|
letrec=>lets+sets
|
||||||
|
|
Loading…
Add table
Reference in a new issue