diff options
| author | 2022-01-02 08:38:11 +0200 | |
|---|---|---|
| committer | 2022-01-02 08:38:11 +0200 | |
| commit | d13e89cbbdda9722fc636b0666adce58501d1c9b (patch) | |
| tree | 9eeddb7ac0f286aeb710789eb2dd590418d146fa /src/Syntax/zig.zig | |
| parent | Improved input (diff) | |
| download | es-d13e89cbbdda9722fc636b0666adce58501d1c9b.tar.gz es-d13e89cbbdda9722fc636b0666adce58501d1c9b.tar.xz es-d13e89cbbdda9722fc636b0666adce58501d1c9b.zip | |
Some changes in Syntax
Diffstat (limited to 'src/Syntax/zig.zig')
| -rw-r--r-- | src/Syntax/zig.zig | 95 |
1 files changed, 52 insertions, 43 deletions
diff --git a/src/Syntax/zig.zig b/src/Syntax/zig.zig index 4826bfb..c8bc225 100644 --- a/src/Syntax/zig.zig +++ b/src/Syntax/zig.zig | |||
| @@ -3,57 +3,66 @@ | |||
| 3 | const es = @import("root"); | 3 | const es = @import("root"); |
| 4 | const std = @import("std"); | 4 | const std = @import("std"); |
| 5 | 5 | ||
| 6 | const ComptimeStringMap = std.ComptimeStringMap; | ||
| 7 | const Highlight = es.Highlight; | ||
| 6 | const Syntax = es.Syntax; | 8 | const Syntax = es.Syntax; |
| 7 | 9 | ||
| 10 | pub const filematch = [_][]const u8{ | ||
| 11 | ".zig", | ||
| 12 | }; | ||
| 13 | |||
| 8 | // TODO: Add support for the multiline string \\ | 14 | // TODO: Add support for the multiline string \\ |
| 9 | pub const syntax = Syntax{ | 15 | pub const syntax = Syntax{ |
| 10 | .name = "Zig", | 16 | .name = "Zig", |
| 11 | .filematch = &[_][]const u8{ ".zig" }, | 17 | .keyword_classifier = ComptimeStringMap( |
| 12 | .keywords1 = &[_][]const u8{ | 18 | Highlight, |
| 13 | // keywords | 19 | Syntax.pairWith(&keywords1, .keyword1) ++ Syntax.pairWith(&keywords2, .keyword2), |
| 14 | "align", "allowzero", "and", "anyframe", "anytype", "asm", "async", "await", "break", | 20 | ).get, |
| 15 | "callconv", "catch", "comptime", "const", "continue", "defer", "else", "enum", "errdefer", | ||
| 16 | "error", "export", "extern", "fn", "for", "if", "inline", "noalias", "nosuspend", "noinline", | ||
| 17 | "opaque", "or", "orelse", "packed", "pub", "resume", "return", "linksection", "struct", | ||
| 18 | "suspend", "switch", "test", "threadlocal", "try", "union", "unreachable", "usingnamespace", | ||
| 19 | "var", "volatile", "while", | ||
| 20 | |||
| 21 | // primitive values | ||
| 22 | "false", "null", "true", "undefined", | ||
| 23 | }, | ||
| 24 | .keywords2 = &[_][]const u8{ | ||
| 25 | // primitive types | ||
| 26 | "i8", "u8", "i16", "u16", "i32", "u32", "i64", "u64", "i128", "u128", "isize", "usize", | ||
| 27 | "c_short", "c_ushort", "c_int", "c_uint", "c_long", "c_ulong", "c_longlong", "c_ulonglong", | ||
| 28 | "c_longdouble", "f16", "f32", "f64", "f128", "bool", "anyopaque", "void", "noreturn", "type", | ||
| 29 | "anyerror", "comptime_int", "comptime_float", | ||
| 30 | |||
| 31 | // removed types | ||
| 32 | "c_void", | ||
| 33 | |||
| 34 | // TODO: Generate all integer types | ||
| 35 | |||
| 36 | // builtin functions | ||
| 37 | "@addWithOverflow", "@alignCast", "@alignOf", "@as", "@asyncCall", "@atomicLoad", | ||
| 38 | "@atomicRmw", "@atomicStore", "@bitCast", "@bitOffsetOf", "@boolToInt", "@bitSizeOf", | ||
| 39 | "@breakpoint", "@mulAdd", "@byteSwap", "@bitReverse", "@offsetOf", "@call", "@cDefine", | ||
| 40 | "@cImport", "@cInclude", "@clz", "@cmpxchgStrong", "@cmpxchgWeak", "@compileError", | ||
| 41 | "@compileLog", "@ctz", "@cUndef", "@divExact", "@divFloor", "@divTrunc", "@embedFile", | ||
| 42 | "@enumToInt", "@errorName", "@errorReturnTrace", "@errorToInt", "@errSetCast", "@export", | ||
| 43 | "@extern", "@fence", "@field", "@fieldParentPtr", "@floatCast", "@floatToInt", "@frame", | ||
| 44 | "@Frame", "@frameAddress", "@frameSize", "@hasDecl", "@hasField", "@import", "@intCast", | ||
| 45 | "@intToEnum", "@intToError" , "@intToFloat", "@intToPtr", "@maximum", "@memcpy", "@memset", | ||
| 46 | "@minimum", "@wasmMemorySize", "@wasmMemoryGrow", "@mod", "@mulWithOverflow", "@panic", | ||
| 47 | "@popCount", "@prefetch", "@ptrCast", "@ptrToInt", "@rem", "@returnAddress", "@select", | ||
| 48 | "@setAlignStack", "@setCold", "@setEvalBranchQuota", "@setFloatMode", "@setRuntimeSafety", | ||
| 49 | "@shlExact", "@shlWithOverflow", "@shrExact", "@shuffle", "@sizeOf", "@splat", "@reduce", | ||
| 50 | "@src", "@sqrt", "@sin", "@cos", "@exp", "@exp2", "@log", "@log2", "@log10", "@fabs", | ||
| 51 | "@floor", "@ceil", "@trunc", "@round", "@subWithOverflow", "@tagName", "@This", "@truncate", | ||
| 52 | "@Type", "@typeInfo", "@typeName", "@TypeOf", "@unionInit", | ||
| 53 | }, | ||
| 54 | .singleline_comment_start = "//", | 21 | .singleline_comment_start = "//", |
| 55 | .multiline_comment_start = null, | 22 | .multiline_comment_start = null, |
| 56 | .multiline_comment_end = null, | 23 | .multiline_comment_end = null, |
| 57 | .separators = "&*^:,.=!<{[(-%|+?>}]);/~", | 24 | .separators = "&*^:,.=!<{[(-%|+?>}]);/~", |
| 58 | .flags = .{ .hl_numbers = true, .hl_strings = true }, | 25 | .flags = .{ .hl_numbers = true, .hl_strings = true }, |
| 59 | }; | 26 | }; |
| 27 | |||
| 28 | const keywords1 = [_][]const u8 { | ||
| 29 | // keywords | ||
| 30 | "align", "allowzero", "and", "anyframe", "anytype", "asm", "async", "await", "break", "callconv", | ||
| 31 | "catch", "comptime", "const", "continue", "defer", "else", "enum", "errdefer", "error", "export", | ||
| 32 | "extern", "fn", "for", "if", "inline", "noalias", "nosuspend", "noinline", "opaque", "or", | ||
| 33 | "orelse", "packed", "pub", "resume", "return", "linksection", "struct", "suspend", "switch", | ||
| 34 | "test", "threadlocal", "try", "union", "unreachable", "usingnamespace", "var", "volatile", | ||
| 35 | "while", | ||
| 36 | |||
| 37 | // primitive values | ||
| 38 | "false", "null", "true", "undefined", | ||
| 39 | }; | ||
| 40 | |||
| 41 | const keywords2 = [_][]const u8 { | ||
| 42 | // primitive types | ||
| 43 | // TODO: generate all the integer types | ||
| 44 | "i8", "u8", "i16", "u16", "i32", "u32", "i64", "u64", "i128", "u128", "isize", "usize", | ||
| 45 | "c_short", "c_ushort", "c_int", "c_uint", "c_long", "c_ulong", "c_longlong", "c_ulonglong", | ||
| 46 | "c_longdouble", "f16", "f32", "f64", "f128", "bool", "anyopaque", "void", "noreturn", "type", | ||
| 47 | "anyerror", "comptime_int", "comptime_float", | ||
| 48 | |||
| 49 | // former primitive types | ||
| 50 | "c_void", | ||
| 51 | |||
| 52 | // builtin functions | ||
| 53 | "@addWithOverflow", "@alignCast", "@alignOf", "@as", "@asyncCall", "@atomicLoad", "@atomicRmw", | ||
| 54 | "@atomicStore", "@bitCast", "@bitOffsetOf", "@boolToInt", "@bitSizeOf", "@breakpoint", "@mulAdd", | ||
| 55 | "@byteSwap", "@bitReverse", "@offsetOf", "@call", "@cDefine", "@cImport", "@cInclude", "@clz", | ||
| 56 | "@cmpxchgStrong", "@cmpxchgWeak", "@compileError", "@compileLog", "@ctz", "@cUndef", "@divExact", | ||
| 57 | "@divFloor", "@divTrunc", "@embedFile", "@enumToInt", "@errorName", "@errorReturnTrace", | ||
| 58 | "@errorToInt", "@errSetCast", "@export", "@extern", "@fence", "@field", "@fieldParentPtr", | ||
| 59 | "@floatCast", "@floatToInt", "@frame", "@Frame", "@frameAddress", "@frameSize", "@hasDecl", | ||
| 60 | "@hasField", "@import", "@intCast", "@intToEnum", "@intToError" , "@intToFloat", "@intToPtr", | ||
| 61 | "@maximum", "@memcpy", "@memset", "@minimum", "@wasmMemorySize", "@wasmMemoryGrow", "@mod", | ||
| 62 | "@mulWithOverflow", "@panic", "@popCount", "@prefetch", "@ptrCast", "@ptrToInt", "@rem", | ||
| 63 | "@returnAddress", "@select", "@setAlignStack", "@setCold", "@setEvalBranchQuota", | ||
| 64 | "@setFloatMode", "@setRuntimeSafety", "@shlExact", "@shlWithOverflow", "@shrExact", "@shuffle", | ||
| 65 | "@sizeOf", "@splat", "@reduce", "@src", "@sqrt", "@sin", "@cos", "@exp", "@exp2", "@log", | ||
| 66 | "@log2", "@log10", "@fabs", "@floor", "@ceil", "@trunc", "@round", "@subWithOverflow", | ||
| 67 | "@tagName", "@This", "@truncate", "@Type", "@typeInfo", "@typeName", "@TypeOf", "@unionInit", | ||
| 68 | }; | ||