Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lexer: cpp: add keywords and operator introduced in C++20 #1784

Merged
merged 1 commit into from
Jan 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/rouge/lexers/cpp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ class Cpp < C

def self.keywords
@keywords ||= super + Set.new(%w(
asm auto catch const_cast delete dynamic_cast explicit export friend
asm auto catch char8_t concept
consteval constexpr constinit const_cast co_await co_return co_yield
delete dynamic_cast explicit export friend
mutable namespace new operator private protected public
reinterpret_cast restrict size_of static_cast this throw throws
reinterpret_cast requires restrict size_of static_cast this throw throws
typeid typename using virtual final override

alignas alignof constexpr decltype noexcept static_assert
alignas alignof decltype noexcept static_assert
thread_local try
))
end
Expand Down Expand Up @@ -68,7 +70,7 @@ def self.reserved
rule %r/#{dq}[lu]*/i, Num::Integer
rule %r/\bnullptr\b/, Name::Builtin
rule %r/(?:u8|u|U|L)?R"([a-zA-Z0-9_{}\[\]#<>%:;.?*\+\-\/\^&|~!=,"']{,16})\(.*?\)\1"/m, Str
rule %r/::/, Operator
rule %r/(::|<=>)/, Operator
end

state :classname do
Expand Down