-
Notifications
You must be signed in to change notification settings - Fork 662
Expand file tree
/
Copy pathcpp.lsh
More file actions
66 lines (64 loc) · 2.41 KB
/
cpp.lsh
File metadata and controls
66 lines (64 loc) · 2.41 KB
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
64
65
66
#[display_name = "C++"]
#[path = "**/*.cpp"]
#[path = "**/*.hpp"]
#[path = "**/*.cc"]
#[path = "**/*.cxx"]
#[path = "**/*.hxx"]
pub fn cpp() {
until /$/ {
yield other;
if /\/\/.*/ {
yield comment;
} else if /\/\*/ {
loop {
yield comment;
await input;
if /\*\// {
yield comment;
break;
}
}
} else if /"/ {
until /$/ {
yield string;
if /\\./ {
// Skip escaped characters
} else if /"/ {
yield string;
break;
}
await input;
}
} else if /'/ {
until /$/ {
yield string;
if /\\./ {
// Skip escaped characters
} else if /'/ {
yield string;
break;
}
await input;
}
} else if /#\s*(?:include|define|undef|if|ifdef|ifndef|elif|else|endif|error|pragma|warning|line)\>/ {
yield keyword.control;
} else if /(?:break|case|catch|continue|default|do|else|for|goto|if|return|switch|throw|try|while)\>/ {
yield keyword.control;
} else if /(?:alignas|alignof|asm|auto|bool|char|char16_t|char32_t|char8_t|class|concept|const|const_cast|consteval|constexpr|constinit|decltype|delete|double|dynamic_cast|enum|explicit|export|extern|float|friend|inline|int|long|mutable|namespace|new|noexcept|operator|private|protected|public|register|reinterpret_cast|requires|short|signed|sizeof|static|static_assert|static_cast|struct|template|this|thread_local|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t)\>/ {
yield keyword.other;
} else if /(?:true|false|NULL|nullptr)\>/ {
yield constant.language;
} else if /(?i:-?(?:0x[\da-fA-F']+|0b[01']+|[\d']+\.?[\d']*|\.[\d']+)(?:p[+-]?[\d']+|e[+-]?[\d']+)?[ulfz]*)/ {
if /\w+/ {
// Invalid numeric literal
} else {
yield constant.numeric;
}
} else if /(\w+)\s*\(/ {
yield $1 as method;
} else if /\w+/ {
// Gobble word chars to align the next iteration on a word boundary.
}
yield other;
}
}