[Top][All Lists]

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

Re: About sweet-expression

From: Mark H Weaver
Subject: Re: About sweet-expression
Date: Mon, 12 Mar 2012 15:05:34 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Nala Ginrut <address@hidden> writes:

> On Tue, Mar 6, 2012 at 12:35 PM, Mark H Weaver <address@hidden> wrote:
>> Guile's reader is of no help at all with source properties.

To clarify, the above quotation was taken out of context.  I was only
talking about one particular example, not making a general statement.

>> Fortunately, Guile provides all of the interfaces you need to do
> this
>> job from Scheme: 'set-source-properties!', 'port-filename',
> 'port-line'
>> and 'port-column'.  This will have to be implemented in the sweet
>> expression reader.
> So, is there any standard for Guile what error messages should I
> provide?

Yes, the format of error messages should be:


You must take into account the fact the the filename might be #f, in
which case you should print "#<unknown port>" instead.  Also, the
printed line number should be 1+ the line number returned by
'port-line', and _maybe_ the same should be done with the column number,
I'm not sure.  Internally, the first line is line 0, but for most people
expect that to be printed as 1.

See 'scm_i_input_error' in read.c or 'syntax-error-printer' in
boot-9.scm for examples.

> And how about the format should I throw with them?
> What about this:
> ------------------------------cut--------------------------------------
> (error "invalid syntax!" port-filename port-line port-column)
> ------------------------------end--------------------------------------

'port-filename', 'port-line', and 'port-column' are procedures that must
be applied to a port.  See the manual for details.

However, these remarks concern only error messages generated by your
sweet expression reader itself.  Your other responsibility is to add
source properties to every datum that you read, so that if an error is
detected later in compilation, the resulting error message will include
the filename, line number, and column number.

If you are able to use Guile's internal 'read' procedure, then you may
rely on it to apply the source properties for anything that it reads.
However, you will still need to use 'set-source-properties!' on anything
that isn't taken care of by the internal 'read', such as lists that are
written in a non-standard way.


reply via email to

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