Skip to content

Commit

Permalink
Added keywords from C++20 (#23)
Browse files Browse the repository at this point in the history
* `__has_cpp_attribute`
* `assert`
* `audit`
* `axiom`
* `char8_t`
* `consteval`
* `ensures`
* `expects`
* `likely`
* `no_unique_address`
* `unlikely`
  • Loading branch information
ludwigpacifici authored Mar 31, 2019
1 parent 9b10e18 commit 02f1047
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.log
*~
/faceup/
README.html
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ It is recommended to use it in addition with the `c++-mode` major mode for extra

# Preview

`modern-c++-font-lock-mode` is enabled:
With `modern-c++-font-lock-mode`:

<p align="center"><img src="https://raw.githubusercontent.com/ludwigpacifici/modern-cpp-font-lock/master/img/mc%2B%2Bfl-on.png" width="640" /></p>
<p align="center"><img src="https://raw.githubusercontent.com/ludwigpacifici/modern-cpp-font-lock/master/img/mc%2B%2Bfl-on.png" /></p>

`modern-c++-font-lock-mode` is disabled:

<p align="center"><img src="https://raw.githubusercontent.com/ludwigpacifici/modern-cpp-font-lock/master/img/mc%2B%2Bfl-off.png" width="640" /></p>

Using `GNU Emacs 24.5.1` and `CC Mode version 5.32.5`.
Using `GNU Emacs 27.0.50` and `CC Mode version 5.33.2`.

# Installation

Expand Down Expand Up @@ -107,6 +103,8 @@ Font-lock keywords are tested with the [faceup](https://github.com/Lindydancer/f

# Feedback

If you find a bug, please check if you can reproduce with `c++-mode` only. If it is the case, send your bug upstream to [CC Mode](http://cc-mode.sourceforge.net/)

Do not hesitate to ask questions or share suggestions.

Happy coding!
Expand Down
3 changes: 3 additions & 0 deletions cpp/keyword/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ concept
const
const_cast
constexpr
consteval
continue
decltype
default
Expand Down Expand Up @@ -69,6 +70,8 @@ template
this
thread_local
throw
audit
axiom
transaction_safe
transaction_safe_dynamic
try
Expand Down
3 changes: 3 additions & 0 deletions cpp/keyword/test.txt.faceup
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
«k:const»
«k:const_cast»
«k:constexpr»
«k:consteval»
«k:continue»
«k:decltype»
«k:default»
Expand Down Expand Up @@ -69,6 +70,8 @@
«k:this»
«k:thread_local»
«k:throw»
«k:audit»
«k:axiom»
«k:transaction_safe»
«k:transaction_safe_dynamic»
«k:try»
Expand Down
30 changes: 30 additions & 0 deletions cpp/raw/test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
bool
char
char8_t
char16_t
char32_t
double
Expand Down Expand Up @@ -49,6 +50,7 @@ __TIME__
__VA_AR_GS__
__cplusplus
__has_include
__has_cpp_attribute

alignas
alignof
Expand All @@ -69,6 +71,7 @@ compl
concept
const
const_cast
consteval
constexpr
continue
decltype
Expand Down Expand Up @@ -118,6 +121,8 @@ template
this
thread_local
throw
audit
axiom
transaction_safe
transaction_safe_dynamic
try
Expand All @@ -140,6 +145,12 @@ xor_eq
[[nodiscard]]
[[noreturn]]
[[optimize_for_synchronized]]
[[likely]]
[[unlikely]]
[[no_unique_address]]
[[expects]]
[[ensures]]
[[assert]]

...

Expand Down Expand Up @@ -301,6 +312,7 @@ aconcept
aconst
aconst_cast
aconstexpr
aconsteval
acontinue
adecltype
adefault
Expand Down Expand Up @@ -349,6 +361,8 @@ atemplate
athis
athread_local
athrow
aaudit
aaxiom
atransaction_safe
atransaction_safe_dynamic
atry
Expand Down Expand Up @@ -382,6 +396,7 @@ concepta
consta
const_casta
constexpra
constevala
continuea
decltypea
defaulta
Expand Down Expand Up @@ -430,6 +445,8 @@ templatea
thisa
thread_locala
throwa
audita
axioma
transaction_safea
transaction_safe_dynamica
trya
Expand All @@ -451,13 +468,26 @@ maybe_unused]]
nodiscard]]
noreturn]]
optimize_for_synchronized]]
likely]]
unlikely]]
no_unique_address]]
expects]]
ensures]]
assert]]

