Replies: 1 comment
-
Hey @nametable, Aside from the fact that the Langium parser is pretty much closed down (as you correctly identified), we use Chevrotain under the hood, which features very limited mechanisms to customize the error recovery. So the answer is: No way to do this in the parser right now. Your best guess might be to adjust the grammar slightly to improve the out-of-the-box behavior, but this obviously isn't ideal and might not even work well. We have an open issue for this #1742, which aims to eventually improve on this, but don't count on it being available any time soon. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I am looking for a way to handle a parser error in a different way. My problem is that in the language I am working on, statements end with a
;
and functions end with a}
. When I have a failure to parse the statement, it is possible for the AST node to end early when consuming tokens. This can cause the parser to go back up to the rule for the function as a whole, and then interpret a}
as the end of the function, when instead it was supposed to be a part of some obj/array initializer (in my lang).Here's an example similar to what I'm talking about:
with some example grammar that is similar to my situation:
Is there a good way to customize the parser to be able to handle errors differently? I looked into created a new class based on
LangiumParser
(or fromBaseParser
directly), but some functions could not be overwritten such asrule
,getRule
,subrule
because the types they use for parameter/return are not exported fromLangium
(ParserRule
,RuleImpl
,RuleResult
).Beta Was this translation helpful? Give feedback.
All reactions