diff options
| author | 2024-02-19 23:38:33 +0200 | |
|---|---|---|
| committer | 2024-02-19 23:38:33 +0200 | |
| commit | d5d5f7f06397d73f497d352f2f38b1a53d932b0d (patch) | |
| tree | 63e34f5f945f4ecf28f844ee02a5a0b7fc581459 /src/Syntax.zig | |
| parent | Create parent directory if doesn't exist on save (diff) | |
| download | es-d5d5f7f06397d73f497d352f2f38b1a53d932b0d.tar.gz es-d5d5f7f06397d73f497d352f2f38b1a53d932b0d.tar.xz es-d5d5f7f06397d73f497d352f2f38b1a53d932b0d.zip | |
Big update to modern zig
Diffstat (limited to 'src/Syntax.zig')
| -rw-r--r-- | src/Syntax.zig | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/Syntax.zig b/src/Syntax.zig index 6858027..18ed477 100644 --- a/src/Syntax.zig +++ b/src/Syntax.zig | |||
| @@ -10,8 +10,7 @@ const Syntax = @This(); | |||
| 10 | 10 | ||
| 11 | pub const chooseSyntax = ComptimeStringMap( | 11 | pub const chooseSyntax = ComptimeStringMap( |
| 12 | Syntax, | 12 | Syntax, |
| 13 | pairWith(&makefile.filematch, makefile.syntax) | 13 | pairWith(&makefile.filematch, makefile.syntax) ++ pairWith(&zig.filematch, zig.syntax), |
| 14 | ++ pairWith(&zig.filematch, zig.syntax), | ||
| 15 | ).get; | 14 | ).get; |
| 16 | 15 | ||
| 17 | pub const Flags = struct { | 16 | pub const Flags = struct { |
| @@ -20,7 +19,7 @@ pub const Flags = struct { | |||
| 20 | }; | 19 | }; |
| 21 | 20 | ||
| 22 | name: []const u8, | 21 | name: []const u8, |
| 23 | keyword_classifier: fn([]const u8) ?Highlight, | 22 | keyword_classifier: *const fn ([]const u8) ?Highlight, |
| 24 | singleline_comment_start: ?[]const u8, | 23 | singleline_comment_start: ?[]const u8, |
| 25 | multiline_comment_start: ?[]const u8, | 24 | multiline_comment_start: ?[]const u8, |
| 26 | multiline_comment_end: ?[]const u8, | 25 | multiline_comment_end: ?[]const u8, |
| @@ -28,7 +27,7 @@ separators: []const u8, | |||
| 28 | flags: Flags, | 27 | flags: Flags, |
| 29 | 28 | ||
| 30 | pub fn isSeparator(self: Syntax, char: u8) bool { | 29 | pub fn isSeparator(self: Syntax, char: u8) bool { |
| 31 | return std.ascii.isSpace(char) or std.mem.indexOfScalar(u8, self.separators, char) != null; | 30 | return std.ascii.isWhitespace(char) or std.mem.indexOfScalar(u8, self.separators, char) != null; |
| 32 | } | 31 | } |
| 33 | 32 | ||
| 34 | pub fn pairWith( | 33 | pub fn pairWith( |
| @@ -37,8 +36,8 @@ pub fn pairWith( | |||
| 37 | ) [keys.len]KeyValue(@TypeOf(value)) { | 36 | ) [keys.len]KeyValue(@TypeOf(value)) { |
| 38 | @setEvalBranchQuota(20000); | 37 | @setEvalBranchQuota(20000); |
| 39 | 38 | ||
| 40 | var pairs = [_]KeyValue(@TypeOf(value)) {undefined} ** keys.len; | 39 | var pairs = [_]KeyValue(@TypeOf(value)){undefined} ** keys.len; |
| 41 | for (keys) |key, i| { | 40 | for (keys, 0..) |key, i| { |
| 42 | pairs[i] = .{ .@"0" = key, .@"1" = value }; | 41 | pairs[i] = .{ .@"0" = key, .@"1" = value }; |
| 43 | } | 42 | } |
| 44 | 43 | ||
| @@ -51,4 +50,3 @@ fn KeyValue(comptime V: type) type { | |||
| 51 | @"1": V, | 50 | @"1": V, |
| 52 | }; | 51 | }; |
| 53 | } | 52 | } |
| 54 | |||