Terminal rule shadowing another - longer_alt #1411
-
Hi guys, I spent some time on this problem I have, but I couldn't solve it myself, so I am asking the community.
The set of words following the terminal rule PRIORITY is included in the set of words following the terminal rule ID, so if PRIORITY was after ID, I would get the error in my dsl code: Expected PRIORITY, but found ID. Unfortunately I can't find the file where to do this. I think on the website they use a manual parser, while Langium creates the Parser depending on the grammar one wrote. I don't know exactly how the whole parsing/ lexing works, but I tried to do a CustomTokenBuilder class, overriding some methods in the DefaultTokenBuilder, but the language server fails when starting it, the error being: "Errors detected in definition of Lexer: A MultiMode Lexer cannot be initialized with a longer_alt on token outside of mode ". I should mention that by commenting/deleting the line: "token.LONGER_ALT = super.buildTerminalToken(this.idRule as GrammarAST.TerminalRule); ", the server starts, but the problem is not solved.
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey @vasilache-radu, without going into the details of Chevrotain+Langium, I would recommend you to make
|
Beta Was this translation helpful? Give feedback.
Hey @vasilache-radu,
without going into the details of Chevrotain+Langium, I would recommend you to make
PRIORITY
a data type rule, that should fix the issue by itself: