-
Hello, I converted my grammar from Xtext to Langium and when I start the VSCode extension I have this message:
The error comes from the Operation rule defined here. The parser works as expected but I would like to fix the ambiguity. I wrote a simplified grammar in the playground. Any idea on how to update the grammar (I cannot change the output format that is already used in production) ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hey @ydaveluy, I'm not sure it's possible to resolve this ambiguity error with the tools provided by Langium. The parser works right now, mostly by abusing the ambiguity behavior (i.e. picking the first option in case of a detected ambiguity). In theory, you would need a manual lookahead that looks a few tokens into the token stream to detect whether there's another |
Beta Was this translation helpful? Give feedback.
-
Ok thanks, I will keep it as is as the parser works properly. |
Beta Was this translation helpful? Give feedback.
Hey @ydaveluy,
I'm not sure it's possible to resolve this ambiguity error with the tools provided by Langium. The parser works right now, mostly by abusing the ambiguity behavior (i.e. picking the first option in case of a detected ambiguity). In theory, you would need a manual lookahead that looks a few tokens into the token stream to detect whether there's another
ID
token right after the currentID
token. However, Langium doesn't provide the API for it.