virgil icon indicating copy to clipboard operation
virgil copied to clipboard

Parser Suggestion: Panic Recovery Mode

Open JohnnyDingYQ opened this issue 4 months ago • 1 comments

In the current state, the Virgril parser reports the first ParseError and stops parsing the given file. On ParseError, panic recovery mode discards input tokens until a synchronizing token is found and continue to parse from that point. I believe panic recovery mode is relatively straightforward to implement and benefits a future language server.

JohnnyDingYQ avatar Aug 28 '25 15:08 JohnnyDingYQ

Hi, an interesting point. It's not quite true that the Virgil parser stops parsing; it mostly starts breaking out of inner productions and loops, but might continue to parse the rest of a production and then signal a couple of parse errors along the way. It won't keep going indefinitely, though. As it is a tokenless parser, it might be a little more tricky to parse up to a synchronization point, but I can imagine that a few strategically placed skip aheads could help it keep going.

titzer avatar Aug 28 '25 18:08 titzer