This project is read-only.

Recovering (parser state) after error

Oct 16, 2014 at 8:22 AM
Is there a errors recovering support? Could you provide any example for this?
For example, if source text contains an several errors in different lines then I want to obtain a list of this errors during single parsing execution.
Currently I get only first grammar error.
Oct 16, 2014 at 9:56 PM
By default the parsers try to recover from errors, but whether this is successful is another story.
So first things first:

All lexers automatically recover from errorneous characters by skipping them. This generally allows them to recover (although this could lead to parsing errors).

All parsers have a RecoverErrors property the controls whether a parser shall attempt to recover from parsing errors. By default this option is 'on'. The precise mechanism for the recovery depends on the parser. For LR parsers, which are the default on the command line option, the parsers tries a bunch of strategies attempting at correcting the input. These are:
  • dropping the unexpected token
  • adding an unexpected token before the error
  • replacing the unexpected token by an expected one
    If all fail, the parser simply stops.
Unfortunately, RNGLR parsers cannot recover from errors at this time due to technical reasons. However this is an ongoing work.

I hope this helps!

Oct 17, 2014 at 1:57 PM
Hi Laurent!
Thanks for your advanced answer, everything becomes clear.

Really, in some cases I get an several errors after parse the wrong source (I use LALR by default).
In the first part of your answer, you note that some characters may be skipped by lexer. I have reproduced this behaviour several times and this does not like for me.
How I can handle this lexer state?
Oct 21, 2014 at 7:46 AM

Unfortunately, at this time you cannot control the behavior of the lexer in this regard.

What kind of control would you need ?

Oct 21, 2014 at 8:01 AM
May be need provide eventhandler like OnSkipSymbol in lexer. Can lexer to detect this own state?