C++: Added C++20 keywords (#2236) This adds support for the ney keywords added in C++20. https://en.cppreference.com/w/cpp/keyword
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
diff --git a/components/prism-cpp.js b/components/prism-cpp.js
index 412d65e..08be199 100644
--- a/components/prism-cpp.js
+++ b/components/prism-cpp.js
@@ -3,7 +3,7 @@ Prism.languages.cpp = Prism.languages.extend('c', {
pattern: /(\b(?:class|enum|struct)\s+)\w+/,
lookbehind: true
},
- 'keyword': /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,
+ 'keyword': /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char8_t|char16_t|char32_t|class|compl|concept|const|consteval|constexpr|constinit|const_cast|continue|co_await|co_return|co_yield|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,
'number': {
pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+\.?[\da-f']*|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+\.?[\d']*|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]*/i,
greedy: true
diff --git a/components/prism-cpp.min.js b/components/prism-cpp.min.js
index 6e8c5dd..819c167 100644
--- a/components/prism-cpp.min.js
+++ b/components/prism-cpp.min.js
@@ -1 +1 @@
-Prism.languages.cpp=Prism.languages.extend("c",{"class-name":{pattern:/(\b(?:class|enum|struct)\s+)\w+/,lookbehind:!0},keyword:/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+\.?[\da-f']*|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+\.?[\d']*|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]*/i,greedy:!0},operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:true|false)\b/}),Prism.languages.insertBefore("cpp","string",{"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:"string",greedy:!0}});
\ No newline at end of file
+Prism.languages.cpp=Prism.languages.extend("c",{"class-name":{pattern:/(\b(?:class|enum|struct)\s+)\w+/,lookbehind:!0},keyword:/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char8_t|char16_t|char32_t|class|compl|concept|const|consteval|constexpr|constinit|const_cast|continue|co_await|co_return|co_yield|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+\.?[\da-f']*|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+\.?[\d']*|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]*/i,greedy:!0},operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:true|false)\b/}),Prism.languages.insertBefore("cpp","string",{"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:"string",greedy:!0}});
\ No newline at end of file
diff --git a/tests/languages/cpp/keyword_feature.test b/tests/languages/cpp/keyword_feature.test
index b782149..ac72b6a 100644
--- a/tests/languages/cpp/keyword_feature.test
+++ b/tests/languages/cpp/keyword_feature.test
@@ -1,51 +1,183 @@
-alignas alignof asm auto bool
-break case catch char char16_t char32_t
+alignas
+alignof
+asm
+auto
+bool
+break
+case
+catch
+char
+char8_t
+char16_t
+char32_t
class;
-compl const constexpr
-const_cast continue decltype default
-delete do double dynamic_cast
-else enum;
-explicit export extern
-float for friend goto if
-inline int long mutable namespace
-new noexcept nullptr operator
-private protected public register
-reinterpret_cast return short
-signed sizeof static static_assert
-static_cast struct;
-switch template
-this thread_local throw try
-typedef typeid typename union
-unsigned using virtual void
-volatile wchar_t while
-int8_t int16_t int32_t int64_t
-uint8_t uint16_t uint32_t uint64_t
+compl
+concept
+const
+consteval
+constexpr
+constinit
+const_cast
+continue
+co_await
+co_return
+co_yield
+decltype
+default
+delete
+do
+double
+dynamic_cast
+else
+enum;
+explicit
+export
+extern
+float
+for
+friend
+goto
+if
+inline
+int
+long
+mutable
+namespace
+new
+noexcept
+nullptr
+operator
+private
+protected
+public
+register
+reinterpret_cast
+requires
+return
+short
+signed
+sizeof
+static
+static_assert
+static_cast
+struct;
+switch
+template
+this
+thread_local
+throw
+try
+typedef
+typeid
+typename
+union
+unsigned
+using
+virtual
+void
+volatile
+wchar_t
+while
+int8_t
+int16_t
+int32_t
+int64_t
+uint8_t
+uint16_t
+uint32_t
+uint64_t
----------------------------------------------------
[
- ["keyword", "alignas"], ["keyword", "alignof"], ["keyword", "asm"], ["keyword", "auto"], ["keyword", "bool"],
- ["keyword", "break"], ["keyword", "case"], ["keyword", "catch"], ["keyword", "char"], ["keyword", "char16_t"], ["keyword", "char32_t"],
+ ["keyword", "alignas"],
+ ["keyword", "alignof"],
+ ["keyword", "asm"],
+ ["keyword", "auto"],
+ ["keyword", "bool"],
+ ["keyword", "break"],
+ ["keyword", "case"],
+ ["keyword", "catch"],
+ ["keyword", "char"],
+ ["keyword", "char8_t"],
+ ["keyword", "char16_t"],
+ ["keyword", "char32_t"],
["keyword", "class"], ["punctuation", ";"],
- ["keyword", "compl"], ["keyword", "const"], ["keyword", "constexpr"],
- ["keyword", "const_cast"], ["keyword", "continue"], ["keyword", "decltype"], ["keyword", "default"],
- ["keyword", "delete"], ["keyword", "do"], ["keyword", "double"], ["keyword", "dynamic_cast"],
- ["keyword", "else"], ["keyword", "enum"], ["punctuation", ";"],
- ["keyword", "explicit"], ["keyword", "export"], ["keyword", "extern"],
- ["keyword", "float"], ["keyword", "for"], ["keyword", "friend"], ["keyword", "goto"], ["keyword", "if"],
- ["keyword", "inline"], ["keyword", "int"], ["keyword", "long"], ["keyword", "mutable"], ["keyword", "namespace"],
- ["keyword", "new"], ["keyword", "noexcept"], ["keyword", "nullptr"], ["keyword", "operator"],
- ["keyword", "private"], ["keyword", "protected"], ["keyword", "public"], ["keyword", "register"],
- ["keyword", "reinterpret_cast"], ["keyword", "return"], ["keyword", "short"],
- ["keyword", "signed"], ["keyword", "sizeof"], ["keyword", "static"], ["keyword", "static_assert"],
- ["keyword", "static_cast"], ["keyword", "struct"], ["punctuation", ";"],
- ["keyword", "switch"], ["keyword", "template"],
- ["keyword", "this"], ["keyword", "thread_local"], ["keyword", "throw"], ["keyword", "try"],
- ["keyword", "typedef"], ["keyword", "typeid"], ["keyword", "typename"], ["keyword", "union"],
- ["keyword", "unsigned"], ["keyword", "using"], ["keyword", "virtual"], ["keyword", "void"],
- ["keyword", "volatile"], ["keyword", "wchar_t"], ["keyword", "while"],
- ["keyword", "int8_t"], ["keyword", "int16_t"], ["keyword", "int32_t"], ["keyword", "int64_t"],
- ["keyword", "uint8_t"], ["keyword", "uint16_t"], ["keyword", "uint32_t"], ["keyword", "uint64_t"]
+ ["keyword", "compl"],
+ ["keyword", "concept"],
+ ["keyword", "const"],
+ ["keyword", "consteval"],
+ ["keyword", "constexpr"],
+ ["keyword", "constinit"],
+ ["keyword", "const_cast"],
+ ["keyword", "continue"],
+ ["keyword", "co_await"],
+ ["keyword", "co_return"],
+ ["keyword", "co_yield"],
+ ["keyword", "decltype"],
+ ["keyword", "default"],
+ ["keyword", "delete"],
+ ["keyword", "do"],
+ ["keyword", "double"],
+ ["keyword", "dynamic_cast"],
+ ["keyword", "else"],
+ ["keyword", "enum"], ["punctuation", ";"],
+ ["keyword", "explicit"],
+ ["keyword", "export"],
+ ["keyword", "extern"],
+ ["keyword", "float"],
+ ["keyword", "for"],
+ ["keyword", "friend"],
+ ["keyword", "goto"],
+ ["keyword", "if"],
+ ["keyword", "inline"],
+ ["keyword", "int"],
+ ["keyword", "long"],
+ ["keyword", "mutable"],
+ ["keyword", "namespace"],
+ ["keyword", "new"],
+ ["keyword", "noexcept"],
+ ["keyword", "nullptr"],
+ ["keyword", "operator"],
+ ["keyword", "private"],
+ ["keyword", "protected"],
+ ["keyword", "public"],
+ ["keyword", "register"],
+ ["keyword", "reinterpret_cast"],
+ ["keyword", "requires"],
+ ["keyword", "return"],
+ ["keyword", "short"],
+ ["keyword", "signed"],
+ ["keyword", "sizeof"],
+ ["keyword", "static"],
+ ["keyword", "static_assert"],
+ ["keyword", "static_cast"],
+ ["keyword", "struct"], ["punctuation", ";"],
+ ["keyword", "switch"],
+ ["keyword", "template"],
+ ["keyword", "this"],
+ ["keyword", "thread_local"],
+ ["keyword", "throw"],
+ ["keyword", "try"],
+ ["keyword", "typedef"],
+ ["keyword", "typeid"],
+ ["keyword", "typename"],
+ ["keyword", "union"],
+ ["keyword", "unsigned"],
+ ["keyword", "using"],
+ ["keyword", "virtual"],
+ ["keyword", "void"],
+ ["keyword", "volatile"],
+ ["keyword", "wchar_t"],
+ ["keyword", "while"],
+ ["keyword", "int8_t"],
+ ["keyword", "int16_t"],
+ ["keyword", "int32_t"],
+ ["keyword", "int64_t"],
+ ["keyword", "uint8_t"],
+ ["keyword", "uint16_t"],
+ ["keyword", "uint32_t"],
+ ["keyword", "uint64_t"]
]
----------------------------------------------------