[m-dev.] moose

Thomas Conway conway at cs.mu.OZ.AU
Mon Aug 14 07:34:02 AEST 2000


On Fri, Aug 11, 2000 at 08:19:44PM EST, Fergus Henderson wrote:
> On 11-Aug-2000, Michael Day <mcda at students.cs.mu.oz.au> wrote:
> > 
> > On an unrelated topic, is the focus of moose creating parsers that are not
> > easy to express in Mercury, or creating parsers that are more efficient
> > than the equivalent code in Mercury, or something else entirely?
> 
> I think the former.  In particular, Moose lets you write left-recursive
> grammars, whereas if you write grammars directly in Mercury using DCGs,
> then you factor your grammar to avoid left-recursion, since that would
> result in infinite loops.

Actually, the motivation was the fact that a parser generator gives
you a 'solve once' solution to problems like doing IO during the
parse. When you write a parser by hand you can:
    - use a DCG and make everything semidet, which is easy to write,
      not too inefficient, but yields horrible error messages (ie none).
    - use a DCG and make everything det and throw exceptions on errors.
      This isn't too bad, but you still can't do IO.
    - use parser combinators (like my XML parser) which lets you do IO,
      but isn't quite as beautiful (though only because of Mercury's
      Prolog syntax), and until some compiler bugs get fixed, can't be
      optimized enough to get good performance.
    - maybe other good options I haven't thought of

Also, a parser generator lets you hide most of the syntactic baggage
so it makes the grammar easier to read.

The left recursion issue was not part of my thinking at all, since it
is trivial to transform your grammar to eliminiate it.

-- 
 Thomas Conway              Unicode for terrorists: U+0001 300C
 <conway at cs.mu.oz.au>         "Tie his hands behind his back"
 Mercurian )O+  
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list