-
First of all, thank you for the great work on this project — it's a very promising tool for building DSLs! I'm working on a language where good user experience during editing is essential. I wanted to ask: Does Langium (or the underlying Chevrotain parser) support error recovery during parsing? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @sho94os,
yes it does! We've specifically chosen Chevrotain for its error recovery feature (in addition to its stellar performance). See also here for more info. In our experience, the error recovery of Chevrotain performs fairly well without any real hiccups to the user experience. The error is reported, and the rest of the program is parsed as expected, which then allows Langium to provide LSP features even after the location of the syntax error. Note that, in some edge cases, for specific grammars, it might fail to recover perfectly. I.e. in some cases, Chevrotain recovers too eagerly (i.e. it will return early from the rule call, even though the rule parsing hasn't finished yet), or it will fail to find the entry point into the code (in which case the parsing actually stops before the end of the file, which is fairly problematic). However, these are rare cases which usually can be fixed by adjusting the grammar. |
Beta Was this translation helpful? Give feedback.
Hey @sho94os,
yes it does! We've specifically chosen Chevrotain for its error recovery feature (in addition to its stellar performance). See also here for more info. In our experience, the error recovery of Chevrotain performs fairly well without any real hiccups to the user experience. The error is reported, and the rest of the program is parsed as expected, which then allows Langium to provide LSP features even after the location of the syntax error.
Note that, in some edge cases, for spe…