summaryrefslogtreecommitdiff
path: root/src/Syntax
diff options
context:
space:
mode:
Diffstat (limited to 'src/Syntax')
-rw-r--r--src/Syntax/makefile.zig133
-rw-r--r--src/Syntax/zig.zig95
2 files changed, 124 insertions, 104 deletions
diff --git a/src/Syntax/makefile.zig b/src/Syntax/makefile.zig
index 5c93df4..6ae7386 100644
--- a/src/Syntax/makefile.zig
+++ b/src/Syntax/makefile.zig
@@ -1,78 +1,89 @@
1// zig fmt: off 1// zig fmt: off
2 2
3const es = @import("root"); 3const es = @import("root");
4const std = @import("std");
4 5
6const ComptimeStringMap = std.ComptimeStringMap;
7const Highlight = es.Highlight;
5const Syntax = es.Syntax; 8const Syntax = es.Syntax;
6 9
10pub const filematch = [_][]const u8{
11 "GNUmakefile", "makefile", "Makefile",
12
13 ".mk",
14};
15
7pub const syntax = Syntax{ 16pub const syntax = Syntax{
8 .name = "Makefile", 17 .name = "Makefile",
9 .filematch = &[_][]const u8{ "GNUmakefile", "makefile", "Makefile", ".mk" }, 18 .keyword_classifier = ComptimeStringMap(
10 .keywords1 = &[_][]const u8{ 19 Highlight,
11 "$@", "$(@D)", "$(@F)", 20 Syntax.pairWith(&keywords1, .keyword1) ++ Syntax.pairWith(&keywords2, .keyword2),
12 "$%", "$(%D)", "$(%F)", 21 ).get,
13 "$<", "$(<D)", "$(<F)", 22 .singleline_comment_start = "#",
14 "$?", "$(?D)", "$(?F)", 23 .multiline_comment_start = null,
15 "$^", "$(^D)", "$(^F)", 24 .multiline_comment_end = null,
16 "$+", "$(+D)", "$(+F)", 25 .separators = "(){};:-@+",
17 "$|", 26 .flags = .{},
18 "$*", "$(*D)", "$(*F)", 27};
19 28
20 ".DEFAULT", ".DEFAULT_GOAL", ".DELETE_ON_ERROR", ".EXPORT_ALL_VARIABLES", ".EXTRA_PREREQS", 29const keywords1 = [_][]const u8{
21 ".FEATURES", ".IGNORE", ".INCLUDE_DIRS", ".INTERMEDIATE", ".LIBPATTERNS", ".LOADED", 30 "$@", "$(@D)", "$(@F)",
22 ".LOW_RESOLUTION_TIME", ".NOTPARALLEL", ".ONESHELL", ".PHONY", ".POSIX", ".PRECIOUS", 31 "$%", "$(%D)", "$(%F)",
23 ".RECIPEPREFIX", ".SECONDARY", ".SECONDEXPANSION", ".SHELLFLAGS", ".SHELLSTATUS", ".SILENT", 32 "$<", "$(<D)", "$(<F)",
24 ".SUFFIXES", ".VARIABLES", 33 "$?", "$(?D)", "$(?F)",
34 "$^", "$(^D)", "$(^F)",
35 "$+", "$(+D)", "$(+F)",
36 "$*", "$(*D)", "$(*F)",
37 "$|",
25 38
26 "abspath", "addprefix", "addsuffix", "and", "basename", "call", "define", "dir", "else", 39 ".DEFAULT", ".DEFAULT_GOAL", ".DELETE_ON_ERROR", ".EXPORT_ALL_VARIABLES", ".EXTRA_PREREQS",
27 "endef", "endif", "error", "eval", "export", "file", "filter", "filter-out", "findstring", 40 ".FEATURES", ".IGNORE", ".INCLUDE_DIRS", ".INTERMEDIATE", ".LIBPATTERNS", ".LOADED",
28 "firstword", "flavor", "foreach", "gmk-eval", "gmk-expand", "guile", "if", "ifdef", "ifeq", 41 ".LOW_RESOLUTION_TIME", ".NOTPARALLEL", ".ONESHELL", ".PHONY", ".POSIX", ".PRECIOUS",
29 "ifndef", "ifneq", "include", "info", "join", "lastword", "load", "notdir", "or", "origin", 42 ".RECIPEPREFIX", ".SECONDARY", ".SECONDEXPANSION", ".SHELLFLAGS", ".SHELLSTATUS", ".SILENT",
30 "override", "patsubst", "private", "realpath", "shell", "sort", "strip", "subst", "suffix", 43 ".SUFFIXES", ".VARIABLES",
31 "undefined", "unexport", "value", "vpath", "warning", "wildcard", "word", "wordlist",
32 "words",
33 44
34 "ar", "as", "awk", "bison", "c99", "cat", "cc", "chgrp", "chmod", "chown", "cmp", "co", "cp", 45 "abspath", "addprefix", "addsuffix", "and", "basename", "call", "define", "dir", "else", "endef",
35 "ctangle", "cweave", "diff", "do", "done", "echo", "elif", "else", "egrep", "expr", "fc", 46 "endif", "error", "eval", "export", "file", "filter", "filter-out", "findstring", "firstword",
36 "for", "f77", "false", "fi", "find", "flex", "g++", "get", "grep", "gzip", "if", "in", 47 "flavor", "foreach", "gmk-eval", "gmk-expand", "guile", "if", "ifdef", "ifeq", "ifndef", "ifneq",
37 "install", "install-info", "ld", "ldconfig", "lex", "lint", "ln", "ls", "m2c", "make", 48 "include", "info", "join", "lastword", "load", "notdir", "or", "origin", "override", "patsubst",
38 "makeinfo", "mkdir", "mknod", "mv", "pc", "printf", "pwd", "ranlib", "rm", "rmdir", "sed", 49 "private", "realpath", "shell", "sort", "strip", "subst", "suffix", "undefined", "unexport",
39 "sleep", "sort", "tangle", "tar", "test", "tex", "texi2dvi", "then", "tr", "true", "touch", 50 "value", "vpath", "warning", "wildcard", "word", "wordlist", "words",
40 "weave", "yacc",
41 },
42 .keywords2 = &[_][]const u8{
43 "AR", "AS", "AWK", "BISON", "CAT", "CC", "CHGRP", "CHMOD", "CHOWN", "CMP", "CO", "CP", "CPP",
44 "CTANGLE", "CWEAVE", "CXX", "DIFF", "ECHO", "EGREP", "EXPR", "FALSE", "FC", "FIND", "FLEX",
45 "GET", "GREP", "GZIP", "INSTALL", "INSTALL_DATA", "INSTALL_INFO", "INSTALL_PROGRAM", "LD",
46 "LDCONFIG", "LEX", "LINT", "LN", "LS", "M2C", "MAKE", "MAKEINFO", "MKDIR", "MKNOD", "MV",
47 "RM", "PC", "PRINTF", "PWD", "RANLIB", "RMDIR", "SED", "SLEEP", "SORT", "TANGLE", "TAR",
48 "TEST", "TEX", "TEXI2DVI", "TOUCH", "TR", "TRUE", "WEAVE", "YACC",
49 51
50 "ARFLAGS", "BISONFLAGS", "ASFLAGS", "CFLAGS", "COFLAGS", "CPPFLAGS", "CXXFLAGS", "FFLAGS", 52 "ar", "as", "awk", "bison", "c99", "cat", "cc", "chgrp", "chmod", "chown", "cmp", "co", "cp",
51 "GFLAGS", "LDFLAGS", "LDLIBS", "LFLAGS", "LINTFLAGS", "MAKEFLAGS", "MFLAGS", "PFLAGS", 53 "ctangle", "cweave", "diff", "do", "done", "echo", "elif", "else", "egrep", "expr", "fc", "for",
52 "REALFLAGS", "YFLAGS", 54 "f77", "false", "fi", "find", "flex", "g++", "get", "grep", "gzip", "if", "in", "install",
55 "install-info", "ld", "ldconfig", "lex", "lint", "ln", "ls", "m2c", "make", "makeinfo", "mkdir",
56 "mknod", "mv", "pc", "printf", "pwd", "ranlib", "rm", "rmdir", "sed", "sleep", "sort", "tangle",
57 "tar", "test", "tex", "texi2dvi", "then", "tr", "true", "touch", "weave", "yacc",
58};
53 59
54 "COMSPEC", "CURDIR", "DESTDIR", "GPATH", "LOADLIBES", "MAKECMDGOALS", "MAKEFILES", 60const keywords2 = [_][]const u8{
55 "MAKEFILE_LIST", "MAKELEVEL", "MAKEOVERRIDES", "MAKESHELL", "MAKE_HOST", "MAKE_RESTARTS", 61 "AR", "AS", "AWK", "BISON", "CAT", "CC", "CHGRP", "CHMOD", "CHOWN", "CMP", "CO", "CP", "CPP",
56 "MAKE_TERMERR", "MAKE_TERMOUT", "MAKE_VERSION", "OUTPUT_OPTION", "SHELL", "SUFFIXES", 62 "CTANGLE", "CWEAVE", "CXX", "DIFF", "ECHO", "EGREP", "EXPR", "FALSE", "FC", "FIND", "FLEX",
57 "VPATH", 63 "GET", "GREP", "GZIP", "INSTALL", "INSTALL_DATA", "INSTALL_INFO", "INSTALL_PROGRAM", "LD",
64 "LDCONFIG", "LEX", "LINT", "LN", "LS", "M2C", "MAKE", "MAKEINFO", "MKDIR", "MKNOD", "MV", "RM",
65 "PC", "PRINTF", "PWD", "RANLIB", "RMDIR", "SED", "SLEEP", "SORT", "TANGLE", "TAR", "TEST", "TEX",
66 "TEXI2DVI", "TOUCH", "TR", "TRUE", "WEAVE", "YACC",
58 67
59 "bindir", "datadir", "datarootdir", "docdir", "dvidir", "exec_prefix", "htmldir", 68 "ARFLAGS", "BISONFLAGS", "ASFLAGS", "CFLAGS", "COFLAGS", "CPPFLAGS", "CXXFLAGS", "FFLAGS",
60 "includedir", "infodir", "libexecdir", "libdir", "lispdir", "localedir", "localstatedir", 69 "GFLAGS", "LDFLAGS", "LDLIBS", "LFLAGS", "LINTFLAGS", "MAKEFLAGS", "MFLAGS", "PFLAGS",
61 "mandir", "manext", "man1dir", "man1ext", "man2dir", "man2ext", "man3dir", "man3ext", 70 "REALFLAGS", "YFLAGS",
62 "man4dir", "man4ext", "man5dir", "man5ext", "man6dir", "man6ext", "man7dir", "man7ext",
63 "man8dir", "man8ext", "manndir", "mannext", "oldincludedir", "pdfdir", "psdir", "prefix",
64 "runstatedir", "sbindir", "srcdir", "sharedstatedir", "sysconfdir",
65 71
66 "all", "check", "clean", "dist", "distclean", "dvi", "html", "info", "install", 72 "COMSPEC", "CURDIR", "DESTDIR", "GPATH", "LOADLIBES", "MAKECMDGOALS", "MAKEFILES",
67 "install-dvi", "install-html", "install-pdf", "install-ps", "install-strip", "installcheck", 73 "MAKEFILE_LIST", "MAKELEVEL", "MAKEOVERRIDES", "MAKESHELL", "MAKE_HOST", "MAKE_RESTARTS",
68 "installdirs", "maintainer-clean", "mostlyclean", "pdf", "ps", "uninstall", "TAGS", 74 "MAKE_TERMERR", "MAKE_TERMOUT", "MAKE_VERSION", "OUTPUT_OPTION", "SHELL", "SUFFIXES", "VPATH",
69 75
70 "NORMAL_INSTALL", "NORMAL_UNINSTALL", "POST_INSTALL", "POST_UNINSTALL", "PRE_INSTALL", 76 "bindir", "datadir", "datarootdir", "docdir", "dvidir", "exec_prefix", "htmldir", "includedir",
71 "PRE_UNINSTALL" 77 "infodir", "libexecdir", "libdir", "lispdir", "localedir", "localstatedir", "mandir", "manext",
72 }, 78 "man1dir", "man1ext", "man2dir", "man2ext", "man3dir", "man3ext", "man4dir", "man4ext",
73 .singleline_comment_start = "#", 79 "man5dir", "man5ext", "man6dir", "man6ext", "man7dir", "man7ext", "man8dir", "man8ext",
74 .multiline_comment_start = null, 80 "manndir", "mannext", "oldincludedir", "pdfdir", "psdir", "prefix", "runstatedir", "sbindir",
75 .multiline_comment_end = null, 81 "srcdir", "sharedstatedir", "sysconfdir",
76 .separators = "(){};:-@+", 82
77 .flags = .{}, 83 "all", "check", "clean", "dist", "distclean", "dvi", "html", "info", "install", "install-dvi",
84 "install-html", "install-pdf", "install-ps", "install-strip", "installcheck", "installdirs",
85 "maintainer-clean", "mostlyclean", "pdf", "ps", "uninstall", "TAGS",
86
87 "NORMAL_INSTALL", "NORMAL_UNINSTALL", "POST_INSTALL", "POST_UNINSTALL", "PRE_INSTALL",
88 "PRE_UNINSTALL",
78}; 89};
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 @@
3const es = @import("root"); 3const es = @import("root");
4const std = @import("std"); 4const std = @import("std");
5 5
6const ComptimeStringMap = std.ComptimeStringMap;
7const Highlight = es.Highlight;
6const Syntax = es.Syntax; 8const Syntax = es.Syntax;
7 9
10pub const filematch = [_][]const u8{
11 ".zig",
12};
13
8// TODO: Add support for the multiline string \\ 14// TODO: Add support for the multiline string \\
9pub const syntax = Syntax{ 15pub 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
28const 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
41const 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};