Skip to content

Commit

Permalink
C++: Added C++20 keywords (#2236)
Browse files Browse the repository at this point in the history
This adds support for the ney keywords added in C++20.
https://en.cppreference.com/w/cpp/keyword
  • Loading branch information
shilch authored Mar 7, 2020
1 parent 1f7a245 commit 462ad57
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 44 deletions.
2 changes: 1 addition & 1 deletion components/prism-cpp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/prism-cpp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

216 changes: 174 additions & 42 deletions tests/languages/cpp/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -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"]
]

----------------------------------------------------
Expand Down

0 comments on commit 462ad57

Please sign in to comment.