From 3ce2ad902b387d07e3e7095abe538faf31377100 Mon Sep 17 00:00:00 2001 From: Christoph Brandau Date: Fri, 10 Jan 2025 08:06:42 +0100 Subject: [PATCH] first try --- syntaxes/tcl.tmLanguage.json | 5469 ++++++++++++++++++++++++++++++++++ 1 file changed, 5469 insertions(+) create mode 100644 syntaxes/tcl.tmLanguage.json diff --git a/syntaxes/tcl.tmLanguage.json b/syntaxes/tcl.tmLanguage.json new file mode 100644 index 0000000..2dbe685 --- /dev/null +++ b/syntaxes/tcl.tmLanguage.json @@ -0,0 +1,5469 @@ +{ + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "foldingStartMarker": "([{(\\[])", + "foldingEndMarker": "([})\\]])", + "name": "Tcl", + "patterns": [ + { + "include": "#root" + } + ], + "repository": { + "root": { + "patterns": [ + { + "include": "#invariant" + }, + { + "include": "#brackets" + }, + { + "include": "#proc-call" + } + ] + }, + "invariant": { + "patterns": [ + { + "include": "#ignore-long-lines" + }, + { + "include": "#no-starting-empty-brackets" + }, + { + "include": "#no-empty-square-brackets" + } + ] + }, + "no-starting-empty-brackets": { + "patterns": [ + { + "match": "(?<=^)\\s*+(\\{\\}|\\[\\])", + "captures": { + "1": { + "name": "invalid.illegal.termination.tcl" + } + } + } + ] + }, + "no-empty-square-brackets": { + "patterns": [ + { + "match": "(\\[\\])", + "captures": { + "1": { + "name": "string.empty.square.brace" + } + } + } + ] + }, + "ignore-long-lines": { + "comment": "long lines are not parsed for performance", + "patterns": [ + { + "match": "^.{1000,}" + } + ] + }, + "brackets": { + "patterns": [ + { + "include": "#invariant" + }, + { + "include": "#special-brackets" + }, + { + "include": "#empty-brackets" + }, + { + "include": "#square-brackets" + }, + { + "include": "#curly-brackets" + } + ] + }, + "square-brackets": { + "patterns": [ + { + "begin": "\\s*+(?])", + "name": "support.type.expression.operator.tcl" + }, + { + "comment": "expression bitwise", + "match": "([|^&!~])", + "name": "support.type.expression.operator.tcl" + }, + { + "comment": "expression ternary", + "match": "([?:])", + "name": "support.type.expression.operator.tcl" + } + ] + }, + "expression-functions": { + "patterns": [ + { + "begin": "\\b(abs|acos|asin|atan|atan2|bool|ceil|cos|cosh|double|entier|exp|floor|fmod|hypot|int|isqrt|log|log10|max|min|pow|rand|round|sin|sinh|sqrt|srand|tan|tanh|wide)\\b(\\()", + "end": "(\\))", + "beginCaptures": { + "1": { + "name": "entity.function.name.math.function.punctuatio.italic.tcl" + }, + "2": { + "name": "entity.function.name.math.function.brace.open.tcl" + } + }, + "endCaptures": { + "1": { + "name": "entity.function.name.math.function.brace.close.tcl" + } + }, + "patterns": [ + { + "include": "#expressions" + } + ] + } + ] + }, + "tcl-vwait": { + "patterns": [ + { + "include": "#line-escape" + }, + { + "comment": "vwait varName", + "begin": "(?<=^|\\[|{|;)\\s*(::)?\\b(vwait)\\b\\s*+(?!$|\n|;|^|\\]|})", + "end": "(?=$|\n|;|\\]|}|\\s)\\s*([^$\n^\\];}\\[\\\\]*)?(\\\\(?!\n))?", + "beginCaptures": { + "1": { + "name": "support.type.ns.tcl" + }, + "2": { + "name": "keyword.control.vwait.tcl" + } + }, + "endCaptures": { + "1": { + "name": "invalid.illegal.numargs.tcl" + }, + "2": { + "name": "invalid.illegal.escape.tcl" + } + }, + "patterns": [ + { + "include": "#line-escape" + }, + { + "include": "#variable" + }, + { + "include": "#variable-bare-italic" + } + ] + } + ] + }, + "tcl-proc": { + "patterns": [ + { + "begin": "(?<=^|[\\[{;])\\s*(::)?\\b(proc)\\b\\s+([^\\s\n]+)\\s+(?={|\\b|\\[|\"|\\\\$)", + "end": "(?=(?|=|==|<=|>=|>_|_<|%))(?=\\s*\\|)", + "name": "support.type" + }, + { + "begin": "\\s*+(\\|)", + "end": "(?=$|;|\n|}|\\])", + "beginCaptures": { + "1": { + "name": "entity.function.name.condition.tcl" + } + }, + "name": "string", + "patterns": [ + { + "include": "#variable-non-substituting" + }, + { + "include": "#glob-match" + }, + { + "include": "#constant-numeric" + } + ] + } + ] + } + ] + }, + "tcl-state-setter-getter": { + "patterns": [ + { + "begin": "(?<=set|get|pull|push)\\b", + "end": "(?=(?)", + "captures": { + "1": { + "name": "meta.constant" + } + } + }, + { + "include": "#variable" + }, + { + "include": "#square-brackets" + }, + { + "include": "#variable-bare" + }, + { + "begin": "\\s*({)", + "end": "(})", + "patterns": [ + { + "match": "(?<={)\\s*([^\\s}]*)", + "name": "string.pull.prop.tcl" + }, + { + "begin": "(?<=\\s)([^\\s}]*)", + "end": "(?=})", + "captures": { + "1": { + "patterns": [ + { + "include": "#variable-bare-italic" + } + ] + } + }, + "patterns": [ + { + "include": "#constant-numeric" + }, + { + "begin": "\\s*({)", + "end": "(})", + "contentName": "string.dict.pull.default.tcl", + "captures": { + "1": { + "name": "entity.function.name.dict.pull.props.tcl" + } + } + }, + { + "include": "#bare-string" + } + ] + }, + { + "include": "#constant-numeric" + } + ] + } + ] + }, + { + "begin": "(?<=set|unset|lappend|incr)\\b", + "end": "(?=(?)", + "name": "meta.constant.re.trashvar.tcl" + }, + { + "include": "#opt" + }, + { + "begin": "\\s*({|\")", + "end": "(}|\")(?=\\s+(?:\\\\\n|$|\n|\\[|\\$|\\b|\"|;|}|-))", + "contentName": "string.tcl", + "patterns": [ + { + "include": "#regular-expression" + } + ] + }, + { + "include": "#quoted-string" + }, + { + "include": "#variable" + }, + { + "include": "#variable-bare-italic" + } + ] + }, + { + "begin": "(?<=_regexp|_re)\\s+(?={|\")", + "end": "(?=(?)|(@|}|$|\n)|\\|", + "beginCaptures": { + "1": { + "name": "support.type.annotate.tcl" + } + }, + "endCaptures": { + "1": { + "name": "support.type.annotate.tcl" + } + }, + "patterns": [ + { + "include": "#variable-non-substituting" + }, + { + "include": "#namespace-separator" + } + ] + } + ] + }, + "annotate-properties": { + "begin": "(?=\\s*@[^\\s\n])", + "end": "(?=$|[\n}@])", + "patterns": [ + { + "comment": "special @ values that are meant as property values", + "match": "\\s*+(@)\\b(type)\\b(\\s+[^{}|@\\[<>-]*)?", + "captures": { + "1": { + "name": "meta.constant.annotate.property.tcl" + }, + "2": { + "name": "support.type.name.tcl" + }, + "3": { + "name": "entity.function.property.name.tcl" + } + } + }, + { + "comment": "special @ values that are meant as property values", + "match": "\\s*+(@)\\b(arg(?:s)?|returns|key|prop|if|example|param|params|opt|option|argument|val|value)\\b(\\s+[^\\/{}|@\\[<>]*)?", + "captures": { + "1": { + "name": "support.type.annotate.property.tcl" + }, + "2": { + "name": "variable.property.name.tcl" + }, + "3": { + "name": "support.type", + "patterns": [ + { + "include": "#opt" + } + ] + } + } + }, + { + "comment": "@ (no space after @)", + "match": "\\s*+(@)\\b([^\\s]*)\\b(\\s+[^\\/{}|@\\[<>-]*)?", + "captures": { + "1": { + "name": "meta.constant.annotate.property.tcl" + }, + "2": { + "name": "entity.function.property.name.tcl" + }, + "3": { + "name": "support.type.tcl" + } + } + }, + { + "include": "#annotate" + } + ] + }, + "annotate-control-block": { + "patterns": [ + { + "comment": "bracketed within a comment", + "contentName": "keyword.operator", + "begin": "^\\s*+(?={)", + "end": "(?<=})", + "patterns": [ + { + "include": "#brackets" + } + ] + } + ] + }, + "annotate-proc-call": { + "patterns": [ + { + "begin": "(\\[)", + "end": "(\\])", + "beginCaptures": { + "1": { + "name": "support.type.annotate.proc-call.tcl" + } + }, + "endCaptures": { + "1": { + "name": "support.type.annotate.proc-call.tcl" + } + }, + "patterns": [ + { + "include": "#proc-call" + } + ] + } + ] + }, + "annotate-type": { + "patterns": [ + { + "comment": "adding @ in a multi-line will make the line emphasized", + "contentName": "entity.function.name.comment.annotate.tcl", + "begin": "\\s*+({)", + "end": "\\s*(})", + "beginCaptures": { + "1": { + "name": "meta.constant.comment.annotate.tcl" + } + }, + "endCaptures": { + "1": { + "name": "meta.constant.comment.annotate.tcl" + } + }, + "patterns": [ + { + "include": "#annotate-regular-expression" + }, + { + "include": "#annotate-proc-call" + }, + { + "begin": "(<)", + "end": "(>)|(?=[}])", + "contentName": "support.type.comment.annotate.property.punctuation.italic.tcl", + "patterns": [ + { + "include": "#annotate-regular-expression" + }, + { + "match": "(\\|)", + "name": "entity.function.name.tcl" + }, + { + "include": "#variable-non-substituting" + }, + { + "match": "([,])", + "name": "entity.function.name.annotate.opt.tcl" + }, + { + "match": "([-])", + "name": "meta.constant.annotate.opt.tcl" + } + ] + }, + { + "match": "(?:(?<={|\\|)([?*])|([?*])(?=}|\\|))", + "name": "variable.modifier.annotate.punctuation.italic.tcl" + }, + { + "match": "(\\|)", + "name": "meta.constant.comment.annotate.tcl" + } + ] + } + ] + }, + "annotate-regular-expression": { + "patterns": [ + { + "begin": "(/)", + "end": "(/|$)", + "beginCaptures": { + "1": { + "name": "support.type.annotate.re.brace.open.tcl" + } + }, + "endCaptures": { + "1": { + "name": "support.type.annotate.re.brace.close.tcl" + } + }, + "contentName": "string.re.expression.comment.annotate.contents.tcl", + "patterns": [ + { + "include": "#regular-expression" + } + ] + } + ] + }, + "annotate-highlight": { + "patterns": [ + { + "comment": "adding | in a multi-line will make the line highlighted (string)", + "match": "(?<=\\|)\\s*([^|]*)", + "captures": { + "1": { + "name": "string.quote.annotate.comment.tcl", + "patterns": [ + { + "include": "#annotate-type" + }, + { + "include": "#annotate-proc-call" + }, + { + "include": "#variable-non-substituting" + }, + { + "match": "\\b(http://([^\\s]*))", + "name": "entity.function.name.markup.underline" + } + ] + } + } + } + ] + }, + "annotate-header": { + "patterns": [ + { + "comment": "adding > in a multi-line will make the line emphasized", + "begin": "\\s*+(>)", + "end": "(<)|(?=$|>)", + "contentName": "meta.constant.annotate.header.tcl", + "captures": { + "1": { + "name": "entity.function.name.annotate.tcl" + }, + "2": { + "name": "meta.constant.annotate.header.tcl" + } + }, + "patterns": [ + { + "include": "#annotate" + } + ] + } + ] + }, + "annotate-list": { + "patterns": [ + { + "match": "^\\s*([0-9]\\.)\\s+", + "name": "meta.class" + } + ] + }, + "opt": { + "patterns": [ + { + "comment": "Handle options sent to commands at various points (cmd -name1 value -name2 value)", + "match": "\\s*+(?<=\\s|^|\"|\\()((-)(?!-|\\s|\"|;|\n|>)[^\\s$\n\\[\\];\"{)(}]*)", + "captures": { + "1": { + "name": "support.type.opt.tcl" + }, + "2": { + "name": "meta.constant.opt.start.tcl" + } + } + } + ] + }, + "line-escape": { + "begin": "\\s*+(\\\\\n)$", + "end": "(^)(?:\\s*(?!$))?", + "beginCaptures": { + "1": { + "name": "constant.character.escape.newline.tcl" + } + }, + "endCaptures": { + "1": { + "name": "meta.lineescape.highlight.tcl" + } + } + }, + "glob-match": { + "patterns": [ + { + "begin": "({)", + "end": "(})", + "patterns": [ + { + "include": "#glob-match" + } + ] + }, + { + "match": "\\s*+(\\*)", + "name": "meta.class" + }, + { + "include": "#string-escapes" + }, + { + "begin": "(?|<|,))(?\\*}\\]/\"\\);\\(\\\\\\$,\\-\\+\\*]*)(\\([^\\s\\\\;\\*}\\]\"\\)\\(\\$,\\-\\+\\*<>]*\\))?)", + "captures": { + "1": { + "name": "support.type.variable.indicator.tcl" + }, + "2": { + "name": "entity.function.name.variable.brace.open.tcl" + }, + "3": { + "patterns": [ + { + "include": "#namespace-separator" + }, + { + "include": "#variable" + }, + { + "match": "([^\\s:\"}{]+)", + "name": "meta.constant.tcl" + } + ] + }, + "4": { + "patterns": [ + { + "begin": "(\\()", + "end": "(\\))", + "contentName": "punctuation.italic.meta.constant", + "beginCaptures": { + "1": { + "name": "support.type" + } + }, + "endCaptures": { + "1": { + "name": "support.type" + } + }, + "patterns": [ + { + "include": "#proc-call-args" + } + ] + } + ] + }, + "5": { + "name": "entity.function.name.variable.brace.close.tcl" + }, + "6": { + "patterns": [ + { + "include": "#namespace-separator" + }, + { + "match": "([^\\s:\"}{\\\\\\]\\[]+)", + "name": "meta.constant" + } + ] + }, + "7": { + "patterns": [ + { + "begin": "(\\()", + "end": "(\\))", + "contentName": "punctuation.italic.meta.constant", + "beginCaptures": { + "1": { + "name": "entity.function.name" + } + }, + "endCaptures": { + "1": { + "name": "entity.function.name" + } + }, + "patterns": [ + { + "include": "#proc-call-args" + } + ] + } + ] + } + } + } + ] + } + }, + "scopeName": "source.tcl" +} \ No newline at end of file