This commit is contained in:
Justin Ethier 2017-12-12 14:19:10 -05:00
parent 29739bc731
commit 55b112afbd
2 changed files with 32 additions and 2 deletions

View file

@ -950,9 +950,14 @@
(let ((val (let ((local (assoc (car exp) local-env))) (let ((val (let ((local (assoc (car exp) local-env)))
(if local (if local
(cdr local) (cdr local)
(env:lookup (car exp) env #f))))) (let ((v (env:lookup (car exp) env #f)))
v ;; TODO: below was for looking up a renamed macro. may want to consider using it
;; in the symbol condition below...
#;(if v
v
(env:lookup (car exp) rename-env #f)))))))
;;(display "/* ") ;;(display "/* ")
;;(write `(app DEBUG ,(car exp) ,val)) ;;(write `(app DEBUG ,(car exp) ,val ,local-env ,rename-env ,(env:lookup (car exp) env #f)))
;;(display "*/ ") ;;(display "*/ ")
;;(newline) ;;(newline)
(cond (cond
@ -968,6 +973,21 @@
env env
rename-env rename-env
local-env)) local-env))
;; TODO: if we are doing this, only want to do so if the original variable is a macro.
;; this is starting to get overly complicated though.
;; if nothing else should encapsulate the above lookup into a function and call that
;; in both places (above and here) to simplify things
;;
;; ((and (symbol? val)
;; (not (eq? val (car exp))))
;; ;; Original macro symbol was renamed. So try again with the orignal symbol
;;(display "/* ")
;;(write `(app DEBUG-syms ,(car exp) ,val ,local-env ,(cdr exp)))
;;(display "*/ ")
;;(newline)
;; (_expand
;; (cons val (cdr exp))
;; env rename-env local-env))
(else (else
(map (map
(lambda (expr) (_expand expr env rename-env local-env)) (lambda (expr) (_expand expr env rename-env local-env))

View file

@ -1,5 +1,15 @@
(import (scheme base) (scheme write) (scheme cyclone pretty-print)) (import (scheme base) (scheme write) (scheme cyclone pretty-print))
;; Just testing, may want to remove this one once the recursive macro expansion works
(define-syntax my-or2 (syntax-rules ()
((my-or2) #f)
((my-or2 e) e)
((my-or2 e1 e2 ...)
(let ((temp e1)) (if temp temp (my-or2 e2 ...))))))
(write (my-or2 #t))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(let-syntax (let-syntax
((my-or (syntax-rules () ((my-or (syntax-rules ()
((my-or) #f) ((my-or) #f)