Oh, I guess what I was seeing is that the location information is lost
on the matched macro name, and I didn't look further to see that the
location information is in fact present in macro arguments.
That is to say, in a macro expansion
(foo a b c)
FOO doesn't have location information but A, B, C do.
So for SchemeUnit it might indeed be possible to pull the location
information out of the macro arguments.
By the way, is there an API for getting location information from a
syntax object?
Thanks,
Andrew Wilcox
(define-syntax foo
(lambda (x)
(display "--- syntax object passed to transformer ---\n")
(pretty-print x)
(newline)
(newline)
(syntax-case x ()
((foo a)
(begin
(display "--- matched pattern syntax object FOO ---\n")
(pretty-print #'foo)
(newline)
(newline)
(display "--- matched pattern syntax object A ---\n")
(pretty-print #'a)
(newline)
(newline)
(let ((result #'(begin (display "Hi, this is ")
(display a)
(newline))))
(display "--- result of macro expansion ---\n")
(pretty-print result)
(newline)
(newline)
result))))))
(foo (+ 1 2 3))
--- syntax object passed to transformer ---
#3(syntax-object
#@(((line-number . 32) (column-number . 1) (source-file . "file:m.scm")) .
(foo #@(((line-number . 32) (column-number . 6) (source-file . "file:m.scm")) .
(+ 1 2 3))))
((#f top)
shift
#4(ribcage (#2(import-token *top*)) ())))
--- matched pattern syntax object FOO ---
#3(syntax-object
foo
((#f top)
shift
#4(ribcage (#2(import-token *top*)) ())))
--- matched pattern syntax object A ---
#3(syntax-object
#@(((line-number . 32) (column-number . 6) (source-file . "file:m.scm")) .
(+ 1 2 3))
((#f top)
shift
#4(ribcage (#2(import-token *top*)) ())))
--- result of macro expansion ---
(#3(syntax-object
begin
((top)
#4(ribcage #2(foo a) #2((top)) #2("i" "i"))
#4(ribcage ())
#4(ribcage #1(x) #1((top)) #1("i"))
#4(ribcage (#2(import-token *top*)) ())))
#3(syntax-object
#@(((line-number . 21) (column-number . 33) (source-file . "file:m.scm")) .
(display "Hi, this is "))
((top)
#4(ribcage #2(foo a) #2((top)) #2("i" "i"))
#4(ribcage ())
#4(ribcage #1(x) #1((top)) #1("i"))
#4(ribcage (#2(import-token *top*)) ())))
(#3(syntax-object
display
((top)
#4(ribcage #2(foo a) #2((top)) #2("i" "i"))
#4(ribcage ())
#4(ribcage #1(x) #1((top)) #1("i"))
#4(ribcage (#2(import-token *top*)) ())))
#3(syntax-object
#@(((line-number . 32) (column-number . 6) (source-file . "file:m.scm")) .
(+ 1 2 3))
((#f top)
shift
#4(ribcage (#2(import-token *top*)) ()))))
.
#3(syntax-object
(#@(((line-number . 23) (column-number . 33) (source-file . "file:m.scm"))
. (newline)))
((top)
#4(ribcage #2(foo a) #2((top)) #2("i" "i"))
#4(ribcage ())
#4(ribcage #1(x) #1((top)) #1("i"))
#4(ribcage (#2(import-token *top*)) ()))))
Hi, this is 6
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
|