guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

line numbers using read


From: Peter S. Christopher
Subject: line numbers using read
Date: Fri, 26 Dec 2003 14:56:28 -0600 (CST)

Hi listers,

   I have an issue that has been biting at me. Suppose that I create
an input file syntax that is fairly complicated. For example:

(santas-list
        (bobby toy-truck)
        (cindy doll)
        (billy (parents non-abusive)))
        
Now it is easy enough to read this in using `(read port)'. However, if
this list is long and the user messes the input file up, I don't know
how to tell the user where the error is. That is, Suppose that
`santas-list' is a few hundred elements long. I want to be able to
tell the user where they messed up: something like

     In subexpression `(billy (parents non-abusive))'
        ON LINE 4: Santa cannot give `billy' `non-abusive' `parents'

The crux of my question is: how do I find out that the `billy'
subexpression started on line 4 USING READ?

The last part of my question is important, I only want to use the read
call to do the parsing. Naturally, there are more complicated solutions
where someone hand-rolls there own version of read -- lets not go into
that right now.

Now, I ask this question because in libguile/read.c the function
scm_lreadr (which seems to be the meat of the read routine) makes many
weak hash inserts to a hash table called `scm_source_whash'. I am
ASSUMING that one can take a expression (list of symbols), look it up
in this hash and get it's line/column number. *** Is this true? ***

I assume that `scm_eval' uses this hash when it needs to flag an
error. So why (I think) couldn't I when I'm dealing with santas-list.

Any thoughts, clarifications or comments would be appreciated.

Pete







reply via email to

[Prev in Thread] Current Thread [Next in Thread]