-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guide how to enable keywords as identifiers #218 #219
Guide how to enable keywords as identifiers #218 #219
Conversation
|
Thanks for your feedback so far! I just pushed the corresponding fixes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this guide @JohannesMeierSE 🙏.
I've a bunch of smaller improvements in the wording, feel free to take those you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more suggestions, I'm done now 🤓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, nice work!
I have a few more detailed optimizations.
Overall it's great, so 🚀
Thanks @sailingKieler for your helpful reviews! I just pushed the fixes. |
Langium treats keywords like `var`, `const` or `function` as keyword tokens, even at unintended locations according to your grammar. | ||
Additionally, these strings are always highlighted as _keyword_ (in blue in this guide, while other text is white) whenever they are used. | ||
Summarizing, these keywords cannot be used as values for names, identifiers or other properties by default and need to be explicitly enabled. | ||
This guide explains how to do that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: The introduction in general is good, but I feel like the requirement to use keywords as identifiers should be explained a bit better:
Langium treats keywords like `var`, `const` or `function` as keyword tokens, even at unintended locations according to your grammar. | |
Additionally, these strings are always highlighted as _keyword_ (in blue in this guide, while other text is white) whenever they are used. | |
Summarizing, these keywords cannot be used as values for names, identifiers or other properties by default and need to be explicitly enabled. | |
This guide explains how to do that. | |
As you write your grammar, you will add keyword such as `var`, `get` or `function` to improve the readability of your language and add structure. | |
These keywords get a special keyword highlighting by default - in blue in this guide, while other text is white - and are handled separately from other terminals such as names, identifiers, numbers and so on. | |
You will quickly notice that a function such as `function get()` will lead to parser errors, as `get` is a keyword and no valid identifier. | |
This guide is all about how to enable these keywords to be treated as identifiers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion, I used it (slightly adapted)!
9fcaf6d
to
a243547
Compare
Thanks @msujew for the review! I applied the suggestions and moved the guide to the new location according to the new structure of the documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. We could eventually factor out step 2 into a dedicated guide for semantic highlighting, but that's currently not necessary.
This PR contributes a guide to the Langium documentation, how to enable keywords to be used as regular names/identifiers/values for properties, according to #218.
It roughly explains the background for the issues and shows to how overcome them along the "hello world" example.
I am looking forward to your feedback!