Order of alternatives has an impact on common lookahead prefix #753
-
Hey guys, I'm trying to get a better understanding of Langium's handling of common lookahead prefixes, and then I came across the following interesting thing. Suppose an integer It seems that the order of alternatives has an impact on common lookahead prefix, right? I'm not quite sure if this is a feature or an issue.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey @luan-xiaokun, yeah that's a feature. Chevrotain is heavily optimized for parsing performance and skips alternatives with shorter prefixes while parsing. This is documented here. Note that we will switch to ALL(*) with Langium 1.0, which alleviates this issue. The parser will then always choose the longest matching alternative. |
Beta Was this translation helpful? Give feedback.
Hey @luan-xiaokun,
yeah that's a feature. Chevrotain is heavily optimized for parsing performance and skips alternatives with shorter prefixes while parsing. This is documented here. Note that we will switch to ALL(*) with Langium 1.0, which alleviates this issue. The parser will then always choose the longest matching alternative.