/usr/lib/ruby/vendor_ruby/rugments/lexers/cpp.rb is in ruby-rugments 1.0.0~beta8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | module Rugments
module Lexers
load_const :C, 'c.rb'
class Cpp < C
title 'C++'
desc 'The C++ programming language'
tag 'cpp'
aliases 'c++'
# the many varied filenames of c++ source files...
filenames '*.cpp', '*.hpp',
'*.c++', '*.h++',
'*.cc', '*.hh',
'*.cxx', '*.hxx'
mimetypes 'text/x-c++hdr', 'text/x-c++src'
def self.keywords
@keywords ||= super + Set.new(%w(
asm catch const_cast delete dynamic_cast explicit export
friend mutable namespace new operator private protected public
reinterpret_cast restrict static_cast template this throw
throws typeid typename using virtual
))
end
def self.reserved
@reserved ||= super + Set.new(%w(
__virtual_inheritance __uuidof __super __single_inheritance
__multiple_inheritance __interface __event
))
end
id = /[a-zA-Z_][a-zA-Z0-9]*/
prepend :root do
# Offload C++ extensions, http://offload.codeplay.com/
rule /(?:__offload|__blockingoffload|__outer)\b/, Keyword::Pseudo
end
# 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 /class\b/, Keyword, :classname
rule %r{(#{dq}[.]#{dq}?|[.]#{dq})(e[+-]?#{dq}[lu]*)?}i, Num::Float
rule %r{#{dq}e[+-]?#{dq}[lu]*}i, Num::Float
rule /0x\h('?\h)*[lu]*/i, Num::Hex
rule /0[0-7]('?[0-7])*[lu]*/i, Num::Oct
rule /#{dq}[lu]*/i, Num::Integer
end
state :classname do
rule id, Name::Class, :pop!
# template specification
rule /\s*(?=>)/m, Text, :pop!
mixin :whitespace
end
end
end
end
|