Gecko: a fast GLR parser with automatic syntax error recovery

15 points by abhin4v


marijn

I'm very confused why this write-up, which does extensive comparing to other tools, fails to include any mention of tree-sitter. That's both a lot more recent than most of the tools mentioned, and, from the sound of it, a lot closer to how this one works (also GLR, using the same GLR search technique for error tolerance).

matklad

I am not too confident in this statement as I haven't played with actual grammars, but I want to share my experience that the following approach to recovery (minimal-cost error recovery)

Gecko’s error recovery guarantees that the parser always produces parse trees corresponding to syntactically correct inputs. The way it achieves this is conceptually simple: some tokens before and/or after the error point are ignored, and the remaining token stream is syntactically valid according to the grammar.

is unsuitable for language servers. For the LSP use-case, you want error resilience rather than recovery. See https://matklad.github.io/2023/05/21/resilient-ll-parsing-tutorial.html#Why-Resilience-is-Needed for the spelled-out argument.