[mercury-users] Parsers in Mercury

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Sep 23 13:33:23 AEST 1999


On 23-Sep-1999, Dan Hazel <d.hazel at mailbox.uq.edu.au> wrote:
> 
> Either
>     1) Make some grubby annotations outside Mercury (in C perhaps).
> or
>     2) Don't fail.  Don't backtrack.
>        I imagine you're threading a token list through your parser?
>        Instead thread a structure which contains your token list and
>        some other information [...]

Another approach is to use exceptions.  Don't fail, don't backtrack,
instead whenever you get a parse error, throw an exception.
Then at strategic points where you want to do error recovery you
can catch exceptions and print appropriate error messages.

For more information about exceptions, see extras/exceptions.m
(in Mercury 0.8) or library/exceptions.m.

Thomas Conway <conway at cs.mu.oz.au> has written a parser using exception
handling, I think, which he would probably be happy to make available
if you're interested.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list