[plt-scheme] Reading s-expression... syntaxes?

From: Matt Jadud (mcj4 at kent.ac.uk)
Date: Wed Jan 4 17:59:57 EST 2006

Say I have s-expression-based Language X. I want to read it into PLT 
Scheme, with source information intact, and use the matcher to pull it 
apart. That is, I want to take the syntax, convert it into structures 
(with source information from the read), and somewhere in my tool be 
able to say "Error on line X, column Y" or similar.

To explore this, I created a file "foo" containing

(define x (+ 3 5))

I then tried

 > (define ip (open-input-file "foo"))
 > (read-syntax (object-name ip) ip)

which yielded the nifty syntax infomercial, but the fields for "line" 
and "column" are both #f.

I've been reading through the Help Desk regarding read-syntax, honus, 
and some other exciting things I hadn't delved into before, but... does 
anyone have a pointer to get me reading in the right direction? I'm 
missing something (obvious?) here. How do I read s-expressions in from a 
file with syntax location info intact? Do I need to implement my own 
reader?

Thanks,
Matt


Posted on the users mailing list.