CFamily: Lex identifiers after case as constants#2084
Merged
Anteru merged 5 commits intopygments:masterfrom Mar 12, 2022
Merged
CFamily: Lex identifiers after case as constants#2084Anteru merged 5 commits intopygments:masterfrom
case as constants#2084Anteru merged 5 commits intopygments:masterfrom
Conversation
Add a state for marking identifiers preceded by a `case` keyword as constants. Additionally, refactor the `label` rule to no longer permit a `case` keyword before a label. Consequentially, identifiers after a `case` keyword (like `foo` in `case foo:`) are no longer wrongly lexed as `Name.Label`, but as `Name.Constant`. In addition, this fixes pygments#2076, as multiple `case` keywords in one line are lexed the same.
jeanas
reviewed
Mar 8, 2022
Contributor
|
I'll leave this for a few days in case other maintainers would like to take a look. |
After a `case`, when lexing a namespaced name, like `foo::bar`, lex the namespace operator `::` as Operator, and not Name.Constant.
Contributor
Author
|
I made a small oversight, so I pushed a couple of commits with a fix. I am sorry for the inconvenience, but I think it should be all good now. Instead of lexing Which is more correct and also consistent with how the lexer treats the |
Collaborator
|
This looks good to me. Thanks for working on this! |
This file contains hidden or 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
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.
Add a state for marking identifiers preceded by a
casekeyword as constants.Additionally, refactor the
labelrule to no longer permit acasekeyword before a label.Consequentially, identifiers after a
casekeyword (likefooincase foo:) are no longer wrongly lexed asName.Label, but asName.Constant.In addition, this fixes #2076, as multiple
casekeywords in one line are lexed the same.