-
First of all thank you for creating this awesome tool. I am amazed by how effective it is and how well it fits together with the entire vscode ecosystem. I am currently working creating grammar for an existing DSL (a SQL like language, but unfortunately has many more syntaxes and ambiguity). There are about 1000 keywords, and for most cases these keywords can also be identifiers. I was following this documentation page for https://langium.org/docs/recipes/keywords-as-identifiers/, which works. I have created a rule KeywordAndID returns string:
ID | Keywords;
Keywords returns string:
'set' | 'let' | 'true' // ... thousand more
terminal ID: /[_a-zA-Z][\w_]*/; But I was wondering if there is a more generic way to achieve this that will work automatically for all keywords? That way I don't need to add a keyword in two different places? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @dhrubomoy,
Thank you, the kind words are much appreciated! :)
Excellent question. There is, see this piece of code. The |
Beta Was this translation helpful? Give feedback.
Hey @dhrubomoy,
Thank you, the kind words are much appreciated! :)
Excellent question. There is, see this piece of code. The
CATEGORIES
usage is documented in Chevrotain for exactly this use case. We should probably update the documentation to reflect that.