@@ -2,29 +2,30 @@ module CodeRay
2
2
module Scanners
3
3
4
4
# Scanner for C++.
5
- #
5
+ #
6
6
# Aliases: +cplusplus+, c++
7
7
class CPlusPlus < Scanner
8
8
9
9
register_for :cpp
10
10
file_extension 'cpp'
11
11
title 'C++'
12
-
12
+
13
13
#-- http://www.cppreference.com/wiki/keywords/start
14
14
KEYWORDS = [
15
15
'and' , 'and_eq' , 'asm' , 'bitand' , 'bitor' , 'break' ,
16
16
'case' , 'catch' , 'class' , 'compl' , 'const_cast' ,
17
17
'continue' , 'default' , 'delete' , 'do' , 'dynamic_cast' , 'else' ,
18
18
'enum' , 'export' , 'for' , 'goto' , 'if' , 'namespace' , 'new' ,
19
19
'not' , 'not_eq' , 'or' , 'or_eq' , 'reinterpret_cast' , 'return' ,
20
- 'sizeof' , 'static_cast ' , 'struct ' , 'switch ' , 'template ' ,
21
- 'throw' , 'try' , 'typedef' , 'typeid' , 'typename' , 'union' ,
20
+ 'sizeof' , 'static_assert ' , 'static_cast ' , 'struct ' , 'switch ' ,
21
+ 'template' , ' throw', 'try' , 'typedef' , 'typeid' , 'typename' , 'union' ,
22
22
'while' , 'xor' , 'xor_eq' ,
23
23
] # :nodoc:
24
-
24
+
25
25
PREDEFINED_TYPES = [
26
- 'bool' , 'char' , 'double' , 'float' , 'int' , 'long' ,
27
- 'short' , 'signed' , 'unsigned' , 'wchar_t' , 'string' ,
26
+ 'bool' , 'char' , 'char16_t' , 'char32_t' , 'double' , 'float' ,
27
+ 'int' , 'long' , 'nullptr' 'short' , 'signed' , 'unsigned' ,
28
+ 'wchar_t' , 'string' ,
28
29
] # :nodoc:
29
30
PREDEFINED_CONSTANTS = [
30
31
'false' , 'true' ,
@@ -34,11 +35,12 @@ class CPlusPlus < Scanner
34
35
'this' ,
35
36
] # :nodoc:
36
37
DIRECTIVES = [
37
- 'auto' , 'const' , 'explicit' , 'extern' , 'friend' , 'inline' , 'mutable' , 'operator' ,
38
- 'private' , 'protected' , 'public' , 'register' , 'static' , 'using' , 'virtual' , 'void' ,
39
- 'volatile' ,
38
+ 'alignas' , 'alignof' , 'auto' , 'const' , 'constexpr' , 'decltype' , 'explicit' ,
39
+ 'extern' , 'final' , 'friend' , 'inline' , 'mutable' , 'noexcept' , 'operator' ,
40
+ 'override' , 'private' , 'protected' , 'public' , 'register' , 'static' ,
41
+ 'thread_local' , 'using' , 'virtual' , 'void' , 'volatile' ,
40
42
] # :nodoc:
41
-
43
+
42
44
IDENT_KIND = WordList . new ( :ident ) .
43
45
add ( KEYWORDS , :keyword ) .
44
46
add ( PREDEFINED_TYPES , :predefined_type ) .
@@ -48,9 +50,9 @@ class CPlusPlus < Scanner
48
50
49
51
ESCAPE = / [rbfntv\n \\ '"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x # :nodoc:
50
52
UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc:
51
-
53
+
52
54
protected
53
-
55
+
54
56
def scan_tokens encoder , options
55
57
56
58
state = :initial
@@ -107,7 +109,7 @@ def scan_tokens encoder, options
107
109
108
110
elsif match = scan ( /\$ / )
109
111
encoder . text_token match , :ident
110
-
112
+
111
113
elsif match = scan ( /L?"/ )
112
114
encoder . begin_group :string
113
115
if match [ 0 ] == ?L
@@ -180,7 +182,7 @@ def scan_tokens encoder, options
180
182
state = :initial
181
183
182
184
end
183
-
185
+
184
186
when :class_name_expected
185
187
if match = scan ( / [A-Za-z_][A-Za-z_0-9]* /x )
186
188
encoder . text_token match , :class
@@ -194,7 +196,7 @@ def scan_tokens encoder, options
194
196
state = :initial
195
197
196
198
end
197
-
199
+
198
200
else
199
201
raise_inspect 'Unknown state' , encoder
200
202
0 commit comments