{
  "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
  "name": "Moxie",
  "scopeName": "source.moxie",
  "patterns": [
    { "include": "#comments" },
    { "include": "#strings" },
    { "include": "#raw-strings" },
    { "include": "#char-literals" },
    { "include": "#numbers" },
    { "include": "#keywords" },
    { "include": "#builtin-functions" },
    { "include": "#builtin-types" },
    { "include": "#constants" },
    { "include": "#operators" },
    { "include": "#func-declaration" },
    { "include": "#type-declaration" },
    { "include": "#identifiers" }
  ],
  "repository": {
    "comments": {
      "patterns": [
        {
          "name": "comment.line.double-slash.moxie",
          "match": "//.*$"
        },
        {
          "name": "comment.block.moxie",
          "begin": "/\\*",
          "end": "\\*/"
        }
      ]
    },
    "strings": {
      "name": "string.quoted.double.moxie",
      "begin": "\"",
      "end": "\"",
      "patterns": [
        {
          "name": "constant.character.escape.moxie",
          "match": "\\\\."
        }
      ]
    },
    "raw-strings": {
      "name": "string.quoted.backtick.moxie",
      "begin": "`",
      "end": "`"
    },
    "char-literals": {
      "name": "string.quoted.single.moxie",
      "begin": "'",
      "end": "'",
      "patterns": [
        {
          "name": "constant.character.escape.moxie",
          "match": "\\\\."
        }
      ]
    },
    "numbers": {
      "patterns": [
        {
          "name": "constant.numeric.float.moxie",
          "match": "\\b[0-9][0-9_]*\\.[0-9_]*([eE][+-]?[0-9_]+)?\\b"
        },
        {
          "name": "constant.numeric.hex.moxie",
          "match": "\\b0[xX][0-9a-fA-F_]+\\b"
        },
        {
          "name": "constant.numeric.octal.moxie",
          "match": "\\b0[oO][0-7_]+\\b"
        },
        {
          "name": "constant.numeric.binary.moxie",
          "match": "\\b0[bB][01_]+\\b"
        },
        {
          "name": "constant.numeric.integer.moxie",
          "match": "\\b[0-9][0-9_]*\\b"
        }
      ]
    },
    "keywords": {
      "patterns": [
        {
          "name": "keyword.control.moxie",
          "match": "\\b(break|case|continue|default|defer|else|for|goto|if|range|return|select|switch)\\b"
        },
        {
          "name": "keyword.declaration.moxie",
          "match": "\\b(chan|const|func|import|interface|map|package|struct|type|var)\\b"
        },
        {
          "name": "keyword.other.spawn.moxie",
          "match": "\\bspawn\\b"
        }
      ]
    },
    "builtin-functions": {
      "name": "support.function.builtin.moxie",
      "match": "\\b(append|cap|clear|close|copy|delete|len|make|panic|print|println|recover)\\b"
    },
    "builtin-types": {
      "name": "support.type.builtin.moxie",
      "match": "\\b(bool|byte|error|float32|float64|int|int8|int16|int32|int64|rune|string|uint|uint8|uint16|uint32|uint64|any|comparable)\\b"
    },
    "constants": {
      "name": "constant.language.moxie",
      "match": "\\b(true|false|nil|iota)\\b"
    },
    "operators": {
      "patterns": [
        {
          "name": "keyword.operator.channel.moxie",
          "match": "<-"
        },
        {
          "name": "keyword.operator.define.moxie",
          "match": ":="
        },
        {
          "name": "keyword.operator.concat.moxie",
          "match": "\\|=?"
        },
        {
          "name": "keyword.operator.moxie",
          "match": "(\\+|-|\\*|/|%|&|\\^|<<|>>|&\\^|==|!=|<=|>=|<|>|=|!|&&|\\|\\|)"
        }
      ]
    },
    "func-declaration": {
      "match": "\\b(func)\\s+([A-Za-z_][A-Za-z0-9_]*)",
      "captures": {
        "1": { "name": "keyword.declaration.moxie" },
        "2": { "name": "entity.name.function.moxie" }
      }
    },
    "type-declaration": {
      "match": "\\b(type)\\s+([A-Za-z_][A-Za-z0-9_]*)",
      "captures": {
        "1": { "name": "keyword.declaration.moxie" },
        "2": { "name": "entity.name.type.moxie" }
      }
    },
    "identifiers": {
      "name": "variable.other.moxie",
      "match": "\\b[A-Za-z_][A-Za-z0-9_]*\\b"
    }
  }
}
