|
Hello, We are using Langium in our application, and have noticed a scenario where the parser throws an error that does not seem to be correct. In our application we have syntax very similar to that shown in the following repository: https://github.com/Greglar4/duplicateKeywordBug If you follow the instructions in the readme it should demonstrate the issue: This repository demonstrates a potential bug in the Langium parser. To see it, do the following:
vegan food [] vegan drinks []
I do not know enough about parsers to know if this is due to a limitation of parsers in general in relation to the desired syntax, or if this is a bug with the Langium parser, so I did not want to raise a bug directly. It seems to be important that the entire vegan food and vegan drinks sections are optional. Thoughts on this would be appreciated! Thanks, Greg |
Replies: 1 comment 4 replies
|
Hey @Greglar4, the issue is likely a limitation in the lookahead. You have a few options in the grammar which are somewhat ambiguous, which result in the lookahead engine trying to scan ahead, but due to missing Please note that I wouldn't recommend designing your grammar in such a way. Ideally, parser rules should be small and flexible. I.e. unless absolutely necessary, I would split the grammar like shown in here. |
Hey @Greglar4,
the issue is likely a limitation in the lookahead. You have a few options in the grammar which are somewhat ambiguous, which result in the lookahead engine trying to scan ahead, but due to missing
STRINGtokens in your input, it essentially says thatvegan food []is not valid in terms of the parser lookahead. I might have accidentally fixed that by fixing a different bug in the lookahead engine. You might want to try to force-update the transitivechevrotain-allstardependency to0.4.2. Alternatively, you can probably change themaxLookaheadvalue in your language config to something like3. That should work quite well.Please note that I wouldn't recommend designing your …