pub const makefile = @import("Syntax/makefile.zig"); pub const zig = @import("Syntax/zig.zig"); const es = @import("root"); const std = @import("std"); const ComptimeStringMap = std.ComptimeStringMap; const Highlight = es.Highlight; const Syntax = @This(); pub const chooseSyntax = ComptimeStringMap( Syntax, pairWith(&makefile.filematch, makefile.syntax) ++ pairWith(&zig.filematch, zig.syntax), ).get; pub const Flags = struct { hl_numbers: bool = false, hl_strings: bool = false, }; name: []const u8, keyword_classifier: fn([]const u8) ?Highlight, singleline_comment_start: ?[]const u8, multiline_comment_start: ?[]const u8, multiline_comment_end: ?[]const u8, separators: []const u8, flags: Flags, pub fn isSeparator(self: Syntax, char: u8) bool { return std.ascii.isSpace(char) or std.mem.indexOfScalar(u8, self.separators, char) != null; } pub fn pairWith( comptime keys: []const []const u8, comptime value: anytype, ) [keys.len]KeyValue(@TypeOf(value)) { @setEvalBranchQuota(20000); var pairs = [_]KeyValue(@TypeOf(value)) {undefined} ** keys.len; for (keys) |key, i| { pairs[i] = .{ .@"0" = key, .@"1" = value }; } return pairs; } fn KeyValue(comptime V: type) type { return struct { @"0": []const u8, @"1": V, }; }