{
  "name": "DataWeave",
  "scopeName": "source.data-weave",
  "fileTypes": [
    "dwl"
  ],
  "uuid": "ba6390ae-c50f-4dce-97f1-951dab8fc607",
  "patterns": [
    {
      "include": "#comments"
    },
    {
      "include": "#directives"
    },
    {
      "match": "(---)",
      "name": "keyword.operator.body-marker.dw"
    },
    {
      "include": "#expressions"
    },
    {
      "match": "([^\\s]+)",
      "name": "invalid"
    }
  ],
  "repository": {
    "directives": {
      "patterns": [
        {
          "include": "#dw-directive"
        },
        {
          "include": "#import-directive"
        },
        {
          "include": "#type-directive"
        },
        {
          "include": "#fun-directive"
        },
        {
          "include": "#var-directive"
        },
        {
          "include": "#ns-directive"
        },
        {
          "include": "#input-directive"
        },
        {
          "include": "#output-directive"
        }
      ]
    },
    "function_call": {
      "name": "function_call",
      "begin": "\\s*\\(",
      "end": "\\s*\\)",
      "patterns": [
        {
          "include": "#punctuation-comma"
        },
        {
          "include": "#expressions"
        }
      ]
    },
    "variable-reference": {
      "patterns": [
        {
          "name": "variable.other.dw",
          "match": "\\b(?!(fun|input|output|type|var|ns|import|%dw|private|---)\\b)((\\+\\+|\\-\\-|[A-Za-z])[a-zA-Z0-9_]*)"
        },
        {
          "name": "invalid",
          "match": "\\b(fun|input|output|type|var|ns|import|private)\\b"
        },
        {
          "name": "variable.parameter.dw",
          "match": "(\\$+)"
        }
      ]
    },
    "cast": {
      "begin": "(?<!\\.|\\$)\\b(as|is)\\s+",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.as.dw"
        }
      },
      "end": "(?=$|^|[;,:})\\]\\s])",
      "patterns": [
        {
          "include": "#types"
        }
      ]
    },
    "case-clause": {
      "name": "case-clause.expr.dw",
      "begin": "(?<!\\.|\\$)\\b(case|else(?=\\s*->))\\b(?!\\$|\\.)",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.switch.dw"
        }
      },
      "end": "\\-\\>",
      "endCaptures": {
        "0": {
          "name": "keyword.control.switch.dw"
        }
      },
      "patterns": [
        {
          "begin": "(?<!\\.|\\$)\\b(is)\\s+",
          "beginCaptures": {
            "1": {
              "name": "keyword.control.is.dw"
            }
          },
          "end": "(?=\\-\\>)",
          "patterns": [
            {
              "include": "#types"
            }
          ]
        },
        {
          "begin": "(?<!\\.|\\$)\\b(matches)\\b",
          "beginCaptures": {
            "1": {
              "name": "keyword.control.matches.dw"
            }
          },
          "end": "(?=\\-\\>)",
          "patterns": [
            {
              "include": "#expressions"
            }
          ]
        },
        {
          "begin": "(?<!\\.|\\$)\\b([A-Za-z][a-zA-Z0-9_]*)\\s*:\\s+",
          "beginCaptures": {
            "1": {
              "name": "entity.name.variable.dw"
            }
          },
          "end": "(?=\\-\\>)",
          "patterns": [
            {
              "include": "#expressions"
            }
          ]
        },
        {
          "begin": "(?<!\\.|\\$)\\b([A-Za-z][a-zA-Z0-9_]*)\\s*(if|matches)\\s+",
          "beginCaptures": {
            "1": {
              "name": "entity.name.variable.dw"
            },
            "2": {
              "name": "keyword.control.if.dw"
            }
          },
          "end": "(?=\\-\\>)",
          "patterns": [
            {
              "include": "#expressions"
            }
          ]
        },
        {
          "include": "#expressions"
        }
      ]
    },
    "comments": {
      "patterns": [
        {
          "name": "comment.block.dw",
          "begin": "/\\*",
          "end": "\\*/",
          "captures": {
            "0": {
              "name": "punctuation.definition.comment.dw"
            }
          }
        },
        {
          "match": "\\s*((//).*$\\n?)",
          "captures": {
            "1": {
              "name": "comment.line.double-slash.dw"
            },
            "2": {
              "name": "punctuation.definition.comment.dw"
            }
          }
        }
      ]
    },
    "constants": {
      "patterns": [
        {
          "name": "constant.language.dw",
          "match": "\\b(true|false|null)\\b"
        },
        {
          "name": "constant.numeric.dw",
          "match": "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)([LlFfUuDd]|UL|ul)?\\b"
        },
        {
          "begin": "\\|",
          "beginCaptures": {
            "0": {
              "name": "constant.numeric.dw"
            }
          },
          "end": "\\|",
          "endCaptures": {
            "0": {
              "name": "constant.numeric.dw"
            }
          },
          "patterns": [
            {
              "name": "constant.numeric.dw",
              "match": "([0-9]+)"
            },
            {
              "name": "constant.character.escape.dw",
              "match": "([+:\\-WYMDTHSPZ\\.])"
            },
            {
              "name": "invalid",
              "match": "([^\\|])"
            }
          ]
        }
      ]
    },
    "dw-directive": {
      "name": "meta.directive.version.dw",
      "begin": "(?<!\\.|\\$)(%dw)\\s+([0-9]\\.[0-9])(?!\\$|\\.)",
      "beginCaptures": {
        "1": {
          "name": "comment.dw"
        },
        "2": {
          "name": "comment.dw"
        }
      },
      "end": "(?=\\n)"
    },
    "infix": {
      "name": "support.function.dw",
      "match": "(?<!^|,|\\[|\\(|=|\\+|>|<|\\-|\\*|:|\\{|case|is|else|not|as|and|or)(?<=[a-zA-Z0-9_$\\}\\])\"'`|/])\\s*(?!(var|match|case|else|fun|input|output|is|as|default|ns|import|null|false|true|using|do|not|and|or)\\s)(\\+\\+|\\-\\-|[a-zA-Z][a-zA-Z_0-9]*)(\\s+|\\s*(?=[\"'/|{]))"
    },
    "expressions": {
      "name": "expression",
      "patterns": [
        {
          "name": "keyword.other.dw",
          "match": "\\b(not)\\s+"
        },
        {
          "include": "#paren-expression"
        },
        {
          "include": "#strings"
        },
        {
          "include": "#constants"
        },
        {
          "include": "#comments"
        },
        {
          "include": "#match-statement"
        },
        {
          "include": "#using-statement"
        },
        {
          "include": "#do-statement"
        },
        {
          "include": "#if-statement"
        },
        {
          "include": "#regex"
        },
        {
          "include": "#keywords"
        },
        {
          "include": "#object-literal"
        },
        {
          "include": "#array-literal"
        },
        {
          "include": "#cast"
        },
        {
          "include": "#object-member"
        },
        {
          "include": "#variable-reference"
        },
        {
          "include": "#selectors"
        },
        {
          "include": "#directives"
        },
        {
          "include": "#infix"
        }
      ]
    },
    "generics": {
      "patterns": [
        {
          "begin": "(:)",
          "beginCaptures": {
            "1": {
              "name": "keyword.operator.declaration.dw"
            }
          },
          "end": "(?=,|>)",
          "patterns": [
            {
              "include": "#types"
            }
          ]
        },
        {
          "name": "keyword.operator.extends.dw",
          "match": "<:"
        },
        {
          "include": "#keywords"
        },
        {
          "name": "entity.name.type.parameter.dw",
          "match": "\\w+"
        }
      ]
    },
    "input-directive": {
      "name": "meta.directive.ns.dw",
      "begin": "(?<!\\.|\\$)\\b(input)\\s+([[:alpha:]][[:alnum:]]*)\\s*",
      "end": "(?=\\n)",
      "beginCaptures": {
        "1": {
          "name": "storage.type.dw"
        },
        "2": {
          "name": "entity.name.variable.dw"
        }
      },
      "patterns": [
        {
          "begin": "(\\:\\s*)",
          "beginCaptures": {
            "1": {
              "name": "keyword.other.dw"
            }
          },
          "end": "(\\s|\\n)",
          "patterns": [
            {
              "include": "#types"
            }
          ]
        },
        {
          "match": "([^{\\n\\s])",
          "name": "string.mime.dw"
        }
      ]
    },
    "keywords": {
      "patterns": [
        {
          "name": "keyword.reserved.dw",
          "match": "\\b(throw|for|yield|enum|private|async)\\b"
        },
        {
          "name": "invalid",
          "match": "\\b(not)\\b"
        },
        {
          "name": "keyword.control.dw",
          "match": "\\b(if|else|while|for|do|using|unless|default)\\b"
        },
        {
          "name": "keyword.operator.comparison.dw",
          "match": "(~=|==|!=|!=|<=|>=|<|>)"
        },
        {
          "name": "keyword.operator.assignment.dw",
          "match": "(=)"
        },
        {
          "name": "keyword.operator.declaration.dw",
          "match": "(:)"
        },
        {
          "name": "keyword.operator.arithmetic.dw",
          "match": "(\\-|\\+|\\*|\\/)"
        },
        {
          "name": "keyword.other.dw",
          "match": "\\b(and|or)\\b"
        }
      ]
    },
    "match-block": {
      "name": "match-block.expr.dw",
      "begin": "\\{",
      "beginCaptures": {
        "0": {
          "name": "punctuation.definition.block.dw"
        }
      },
      "end": "(?=\\})",
      "patterns": [
        {
          "include": "#case-clause"
        },
        {
          "include": "#expressions"
        }
      ]
    },
    "match-statement": {
      "name": "match-statement.expr.dw",
      "begin": "(?<!\\.|\\$)\\b(match)\\s*(?=\\{)",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.switch.dw"
        }
      },
      "end": "\\}",
      "endCaptures": {
        "1": {
          "name": "punctuation.definition.block.dw"
        }
      },
      "patterns": [
        {
          "include": "#match-block"
        }
      ]
    },
    "using-statement": {
      "name": "using-statement.expr.dw",
      "begin": "(?<!\\.|\\$)\\b(using)\\s*(\\()",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.using.dw"
        },
        "2": {
          "name": "punctuation.definitions.begin.dw"
        }
      },
      "end": "(\\))",
      "endCaptures": {
        "1": {
          "name": "punctuation.definitions.end.dw"
        }
      },
      "patterns": [
        {
          "match": "((?:\\+\\+|\\-\\-|[A-Za-z])(?:[a-zA-Z0-9_]*))(\\s*=)",
          "captures": {
            "1": {
              "name": "entity.name.variable.dw"
            },
            "2": {
              "name": "keyword.operator.dw"
            }
          }
        },
        {
          "include": "#expressions"
        }
      ]
    },
    "do-statement": {
      "name": "do-statement.expr.dw",
      "begin": "(?<!\\.|\\$)\\b(do)\\s*(\\{)",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.do.dw"
        },
        "2": {
          "name": "punctuation.definitions.begin.dw"
        }
      },
      "end": "(\\})",
      "endCaptures": {
        "1": {
          "name": "punctuation.definitions.end.dw"
        }
      },
      "patterns": [
        {
          "include": "#comments"
        },
        {
          "include": "#directives"
        },
        {
          "match": "(---)",
          "name": "keyword.operator.body-marker.dw"
        },
        {
          "include": "#expressions"
        },
        {
          "match": "([^\\s]+)",
          "name": "invalid"
        }
      ]
    },
    "if-statement": {
      "name": "meta.if.dw",
      "begin": "(?<!\\.|\\$)\\b(if\\s*)\\(",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.if.dw"
        }
      },
      "end": "\\)",
      "patterns": [
        {
          "include": "#expressions"
        }
      ]
    },
    "ns-directive": {
      "name": "meta.directive.ns.dw",
      "begin": "(?<!\\.|\\$)\\b(ns)\\s+([A-Za-z][a-zA-Z0-9_]*)\\s+([^\\n]*)(?!\\$|\\.)",
      "beginCaptures": {
        "1": {
          "name": "storage.type.dw"
        },
        "2": {
          "name": "entity.name.namespace.dw"
        },
        "3": {
          "name": "meta.definition.ns.dw string.url.dw"
        }
      },
      "end": "(?=\\n)"
    },
    "object-literal": {
      "name": "meta.objectliteral.dw",
      "begin": "\\{",
      "beginCaptures": {
        "0": {
          "name": "punctuation.definition.block.dw"
        }
      },
      "end": "\\}",
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.block.dw"
        }
      },
      "patterns": [
        {
          "include": "#object-member"
        }
      ]
    },
    "attr-literal": {
      "name": "meta.attributes.dw",
      "begin": "\\@\\(",
      "beginCaptures": {
        "0": {
          "name": "keyword.operator.attributes.dw"
        }
      },
      "end": "\\)",
      "endCaptures": {
        "0": {
          "name": "keyword.operator.attributes.dw"
        }
      },
      "patterns": [
        {
          "include": "#object-member"
        }
      ]
    },
    "selectors": {
      "name": "meta.selector.data-weave",
      "begin": "(?<![\\[\\(:+*/\\-])(\\s*\\.\\.\\*|\\s*\\.\\.|\\s*\\.\\*|\\s*\\.\\@|\\s*\\.#|\\s*\\.&|\\s*\\.|(?=\\[)|\\:\\:)",
      "end": "(?=\\s|,|\\}|\\)|\\n|\\]|\\(|-|$)",
      "patterns": [
        {
          "name": "meta.object.member.dw",
          "match": "\\b([[:alpha:]][_[:alnum:]]+#)",
          "captures": {
            "0": {
              "name": "variable.language.dw"
            }
          }
        },
        {
          "match": "((?:[A-Za-z])([a-zA-Z0-9_]*)[?!]?|(\\$)+)",
          "name": "meta.object.member.dw"
        },
        {
          "include": "#strings"
        },
        {
          "begin": "(\\[(@|\\^)?)",
          "end": "(\\])",
          "patterns": [
            {
              "include": "#expressions"
            },
            {
              "match": "([\\)])",
              "name": "invalid"
            }
          ]
        },
        {
          "include": "#selectors"
        }
      ]
    },
    "object-key": {
      "patterns": [
        {
          "name": "meta.object.member.dw meta.object-literal.namespace.dw",
          "match": "\\b([[:alpha:]][_[:alnum:]]+#)",
          "captures": {
            "0": {
              "name": "variable.language.dw"
            }
          }
        },
        {
          "name": "meta.object.member.dw meta.object-literal.key.dw",
          "begin": "(?=[\\'\\\"\\`])",
          "end": "(?=@\\(|:)",
          "patterns": [
            {
              "include": "#strings"
            }
          ]
        },
        {
          "name": "meta.object.member.dw",
          "end": "(?=,|\\}|\\))",
          "match": "(?:[_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:|@\\()",
          "captures": {
            "1": {
              "name": "meta.object-literal.key.dw"
            }
          }
        }
      ]
    },
    "object-member": {
      "patterns": [
        {
          "include": "#comments"
        },
        {
          "include": "#paren-expression"
        },
        {
          "begin": "\\s+if\\b",
          "beginCaptures": {
            "0": {
              "name": "keyword.control.dw"
            }
          },
          "end": "(?=,|})",
          "patterns": [
            {
              "include": "#expressions"
            }
          ]
        },
        {
          "include": "#object-key"
        },
        {
          "include": "#attr-literal"
        },
        {
          "include": "#object-member-body"
        },
        {
          "include": "#punctuation-comma"
        }
      ]
    },
    "object-member-body": {
      "name": "meta.object.member.dw",
      "begin": ":",
      "beginCaptures": {
        "0": {
          "name": "meta.object-literal.key.dw punctuation.separator.key-value.dw"
        }
      },
      "end": "(?=,|\\}|\\))",
      "patterns": [
        {
          "include": "#expressions"
        }
      ]
    },
    "output-directive": {
      "name": "meta.directive.ns.dw",
      "begin": "(?<!\\.|\\$)\\b(output)\\s+([^\\n{\\s]*)(?!\\$|\\.)",
      "beginCaptures": {
        "1": {
          "name": "storage.type.dw"
        },
        "2": {
          "name": "string.other.dw"
        }
      },
      "end": "(?=\\n)"
    },
    "parameters": {
      "patterns": [
        {
          "begin": "(:)",
          "beginCaptures": {
            "1": {
              "name": "keyword.operator.declaration.dw"
            }
          },
          "end": "(?=,|\\)|=)",
          "patterns": [
            {
              "include": "#types"
            }
          ]
        },
        {
          "begin": "(=)",
          "beginCaptures": {
            "1": {
              "name": "keyword.operator.declaration.dw"
            }
          },
          "end": "(?=,|\\))",
          "patterns": [
            {
              "include": "#expressions"
            }
          ]
        },
        {
          "name": "variable.parameter.dw",
          "match": "\\w+"
        }
      ]
    },
    "paren-expression": {
      "begin": "(\\()",
      "beginCaptures": {
        "1": {
          "name": "punctuation.expression.begin.dw"
        }
      },
      "end": "(\\))",
      "endCaptures": {
        "1": {
          "name": "punctuation.expression.end.dw"
        }
      },
      "patterns": [
        {
          "include": "#expressions"
        }
      ]
    },
    "punctuation-comma": {
      "name": "punctuation.separator.comma.dw",
      "match": ","
    },
    "strings": {
      "patterns": [
        {
          "include": "#qstring-single"
        },
        {
          "include": "#qstring-double"
        },
        {
          "include": "#qstring-backtick"
        },
        {
          "include": "#template"
        }
      ]
    },
    "qstring-backtick": {
      "begin": "`",
      "beginCaptures": {
        "0": {
          "name": "string.quoted.double.dw punctuation.definition.string.begin.dw"
        }
      },
      "end": "`",
      "endCaptures": {
        "0": {
          "name": "string.quoted.double.dw punctuation.definition.string.end.dw"
        }
      },
      "patterns": [
        {
          "include": "#template-substitution-element"
        },
        {
          "include": "#template-dollar"
        },
        {
          "include": "#string-character-escape"
        },
        {
          "match": "([^`])",
          "name": "string.template.dw"
        }
      ]
    },
    "template": {
      "begin": "([$[:alpha:]][_$[:alnum:]]*)\\s*(`)",
      "beginCaptures": {
        "1": {
          "name": "support.function.dw"
        },
        "2": {
          "name": "string.template.dw punctuation.definition.string.template.begin.dw"
        }
      },
      "end": "`",
      "endCaptures": {
        "0": {
          "name": "string.template.dw punctuation.definition.string.template.end.dw"
        }
      },
      "patterns": [
        {
          "include": "#template-substitution-element"
        },
        {
          "include": "#template-dollar"
        },
        {
          "include": "#string-character-escape"
        },
        {
          "match": "([^`])",
          "name": "string.template.dw"
        }
      ]
    },
    "string-character-escape": {
      "name": "constant.character.escape.dw",
      "match": "\\\\(u\\h{4}|$|.)"
    },
    "qstring-double": {
      "begin": "\"",
      "beginCaptures": {
        "0": {
          "name": "string.quoted.double.dw punctuation.definition.string.begin.dw"
        }
      },
      "end": "\"",
      "endCaptures": {
        "0": {
          "name": "string.quoted.double.dw punctuation.definition.string.end.dw"
        }
      },
      "patterns": [
        {
          "include": "#template-substitution-element"
        },
        {
          "include": "#template-dollar"
        },
        {
          "include": "#string-character-escape"
        },
        {
          "match": "([^\"])",
          "name": "string.quoted.double.dw"
        }
      ]
    },
    "qstring-single": {
      "begin": "'",
      "beginCaptures": {
        "0": {
          "name": "string.quoted.single.dw punctuation.definition.string.begin.dw"
        }
      },
      "end": "(\\')|((?:[^\\\\\\n])$)",
      "endCaptures": {
        "1": {
          "name": "string.quoted.single.dw punctuation.definition.string.end.dw"
        },
        "2": {
          "name": "invalid.illegal.newline.dw"
        }
      },
      "patterns": [
        {
          "include": "#template-substitution-element"
        },
        {
          "include": "#template-dollar"
        },
        {
          "include": "#string-character-escape"
        },
        {
          "match": "([^'])",
          "name": "string.quoted.single.dw"
        }
      ]
    },
    "template-dollar": {
      "patterns": [
        {
          "match": "(\\$(\\$)+)",
          "name": "variable.parameter.dw"
        },
        {
          "match": "(\\$)(?![a-zA-Z(])",
          "name": "variable.parameter.dw"
        },
        {
          "match": "(\\$)([a-zA-Z][a-zA-Z0-9_]*)",
          "captures": {
            "1": {
              "name": "keyword.other.dw"
            },
            "2": {
              "name": "variable.other.dw"
            }
          },
          "name": "variable.parameter.dw"
        }
      ]
    },
    "template-substitution-element": {
      "name": "meta.template.expression.dw",
      "begin": "\\$\\(",
      "beginCaptures": {
        "0": {
          "name": "keyword.other.dw"
        }
      },
      "end": "\\)",
      "endCaptures": {
        "0": {
          "name": "keyword.other.dw"
        }
      },
      "patterns": [
        {
          "include": "#expressions"
        }
      ]
    },
    "types": {
      "patterns": [
        {
          "include": "#comments"
        },
        {
          "name": "support.class.dw",
          "match": "\\b(String|Boolean|Number|Range|Namespace|Uri|DateTime|LocalDateTime|Date|LocalTime|Time|TimeZone|Period|Binary|Null|Regex|Nothing|Any|Object|Key)\\b"
        },
        {
          "begin": "\\b(Array|Type)\\s*<\\b",
          "beginCaptures": {
            "1": {
              "name": "support.type.dw"
            }
          },
          "end": ">",
          "patterns": [
            {
              "match": ",",
              "name": "invalid"
            },
            {
              "include": "#types"
            }
          ]
        },
        {
          "name": "keyword.operator.declaration.dw",
          "match": "(&|\\|)"
        },
        {
          "name": "keyword.operator.declaration.dw",
          "match": "<:"
        },
        {
          "name": "support.class.dw",
          "match": "\\b([A-Z][a-zA-Z0-9_]*)"
        },
        {
          "begin": "<",
          "end": ">",
          "patterns": [
            {
              "include": "#types"
            },
            {
              "include": "#punctuation-comma"
            },
            {
              "include": "#comments"
            }
          ]
        },
        {
          "begin": "\\(",
          "beginCaptures": {
            "1": {
              "name": "keyword.operator.tuple.dw"
            }
          },
          "end": "(\\)\\s*\\-\\>)",
          "patterns": [
            {
              "include": "#types"
            },
            {
              "include": "#parameters"
            }
          ]
        },
        {
          "begin": "\\{\\-\\|",
          "end": "\\|\\-\\}",
          "patterns": [
            {
              "include": "#punctuation-comma"
            },
            {
              "include": "#object-member-type"
            }
          ]
        },
        {
          "begin": "\\{\\|",
          "end": "\\|\\}",
          "patterns": [
            {
              "include": "#punctuation-comma"
            },
            {
              "include": "#object-member-type"
            }
          ]
        },
        {
          "begin": "\\{\\-",
          "end": "\\-\\}",
          "patterns": [
            {
              "include": "#punctuation-comma"
            },
            {
              "include": "#object-member-type"
            }
          ]
        },
        {
          "begin": "\\{",
          "end": "\\}",
          "patterns": [
            {
              "include": "#punctuation-comma"
            },
            {
              "include": "#object-member-type"
            }
          ]
        },
        {
          "begin": "\\(",
          "end": "\\)",
          "patterns": [
            {
              "include": "#types"
            }
          ]
        },
        {
          "match": "\\b(var|fun|ns)\\b"
        },
        {
          "name": "invalid",
          "match": "\\b(input|output|var|ns|import|try|catch|throw|do|for|yield|enum|private|async)\\b"
        },
        {
          "name": "invalid",
          "match": "\\b(if|else|while|for|do|using|unless|default|match)\\b"
        },
        {
          "name": "invalid",
          "match": "(~=|==|!=|===|!==|<=|>=|<|>|\\$+)"
        }
      ]
    },
    "object-member-type": {
      "patterns": [
        {
          "include": "#comments"
        },
        {
          "match": "_",
          "name": "variable.language.dw"
        },
        {
          "match": "([a-zA-Z0-9]+#)",
          "name": "variable.language.dw"
        },
        {
          "match": "\\(\\s*([a-zA-Z][a-zA-Z0-9]*)\\s*\\)",
          "name": "entity.name.type.dw"
        },
        {
          "match": "([a-zA-Z][a-zA-Z0-9]*)",
          "name": "meta.object.member.dw"
        },
        {
          "include": "#strings"
        },
        {
          "match": "\\?",
          "name": "keyword.operator.optional.dw"
        },
        {
          "match": "\\*",
          "name": "keyword.operator.optional.dw"
        },
        {
          "begin": "(\\@\\()",
          "beginCaptures": {
            "1": {
              "name": "keyword.operator.attributes.dw"
            }
          },
          "end": "(\\))",
          "endCaptures": {
            "1": {
              "name": "keyword.operator.attributes.dw"
            }
          },
          "patterns": [
            {
              "include": "#punctuation-comma"
            },
            {
              "include": "#object-member-type"
            }
          ]
        },
        {
          "begin": "(:)",
          "beginCaptures": {
            "1": {
              "name": "keyword.operator.declaration.dw"
            }
          },
          "end": "(?=,|}|\\)|\\|}|\\-}|\\|\\-})",
          "patterns": [
            {
              "include": "#types"
            }
          ]
        },
        {
          "match": "([^\\s])",
          "name": "invalid"
        }
      ]
    },
    "type-directive": {
      "name": "meta.directive.type.dw",
      "begin": "(\\s*(type)\\s+([a-zA-Z][a-zA-Z0-9]*))",
      "end": "(?=(fun|input|output|type|var|ns|import|%dw|private|---)\\s)",
      "beginCaptures": {
        "2": {
          "name": "storage.type.dw"
        },
        "3": {
          "name": "entity.name.type.dw"
        }
      },
      "patterns": [
        {
          "begin": "<",
          "end": ">",
          "patterns": [
            {
              "include": "#generics"
            }
          ]
        },
        {
          "name": "keyword.other.dw",
          "match": "\\="
        },
        {
          "include": "#types"
        }
      ]
    },
    "import-directive": {
      "name": "meta.directive.import.dw",
      "begin": "(\\s*(import)\\s+)",
      "end": "(?=(fun|input|output|type|var|ns|import|%dw|private|---)\\s|$)",
      "beginCaptures": {
        "2": {
          "name": "storage.type.dw"
        }
      },
      "patterns": [
        {
          "include": "#comments"
        },
        {
          "match": "(,)"
        },
        {
          "match": "(\\*)"
        },
        {
          "match": "\\b(from)\\s+",
          "captures": {
            "1": {
              "name": "storage.type.dw"
            }
          }
        },
        {
          "match": "(?:[a-zA-Z][a-zA-Z0-9]*(?:::[a-zA-Z][a-zA-Z0-9]*)*)\n",
          "name": "entity.name.other.dw"
        },
        {
          "match": "\\s+(as)\\s+([a-zA-Z][a-zA-Z0-9]*)",
          "captures": {
            "1": {
              "name": "keyword.other.dw"
            },
            "2": {
              "name": "entity.name.other.dw"
            }
          }
        }
      ]
    },
    "var-directive": {
      "name": "meta.directive.var.dw",
      "begin": "(\\s*(var)\\s+([a-zA-Z][a-zA-Z0-9]*))",
      "end": "(=)",
      "beginCaptures": {
        "2": {
          "name": "storage.type.dw"
        },
        "3": {
          "name": "entity.name.variable.dw"
        }
      },
      "endCaptures": {
        "0": {
          "name": "keyword.operator.assignment.dw"
        }
      },
      "patterns": [
        {
          "begin": "<",
          "end": ">",
          "patterns": [
            {
              "include": "#generics"
            }
          ]
        },
        {
          "begin": "(:)",
          "beginCaptures": {
            "1": {
              "name": "keyword.operator.declaration.dw"
            }
          },
          "end": "(?==|$)",
          "patterns": [
            {
              "include": "#comments"
            },
            {
              "include": "#types"
            }
          ]
        }
      ]
    },
    "fun-directive": {
      "name": "meta.directive.fun.dw",
      "begin": "(\\s*(fun)\\s+([a-zA-Z][a-zA-Z0-9]*))",
      "end": "(=)",
      "beginCaptures": {
        "2": {
          "name": "storage.type.dw"
        },
        "3": {
          "name": "entity.name.function.dw"
        }
      },
      "endCaptures": {
        "0": {
          "name": "keyword.operator.assignment.dw"
        }
      },
      "patterns": [
        {
          "begin": "<",
          "end": ">",
          "patterns": [
            {
              "include": "#generics"
            }
          ]
        },
        {
          "begin": "\\(",
          "end": "\\)",
          "patterns": [
            {
              "include": "#parameters"
            }
          ]
        },
        {
          "begin": "(:)",
          "beginCaptures": {
            "1": {
              "name": "keyword.operator.declaration.dw"
            }
          },
          "end": "(?==)",
          "patterns": [
            {
              "include": "#types"
            }
          ]
        }
      ]
    },
    "array-literal": {
      "name": "meta.array.literal.dw",
      "begin": "(?<!\\w|}|])(\\[)",
      "beginCaptures": {
        "0": {
          "name": "meta.brace.square.dw"
        }
      },
      "end": "\\]",
      "endCaptures": {
        "0": {
          "name": "meta.brace.square.dw"
        }
      },
      "patterns": [
        {
          "include": "#expressions"
        },
        {
          "include": "#punctuation-comma"
        }
      ]
    },
    "regex": {
      "patterns": [
        {
          "name": "string.regexp.dw",
          "begin": "(?<=[=(:,\\[?+!]|replace|match|scan|matches|contains|---|case|->|and|or|\\*\\/)\\s*(\\/)(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/(?![\\/*])(?!\\s*[a-zA-Z0-9_$]))",
          "beginCaptures": {
            "1": {
              "name": "punctuation.definition.string.begin.dw"
            }
          },
          "end": "(/)",
          "endCaptures": {
            "1": {
              "name": "punctuation.definition.string.end.dw"
            }
          },
          "patterns": [
            {
              "include": "#regexp"
            }
          ]
        },
        {
          "name": "string.regexp.dw",
          "begin": "(?<![_$[:alnum:])])\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/(?![\\/*])(?!\\s*[a-zA-Z0-9_$]))",
          "beginCaptures": {
            "0": {
              "name": "punctuation.definition.string.begin.dw"
            }
          },
          "end": "(/)",
          "endCaptures": {
            "1": {
              "name": "punctuation.definition.string.end.dw"
            }
          },
          "patterns": [
            {
              "include": "#regexp"
            }
          ]
        }
      ]
    },
    "regexp": {
      "patterns": [
        {
          "name": "keyword.control.anchor.regexp",
          "match": "\\\\[bB]|\\^|\\$"
        },
        {
          "name": "keyword.other.back-reference.regexp",
          "match": "\\\\[1-9]\\d*"
        },
        {
          "name": "keyword.operator.quantifier.regexp",
          "match": "[?+*]|\\{(\\d+,\\d+|\\d+,|,\\d+|\\d+)\\}\\??"
        },
        {
          "name": "keyword.operator.or.regexp",
          "match": "\\|"
        },
        {
          "name": "meta.group.assertion.regexp",
          "begin": "(\\()((\\?=)|(\\?!))",
          "beginCaptures": {
            "1": {
              "name": "punctuation.definition.group.regexp"
            },
            "2": {
              "name": "punctuation.definition.group.assertion.regexp"
            },
            "3": {
              "name": "meta.assertion.look-ahead.regexp"
            },
            "4": {
              "name": "meta.assertion.negative-look-ahead.regexp"
            }
          },
          "end": "(\\))",
          "endCaptures": {
            "1": {
              "name": "punctuation.definition.group.regexp"
            }
          },
          "patterns": [
            {
              "include": "#regexp"
            }
          ]
        },
        {
          "name": "meta.group.regexp",
          "begin": "\\((\\?:)?",
          "beginCaptures": {
            "0": {
              "name": "punctuation.definition.group.regexp"
            },
            "1": {
              "name": "punctuation.definition.group.capture.regexp"
            }
          },
          "end": "\\)",
          "endCaptures": {
            "0": {
              "name": "punctuation.definition.group.regexp"
            }
          },
          "patterns": [
            {
              "include": "#regexp"
            }
          ]
        },
        {
          "name": "constant.other.character-class.set.regexp",
          "begin": "(\\[)(\\^)?",
          "beginCaptures": {
            "1": {
              "name": "punctuation.definition.character-class.regexp"
            },
            "2": {
              "name": "keyword.operator.negation.regexp"
            }
          },
          "end": "(\\])",
          "endCaptures": {
            "1": {
              "name": "punctuation.definition.character-class.regexp"
            }
          },
          "patterns": [
            {
              "name": "constant.other.character-class.range.regexp",
              "match": "(?:.|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))",
              "captures": {
                "1": {
                  "name": "constant.character.numeric.regexp"
                },
                "2": {
                  "name": "constant.character.control.regexp"
                },
                "3": {
                  "name": "constant.character.escape.backslash.regexp"
                },
                "4": {
                  "name": "constant.character.numeric.regexp"
                },
                "5": {
                  "name": "constant.character.control.regexp"
                },
                "6": {
                  "name": "constant.character.escape.backslash.regexp"
                }
              }
            },
            {
              "include": "#regex-character-class"
            }
          ]
        },
        {
          "include": "#regex-character-class"
        }
      ]
    },
    "regex-character-class": {
      "patterns": [
        {
          "name": "constant.other.character-class.regexp",
          "match": "\\\\[wWsSdDtrnvf]|\\."
        },
        {
          "name": "constant.character.numeric.regexp",
          "match": "\\\\([0-7]{3}|x\\h\\h|u\\h\\h\\h\\h)"
        },
        {
          "name": "constant.character.control.regexp",
          "match": "\\\\c[A-Z]"
        },
        {
          "name": "constant.character.escape.backslash.regexp",
          "match": "\\\\."
        }
      ]
    }
  }
}