tlaplus-community / tree-sitter-tlaplus

A tree-sitter grammar for TLA⁺ and PlusCal
MIT License
57 stars 10 forks source link

Improve external scanner to function usefully during error recovery #19

Closed ahelwer closed 9 months ago

ahelwer commented 3 years ago

Per https://github.com/tree-sitter/tree-sitter/issues/1259, tree-sitter will call the external scanner with all symbols marked valid when it enters error recovery mode. Currently, the scanner immediately bails & returns false when this happens. The scanner should instead attempt to handle itself gracefully during error recovery, for example continuing to look for additional elements of a jlist and emitting INDENT/NEWLINE/DEDENT tokens. It's also possible the external scanner could emit some "anchor" tokens to identify the next unit definition as an error recovery point; see also https://github.com/tree-sitter/tree-sitter/discussions/1205

ahelwer commented 9 months ago

It works pretty well and I don't think there is much that could be done to improve it.