Skip to content

Commit c3f9fb7

Browse files
authoredDec 9, 2021
Zig: Use standard char token (#3264)
1 parent a5b6c5e commit c3f9fb7

7 files changed

+182
-132
lines changed
 

‎components/prism-zig.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@
4949
pattern: /([\r\n])([ \t]+c?\\{2}).*(?:(?:\r\n?|\n)\2.*)*/,
5050
lookbehind: true,
5151
greedy: true
52-
},
53-
{
54-
// characters 'a', '\n', '\xFF', '\u{10FFFF}'
55-
pattern: /(^|[^\\])'(?:[^'\\\r\n]|[\uD800-\uDFFF]{2}|\\(?:.|x[a-fA-F\d]{2}|u\{[a-fA-F\d]{1,6}\}))'/,
56-
lookbehind: true,
57-
greedy: true
5852
}
5953
],
54+
'char': {
55+
// characters 'a', '\n', '\xFF', '\u{10FFFF}'
56+
pattern: /(^|[^\\])'(?:[^'\\\r\n]|[\uD800-\uDFFF]{2}|\\(?:.|x[a-fA-F\d]{2}|u\{[a-fA-F\d]{1,6}\}))'/,
57+
lookbehind: true,
58+
greedy: true
59+
},
6060
'builtin': /\B@(?!\d)\w+(?=\s*\()/,
6161
'label': {
6262
pattern: /(\b(?:break|continue)\s*:\s*)\w+\b|\b(?!\d)\w+\b(?=\s*:\s*(?:\{|while\b))/,
@@ -80,7 +80,7 @@
8080
inside: null // see below
8181
}
8282
],
83-
'builtin-types': {
83+
'builtin-type': {
8484
pattern: /\b(?:anyerror|bool|c_u?(?:int|long|longlong|short)|c_longdouble|c_void|comptime_(?:float|int)|f(?:16|32|64|128)|[iu](?:8|16|32|64|128|size)|noreturn|type|void)\b/,
8585
alias: 'keyword'
8686
},

‎components/prism-zig.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
i8
2+
u8
3+
i16
4+
u16
5+
i32
6+
u32
7+
i64
8+
u64
9+
i128
10+
u128
11+
isize
12+
usize
13+
c_short
14+
c_ushort
15+
c_int
16+
c_uint
17+
c_long
18+
c_ulong
19+
c_longlong
20+
c_ulonglong
21+
c_longdouble
22+
c_void
23+
f16
24+
f32
25+
f64
26+
f128
27+
bool
28+
void
29+
noreturn
30+
type
31+
anyerror
32+
comptime_int
33+
comptime_float
34+
35+
----------------------------------------------------
36+
37+
[
38+
["builtin-type", "i8"],
39+
["builtin-type", "u8"],
40+
["builtin-type", "i16"],
41+
["builtin-type", "u16"],
42+
["builtin-type", "i32"],
43+
["builtin-type", "u32"],
44+
["builtin-type", "i64"],
45+
["builtin-type", "u64"],
46+
["builtin-type", "i128"],
47+
["builtin-type", "u128"],
48+
["builtin-type", "isize"],
49+
["builtin-type", "usize"],
50+
["builtin-type", "c_short"],
51+
["builtin-type", "c_ushort"],
52+
["builtin-type", "c_int"],
53+
["builtin-type", "c_uint"],
54+
["builtin-type", "c_long"],
55+
["builtin-type", "c_ulong"],
56+
["builtin-type", "c_longlong"],
57+
["builtin-type", "c_ulonglong"],
58+
["builtin-type", "c_longdouble"],
59+
["builtin-type", "c_void"],
60+
["builtin-type", "f16"],
61+
["builtin-type", "f32"],
62+
["builtin-type", "f64"],
63+
["builtin-type", "f128"],
64+
["builtin-type", "bool"],
65+
["builtin-type", "void"],
66+
["builtin-type", "noreturn"],
67+
["builtin-type", "type"],
68+
["builtin-type", "anyerror"],
69+
["builtin-type", "comptime_int"],
70+
["builtin-type", "comptime_float"]
71+
]
72+
73+
----------------------------------------------------
74+
75+
Checks for builtin types.

‎tests/languages/zig/builtin-types_feature.test

-75
This file was deleted.

‎tests/languages/zig/class-name_feature.test

+80-40
Large diffs are not rendered by default.

‎tests/languages/zig/label_feature.test

+12-2
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,33 @@ fn eventuallyErrorSequence() anyerror!u32 {
2121
["boolean", "true"],
2222
["punctuation", ")"],
2323
["punctuation", "{"],
24+
2425
["keyword", "while"],
2526
["punctuation", "("],
2627
["boolean", "true"],
2728
["punctuation", ")"],
2829
["punctuation", "{"],
30+
2931
["keyword", "break"],
3032
["punctuation", ":"],
3133
["label", "outer"],
3234
["punctuation", ";"],
35+
3336
["punctuation", "}"],
37+
3438
["punctuation", "}"],
39+
3540
["keyword", "fn"],
3641
["function", "eventuallyErrorSequence"],
3742
["punctuation", "("],
3843
["punctuation", ")"],
3944
["class-name", [
40-
["builtin-types", "anyerror"],
45+
["builtin-type", "anyerror"],
4146
["operator", "!"],
42-
["builtin-types", "u32"]
47+
["builtin-type", "u32"]
4348
]],
4449
["punctuation", "{"],
50+
4551
["keyword", "return"],
4652
["keyword", "if"],
4753
["punctuation", "("],
@@ -56,17 +62,21 @@ fn eventuallyErrorSequence() anyerror!u32 {
5662
["label", "blk"],
5763
["punctuation", ":"],
5864
["punctuation", "{"],
65+
5966
"\r\n\t\tnumbers_left ",
6067
["operator", "-="],
6168
["number", "1"],
6269
["punctuation", ";"],
70+
6371
["keyword", "break"],
6472
["punctuation", ":"],
6573
["label", "blk"],
6674
" numbers_left",
6775
["punctuation", ";"],
76+
6877
["punctuation", "}"],
6978
["punctuation", ";"],
79+
7080
["punctuation", "}"]
7181
]
7282

‎tests/languages/zig/string_feature.test ‎tests/languages/zig/string_char_feature.test

+7-7
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const hello_world_in_c =
7777
["punctuation", ":"],
7878
["number", "0"],
7979
["punctuation", "]"],
80-
["builtin-types", "u8"],
80+
["builtin-type", "u8"],
8181
["punctuation", ")"],
8282
["punctuation", ";"],
8383

@@ -98,7 +98,7 @@ const hello_world_in_c =
9898
["number", "1"],
9999
["punctuation", "]"],
100100
["operator", "=="],
101-
["string", "'e'"],
101+
["char", "'e'"],
102102
["punctuation", ")"],
103103
["punctuation", ";"],
104104

@@ -115,23 +115,23 @@ const hello_world_in_c =
115115

116116
["function", "expect"],
117117
["punctuation", "("],
118-
["string", "'e'"],
118+
["char", "'e'"],
119119
["operator", "=="],
120-
["string", "'\\x65'"],
120+
["char", "'\\x65'"],
121121
["punctuation", ")"],
122122
["punctuation", ";"],
123123

124124
["function", "expect"],
125125
["punctuation", "("],
126-
["string", "'\\u{1f4a9}'"],
126+
["char", "'\\u{1f4a9}'"],
127127
["operator", "=="],
128128
["number", "128169"],
129129
["punctuation", ")"],
130130
["punctuation", ";"],
131131

132132
["function", "expect"],
133133
["punctuation", "("],
134-
["string", "'💯'"],
134+
["char", "'💯'"],
135135
["operator", "=="],
136136
["number", "128175"],
137137
["punctuation", ")"],
@@ -143,7 +143,7 @@ const hello_world_in_c =
143143
["punctuation", "."],
144144
["function", "eql"],
145145
["punctuation", "("],
146-
["builtin-types", "u8"],
146+
["builtin-type", "u8"],
147147
["punctuation", ","],
148148
["string", "\"hello\""],
149149
["punctuation", ","],

0 commit comments

Comments
 (0)
Please sign in to comment.