[m-rev.] Re: for review: parsing_utils improvements

Ian MacLarty maclarty at csse.unimelb.edu.au
Tue Sep 29 17:08:58 AEST 2009


On Tue, Sep 29, 2009 at 4:02 PM, Ralph Becket <rafe at csse.unimelb.edu.au> wrote:
> Ian MacLarty, Tuesday, 29 September 2009:
>> > Having said that, aren't grammars like this fairly rare?  I mean,
>> > can the mutable stuff be separated out just for the parsers that need
>> > it?
>>
>> I don't know. What did you have in mind?
>
> Well, my sparql parser might simply define its own mutable and implement
> its own fail_with_error predicate.  The position only needs to be
> recorded at the point where fail_with_error is called.  If the parser
> succeeds at a point further than that stored in the mutable, then the
> error therein can be ignored.
>

Yes I suppose you could do that, but I think that puts too much burden
on the parser writer since they would have to write all the impure
code to manage the mutable.  The point of this change is to put that
behind an abstraction barrier so users don't shoot themselves in the
foot.

Also with this change you don't actually have to call
fail_with_message at all to get a usable error report.  Even if you
never call fail_with_message you can still get the furthest offset the
parser got to before it failed, which is a lot more useful than no
information at all.
The idea is that users could write their parser in a naive style and
still end up with something that is usable.

Ian.

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list