Document error recovery

This commit is contained in:
Robin Jadoul 2017-01-30 17:49:00 +01:00
parent 9777ab029d
commit 25e346b8cd
1 changed files with 4 additions and 0 deletions

View File

@ -126,6 +126,10 @@ Comments are from a `#` to the end of the line.
Of course, how you use the generated parser highly depends on which backend you used to generate it. For the default c++ backend however, the easiest way of getting to know the parser is probably having a look at the class definition in the generated header file, usually named *<Parsername>.h*. Of course, how you use the generated parser highly depends on which backend you used to generate it. For the default c++ backend however, the easiest way of getting to know the parser is probably having a look at the class definition in the generated header file, usually named *<Parsername>.h*.
In general, there should be some way to run the parser, along with user defined actions, and get back the generated structure or abstract syntax tree. In general, there should be some way to run the parser, along with user defined actions, and get back the generated structure or abstract syntax tree.
### Error recovery
If you provide a rule with `<error>` somewhere inside the body, this can be used to recover from errors. The generated parser will discard states until it encounters somewhere it can use such a rule. Afterwards, it will start discarding tokens until it can proceed in parsing. If it's impossible to recover from the error (cannot find a recovery rule or cannot find a synchronizing token before EOF), there will generally be an error (depending on the backend). Usually, some sort of reporting mechanism should also be in place by the generated parser.
### Bash completion ### Bash completion
A file that provides bash completion is also provided for your convenience, to use it, do: A file that provides bash completion is also provided for your convenience, to use it, do: