lib/rouge/lexers/cpp.rb in rouge-3.17.0 vs lib/rouge/lexers/cpp.rb in rouge-3.18.0
- old
+ new
@@ -20,14 +20,14 @@
'*.tpp', '*.h'
mimetypes 'text/x-c++hdr', 'text/x-c++src'
def self.keywords
@keywords ||= super + Set.new(%w(
- asm auto catch const_cast delete dynamic_cast explicit export
- friend mutable namespace new operator private protected public
- reinterpret_cast restrict size_of static_cast template this throw
- throws typeid typename using virtual final override
+ asm auto catch const_cast delete dynamic_cast explicit export friend
+ mutable namespace new operator private protected public
+ reinterpret_cast restrict size_of static_cast this throw throws
+ typeid typename using virtual final override
alignas alignof constexpr decltype noexcept static_assert
thread_local try
))
end
@@ -55,11 +55,12 @@
# digits with optional inner quotes
# see www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf
dq = /\d('?\d)*/
prepend :statements do
- rule %r/class\b/, Keyword, :classname
+ rule %r/(class|struct)\b/, Keyword, :classname
+ rule %r/template\b/, Keyword, :template
rule %r/\d+(\.\d+)?(?:h|(?:min)|s|(?:ms)|(?:us)|(?:ns))/, Num::Other
rule %r((#{dq}[.]#{dq}?|[.]#{dq})(e[+-]?#{dq}[lu]*)?)i, Num::Float
rule %r(#{dq}e[+-]?#{dq}[lu]*)i, Num::Float
rule %r/0x\h('?\h)*[lu]*/i, Num::Hex
rule %r/0b[01]+(?:_[01]+)*/, Num::Bin
@@ -74,9 +75,15 @@
# template specification
rule %r/\s*(?=>)/m, Text, :pop!
rule %r/[.]{3}/, Operator
mixin :whitespace
+ end
+
+ state :template do
+ rule %r/>/, Punctuation, :pop!
+ rule %r/typename\b/, Keyword, :classname
+ mixin :root
end
end
end
end