summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Di Bella <cjdb.ns@gmail.com>2023-04-26 00:36:39 -0700
committerGitHub <noreply@github.com>2023-04-26 09:36:39 +0200
commitadc6a48a17fe7fb7bfa81edbbf550bb9796869b6 (patch)
treefd629ec8a258239697ff62dd6f016134183ab175
parenta0df083d1d01a65daff6b7d2a748dc812ebdcc6e (diff)
downloadpygments-git-adc6a48a17fe7fb7bfa81edbbf550bb9796869b6.tar.gz
adds C++ alternative tokens as keywords (#2421)
-rw-r--r--pygments/lexers/c_cpp.py3
-rw-r--r--tests/snippets/cpp/alternative_tokens.txt46
2 files changed, 48 insertions, 1 deletions
diff --git a/pygments/lexers/c_cpp.py b/pygments/lexers/c_cpp.py
index b5fd704d..aed8b4a4 100644
--- a/pygments/lexers/c_cpp.py
+++ b/pygments/lexers/c_cpp.py
@@ -384,7 +384,8 @@ class CppLexer(CFamilyLexer):
'try', 'typeid', 'using', 'virtual', 'constexpr', 'nullptr', 'concept',
'decltype', 'noexcept', 'override', 'final', 'constinit', 'consteval',
'co_await', 'co_return', 'co_yield', 'requires', 'import', 'module',
- 'typename'),
+ 'typename', 'and', 'and_eq', 'bitand', 'bitor', 'compl', 'not',
+ 'not_eq', 'or', 'or_eq', 'xor', 'xor_eq'),
suffix=r'\b'), Keyword),
(r'namespace\b', Keyword, 'namespace'),
(r'(enum)(\s+)', bygroups(Keyword, Whitespace), 'enumname'),
diff --git a/tests/snippets/cpp/alternative_tokens.txt b/tests/snippets/cpp/alternative_tokens.txt
new file mode 100644
index 00000000..69919cc9
--- /dev/null
+++ b/tests/snippets/cpp/alternative_tokens.txt
@@ -0,0 +1,46 @@
+---input---
+and
+and_eq
+bitand
+bitor
+compl
+not
+not_eq
+or
+or_eq
+xor
+xor_eq
+
+---tokens---
+'and' Keyword
+'\n' Text.Whitespace
+
+'and_eq' Keyword
+'\n' Text.Whitespace
+
+'bitand' Keyword
+'\n' Text.Whitespace
+
+'bitor' Keyword
+'\n' Text.Whitespace
+
+'compl' Keyword
+'\n' Text.Whitespace
+
+'not' Keyword
+'\n' Text.Whitespace
+
+'not_eq' Keyword
+'\n' Text.Whitespace
+
+'or' Keyword
+'\n' Text.Whitespace
+
+'or_eq' Keyword
+'\n' Text.Whitespace
+
+'xor' Keyword
+'\n' Text.Whitespace
+
+'xor_eq' Keyword
+'\n' Text.Whitespace