mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-13 07:47:39 +02:00
Refactoring
This commit is contained in:
parent
6ed5d735f6
commit
ce801e092a
1 changed files with 19 additions and 11 deletions
|
@ -903,19 +903,18 @@
|
||||||
(append begin-exprs (cdr exp))
|
(append begin-exprs (cdr exp))
|
||||||
env)))
|
env)))
|
||||||
((app? this-exp)
|
((app? this-exp)
|
||||||
(let ((macro #f))
|
(cond
|
||||||
(when (and (app? this-exp)
|
((symbol? (caar exp))
|
||||||
(symbol? (caar exp)))
|
(let ((val (env:lookup (caar exp) env #f)))
|
||||||
(set! macro (env:lookup (caar exp) env #f)))
|
(if (tagged-list? 'macro val)
|
||||||
(if (tagged-list? 'macro macro)
|
|
||||||
;; Expand macro here so we can catch begins in the expanded code,
|
;; Expand macro here so we can catch begins in the expanded code,
|
||||||
;; including nested begins
|
;; including nested begins
|
||||||
(let ((expanded (macro:expand this-exp macro env)))
|
(expand-body
|
||||||
;; Call with expanded macro in case we need to expand again
|
result
|
||||||
(expand-body
|
(cons
|
||||||
result
|
(macro:expand this-exp val env)
|
||||||
(cons expanded (cdr exp))
|
(cdr exp))
|
||||||
env))
|
env)
|
||||||
;; No macro, use main expand function to process
|
;; No macro, use main expand function to process
|
||||||
(expand-body
|
(expand-body
|
||||||
(cons
|
(cons
|
||||||
|
@ -925,6 +924,15 @@
|
||||||
result)
|
result)
|
||||||
(cdr exp)
|
(cdr exp)
|
||||||
env))))
|
env))))
|
||||||
|
(else
|
||||||
|
(expand-body
|
||||||
|
(cons
|
||||||
|
(map
|
||||||
|
(lambda (expr) (expand expr env))
|
||||||
|
this-exp)
|
||||||
|
result)
|
||||||
|
(cdr exp)
|
||||||
|
env))))
|
||||||
(else
|
(else
|
||||||
(error "unknown exp: " this-exp))))))
|
(error "unknown exp: " this-exp))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue