From b8d9c95e48e216a6e98f847d33b87c922e339a68 Mon Sep 17 00:00:00 2001 From: Aiden Fox Ivey Date: Sat, 10 Aug 2024 22:03:31 -0400 Subject: [PATCH] Revert "Remove textmate language files" This reverts commit 592332da570bd00a284bb8ae9efb2fa21d701291. --- Syntaxes/Zig.YAML-tmLanguage | 384 +++++++++++++++ Syntaxes/Zig.tmLanguage | 882 ++++++++++++++++++++++++++++++++++ Syntaxes/Zig.tmLanguage.json | 551 ++++++++++++++++++++++ Syntaxes/Zon.YAML-tmLanguage | 390 +++++++++++++++ Syntaxes/Zon.tmLanguage | 892 +++++++++++++++++++++++++++++++++++ 5 files changed, 3099 insertions(+) create mode 100644 Syntaxes/Zig.YAML-tmLanguage create mode 100644 Syntaxes/Zig.tmLanguage create mode 100644 Syntaxes/Zig.tmLanguage.json create mode 100644 Syntaxes/Zon.YAML-tmLanguage create mode 100644 Syntaxes/Zon.tmLanguage diff --git a/Syntaxes/Zig.YAML-tmLanguage b/Syntaxes/Zig.YAML-tmLanguage new file mode 100644 index 0000000..ccce12c --- /dev/null +++ b/Syntaxes/Zig.YAML-tmLanguage @@ -0,0 +1,384 @@ +# [PackageDev] target_format: plist, ext: tmLanguage +# [PackageDev] target_format: json, ext: tmLanguage.json + +name: Zig +uuid: 06C2FF99-3080-441A-9019-460C51E93116 +scopeName: source.zig +fileTypes: + - zig + +patterns: + - include: '#dummy_main' + +repository: + character_escapes: + patterns: + - name: constant.character.escape.newline.zig + match: \\n + - name: constant.character.escape.carrigereturn.zig + match: \\r + - name: constant.character.escape.tabulator.zig + match: \\t + - name: constant.character.escape.backslash.zig + match: \\\\ + - name: constant.character.escape.single-quote.zig + match: \\' + - name: constant.character.escape.double-quote.zig + match: \\\" + - name: constant.character.escape.hexidecimal.zig + match: \\x[a-fA-F\d]{2} + - name: constant.character.escape.hexidecimal.zig + match: \\u\{[a-fA-F\d]{1,6}\} + + param_list: + begin: '([a-zA-Z_]\w*|@\".+\")\s*(:)\s*' + beginCaptures: + '1': + name: variable.parameter.zig + '2': + name: punctuation.separator.zig + + end: '([a-zA-Z_][\w.]*|@\".+\")?\s*(?:(,)|(\)))' + endCaptures: + '1': + name: storage.type.zig + '2': + name: punctuation.separator.zig + '3': + name: punctuation.section.parens.end.zig + + patterns: + - include: '#dummy_main' + + - match: '([a-zA-Z_][\w.]*|@\".+\")' + name: storage.type.zig + + field_decl: + begin: '([a-zA-Z_]\w*|@\".+\")\s*(:)\s*' + beginCaptures: + '1': + name: variable.other.member.zig + '2': + name: punctuation.separator.zig + + end: '([a-zA-Z_][\w.]*|@\".+\")?\s*(?:(,)|(=)|$)' + endCaptures: + '1': + name: storage.type.zig + '2': + name: punctuation.separator.zig + '3': + name: keyword.operator.assignment.zig + + patterns: + - include: '#dummy_main' + + storage_modifier: + name: storage.modifier.zig + match: '\b(const|var|extern|packed|export|pub|noalias|inline|noinline|comptime|volatile|align|linksection|threadlocal|allowzero)\b' + + container_decl: + patterns: + - match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:union)\s*[(\{])' + name: entity.name.union.zig + + - match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:struct)\s*[(\{])' + name: entity.name.struct.zig + + - match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:enum)\s*[(\{])' + name: entity.name.enum.zig + + - match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:error)\s*[(\{])' + name: entity.name.error.zig + + - match: '\b(error)(\.)([a-zA-Z_]\w*|@\".+\")' + captures: + '1': + name: storage.type.error.zig + '2': + name: punctuation.accessor.zig + '3': + name: entity.name.error.zig + + constants: + patterns: + - name: constant.language.zig + match: '\b(null|undefined|true|false)\b' + + - name: constant.numeric.integer.zig + match: '\b(?|<)=?)' + + - name: keyword.operator.word.zig + match: '\b(and|or)\b' + + - name: keyword.operator.assignment.zig + match: '((?:(?:\+|-|\*)\%?|/|%|<<|>>|&|\|(?=[^\|])|\^)?=)' + + - name: keyword.operator.arithmetic.zig + match: '((?:\+|-|\*)\%?|/(?!/)|%)' + + - name: keyword.operator.bitwise.zig + match: '(<<|>>|&(?=[a-zA-Z_]|@\")|\|(?=[^\|])|\^|~)' + + - name: keyword.operator.other.zig + match: '(\+\+|\*\*|->|\.\?|\.\*|&(?=[a-zA-Z_]|@\")|\?|\|\||\.{2,3})' + + support: + name: support.function.zig + match: '(?)?\s*(?:([a-zA-Z_][\w.]*|@\".+\")\b(?!\s*\())?' + captures: + '1': + name: storage.type.zig + '2': + name: keyword.operator.zig + '3': + name: storage.type.zig + + - name: storage.type.function.zig + match: '\bfn\b' + + - name: storage.type.test.zig + match: '\btest\b' + + - name: storage.type.struct.zig + match: '\bstruct\b' + + - name: storage.type.enum.zig + match: '\benum\b' + + - name: storage.type.union.zig + match: '\bunion\b' + + - name: storage.type.error.zig + match: '\berror\b' + + punctuation: + patterns: + - name: punctuation.separator.zig + match: ',' + + - name: punctuation.terminator.zig + match: ';' + + - match: '(\()' + name: punctuation.section.parens.begin.zig + + - match: '(\))' + name: punctuation.section.parens.end.zig + + label: + match: '\b(break|continue)\s*:\s*([a-zA-Z_]\w*|@\".+\")\b|\b(?!\d)([a-zA-Z_]\w*|@\".+\")\b(?=\s*:\s*(?:\{|while\b))' + captures: + '1': + name: keyword.control.zig + '2': + name: entity.name.label.zig + '3': + name: entity.name.label.zig + + block: + begin: '([a-zA-Z_][\w.]*|@\".+\")?\s*(\{)' + beginCaptures: + '1': + name: storage.type.zig + '2': + name: punctuation.section.braces.begin.zig + + end: '(\})' + endCaptures: + '1': + name: punctuation.section.braces.end.zig + + patterns: + - include: '#dummy_main' + + function_def: + begin: '(?<=fn)\s+([a-zA-Z_]\w*|@\".+\")(\()' + beginCaptures: + '1': + name: entity.name.function + '2': + name: punctuation.section.parens.begin.zig + + end: '(?<=\)[^\)])\s*([a-zA-Z_][\w.]*|@\".+\")?(!)?\s*(?:([a-zA-Z_][\w.]*|@\".+\")\b(?!\s*\())?' + endCaptures: + '1': + name: storage.type.zig + '2': + name: keyword.operator.zig + '3': + name: storage.type.zig + + patterns: + - include: '#label' + - include: '#param_list' + + - match: '([a-zA-Z_][\w.]*|@\".+\")' + name: storage.type.zig + + - include: '#dummy_main' + + function_call: + name: variable.function.zig + match: '(?])' + name: constant.language.enum + + variables: + name: meta.variable.zig + patterns: + - match: '\b[_A-Z][_A-Z0-9]+\b' + name: variable.constant.zig + + - match: '\b[_a-zA-Z][_a-zA-Z0-9]*_t\b' + name: entity.name.type.zig + + - match: '\b[A-Z][a-zA-Z0-9]*\b' + name: entity.name.type.zig + + - match: '\b[_a-zA-Z][_a-zA-Z0-9]*\b' + name: variable.zig + + dummy_main: + patterns: + - include: '#label' + - include: '#function_type' + - include: '#punctuation' + - include: '#storage_modifier' + - include: '#container_decl' + - include: '#constants' + - include: '#comments' + - include: '#strings' + - include: '#storage' + - include: '#keywords' + - include: '#operators' + - include: '#support' + - include: '#field_decl' + - include: '#block' + - include: '#function_def' + - include: '#function_call' + - include: '#enum_literal' + - include: '#variables' diff --git a/Syntaxes/Zig.tmLanguage b/Syntaxes/Zig.tmLanguage new file mode 100644 index 0000000..5245d69 --- /dev/null +++ b/Syntaxes/Zig.tmLanguage @@ -0,0 +1,882 @@ + + + + + fileTypes + + zig + + keyEquivalent + ^~Z + name + Zig + patterns + + + include + #dummy_main + + + repository + + block + + begin + ([a-zA-Z_][\w.]*|@\".+\")?\s*(\{) + beginCaptures + + 1 + + name + storage.type.zig + + 2 + + name + punctuation.section.braces.begin.zig + + + end + (\}) + endCaptures + + 1 + + name + punctuation.section.braces.end.zig + + + patterns + + + include + #dummy_main + + + + character_escapes + + patterns + + + match + \\n + name + constant.character.escape.newline.zig + + + match + \\r + name + constant.character.escape.carrigereturn.zig + + + match + \\t + name + constant.character.escape.tabulator.zig + + + match + \\\\ + name + constant.character.escape.backslash.zig + + + match + \\' + name + constant.character.escape.single-quote.zig + + + match + \\\" + name + constant.character.escape.double-quote.zig + + + match + \\x[a-fA-F\d]{2} + name + constant.character.escape.hexidecimal.zig + + + match + \\u\{[a-fA-F\d]{1,6}\} + name + constant.character.escape.hexidecimal.zig + + + + comments + + patterns + + + begin + /// + end + $\n? + name + comment.line.documentation.zig + + + begin + //[^/]\s*TODO + end + $\n? + name + comment.line.todo.zig + + + begin + //[^/]* + end + $\n? + name + comment.line.zig + + + + constants + + patterns + + + match + \b(null|undefined|true|false)\b + name + constant.language.zig + + + match + \b(?<!\.)(-?[\d_]+)(?!\.)\b + name + constant.numeric.integer.zig + + + match + \b(?<!\.)(0x[a-fA-F\d_]+)(?!\.)\b + name + constant.numeric.integer.hexadecimal.zig + + + match + \b(?<!\.)(0o[0-7_]+)(?!\.)\b + name + constant.numeric.integer.octal.zig + + + match + \b(?<!\.)(0b[01_]+)(?!\.)\b + name + constant.numeric.integer.binary.zig + + + match + (?<!\.)(-?\b[\d_]+(?:\.[\d_]+)?(?:[eE][+-]?[\d_]+)?)(?!\.)\b + name + constant.numeric.float.zig + + + match + (?<!\.)(-?\b0x[a-fA-F\d_]+(?:\.[a-fA-F\d_]+)?[pP]?(?:[+-]?[\d_]+)?)(?!\.)\b + name + constant.numeric.float.hexadecimal.zig + + + + container_decl + + patterns + + + match + \b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:union)\s*[(\{]) + name + entity.name.union.zig + + + match + \b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:struct)\s*[(\{]) + name + entity.name.struct.zig + + + match + \b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:enum)\s*[(\{]) + name + entity.name.enum.zig + + + match + \b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:error)\s*[(\{]) + name + entity.name.error.zig + + + captures + + 1 + + name + storage.type.error.zig + + 2 + + name + punctuation.accessor.zig + + 3 + + name + entity.name.error.zig + + + match + \b(error)(\.)([a-zA-Z_]\w*|@\".+\") + + + + dummy_main + + patterns + + + include + #label + + + include + #function_type + + + include + #punctuation + + + include + #storage_modifier + + + include + #container_decl + + + include + #constants + + + include + #comments + + + include + #strings + + + include + #storage + + + include + #keywords + + + include + #operators + + + include + #support + + + include + #field_decl + + + include + #block + + + include + #function_def + + + include + #function_call + + + include + #enum_literal + + + include + #variables + + + + enum_literal + + match + (?<!\w|\)|\?|\}|\]|\*)(\.(?:[a-zA-Z_]\w*\b|@\"[^\"]*\"))(?!\(|\s*=[^=>]) + name + constant.language.enum + + field_decl + + begin + ([a-zA-Z_]\w*|@\".+\")\s*(:)\s* + beginCaptures + + 1 + + name + variable.other.member.zig + + 2 + + name + punctuation.separator.zig + + + end + ([a-zA-Z_][\w.]*|@\".+\")?\s*(?:(,)|(=)|$) + endCaptures + + 1 + + name + storage.type.zig + + 2 + + name + punctuation.separator.zig + + 3 + + name + keyword.operator.assignment.zig + + + patterns + + + include + #dummy_main + + + + function_call + + match + (?<!fn)\b([a-zA-Z_]\w*|@\".+\")(?=\s*\() + name + variable.function.zig + + function_def + + begin + (?<=fn)\s+([a-zA-Z_]\w*|@\".+\")(\() + beginCaptures + + 1 + + name + entity.name.function + + 2 + + name + punctuation.section.parens.begin.zig + + + end + (?<=\)[^\)])\s*([a-zA-Z_][\w.]*|@\".+\")?(!)?\s*(?:([a-zA-Z_][\w.]*|@\".+\")\b(?!\s*\())? + endCaptures + + 1 + + name + storage.type.zig + + 2 + + name + keyword.operator.zig + + 3 + + name + storage.type.zig + + + patterns + + + include + #label + + + include + #param_list + + + match + ([a-zA-Z_][\w.]*|@\".+\") + name + storage.type.zig + + + include + #dummy_main + + + + function_type + + begin + \b(fn)\s*(\() + beginCaptures + + 1 + + name + storage.type.function.zig + + 2 + + name + punctuation.section.parens.begin.zig + + + contentName + meta.function.parameters.zig + end + (?<=\)|\})\s*([a-zA-Z_][\w.]*|@\".+\")?\s*(!)?\s*([a-zA-Z_][\w.]*|@\".+\") + endCaptures + + 1 + + name + storage.type.zig + + 2 + + name + keyword.operator.zig + + 3 + + name + storage.type.zig + + + patterns + + + include + #label + + + include + #param_list + + + match + ([a-zA-Z_][\w.]*|@\".+\") + name + storage.type.zig + + + include + #dummy_main + + + + keywords + + patterns + + + match + \b(while|for|break|return|continue|asm|defer|errdefer|unreachable)\b + name + keyword.control.zig + + + match + \b(async|await|suspend|nosuspend|resume)\b + name + keyword.control.async.zig + + + match + \b(if|else|switch|try|catch|orelse)\b + name + keyword.control.conditional.zig + + + match + (?<!\w)(@import|@cImport|@cInclude)\b + name + keyword.control.import.zig + + + match + \b(usingnamespace)\b + name + keyword.other.usingnamespace.zig + + + + label + + captures + + 1 + + name + keyword.control.zig + + 2 + + name + entity.name.label.zig + + 3 + + name + entity.name.label.zig + + + match + \b(break|continue)\s*:\s*([a-zA-Z_]\w*|@\".+\")\b|\b(?!\d)([a-zA-Z_]\w*|@\".+\")\b(?=\s*:\s*(?:\{|while\b)) + + operators + + patterns + + + match + \b!\b + name + keyword.operator.zig + + + match + (==|(?:!|>|<)=?) + name + keyword.operator.logical.zig + + + match + \b(and|or)\b + name + keyword.operator.word.zig + + + match + ((?:(?:\+|-|\*)\%?|/|%|<<|>>|&|\|(?=[^\|])|\^)?=) + name + keyword.operator.assignment.zig + + + match + ((?:\+|-|\*)\%?|/(?!/)|%) + name + keyword.operator.arithmetic.zig + + + match + (<<|>>|&(?=[a-zA-Z_]|@\")|\|(?=[^\|])|\^|~) + name + keyword.operator.bitwise.zig + + + match + (\+\+|\*\*|->|\.\?|\.\*|&(?=[a-zA-Z_]|@\")|\?|\|\||\.{2,3}) + name + keyword.operator.other.zig + + + + param_list + + begin + ([a-zA-Z_]\w*|@\".+\")\s*(:)\s* + beginCaptures + + 1 + + name + variable.parameter.zig + + 2 + + name + punctuation.separator.zig + + + end + ([a-zA-Z_][\w.]*|@\".+\")?\s*(?:(,)|(\))) + endCaptures + + 1 + + name + storage.type.zig + + 2 + + name + punctuation.separator.zig + + 3 + + name + punctuation.section.parens.end.zig + + + patterns + + + include + #dummy_main + + + match + ([a-zA-Z_][\w.]*|@\".+\") + name + storage.type.zig + + + + punctuation + + patterns + + + match + , + name + punctuation.separator.zig + + + match + ; + name + punctuation.terminator.zig + + + match + (\() + name + punctuation.section.parens.begin.zig + + + match + (\)) + name + punctuation.section.parens.end.zig + + + + storage + + patterns + + + match + \b(bool|void|noreturn|type|anyerror|anytype)\b + name + storage.type.zig + + + match + \b(?<!\.)([iu]\d+|[iu]size|comptime_int)\b + name + storage.type.integer.zig + + + match + \b(f16|f32|f64|f128|comptime_float)\b + name + storage.type.float.zig + + + match + \b(c_short|c_ushort|c_int|c_uint|c_long|c_ulong|c_longlong|c_ulonglong|c_longdouble|c_void)\b + name + storage.type.c_compat.zig + + + captures + + 1 + + name + storage.type.zig + + 2 + + name + keyword.operator.zig + + 3 + + name + storage.type.zig + + + match + \b(anyframe)\b\s*(->)?\s*(?:([a-zA-Z_][\w.]*|@\".+\")\b(?!\s*\())? + + + match + \bfn\b + name + storage.type.function.zig + + + match + \btest\b + name + storage.type.test.zig + + + match + \bstruct\b + name + storage.type.struct.zig + + + match + \benum\b + name + storage.type.enum.zig + + + match + \bunion\b + name + storage.type.union.zig + + + match + \berror\b + name + storage.type.error.zig + + + + storage_modifier + + match + \b(const|var|extern|packed|export|pub|noalias|inline|noinline|comptime|volatile|align|linksection|threadlocal|allowzero)\b + name + storage.modifier.zig + + strings + + patterns + + + begin + \' + end + \' + name + string.quoted.single.zig + patterns + + + include + #character_escapes + + + match + \\[^\'][^\']*? + name + invalid.illegal.character.zig + + + + + begin + c?\" + end + \" + name + string.quoted.double.zig + patterns + + + include + #character_escapes + + + match + \\[^\'][^\']*? + name + invalid.illegal.character.zig + + + + + begin + c?\\\\ + end + $\n? + name + string.quoted.other.zig + + + + support + + match + (?<!\w)@[^\"\d][a-zA-Z_]\w*\b + name + support.function.zig + + variables + + name + meta.variable.zig + patterns + + + match + \b[_A-Z][_A-Z0-9]+\b + name + variable.constant.zig + + + match + \b[_a-zA-Z][_a-zA-Z0-9]*_t\b + name + entity.name.type.zig + + + match + \b[A-Z][a-zA-Z0-9]*\b + name + entity.name.type.zig + + + match + \b[_a-zA-Z][_a-zA-Z0-9]*\b + name + variable.zig + + + + + scopeName + source.zig + uuid + 06C2FF99-3080-441A-9019-460C51E93116 + + diff --git a/Syntaxes/Zig.tmLanguage.json b/Syntaxes/Zig.tmLanguage.json new file mode 100644 index 0000000..975b9b8 --- /dev/null +++ b/Syntaxes/Zig.tmLanguage.json @@ -0,0 +1,551 @@ +{ + "scopeName": "source.zig", + "fileTypes": [ + "zig" + ], + "uuid": "06C2FF99-3080-441A-9019-460C51E93116", + "patterns": [ + { + "include": "#dummy_main" + } + ], + "repository": { + "operators": { + "patterns": [ + { + "match": "\\b!\\b", + "name": "keyword.operator.zig" + }, + { + "match": "(==|(?:!|>|<)=?)", + "name": "keyword.operator.logical.zig" + }, + { + "match": "\\b(and|or)\\b", + "name": "keyword.operator.word.zig" + }, + { + "match": "((?:(?:\\+|-|\\*)\\%?|/|%|<<|>>|&|\\|(?=[^\\|])|\\^)?=)", + "name": "keyword.operator.assignment.zig" + }, + { + "match": "((?:\\+|-|\\*)\\%?|/(?!/)|%)", + "name": "keyword.operator.arithmetic.zig" + }, + { + "match": "(<<|>>|&(?=[a-zA-Z_]|@\\\")|\\|(?=[^\\|])|\\^|~)", + "name": "keyword.operator.bitwise.zig" + }, + { + "match": "(\\+\\+|\\*\\*|->|\\.\\?|\\.\\*|&(?=[a-zA-Z_]|@\\\")|\\?|\\|\\||\\.{2,3})", + "name": "keyword.operator.other.zig" + } + ] + }, + "support": { + "match": "(?)?\\s*(?:([a-zA-Z_][\\w.]*|@\\\".+\\\")\\b(?!\\s*\\())?" + }, + { + "match": "\\bfn\\b", + "name": "storage.type.function.zig" + }, + { + "match": "\\btest\\b", + "name": "storage.type.test.zig" + }, + { + "match": "\\bstruct\\b", + "name": "storage.type.struct.zig" + }, + { + "match": "\\benum\\b", + "name": "storage.type.enum.zig" + }, + { + "match": "\\bunion\\b", + "name": "storage.type.union.zig" + }, + { + "match": "\\berror\\b", + "name": "storage.type.error.zig" + } + ] + }, + "enum_literal": { + "match": "(?])", + "name": "constant.language.enum" + }, + "character_escapes": { + "patterns": [ + { + "match": "\\\\n", + "name": "constant.character.escape.newline.zig" + }, + { + "match": "\\\\r", + "name": "constant.character.escape.carrigereturn.zig" + }, + { + "match": "\\\\t", + "name": "constant.character.escape.tabulator.zig" + }, + { + "match": "\\\\\\\\", + "name": "constant.character.escape.backslash.zig" + }, + { + "match": "\\\\'", + "name": "constant.character.escape.single-quote.zig" + }, + { + "match": "\\\\\\\"", + "name": "constant.character.escape.double-quote.zig" + }, + { + "match": "\\\\x[a-fA-F\\d]{2}", + "name": "constant.character.escape.hexidecimal.zig" + }, + { + "match": "\\\\u\\{[a-fA-F\\d]{1,6}\\}", + "name": "constant.character.escape.hexidecimal.zig" + } + ] + }, + "param_list": { + "begin": "([a-zA-Z_]\\w*|@\\\".+\\\")\\s*(:)\\s*", + "patterns": [ + { + "include": "#dummy_main" + }, + { + "match": "([a-zA-Z_][\\w.]*|@\\\".+\\\")", + "name": "storage.type.zig" + } + ], + "beginCaptures": { + "2": { + "name": "punctuation.separator.zig" + }, + "1": { + "name": "variable.parameter.zig" + } + }, + "end": "([a-zA-Z_][\\w.]*|@\\\".+\\\")?\\s*(?:(,)|(\\)))", + "endCaptures": { + "3": { + "name": "punctuation.section.parens.end.zig" + }, + "2": { + "name": "punctuation.separator.zig" + }, + "1": { + "name": "storage.type.zig" + } + } + }, + "field_decl": { + "begin": "([a-zA-Z_]\\w*|@\\\".+\\\")\\s*(:)\\s*", + "patterns": [ + { + "include": "#dummy_main" + } + ], + "beginCaptures": { + "2": { + "name": "punctuation.separator.zig" + }, + "1": { + "name": "variable.other.member.zig" + } + }, + "end": "([a-zA-Z_][\\w.]*|@\\\".+\\\")?\\s*(?:(,)|(=)|$)", + "endCaptures": { + "3": { + "name": "keyword.operator.assignment.zig" + }, + "2": { + "name": "punctuation.separator.zig" + }, + "1": { + "name": "storage.type.zig" + } + } + }, + "block": { + "begin": "([a-zA-Z_][\\w.]*|@\\\".+\\\")?\\s*(\\{)", + "patterns": [ + { + "include": "#dummy_main" + } + ], + "beginCaptures": { + "2": { + "name": "punctuation.section.braces.begin.zig" + }, + "1": { + "name": "storage.type.zig" + } + }, + "end": "(\\})", + "endCaptures": { + "1": { + "name": "punctuation.section.braces.end.zig" + } + } + }, + "label": { + "captures": { + "3": { + "name": "entity.name.label.zig" + }, + "2": { + "name": "entity.name.label.zig" + }, + "1": { + "name": "keyword.control.zig" + } + }, + "match": "\\b(break|continue)\\s*:\\s*([a-zA-Z_]\\w*|@\\\".+\\\")\\b|\\b(?!\\d)([a-zA-Z_]\\w*|@\\\".+\\\")\\b(?=\\s*:\\s*(?:\\{|while\\b))" + }, + "storage_modifier": { + "match": "\\b(const|var|extern|packed|export|pub|noalias|inline|noinline|comptime|volatile|align|linksection|threadlocal|allowzero)\\b", + "name": "storage.modifier.zig" + }, + "punctuation": { + "patterns": [ + { + "match": ",", + "name": "punctuation.separator.zig" + }, + { + "match": ";", + "name": "punctuation.terminator.zig" + }, + { + "match": "(\\()", + "name": "punctuation.section.parens.begin.zig" + }, + { + "match": "(\\))", + "name": "punctuation.section.parens.end.zig" + } + ] + }, + "function_def": { + "begin": "(?<=fn)\\s+([a-zA-Z_]\\w*|@\\\".+\\\")(\\()", + "patterns": [ + { + "include": "#label" + }, + { + "include": "#param_list" + }, + { + "match": "([a-zA-Z_][\\w.]*|@\\\".+\\\")", + "name": "storage.type.zig" + }, + { + "include": "#dummy_main" + } + ], + "beginCaptures": { + "2": { + "name": "punctuation.section.parens.begin.zig" + }, + "1": { + "name": "entity.name.function" + } + }, + "end": "(?<=\\)[^\\)])\\s*([a-zA-Z_][\\w.]*|@\\\".+\\\")?(!)?\\s*(?:([a-zA-Z_][\\w.]*|@\\\".+\\\")\\b(?!\\s*\\())?", + "endCaptures": { + "3": { + "name": "storage.type.zig" + }, + "2": { + "name": "keyword.operator.zig" + }, + "1": { + "name": "storage.type.zig" + } + } + }, + "constants": { + "patterns": [ + { + "match": "\\b(null|undefined|true|false)\\b", + "name": "constant.language.zig" + }, + { + "match": "\\b(?|<)=?)' + + - name: keyword.operator.word.zon + match: '\b(and|or)\b' + + - name: keyword.operator.assignment.zon + match: '((?:(?:\+|-|\*)\%?|/|%|<<|>>|\|(?=[^\|])|\^)?=)' + + - name: keyword.operator.arithmetic.zon + match: '((?:\+|-|\*)\%?|/(?!/)|%)' + + - name: keyword.operator.bitwise.zon + match: '(<<|>>|\|(?=[^\|])|\^|~)' + + - name: keyword.operator.other.zon + match: '(\+\+|\*\*|->|\.\?|\.\*|\?|\|\||\.{2,3})' + + support: + name: support.function.zon + match: '(?)?\s*(?:([a-zA-Z_][\w.]*|@\".+\")\b(?!\s*\())?' + captures: + '1': + name: storage.type.zon + '2': + name: keyword.operator.zon + '3': + name: storage.type.zon + + - name: storage.type.function.zon + match: '\bfn\b' + + - name: storage.type.test.zon + match: '\btest\b' + + - name: storage.type.struct.zon + match: '\bstruct\b' + + - name: storage.type.enum.zon + match: '\benum\b' + + - name: storage.type.union.zon + match: '\bunion\b' + + - name: storage.type.error.zon + match: '\berror\b' + + punctuation: + patterns: + - name: punctuation.separator.zon + match: ',' + + - name: punctuation.terminator.zon + match: ';' + + - match: '(\()' + name: punctuation.section.parens.begin.zon + + - match: '(\))' + name: punctuation.section.parens.end.zon + + label: + match: '\b(break|continue)\s*:\s*([a-zA-Z_]\w*|@\".+\")\b|\b(?!\d)([a-zA-Z_]\w*|@\".+\")\b(?=\s*:\s*(?:\{|while\b))' + captures: + '1': + name: keyword.control.zon + '2': + name: entity.name.label.zon + '3': + name: entity.name.label.zon + + block: + begin: '([a-zA-Z_][\w.]*|@\".+\")?\s*(\{)' + beginCaptures: + '1': + name: storage.type.zon + '2': + name: punctuation.section.braces.begin.zon + + end: '(\})' + endCaptures: + '1': + name: punctuation.section.braces.end.zon + + patterns: + - include: '#dummy_main' + + function_def: + begin: '(?<=fn)\s+([a-zA-Z_]\w*|@\".+\")(\()' + beginCaptures: + '1': + name: entity.name.function + '2': + name: punctuation.section.parens.begin.zon + + end: '(?<=\)[^\)])\s*([a-zA-Z_][\w.]*|@\".+\")?(!)?\s*(?:([a-zA-Z_][\w.]*|@\".+\")\b(?!\s*\())?' + endCaptures: + '1': + name: storage.type.zon + '2': + name: keyword.operator.zon + '3': + name: storage.type.zon + + patterns: + - include: '#label' + - include: '#param_list' + + - match: '([a-zA-Z_][\w.]*|@\".+\")' + name: storage.type.zon + + - include: '#dummy_main' + + function_call: + name: variable.function.zon + match: '(?])' + name: constant.language.enum + + variables: + name: meta.variable.zon + patterns: + - match: '\b[_A-Z][_A-Z0-9]+\b' + name: variable.constant.zon + + - match: '\b[_a-zA-Z][_a-zA-Z0-9]*_t\b' + name: entity.name.type.zon + + - match: '\b[A-Z][a-zA-Z0-9]*\b' + name: entity.name.type.zon + + - match: '\b[_a-zA-Z][_a-zA-Z0-9]*\b' + name: variable.zon + + dummy_main: + patterns: + - include: '#label' + - include: '#function_type' + - include: '#punctuation' + - include: '#storage_modifier' + - include: '#container_decl' + - include: '#constants' + - include: '#comments' + - include: '#strings' + - include: '#storage' + - include: '#keywords' + - include: '#operators' + - include: '#support' + - include: '#field_decl' + - include: '#block' + - include: '#function_def' + - include: '#function_call' + - include: '#enum_literal' + - include: '#variables' diff --git a/Syntaxes/Zon.tmLanguage b/Syntaxes/Zon.tmLanguage new file mode 100644 index 0000000..b6e71d6 --- /dev/null +++ b/Syntaxes/Zon.tmLanguage @@ -0,0 +1,892 @@ + + + + + fileTypes + + zon + + name + Zon + patterns + + + include + #dummy_main + + + repository + + block + + begin + ([a-zA-Z_][\w.]*|@\".+\")?\s*(\{) + beginCaptures + + 1 + + name + storage.type.zon + + 2 + + name + punctuation.section.braces.begin.zon + + + end + (\}) + endCaptures + + 1 + + name + punctuation.section.braces.end.zon + + + patterns + + + include + #dummy_main + + + + character_escapes + + patterns + + + match + \\n + name + constant.character.escape.newline.zon + + + match + \\r + name + constant.character.escape.carrigereturn.zon + + + match + \\t + name + constant.character.escape.tabulator.zon + + + match + \\\\ + name + constant.character.escape.backslash.zon + + + match + \\' + name + constant.character.escape.single-quote.zon + + + match + \\\" + name + constant.character.escape.double-quote.zon + + + match + \\x[a-fA-F\d]{2} + name + constant.character.escape.hexidecimal.zon + + + match + \\u\{[a-fA-F\d]{1,6}\} + name + constant.character.escape.hexidecimal.zon + + + + comments + + patterns + + + begin + /// + end + $\n? + name + comment.line.documentation.zon + + + begin + //[^/]\s*TODO + end + $\n? + name + comment.line.todo.zon + + + begin + //[^/]* + end + $\n? + name + comment.line.zon + + + + constants + + patterns + + + match + \b(null|undefined|true|false)\b + name + constant.language.zon + + + match + \b(?<!\.)(-?[\d_]+)(?!\.)\b + name + constant.numeric.integer.zon + + + match + \b(?<!\.)(0x[a-fA-F\d_]+)(?!\.)\b + name + constant.numeric.integer.hexadecimal.zon + + + match + \b(?<!\.)(0o[0-7_]+)(?!\.)\b + name + constant.numeric.integer.octal.zon + + + match + \b(?<!\.)(0b[01_]+)(?!\.)\b + name + constant.numeric.integer.binary.zon + + + match + (?<!\.)(-?\b[\d_]+(?:\.[\d_]+)?(?:[eE][+-]?[\d_]+)?)(?!\.)\b + name + constant.numeric.float.zon + + + match + (?<!\.)(-?\b0x[a-fA-F\d_]+(?:\.[a-fA-F\d_]+)?[pP]?(?:[+-]?[\d_]+)?)(?!\.)\b + name + constant.numeric.float.hexadecimal.zon + + + match + nan + name + constant.numeric.nan.zon + + + match + inf + name + constant.numeric.inf.zon + + + + container_decl + + patterns + + + match + \b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:union)\s*[(\{]) + name + entity.name.union.zon + + + match + \b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:struct)\s*[(\{]) + name + entity.name.struct.zon + + + match + \b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:enum)\s*[(\{]) + name + entity.name.enum.zon + + + match + \b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:error)\s*[(\{]) + name + entity.name.error.zon + + + captures + + 1 + + name + storage.type.error.zon + + 2 + + name + punctuation.accessor.zon + + 3 + + name + entity.name.error.zon + + + match + \b(error)(\.)([a-zA-Z_]\w*|@\".+\") + + + + dummy_main + + patterns + + + include + #label + + + include + #function_type + + + include + #punctuation + + + include + #storage_modifier + + + include + #container_decl + + + include + #constants + + + include + #comments + + + include + #strings + + + include + #storage + + + include + #keywords + + + include + #operators + + + include + #support + + + include + #field_decl + + + include + #block + + + include + #function_def + + + include + #function_call + + + include + #enum_literal + + + include + #variables + + + + enum_literal + + match + (?<!\w|\)|\?|\}|\]|\*)(\.(?:[a-zA-Z_]\w*\b|@\"[^\"]*\"))(?!\(|\s*=[^=>]) + name + constant.language.enum + + field_decl + + begin + ([a-zA-Z_]\w*|@\".+\")\s*(:)\s* + beginCaptures + + 1 + + name + variable.other.member.zon + + 2 + + name + punctuation.separator.zon + + + end + ([a-zA-Z_][\w.]*|@\".+\")?\s*(?:(,)|(=)|$) + endCaptures + + 1 + + name + storage.type.zon + + 2 + + name + punctuation.separator.zon + + 3 + + name + keyword.operator.assignment.zon + + + patterns + + + include + #dummy_main + + + + function_call + + match + (?<!fn)\b([a-zA-Z_]\w*|@\".+\")(?=\s*\() + name + variable.function.zon + + function_def + + begin + (?<=fn)\s+([a-zA-Z_]\w*|@\".+\")(\() + beginCaptures + + 1 + + name + entity.name.function + + 2 + + name + punctuation.section.parens.begin.zon + + + end + (?<=\)[^\)])\s*([a-zA-Z_][\w.]*|@\".+\")?(!)?\s*(?:([a-zA-Z_][\w.]*|@\".+\")\b(?!\s*\())? + endCaptures + + 1 + + name + storage.type.zon + + 2 + + name + keyword.operator.zon + + 3 + + name + storage.type.zon + + + patterns + + + include + #label + + + include + #param_list + + + match + ([a-zA-Z_][\w.]*|@\".+\") + name + storage.type.zon + + + include + #dummy_main + + + + function_type + + begin + \b(fn)\s*(\() + beginCaptures + + 1 + + name + storage.type.function.zon + + 2 + + name + punctuation.section.parens.begin.zon + + + contentName + meta.function.parameters.zon + end + (?<=\)|\})\s*([a-zA-Z_][\w.]*|@\".+\")?\s*(!)?\s*([a-zA-Z_][\w.]*|@\".+\") + endCaptures + + 1 + + name + storage.type.zon + + 2 + + name + keyword.operator.zon + + 3 + + name + storage.type.zon + + + patterns + + + include + #label + + + include + #param_list + + + match + ([a-zA-Z_][\w.]*|@\".+\") + name + storage.type.zon + + + include + #dummy_main + + + + keywords + + patterns + + + match + \b(while|for|break|return|continue|asm|defer|errdefer|unreachable)\b + name + keyword.control.zon + + + match + \b(async|await|suspend|nosuspend|resume)\b + name + keyword.control.async.zon + + + match + \b(if|else|switch|try|catch|orelse)\b + name + keyword.control.conditional.zon + + + match + (?<!\w)(@import|@cImport|@cInclude)\b + name + keyword.control.import.zon + + + match + \b(usingnamespace)\b + name + keyword.other.usingnamespace.zon + + + + label + + captures + + 1 + + name + keyword.control.zon + + 2 + + name + entity.name.label.zon + + 3 + + name + entity.name.label.zon + + + match + \b(break|continue)\s*:\s*([a-zA-Z_]\w*|@\".+\")\b|\b(?!\d)([a-zA-Z_]\w*|@\".+\")\b(?=\s*:\s*(?:\{|while\b)) + + operators + + patterns + + + match + \b!\b + name + keyword.operator.zon + + + match + (==|(?:!|>|<)=?) + name + keyword.operator.logical.zon + + + match + \b(and|or)\b + name + keyword.operator.word.zon + + + match + ((?:(?:\+|-|\*)\%?|/|%|<<|>>|\|(?=[^\|])|\^)?=) + name + keyword.operator.assignment.zon + + + match + ((?:\+|-|\*)\%?|/(?!/)|%) + name + keyword.operator.arithmetic.zon + + + match + (<<|>>|\|(?=[^\|])|\^|~) + name + keyword.operator.bitwise.zon + + + match + (\+\+|\*\*|->|\.\?|\.\*|\?|\|\||\.{2,3}) + name + keyword.operator.other.zon + + + + param_list + + begin + ([a-zA-Z_]\w*|@\".+\")\s*(:)\s* + beginCaptures + + 1 + + name + variable.parameter.zon + + 2 + + name + punctuation.separator.zon + + + end + ([a-zA-Z_][\w.]*|@\".+\")?\s*(?:(,)|(\))) + endCaptures + + 1 + + name + storage.type.zon + + 2 + + name + punctuation.separator.zon + + 3 + + name + punctuation.section.parens.end.zon + + + patterns + + + include + #dummy_main + + + match + ([a-zA-Z_][\w.]*|@\".+\") + name + storage.type.zon + + + + punctuation + + patterns + + + match + , + name + punctuation.separator.zon + + + match + ; + name + punctuation.terminator.zon + + + match + (\() + name + punctuation.section.parens.begin.zon + + + match + (\)) + name + punctuation.section.parens.end.zon + + + + storage + + patterns + + + match + \b(bool|void|noreturn|type|anyerror|anytype)\b + name + storage.type.zon + + + match + \b(?<!\.)([iu]\d+|[iu]size|comptime_int)\b + name + storage.type.integer.zon + + + match + \b(f16|f32|f64|f128|comptime_float)\b + name + storage.type.float.zon + + + match + \b(c_short|c_ushort|c_int|c_uint|c_long|c_ulong|c_longlong|c_ulonglong|c_longdouble|c_void)\b + name + storage.type.c_compat.zon + + + captures + + 1 + + name + storage.type.zon + + 2 + + name + keyword.operator.zon + + 3 + + name + storage.type.zon + + + match + \b(anyframe)\b\s*(->)?\s*(?:([a-zA-Z_][\w.]*|@\".+\")\b(?!\s*\())? + + + match + \bfn\b + name + storage.type.function.zon + + + match + \btest\b + name + storage.type.test.zon + + + match + \bstruct\b + name + storage.type.struct.zon + + + match + \benum\b + name + storage.type.enum.zon + + + match + \bunion\b + name + storage.type.union.zon + + + match + \berror\b + name + storage.type.error.zon + + + + storage_modifier + + match + \b(const|var|extern|packed|export|pub|noalias|inline|noinline|comptime|volatile|align|linksection|threadlocal|allowzero)\b + name + storage.modifier.zon + + strings + + patterns + + + begin + \' + end + \' + name + string.quoted.single.zon + patterns + + + include + #character_escapes + + + match + \\[^\'][^\']*? + name + invalid.illegal.character.zon + + + + + begin + c?\" + end + \" + name + string.quoted.double.zon + patterns + + + include + #character_escapes + + + match + \\[^\'][^\']*? + name + invalid.illegal.character.zon + + + + + begin + c?\\\\ + end + $\n? + name + string.quoted.other.zon + + + + support + + match + (?<!\w)@[^\"\d][a-zA-Z_]\w*\b + name + support.function.zon + + variables + + name + meta.variable.zon + patterns + + + match + \b[_A-Z][_A-Z0-9]+\b + name + variable.constant.zon + + + match + \b[_a-zA-Z][_a-zA-Z0-9]*_t\b + name + entity.name.type.zon + + + match + \b[A-Z][a-zA-Z0-9]*\b + name + entity.name.type.zon + + + match + \b[_a-zA-Z][_a-zA-Z0-9]*\b + name + variable.zon + + + + + scopeName + source.zon + uuid + 06C2FF99-3080-441A-9019-460C51E93116 + +