diff options
author | amitkummer <49096391+amitkummer@users.noreply.github.com> | 2022-03-12 16:00:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-12 15:00:31 +0100 |
commit | 62dd19e9d3e0400fff0aeddabae490797425c87e (patch) | |
tree | e3883dafbe0fcdce2a9932282ddc07860b55c346 /tests/snippets | |
parent | 6e07d3f31654c67881e39f0342d024e12e91a667 (diff) | |
download | pygments-git-62dd19e9d3e0400fff0aeddabae490797425c87e.tar.gz |
CFamily: Lex identifiers after `case` as constants (#2084)
* Lex identifiers after `case` as constants
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 #2076, as multiple `case` keywords in one
line are lexed the same.
* Add test for multiple `case` keywords in one line
* Fix existing tests
* Lex `::` as Operator and not Name.Constant
After a `case`, when lexing a namespaced name, like `foo::bar`, lex the
namespace operator `::` as Operator, and not Name.Constant.
* Regenerate tokens
Diffstat (limited to 'tests/snippets')
-rw-r--r-- | tests/snippets/c/test_switch.txt | 2 | ||||
-rw-r--r-- | tests/snippets/c/test_switch_space_before_colon.txt | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/tests/snippets/c/test_switch.txt b/tests/snippets/c/test_switch.txt index 847cc86d..d1c11482 100644 --- a/tests/snippets/c/test_switch.txt +++ b/tests/snippets/c/test_switch.txt @@ -36,7 +36,7 @@ int main() 'case' Keyword ' ' Text.Whitespace '0' Literal.Number.Integer -':' Operator +':' Punctuation '\n' Text.Whitespace ' ' Text.Whitespace diff --git a/tests/snippets/c/test_switch_space_before_colon.txt b/tests/snippets/c/test_switch_space_before_colon.txt index 482bff54..583f77c1 100644 --- a/tests/snippets/c/test_switch_space_before_colon.txt +++ b/tests/snippets/c/test_switch_space_before_colon.txt @@ -37,7 +37,7 @@ int main() ' ' Text.Whitespace '0' Literal.Number.Integer ' ' Text.Whitespace -':' Operator +':' Punctuation '\n' Text.Whitespace ' ' Text.Whitespace |