[[carries_dependency
[[deprecated
[[fallthrough
[[maybe_unused
[[nodiscard
[[noreturn
[[optimize_for_synchronized
[[likely
[[unlikely
[[no_unique_address
[[expects
[[ensures
[[assert

08
09
Expand Down
30 changes: 30 additions & 0 deletions cpp/raw/test.txt.faceup
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
«t:bool»
«t:char»
«t:char8_t»
«t:char16_t»
«t:char32_t»
«t:double»
Expand Down Expand Up @@ -49,6 +50,7 @@
«p:__VA_AR_GS__»
«p:__cplusplus»
«p:__has_include»
«p:__has_cpp_attribute»

«k:alignas»
«k:alignof»
Expand All @@ -69,6 +71,7 @@
«k:concept»
«k:const»
«k:const_cast»
«k:consteval»
«k:constexpr»
«k:continue»
«k:decltype»
Expand Down Expand Up @@ -118,6 +121,8 @@
«k:this»
«k:thread_local»
«k:throw»
«k:audit»
«k:axiom»
«k:transaction_safe»
«k:transaction_safe_dynamic»
«k:try»
Expand All @@ -140,6 +145,12 @@
[[«c:nodiscard»]]
[[«c:noreturn»]]
[[«c:optimize_for_synchronized»]]
[[«c:likely»]]
[[«c:unlikely»]]
[[«c:no_unique_address»]]
[[«c:expects»]]
[[«c:ensures»]]
[[«c:assert»]]

«f:...»

Expand Down Expand Up @@ -301,6 +312,7 @@ aconcept
aconst
aconst_cast
aconstexpr
aconsteval
acontinue
adecltype
adefault
Expand Down Expand Up @@ -349,6 +361,8 @@ atemplate
athis
athread_local
athrow
aaudit
aaxiom
atransaction_safe
atransaction_safe_dynamic
atry
Expand Down Expand Up @@ -382,6 +396,7 @@ concepta
consta
«k:const»_casta
constexpra
constevala
continuea
decltypea
defaulta
Expand Down Expand Up @@ -430,6 +445,8 @@ templatea
thisa
thread_locala
throwa
audita
axioma
transaction_safea
«k:transaction_safe»_dynamica
trya
Expand All @@ -451,13 +468,26 @@ maybe_unused]]
nodiscard]]
noreturn]]
optimize_«k:for»_«k:synchronized»]]
likely]]
unlikely]]
no_unique_address]]
expects]]
ensures]]
assert]]

[[carries_dependency
[[deprecated
[[fallthrough
[[maybe_unused
[[nodiscard
[[noreturn
[[optimize_«k:for»_«k:synchronized»
[[likely
[[unlikely
[[no_unique_address
[[expects
[[ensures
[[assert

08
09
Expand Down
Binary file removed img/all-operator-off-sample.png
Binary file not shown.
Binary file removed img/mc++fl-off.png
Binary file not shown.
Binary file modified img/mc++fl-on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions modern-cpp-font-lock.el
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

(defcustom modern-c++-types
(eval-when-compile
(sort '("bool" "char" "char16_t" "char32_t" "double" "float" "int" "long" "short" "signed" "unsigned" "void" "wchar_t")
(sort '("bool" "char" "char8_t" "char16_t" "char32_t" "double" "float" "int" "long" "short" "signed" "unsigned" "void" "wchar_t")
'modern-c++-string-lenght>))
"List of C++ types. See doc:
http://en.cppreference.com/w/cpp/language/types"
Expand All @@ -74,7 +74,7 @@ http://en.cppreference.com/w/cpp/language/types"

(defcustom modern-c++-preprocessors
(eval-when-compile
(sort '("#define" "#defined" "#elif" "#else" "#endif" "#error" "#if" "#ifdef" "#ifndef" "#include" "#line" "#pragma STDC CX_LIMITED_RANGE" "#pragma STDC FENV_ACCESS" "#pragma STDC FP_CONTRACT" "#pragma once" "#pragma pack" "#pragma" "#undef" "_Pragma" "__DATE__" "__FILE__" "__LINE__" "__STDCPP_STRICT_POINTER_SAFETY__" "__STDCPP_THREADS__" "__STDC_HOSTED__" "__STDC_ISO_10646__" "__STDC_MB_MIGHT_NEQ_WC__" "__STDC_VERSION__" "__STDC__" "__TIME__" "__VA_AR_GS__" "__cplusplus" "__has_include")
(sort '("#define" "#defined" "#elif" "#else" "#endif" "#error" "#if" "#ifdef" "#ifndef" "#include" "#line" "#pragma STDC CX_LIMITED_RANGE" "#pragma STDC FENV_ACCESS" "#pragma STDC FP_CONTRACT" "#pragma once" "#pragma pack" "#pragma" "#undef" "_Pragma" "__DATE__" "__FILE__" "__LINE__" "__STDCPP_STRICT_POINTER_SAFETY__" "__STDCPP_THREADS__" "__STDC_HOSTED__" "__STDC_ISO_10646__" "__STDC_MB_MIGHT_NEQ_WC__" "__STDC_VERSION__" "__STDC__" "__TIME__" "__VA_AR_GS__" "__cplusplus" "__has_include" "__has_cpp_attribute")
'modern-c++-string-lenght>))
"List of C++ preprocessor words. See doc:
http://en.cppreference.com/w/cpp/keyword and
Expand All @@ -85,7 +85,7 @@ http://en.cppreference.com/w/cpp/preprocessor"

(defcustom modern-c++-keywords
(eval-when-compile
(sort '("alignas" "alignof" "and" "and_eq" "asm" "atomic_cancel" "atomic_commit" "atomic_noexcept" "auto" "bitand" "bitor" "break" "case" "catch" "class" "compl" "concept" "const" "constexpr" "const_cast" "continue" "co_await" "co_return" "co_yield" "decltype" "default" "delete" "do" "dynamic_cast" "else" "enum" "explicit" "export" "extern" "final" "for" "friend" "goto" "if" "import" "inline" "module" "mutable" "namespace" "new" "noexcept" "not" "not_eq" "operator" "or" "or_eq" "override" "private" "protected" "public" "register" "reinterpret_cast" "requires" "return" "sizeof" "static" "static_assert" "static_cast" "struct" "switch" "synchronized" "template" "this" "thread_local" "throw" "transaction_safe" "transaction_safe_dynamic" "try" "typedef" "typeid" "typename" "union" "using" "virtual" "volatile" "while" "xor" "xor_eq")
(sort '("alignas" "alignof" "and" "and_eq" "asm" "atomic_cancel" "atomic_commit" "atomic_noexcept" "audit" "auto" "axiom" "bitand" "bitor" "break" "case" "catch" "class" "compl" "concept" "const" "constexpr" "consteval" "const_cast" "continue" "co_await" "co_return" "co_yield" "decltype" "default" "delete" "do" "dynamic_cast" "else" "enum" "explicit" "export" "extern" "final" "for" "friend" "goto" "if" "import" "inline" "module" "mutable" "namespace" "new" "noexcept" "not" "not_eq" "operator" "or" "or_eq" "override" "private" "protected" "public" "register" "reinterpret_cast" "requires" "return" "sizeof" "static" "static_assert" "static_cast" "struct" "switch" "synchronized" "template" "this" "thread_local" "throw" "transaction_safe" "transaction_safe_dynamic" "try" "typedef" "typeid" "typename" "union" "using" "virtual" "volatile" "while" "xor" "xor_eq")
'modern-c++-string-lenght>))
"List of C++ keywords. See doc:
http://en.cppreference.com/w/cpp/keyword"
Expand All @@ -95,7 +95,7 @@ http://en.cppreference.com/w/cpp/keyword"

(defcustom modern-c++-attributes
(eval-when-compile
(sort '("carries_dependency" "deprecated" "fallthrough" "maybe_unused" "nodiscard" "noreturn" "optimize_for_synchronized")
(sort '("carries_dependency" "deprecated" "fallthrough" "maybe_unused" "nodiscard" "noreturn" "optimize_for_synchronized" "likely" "unlikely" "no_unique_address" "expects" "ensures" "assert")
'modern-c++-string-lenght>))
"List of C++ attributes. See doc:
http://en.cppreference.com/w/cpp/language/attributes"
Expand Down

0 comments on commit 02f1047

Please sign in to comment.