diff --git a/grammars/cylc.json b/grammars/cylc.json deleted file mode 120000 index be94bab..0000000 --- a/grammars/cylc.json +++ /dev/null @@ -1 +0,0 @@ -../cylc-textmate-grammar/cylc.tmLanguage.json \ No newline at end of file diff --git a/grammars/cylc.json b/grammars/cylc.json new file mode 100644 index 0000000..925bfdd --- /dev/null +++ b/grammars/cylc.json @@ -0,0 +1,852 @@ +{ + "scopeName": "source.cylc", + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "fileTypes": [ + "suite.rc", + "suite.rc.processed", + "cylc", + "flow.rc", + "flow-tests.rc" + ], + "name": "cylc", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#jinja2" + }, + { + "include": "#graphSections" + }, + { + "include": "#headers" + }, + { + "include": "#settings" + }, + { + "include": "#includeFiles" + }, + { + "include": "#keywords" + }, + { + "include": "#strings" + } + ], + "repository": { + "headers": { + "patterns": [ + { + "name": "meta.section.cylc", + "match": "(\\[+)([^\\[\\]]+?)(\\]+)", + "captures": { + "1": { + "name": "punctuation.definition.tag.begin.cylc" + }, + "2": { + "name": "entity.name.tag.cylc", + "patterns": [ + { + "include": "#parameterizations" + }, + { + "include": "#jinja2" + } + ] + }, + "3": { + "name": "punctuation.definition.tag.end.cylc" + } + }, + "comment": "@TODO handle `+`, `-`, `/` chars; convert to begin/end instead of match?" + } + ] + }, + "graphSections": { + "patterns": [ + { + "comment": "Cylc 7 graph syntax", + "begin": "\\b(graph)[\\t ]*(=)[\\t ]*", + "end": "(?=[#\\n\\r])", + "beginCaptures": { + "1": { + "name": "keyword.graph.cylc" + }, + "2": { + "name": "keyword.operator.assignment.cylc" + } + }, + "patterns": [ + { + "include": "#graphStrings" + }, + { + "comment": "In this situation, we cannot have string after string, or string on new line", + "match": "(?:^|(?<=\"))[\\t ]*+([^#\\n\\r]+)", + "captures": { + "1": { + "name": "invalid.illegal.string.cylc" + } + } + } + ] + }, + { + "contentName": "meta.graph-section.cylc", + "comment": "Cylc 8 graph syntax", + "begin": "\\[{2}[\\t ]*graph[\\t ]*\\]{2}", + "end": "(?=^[\\t ]*\\[)", + "beginCaptures": { + "0": { + "patterns": [ + { + "include": "#headers" + } + ] + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "begin": "(\\S[^=#]*)(=)[\\t ]*", + "end": "(?=[#\\n\\r])", + "beginCaptures": { + "1": { + "patterns": [ + { + "include": "#jinja2" + }, + { + "name": "keyword.graph.cylc", + "match": "[\\w\\+\\^\\$][\\w\\+\\-\\^\\$\\/\\t ,:]*" + } + ] + }, + "2": { + "name": "keyword.operator.assignment.cylc" + } + }, + "patterns": [ + { + "include": "#graphStrings" + }, + { + "comment": "In this situation, we cannot have string after string, or string on new line", + "match": "(?:^|(?<=\"))[\\t ]*+([^#\\n\\r]+)", + "captures": { + "1": { + "name": "invalid.illegal.string.cylc" + } + } + } + ] + } + ] + } + ] + }, + "graphStrings": { + "patterns": [ + { + "name": "meta.graph-syntax.quoted.triple.cylc", + "begin": "\\G(\"{3})", + "end": "(\"{3})", + "beginCaptures": { + "0": { + "name": "string.quoted.triple.cylc" + }, + "1": { + "name": "punctuation.definition.string.begin.cylc" + } + }, + "endCaptures": { + "0": { + "name": "string.quoted.triple.cylc" + }, + "1": { + "name": "punctuation.definition.string.end.cylc" + } + }, + "patterns": [ + { + "include": "#graphSyntax" + } + ] + }, + { + "name": "meta.graph-syntax.quoted.double.cylc", + "begin": "\\G(\")", + "end": "([\"\\n\\r])", + "beginCaptures": { + "0": { + "name": "string.quoted.double.cylc" + }, + "1": { + "name": "punctuation.definition.string.begin.cylc" + } + }, + "endCaptures": { + "0": { + "name": "string.quoted.double.cylc" + }, + "1": { + "name": "punctuation.definition.string.end.cylc" + } + }, + "patterns": [ + { + "include": "#graphSyntax" + } + ] + }, + { + "name": "meta.graph-syntax.unquoted.cylc", + "match": "\\G[^#\\n\\r\"]+", + "captures": { + "0": { + "patterns": [ + { + "include": "#graphSyntax" + } + ] + } + } + } + ] + }, + "graphSyntax": { + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#parameterizations" + }, + { + "include": "#jinja2" + }, + { + "name": "meta.variable.task.cylc", + "match": "\\b\\w[\\w\\+\\-@%]*" + }, + { + "name": "keyword.control.trigger.cylc", + "match": "=>" + }, + { + "name": "keyword.other.logical.cylc", + "match": "[\\|&]" + }, + { + "name": "meta.parens.cylc", + "begin": "\\(", + "end": "[\\)\\n\\r]", + "beginCaptures": { + "0": { + "name": "punctuation.section.parens.begin.cylc" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.section.parens.end.cylc" + } + }, + "patterns": [ + { + "include": "#graphSyntax" + } + ] + }, + { + "name": "meta.variable.suicide.cylc", + "match": "(?<=^|[\\s&>])(!)(\\b\\w[\\w\\+\\-@%]*)", + "captures": { + "1": { + "name": "keyword.other.suicide.cylc" + }, + "2": { + "name": "meta.variable.task.cylc" + } + } + }, + { + "name": "variable.other.xtrigger.cylc", + "match": "(@)[\\w\\-]+", + "captures": { + "1": { + "name": "punctuation.definition.variable.cylc" + } + } + }, + { + "name": "constant.character.escape.continuation.cylc", + "match": "\\\\" + }, + { + "comment": "e.g. foo:fail => bar", + "match": "(?", + "beginCaptures": { + "0": { + "name": "punctuation.definition.annotation.begin.cylc" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.annotation.end.cylc" + } + }, + "patterns": [ + { + "include": "#jinja2" + }, + { + "name": "meta.polling.cylc", + "patterns": [ + { + "match": "([^\\s<>]+)(?=::)", + "captures": { + "1": { + "name": "entity.name.namespace.suite.cylc" + } + } + }, + { + "name": "punctuation.accessor.cylc", + "match": "(?<=\\S)::(?=\\S)" + }, + { + "match": "(?<=::)(\\b\\w[\\w\\+\\-@%]*)", + "captures": { + "1": { + "name": "meta.variable.task.cylc" + } + } + }, + { + "comment": "e.g. foo:fail => bar", + "match": "(?