mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 00:37:35 +02:00
WIP, able to expand some let-syntax now
Still is debugging here though, needs lots of cleanup
This commit is contained in:
parent
18eed21246
commit
046c1f9d22
1 changed files with 18 additions and 6 deletions
|
@ -452,14 +452,16 @@
|
||||||
|
|
||||||
(define (analyze-let-syntax exp a-env)
|
(define (analyze-let-syntax exp a-env)
|
||||||
(let* ((rename-env (env:extend-environment '() '() '()))
|
(let* ((rename-env (env:extend-environment '() '() '()))
|
||||||
(expanded (expand exp (macro:get-env) rename-env))
|
(expanded (expand exp a-env rename-env))
|
||||||
|
;(expanded (expand exp (macro:get-env) rename-env))
|
||||||
|
(cleaned (macro:cleanup expanded rename-env))
|
||||||
)
|
)
|
||||||
;; TODO: probably just create a fresh env for renames
|
;; TODO: probably just create a fresh env for renames
|
||||||
;; TODO: expand, do we need to clean as well?
|
;; TODO: expand, do we need to clean as well?
|
||||||
;; TODO: run results back through analyze: (analyze (expand env? rename-env?
|
;; TODO: run results back through analyze: (analyze (expand env? rename-env?
|
||||||
(write `(DEBUG ,expanded))
|
(write `(DEBUG ,cleaned))
|
||||||
(newline)
|
(newline)
|
||||||
(analyze expanded a-env)))
|
(analyze cleaned a-env)))
|
||||||
|
|
||||||
(define (analyze-syntax exp a-env)
|
(define (analyze-syntax exp a-env)
|
||||||
(let ((var (cadr exp)))
|
(let ((var (cadr exp)))
|
||||||
|
@ -937,15 +939,25 @@
|
||||||
(if local
|
(if local
|
||||||
(cdr local)
|
(cdr local)
|
||||||
(env:lookup (car exp) env #f)))))
|
(env:lookup (car exp) env #f)))))
|
||||||
(if (tagged-list? 'macro val)
|
(write `(app DEBUG ,(car exp) ,val))
|
||||||
|
(newline)
|
||||||
|
(cond
|
||||||
|
((tagged-list? 'macro val)
|
||||||
(_expand ; Could expand into another macro
|
(_expand ; Could expand into another macro
|
||||||
(macro:expand exp val env rename-env)
|
(macro:expand exp val env rename-env)
|
||||||
env
|
env
|
||||||
rename-env
|
rename-env
|
||||||
local-env)
|
local-env))
|
||||||
|
((Cyc-macro? val)
|
||||||
|
(_expand ; Could expand into another macro
|
||||||
|
(macro:expand exp (list 'macro val) env rename-env)
|
||||||
|
env
|
||||||
|
rename-env
|
||||||
|
local-env))
|
||||||
|
(else
|
||||||
(map
|
(map
|
||||||
(lambda (expr) (_expand expr env rename-env local-env))
|
(lambda (expr) (_expand expr env rename-env local-env))
|
||||||
exp))))
|
exp)))))
|
||||||
(else
|
(else
|
||||||
;; TODO: note that map does not guarantee that expressions are
|
;; TODO: note that map does not guarantee that expressions are
|
||||||
;; evaluated in order. For example, the list might be processed
|
;; evaluated in order. For example, the list might be processed
|
||||||
|
|
Loading…
Add table
Reference in a new issue