Error recovery lets a parser continue analyzing a textual DSL after a syntactic error. Instead of failing at the first bad character, it resynchronizes and resumes as soon as possible, preventing one mistake from invalidating the remaining content. section 15.1
This capability is essential when domain experts create or repair invalid DSL text, but useful recovery is difficult to implement without substantial parser-generator support. section 15.1
Listing 15.2 A grammar in EBNF that can parse listing 15.1
STRING: '"' [A-Za-z0-9 ]+ '"' ; #1
type: 'amount' | 'date range' | 'percentage' ; #2
WS: (' ' | '\t' | '\n')+ ; #3
attributeReference: '->' WS? STRING ;
number: [0-9]+ ('.' [0-9]+)? ;
value: attributeReference | number ;
attribute: STRING WS? ':' WS? type (WS 'initially' WS? value)? ;
recordType: WS? 'record type' WS? STRING WS?
'having attributes:' (WS? attribute)* WS? ;
Use the example EBNF grammar to see the textual structure whose errors a parser must recover from. section 15.1
