[erlang-questions] Parsing C with leex and yecc

French, Mike <>
Wed Jul 21 13:35:29 CEST 2010

> -----Original Message-----
> From:  
> [mailto:]On
> Behalf Of French, Mike
> Sent: 21 July 2010 09:22
> To: 'Joe Armstrong'; Tony Arcieri
> Cc: Erlang
> Subject: RE: [erlang-questions] Parsing C with leex and yecc
> > -----Original Message-----
> > From:  
> > [mailto:]On
> > Behalf Of Joe Armstrong
> > Sent: 20 July 2010 19:40
> > To: Tony Arcieri
> > Cc: Erlang
> > Subject: Re: [erlang-questions] Parsing C with leex and yecc
> ...
> > Yes - I've also been playing with my own peg combinator library :-).
> > The problem is that LALR(1) parsers can give you pretty good automatic
> > diagnostics on faulty input. Peg grammars just fail - period - and you
> > have to write your own error recovery in the grammar ...
> I think PEGs can be written to handle errors elegantly.
> Each combinator applies an exploration strategy to the input top-down,
> and passes the remaining input on to subsequent analysis steps.
> When an error occurs, it should pass back the reason for the failure.
> Each error ultimately originates from a failed character lexing rule.
> Just as input is reduced by moving forwards, so errors are accumulated 
> flowing backwards. Each combinator is then responsible for merging the 
> error reports coming back into it. The error handling process is in 
> some sense dual to the original input processing, so in some sense, 
> each parser combinator must contain an error co-combinator.

This duality becomes clearer with a slight change of terminology.
It's not really an 'error' until all rules have not matched.
So if you replace 'parser' with 'match' and 'error' with 'non-match', then:

  "Each match combinator must contain a non-match co-combinator".


Thales UK Ltd (Wells) DISCLAIMER: The information contained in this e-mail
is confidential. It may also be legally privileged. It is intended only for
the stated addressee(s) and access to it by any other person is
unauthorised. If you are not an addressee, you must not disclose, copy,
circulate or in any other way use or rely on the information contained in
this e-mail. Such unauthorised use may be unlawful. We may monitor all
e-mail communications through our networks. If you have received this e-mail
in error, please inform us immediately on sender's telephone number above
and delete it and all copies from your system. We accept no responsibility
for changes to any e-mail which occur after it has been sent.  Attachments
to this e-mail may contain software viruses which could damage your system.
We therefore recommend you virus-check all attachments before opening.
Thales UK Ltd. Registered Office: 2 Dashwood Lang Road, The Bourne Business
Park, Addlestone, Weybridge, Surrey KT15 2NX Registered in England No.

More information about the erlang-questions mailing list