-
Notifications
You must be signed in to change notification settings - Fork 57
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
Semantic syntax highlighting #367
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Mar 17, 2022
zth
force-pushed
the
semantic-highlighting
branch
from
March 19, 2022 13:00
94970db
to
b7dd509
Compare
…uments, binary operators.
With upper case ids, emit Token.JsxTag With lower case ids, emit Token.Variable Still need to do module declarations and expressions (and e.g. open M etc).
Don't emit semantic tokens for true/false. Remove redundant parts of grammar that were overriding booleans.
In case the user types `\""`
Labels are not handled by semantic highlighting (because there is no precise location information in the AST). But the grammar defines to/downto as keywords, in order to handle for loops. There are 3 cases where to/downto can be labels: 1) function definition `(~to as x) =>...` 2) function application `foo(~to=...)` 3) JSX props `<foo to=...` (punned cases are not problematic as they are also variables, and variables are handled via semantic highlighting). The grammar now recognises patterns of the form `to = ` and `to as` and highlights `to` as a variable. The correctness of this relies on an observation: in `to =` and `to as`, it's not possible that `to` is the keyword of a syntactically valid for loop, as for that to be the case it must be followed by an expression.
The jsx grammar only needs to take care of `<>` and `</>` and `</` and `/>`. The `<` and `>` cases are handled via semantic highlighting. And the ids are handled via semantic highlighting just like ids in any other context.
Does not rely on the code to be formatted in order to determine if there are children.
….someType. - #foo is marked as enum - space is allowed: # foo - #...foo. is a type
cristianoc
force-pushed
the
semantic-highlighting
branch
from
March 19, 2022 13:06
8d801ff
to
2d7fcd1
Compare
Clean up keywords, and remove variant constructors and module access, which are handled at the semantic level.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check out the forum post for context.
Closes #89
Closes #357
Closes #85
Closes #57
Closes #35
Closes #275
Closes #21