[plt-scheme] Getting line-no for s-exps read by (read)

From: Richard Cleis (rcleis at mac.com)
Date: Wed May 23 23:49:31 EDT 2007

I'm not sure what you are trying to do, but this might help:

(define source
   "(for x in (range 10)
       (print (* x x)))")

(define ip
   (open-input-string source))

(read-line ip)
(read-line ip)

rac


On May 23, 2007, at 9:36 PM, Sridhar Ratna wrote:

> Hi,
>
> The ``(read)" function reads a s-exp from standard input or file. As
> part of my project, I am translating the s-exp to Python byte-codes.
>
> Despite my futile attempts, I cannot yet figure out a way to get the
> line-no for each of the s-exp.
>
> For example,
>
> (for x in (range 10)
>    (print (* x x)))
>
> Here, the forms `(for ...)', `(range ...)', `x', ... belong to line-no
> 1, while `(print ...)', .. to line-no 2.
>
> I would be much grateful if anyone could point me to a way to get the
> line-no for each of the forms read by (read).
>
> -- 
> http://srid.nfshost.com/
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.