mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-03 19:26:34 +02:00
Added (base-expander)
This commit is contained in:
parent
e41586da69
commit
eef7892d14
1 changed files with 23 additions and 9 deletions
32
cyclone.scm
32
cyclone.scm
|
@ -288,14 +288,15 @@
|
||||||
;; - imports
|
;; - imports
|
||||||
;; - remaining program
|
;; - remaining program
|
||||||
(define (import-reduction expr)
|
(define (import-reduction expr)
|
||||||
;; TODO: consolidate this with other macro loading code
|
; ;; TODO: consolidate this with other macro loading code
|
||||||
(define rename-env (env:extend-environment '() '() '()))
|
; (define rename-env (env:extend-environment '() '() '()))
|
||||||
(let ((macros (filter
|
; (let ((macros (filter
|
||||||
(lambda (v)
|
; (lambda (v)
|
||||||
(Cyc-macro? (Cyc-get-cvar (cdr v))))
|
; (Cyc-macro? (Cyc-get-cvar (cdr v))))
|
||||||
(Cyc-global-vars))))
|
; (Cyc-global-vars))))
|
||||||
(macro:load-env! macros (create-environment '() '())))
|
; (macro:load-env! macros (create-environment '() '())))
|
||||||
;;
|
; ;;
|
||||||
|
(define expander (base-expander))
|
||||||
(let ((results
|
(let ((results
|
||||||
(foldl
|
(foldl
|
||||||
(lambda (ex accum)
|
(lambda (ex accum)
|
||||||
|
@ -307,7 +308,7 @@
|
||||||
(cons (car accum) (cons e (cdr accum))))))
|
(cons (car accum) (cons e (cdr accum))))))
|
||||||
(cond
|
(cond
|
||||||
((tagged-list? 'cond-expand ex)
|
((tagged-list? 'cond-expand ex)
|
||||||
(let ((ex* (expand ex (macro:get-env) rename-env)))
|
(let ((ex* (expander ex))) ;(expand ex (macro:get-env) rename-env)))
|
||||||
;(trace:info `(DEBUG ,ex* ,ex))
|
;(trace:info `(DEBUG ,ex* ,ex))
|
||||||
(if (tagged-list? 'import ex*)
|
(if (tagged-list? 'import ex*)
|
||||||
(process ex*)
|
(process ex*)
|
||||||
|
@ -320,6 +321,19 @@
|
||||||
(apply append (reverse (car results)))
|
(apply append (reverse (car results)))
|
||||||
(reverse (cdr results)))))
|
(reverse (cdr results)))))
|
||||||
|
|
||||||
|
;; Return a function to expand any built-in macros
|
||||||
|
;; NOTE: since this uses a global macro env, it will be overridden later on when
|
||||||
|
;; macros are loaded from dependent libraries.
|
||||||
|
(define (base-expander)
|
||||||
|
(let ((rename-env (env:extend-environment '() '() '()))
|
||||||
|
(macros (filter
|
||||||
|
(lambda (v)
|
||||||
|
(Cyc-macro? (Cyc-get-cvar (cdr v))))
|
||||||
|
(Cyc-global-vars))))
|
||||||
|
(macro:load-env! macros (create-environment '() '()))
|
||||||
|
(lambda (ex)
|
||||||
|
(expand ex (macro:get-env) rename-env))))
|
||||||
|
|
||||||
;; TODO: longer-term, will be used to find where cyclone's data is installed
|
;; TODO: longer-term, will be used to find where cyclone's data is installed
|
||||||
(define (get-data-path)
|
(define (get-data-path)
|
||||||
".")
|
".")
|
||||||
|
|
Loading…
Add table
Reference in a new issue