Re: Error reporting/recovery

Jean-Marc Bourguet <bourguet@my-deja.com>
14 Apr 2000 01:01:49 -0400

          From comp.compilers

Related articles
Error reporting/recovery bourguet@my-deja.com (Jean-Marc Bourguet) (2000-04-05)
Re: Error reporting/recovery iank@bearcave.com (2000-04-11)
Re: Error reporting/recovery grosch@cocolab.de (2000-04-11)
Re: Error reporting/recovery bourguet@my-deja.com (Jean-Marc Bourguet) (2000-04-14)
Re: Error reporting/recovery bourguet@my-deja.com (Jean-Marc Bourguet) (2000-04-14)
Re: Error reporting/recovery rod.bates@wichita.boeing.com (Rodney M. Bates) (2000-04-14)
Re: Error reporting/recovery nr@labrador.eecs.harvard.edu (2000-04-16)
Re: Error reporting/recovery j.coulmance@itecor-software.com (Jocelyn Coulmance) (2000-04-20)
Re: Error reporting/recovery pnyq@my-deja.com (2000-05-08)
| List of all articles for this month |

From: Jean-Marc Bourguet <bourguet@my-deja.com>
Newsgroups: comp.compilers
Date: 14 Apr 2000 01:01:49 -0400
Organization: Deja.com - Before you buy.
References: 00-04-053 00-04-074
Keywords: parse, errors

    grosch@cocolab.de (Josef Grosch) wrote:
> Jean-Marc Bourguet <bourguet@my-deja.com> asked about error
> reporting/recovery provided by parser generators:
>
> > - if there was other parser generators freely available
> > who did a better jobs,
>
> The parser generators Lark (LALR(2)) and Ell (LL(1)) of the Cocktail
> Toolbox provide automatic error reporting, recovery and repair.
> There is no need to add extra grammar rules using an error token.
> Everything is generated automatically. Example:
>
> if (a = b] write (a);
>
> The above source line would result in the following message:
>
> 3, 13: Error found/expected : ]/) = + - <> <= >= < > IN OR ...


That is indeed a better job than yacc (but that's not difficult). I
was searching for something better than just giving the valid tokens
which is something I'd call the mimimum acceptable as error reporting.


I remember having read a something in which a parser generator was
described which generated parser able to write this kind of messages
for some recursive rules but I've lost the reference. (It was a kind
of LR parser).


if (x = (a + b] then write (a);
                ^^^^^^^
Missing ")" for closing structure, replacing ']' by ')'
      ^^^^^^^^^^^^
Missing ")" for closing structure, inserting ')'


> Error recovery also happens automatically. A minimal sequence of
> tokens is skipped so that parsing can safely continue. Moreover
> a minimal sequence of tokens is inserted (virtually) in order to
> repair the error. This has the advantage that the output of the parser
> is always consistent in the sense that it belongs to a syntactically
> correct input. Therefore phases following after parsing do not have to
> take care about syntax errors.


I wonder how you can insert tokens for which the lexeme have an
importance (say an identifier) without these phase having to take care
about the fact that a token has been inserted and without generating
spurious messages (like "identifier not defined").


-- Jean-Marc


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.