Fix source syntax recovery.

This commit is contained in:
Vincent St-Amour 2013-11-19 18:35:16 -05:00
parent fab0d0f955
commit 632ce4e30a

View File

@ -37,6 +37,7 @@
;; add-to-table: stx or #f -> stx or #f
;; #f as `lookfor` indicates "traverse all of `expanded`
(define (add-to-table lookfor)
;; stx is expanded syntax, target is source syntax
(let loop ([stx expanded] [target initial-target])
(cond
[(syntax? stx)
@ -53,9 +54,16 @@
;; take apart stx and loop on the components
[else
(define stxe (syntax-e stx))
(and (pair? stxe)
(or (loop (car stxe) stx) (loop (cdr stxe) stx)))])]
(let inner ([stxe (syntax-e stx)])
(cond [(list? stxe)
(for/or ([x (in-list stxe)])
(loop x new-target))]
[(pair? stxe) ; may be an improper syntax list
(or (loop (car stxe) new-target) (inner (cdr stxe)))]
[(syntax? stxe) ; base case
(loop stxe new-target)]
[else
#f]))])]
[else #f])))
;; if now?, add everything to the table