{
  "name": "Chapel",
  "scopeName": "source.chapel",
  "patterns": [
    {
      "include": "#comments"
    },
    {
      "name": "keyword.control.chapel",
      "match": "\\b(align|as|atomic|begin|break|by|catch|class|cobegin|coforall|continue|delete|dmapped|do|else|enum|except|export|extern|for|forall|if|index|inline|in|inout|iter|label|lambda|let|local|module|new|noinit|on|only|otherwise|out|pragma|private|proc|prototype|public|record|reduce|ref|require|return|scan|select|serial|sync|then|throw|throws|try|union|use|var|when|where|while|with|yield|zip)\\b"
    },
    {
      "name": "storage.type.chapel",
      "match": "\\b(bool|complex|dmap|domain|imag|int|opaque|range|real|string|subdomain|tuple|uint)\\b"
    },
    {
      "name": "storage.modifier.chapel",
      "match": "\\b(config|const|enum|param|private|public|single|sparse|sync|type)\\b"
    },
    {
      "name": "constant.language.chapel",
      "match": "\\b(true|false|nil)\\b"
    },
    {
      "name": "constant.numeric.chapel",
      "match": "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
    },
    {
      "name": "variable.language.chapel",
      "match": "\\b(FileAccessMode|here|LocaleSpace|Locales|locale|numLocales|super|these|this)\\b"
    },
    {
      "name": "string.quoted.double.chapel",
      "begin": "\"",
      "end": "\"",
      "patterns": [
        {
          "include": "#string_escaped_char"
        },
        {
          "include": "#string_placeholder"
        }
      ],
      "beginCaptures": {
        "0": {
          "name": "punctuation.definition.string.begin.chapel"
        }
      },
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.string.end.chapel"
        }
      }
    },
    {
      "name": "string.quoted.single.chapel",
      "begin": "'",
      "end": "'",
      "patterns": [
        {
          "include": "#string_escaped_char"
        }
      ],
      "beginCaptures": {
        "0": {
          "name": "punctuation.definition.string.begin.chapel"
        }
      },
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.string.end.chapel"
        }
      }
    },
    {
      "name": "keyword.operator.comparison.chapel",
      "match": "\u003c\\=|\u003e\\=|\\=\\=|\u003c|\u003e|\\!\\="
    },
    {
      "name": "keyword.operator.assignment.augmented.chapel",
      "match": "\\+\\=|-\\=|\\*\\=|/\\=|//\\=|%\\=|\u0026\\=|\\|\\=|\\^\\=|\u003e\u003e\\=|\u003c\u003c\\=|\\*\\*\\="
    },
    {
      "name": "keyword.operator.arithmetic.chapel",
      "match": "\\+|\\-|\\*|\\*\\*|/|//|%|\u003c\u003c|\u003e\u003e|\u0026|\\||\\^|~|\u003c\\=\u003e\\\\.\\.\\."
    },
    {
      "name": "keyword.operator.assignment.chapel",
      "match": "\\="
    },
    {
      "name": "keyword.operator.others.chapel",
      "match": ":"
    },
    {
      "name": "keyword.operator.domain.chapel",
      "match": "\\[|\\]"
    },
    {
      "name": "meta.function.chapel",
      "begin": "^\\s*(proc)\\s+(?=[A-Za-z_][A-Za-z0-9_]*)",
      "end": "(\\()|\\s*($\\n?|#.*$\\n?)",
      "patterns": [
        {
          "contentName": "entity.name.function.chapel",
          "begin": "(?=[A-Za-z_][A-Za-z0-9_]*)",
          "end": "(?![A-Za-z0-9_])"
        },
        {
          "contentName": "keyword.control.chapel",
          "match": "proc"
        },
        {
          "contentName": "meta.function.parameters.chapel",
          "begin": "(\\()",
          "end": "(?=\\)).*\\{",
          "patterns": [
            {
              "match": "\\b([a-zA-Z_][a-zA-Z_0-9]*)",
              "captures": {
                "1": {
                  "name": "variable.parameter.function.chapel"
                }
              }
            }
          ]
        }
      ],
      "beginCaptures": {
        "1": {
          "name": "keyword.control.chapel"
        }
      }
    },
    {
      "name": "meta.function-call.chapel",
      "begin": "(?=[A-Za-z_][A-Za-z0-9_]*(?:\\.[a-zA-Z_][a-zA-Z_0-9]*)*\\s*\\()",
      "end": "(\\))",
      "patterns": [
        {
          "begin": "(?=[A-Za-z_][A-Za-z0-9_]*(?:\\.[A-Za-z_][A-Za-z0-9_]*)*\\s*\\()",
          "end": "(?=\\s*\\()",
          "patterns": [
            {
              "include": "#builtin_functions"
            }
          ]
        },
        {
          "contentName": "meta.function-call.arguments.chapel",
          "begin": "(\\()",
          "end": "(?=\\))",
          "patterns": [
            {
              "include": "$self"
            }
          ],
          "beginCaptures": {
            "1": {
              "name": "punctuation.definition.arguments.begin.chapel"
            }
          }
        }
      ]
    }
  ],
  "repository": {
    "builtin_functions": {
      "name": "support.function.builtin.chapel",
      "match": "(?x)\\b(\n              \t abs | close | exit| max | min | open | read | readln | sqrt | write | writeln\n\t\t\t\n\t\t\t)\\b"
    },
    "comments": {
      "patterns": [
        {
          "name": "comment.block.chapel",
          "match": "^/\\* =(\\s*.*?)\\s*= \\*/$\\n?",
          "captures": {
            "1": {
              "name": "meta.toc-list.banner.block.c"
            }
          }
        },
        {
          "name": "comment.block.chapel",
          "begin": "/\\*",
          "end": "\\*/",
          "captures": {
            "0": {
              "name": "punctuation.definition.comment.c"
            }
          }
        },
        {
          "name": "invalid.illegal.stray-comment-end.c",
          "match": "\\*/.*\\n"
        },
        {
          "name": "comment.line.banner.c++",
          "match": "^// =(\\s*.*?)\\s*=\\s*$\\n?",
          "captures": {
            "1": {
              "name": "meta.toc-list.banner.line.c"
            }
          }
        },
        {
          "name": "comment.line.double-slash.c++",
          "begin": "//",
          "end": "$\\n?",
          "patterns": [
            {
              "name": "punctuation.separator.continuation.c++",
              "match": "(?\u003e\\\\\\s*\\n)"
            }
          ],
          "beginCaptures": {
            "0": {
              "name": "punctuation.definition.comment.c"
            }
          }
        }
      ]
    },
    "entity_name_function": {
      "patterns": [
        {
          "include": "#illegal_names"
        },
        {
          "include": "#generic_names"
        }
      ]
    },
    "generic_names": {
      "match": "[A-Za-z_][A-Za-z0-9_]*"
    },
    "illegal_names": {
      "name": "invalid.illegal.name.chapel",
      "match": "\\b(align|as|atomic|begin|break|by|catch|class|cobegin|coforall|continue|delete|dmapped|do|else|enum|except|export|extern|for|forall|if|index|inline|in|inout|iter|label|lambda|let|local|module|new|noinit|on|only|otherwise|out|pragma|private|proc|public|record|reduce|ref|require|return|scan|select|serial|single|sync|then|throw|throws|try|union|use|var|when|where|while|with|yield|zip)\\b"
    },
    "string_escaped_char": {
      "patterns": [
        {
          "name": "constant.character.escape.c",
          "match": "\\\\(\\\\|[abefnprtv'\"?]|[0-3]\\d{0,2}|[4-7]\\d?|x[a-fA-F0-9]{0,2}|u[a-fA-F0-9]{0,4}|U[a-fA-F0-9]{0,8})"
        },
        {
          "name": "invalid.illegal.unknown-escape.c",
          "match": "\\\\."
        }
      ]
    },
    "string_placeholder": {
      "patterns": [
        {
          "name": "constant.other.placeholder.c",
          "match": "(?x)%\n    \t\t\t\t\t\t(\\d+\\$)?                             # field (argument #)\n    \t\t\t\t\t\t[#0\\- +']*                           # flags\n    \t\t\t\t\t\t[,;:_]?                              # separator character (AltiVec)\n    \t\t\t\t\t\t((-?\\d+)|\\*(-?\\d+\\$)?)?              # minimum field width\n    \t\t\t\t\t\t(\\.((-?\\d+)|\\*(-?\\d+\\$)?)?)?         # precision\n    \t\t\t\t\t\t(hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)? # length modifier\n    \t\t\t\t\t\t[diouxXDOUeEfFgGaACcSspn%]           # conversion type\n    \t\t\t\t\t"
        }
      ]
    }
  }
}