Closed sperlis closed 2 months ago
I can of two solutions.
The first one would be for the grammar to handle these possibilities and instead of returning Error or not matching anything have a role not generic which can match what you would expect to be an error but just return it as a special node or a flag in the Parser context you provide. Maybe we could add an ErrorAndContinue() kind of parser. I'll provide an example when I have more time.
The second option could be native to Parlot in the form of a parser definition to lookup to recover from and start fresh. For instance ';' or LF such that if an error occurs it does it but then tries to find the next occurrence of this pattern and starts from a specific known parser again. But this could definitely be the ErrorAndContinue parser I was mentioning above.
Thank you for the response. Gave me some things to think about.
I had two pieces of code that had error in them:
I used
lex
instead oflet
And:Notice the trailing
";
at the end of the second line.The parser throws an exception when hitting these mistakes.
Is there a way to tell the parser to try and continue? Ignore the errors somehow?