-
I am new to langium so this might be a silly question that has straight forward answer. I have some rules:
Here Basically in the But the problem arises when I add other Rules that also have a 'from' keyword but not followed by a FILE_PATH, e.g. the At this point, using synthetic token option is also not working. Is there a way to trigger the pattern/matcher function for FILE_PATH only when it is mentioned in the rule, e.g. in Is there any other solution that will help me achieve my goal? Any help would be appreciated. Thanks in advance. Here is the full token builder class in case it helps.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @dhrubomoy, unfortunately, that's an inherent limitation of how LL language parsers work. During the tokenization phase, you have rather limited information about what the tokens in the input actually represent. Due to the other My recommendation would be to use a system similar to TypeScript, which uses langium/packages/langium/src/grammar/langium-grammar.langium Lines 65 to 66 in 1a93a22 Generally, when referencing paths, I would always recommend to use |
Beta Was this translation helpful? Give feedback.
Hey @dhrubomoy,
unfortunately, that's an inherent limitation of how LL language parsers work. During the tokenization phase, you have rather limited information about what the tokens in the input actually represent. Due to the other
from
keyword in your language, even features such as lexer modes or positive lookbehind in the regex will not work as expected. Other systems such as PEG can take the context of the current rule into account during the parsing/tokenization of the input (PEG has no separate lexing/parsing phase), but PEG parsers are rather slow as a consequence.My recommendation would be to use a system similar to TypeScript, which uses
STRING
terminals for imports. See also o…