Skip to content
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

Conversation

JohannesMeierSE
Copy link
Contributor

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!

Copy link

github-actions bot commented Mar 13, 2024

PR Preview Action v1.4.6
Preview removed because the pull request was closed.
2024-05-16 09:41 UTC

@JohannesMeierSE
Copy link
Contributor Author

Thanks for your feedback so far! I just pushed the corresponding fixes.

Copy link

@sailingKieler sailingKieler left a 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.

hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
Copy link

@sailingKieler sailingKieler left a 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 🤓

hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
Copy link

@sailingKieler sailingKieler left a 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 🚀

hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
@JohannesMeierSE
Copy link
Contributor Author

Thanks @sailingKieler for your helpful reviews! I just pushed the fixes.

Comment on lines 6 to 9
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.
Copy link
Member

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:

Suggested change
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.

Copy link
Contributor Author

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)!

hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
hugo/content/guides/keywords-as-identifiers/_index.md Outdated Show resolved Hide resolved
@JohannesMeierSE
Copy link
Contributor Author

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.

Copy link
Member

@msujew msujew left a 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.

@msujew msujew merged commit 1de22ce into eclipse-langium:main May 16, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants