From 73093f9497f1f6db1407801a2f110b2ab4b67918 Mon Sep 17 00:00:00 2001 From: Antonino Siena Date: Sat, 6 Jul 2019 07:51:12 +0200 Subject: [PATCH] Added Ziglang syntax support (#1354) * Added Ziglang syntax support * Removed unused constant string markup * Added 'fn' as keyword * Added constant matching ending with numbers and proper hexadecimal matching * Added missing types * Added all keywords in alphabetical order --- runtime/syntax/zig.yaml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 runtime/syntax/zig.yaml diff --git a/runtime/syntax/zig.yaml b/runtime/syntax/zig.yaml new file mode 100644 index 00000000..5c748626 --- /dev/null +++ b/runtime/syntax/zig.yaml @@ -0,0 +1,37 @@ +filetype: zig + +detect: + filename: "\\.zig$" + +rules: + # function definition + - identifier: "fn [a-z0-9_]+" + # Reserved words + - statement: "\\b(align|and|allowzero|anyerror|asm|async|await|break|cancel|catch|comptime|const|continue|defer|else|enum|errdefer|error|export|extern|false|fn|for|if|inline|nakedcc|noalias|null|or|orelse|packed|promise|pub|resume|return|linksection|stdcallcc|struct|suspend|switch|test|threadlocal|true|try|undefined|union|unreachable|use|var|volatile|while)\\b" + # builtin functions + - special: "@+[a-z_]+" + # Constants + - constant: "[A-Z][A-Z_]+([0-9]+)?" + # Numbers (hexadecimal + decimal) + - constant.number: "\\b(0x[A-F0-9]+|[0-9]+)\\b" + # Primitive Types / Derived Data Types + - type: "([A-Z][a-z]+|(i8|u8|i16|u16|i32|u32|i64|u64|i128|u128|isize|usize|c_short|c_ushort|c_int|c_uint|c_long|c_ulong|c_longlong|c_ulonglong|c_longdouble|c_void|f16|f32|f64|f128|bool|void|noreturn|type|anyerror|comptime_int|comptime_float))" + + - constant.string: + start: "\"" + end: "\"" + skip: "\\\\." + rules: + - constant.specialChar: "\\\\." + + - comment: + start: "//" + end: "$" + rules: + - todo: "(TODO|XXX|FIXME):?" + + - comment: + start: "/\\*" + end: "\\*/" + rules: + - todo: "(TODO|XXX|FIXME):?"