{
  "name": "powerquery",
  "scopeName": "source.powerquery",
  "fileTypes": ["pq", "pqm"],
  "uuid": "41968B57-12E6-4AC5-92A4-A837010E8B0A",
  "patterns": [
    {
      "include": "#Noise"
    },
    {
      "include": "#LiteralExpression"
    },
    {
      "include": "#Keywords"
    },
    {
      "include": "#ImplicitVariable"
    },
    {
      "include": "#IntrinsicVariable"
    },
    {
      "include": "#Operators"
    },
    {
      "include": "#DotOperators"
    },
    {
      "include": "#TypeName"
    },
    {
      "include": "#RecordExpression"
    },
    {
      "include": "#Punctuation"
    },
    {
      "include": "#QuotedIdentifier"
    },
    {
      "include": "#Identifier"
    }
  ],
  "repository": {
    "Keywords": {
      "match": "\\b(?:(and|or|not)|(if|then|else)|(try|otherwise)|(as|each|in|is|let|meta|type|error)|(section|shared))\\b",
      "captures": {
        "1": {
          "name": "keyword.operator.word.logical.powerquery"
        },
        "2": {
          "name": "keyword.control.conditional.powerquery"
        },
        "3": {
          "name": "keyword.control.exception.powerquery"
        },
        "4": {
          "name": "keyword.other.powerquery"
        },
        "5": {
          "name": "keyword.powerquery"
        }
      }
    },
    "TypeName": {
      "match": "\\b(?:(optional|nullable)|(action|any|anynonnull|binary|date|datetime|datetimezone|duration|function|list|logical|none|null|number|record|table|text|type))\\b",
      "captures": {
        "1": {
          "name": "storage.modifier.powerquery"
        },
        "2": {
          "name": "storage.type.powerquery"
        }
      }
    },
    "LiteralExpression": {
      "patterns": [
        {
          "include": "#String"
        },
        {
          "include": "#NumericConstant"
        },
        {
          "include": "#LogicalConstant"
        },
        {
          "include": "#NullConstant"
        },
        {
          "include": "#FloatNumber"
        },
        {
          "include": "#DecimalNumber"
        },
        {
          "include": "#HexNumber"
        },
        {
          "include": "#IntNumber"
        }
      ]
    },
    "Noise": {
      "patterns": [
        {
          "include": "#BlockComment"
        },
        {
          "include": "#LineComment"
        },
        {
          "include": "#Whitespace"
        }
      ]
    },
    "Whitespace": {
      "match": "\\s+"
    },
    "BlockComment": {
      "begin": "/\\*",
      "end": "\\*/",
      "name": "comment.block.powerquery"
    },
    "LineComment": {
      "match": "//.*",
      "name": "comment.line.double-slash.powerquery"
    },
    "String": {
      "begin": "\"",
      "beginCaptures": {
        "0": {
          "name": "punctuation.definition.string.begin.powerquery"
        }
      },
      "end": "\"(?!\")",
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.string.end.powerquery"
        }
      },
      "patterns": [
        {
          "match": "\"\"",
          "name": "constant.character.escape.quote.powerquery"
        },
        {
          "include": "#EscapeSequence"
        }
      ],
      "name": "string.quoted.double.powerquery"
    },
    "QuotedIdentifier": {
      "begin": "#\"",
      "beginCaptures": {
        "0": {
          "name": "punctuation.definition.quotedidentifier.begin.powerquery"
        }
      },
      "end": "\"(?!\")",
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.quotedidentifier.end.powerquery"
        }
      },
      "patterns": [
        {
          "match": "\"\"",
          "name": "constant.character.escape.quote.powerquery"
        },
        {
          "include": "#EscapeSequence"
        }
      ],
      "name": "entity.name.powerquery"
    },
    "EscapeSequence": {
      "begin": "#\\(",
      "beginCaptures": {
        "0": {
          "name": "punctuation.definition.escapesequence.begin.powerquery"
        }
      },
      "end": "\\)",
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.escapesequence.end.powerquery"
        }
      },
      "patterns": [
        {
          "match": "(#|\\h{4}|\\h{8}|cr|lf|tab)(?:,(#|\\h{4}|\\h{8}|cr|lf|tab))*"
        },
        {
          "match": "[^\\)]",
          "name": "invalid.illegal.escapesequence.powerquery"
        }
      ],
      "name": "constant.character.escapesequence.powerquery"
    },
    "LogicalConstant": {
      "match": "\\b(true|false)\\b",
      "name": "constant.language.logical.powerquery"
    },
    "NullConstant": {
      "match": "\\b(null)\\b",
      "name": "constant.language.null.powerquery"
    },
    "NumericConstant": {
      "match": "(?<![\\d\\w])(#infinity|#nan)\\b",
      "captures": {
        "1": {
          "name": "constant.language.numeric.float.powerquery"
        }
      }
    },
    "HexNumber": {
      "match": "0(x|X)\\h+",
      "name": "constant.numeric.integer.hexadecimal.powerquery"
    },
    "IntNumber": {
      "match": "\\b(\\d+)\\b",
      "captures": {
        "1": {
          "name": "constant.numeric.integer.powerquery"
        }
      }
    },
    "DecimalNumber": {
      "match": "(?<![\\d\\w])(\\d*\\.\\d+)\\b",
      "name": "constant.numeric.decimal.powerquery"
    },
    "FloatNumber": {
      "match": "(\\d*\\.)?\\d+(e|E)(\\+|-)?\\d+",
      "name": "constant.numeric.float.powerquery"
    },
    "InclusiveIdentifier": {
      "match": "@",
      "captures": {
        "0": {
          "name": "inclusiveidentifier.powerquery"
        }
      }
    },
    "Identifier": {
      "match": "(?x:(?<![\\._\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Nd}\\p{Pc}\\p{Mn}\\p{Mc}\\p{Cf}])(@?)([_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}][_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Nd}\\p{Pc}\\p{Mn}\\p{Mc}\\p{Cf}]*(?:\\.[_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}][_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Nd}\\p{Pc}\\p{Mn}\\p{Mc}\\p{Cf}])*)\\b)",
      "captures": {
        "1": {
          "name": "keyword.operator.inclusiveidentifier.powerquery"
        },
        "2": {
          "name": "entity.name.powerquery"
        }
      }
    },
    "Operators": {
      "match": "(=>)|(=)|(<>|<|>|<=|>=)|(&)|(\\+|-|\\*|\\/)|(!)|(\\?)",
      "captures": {
        "1": {
          "name": "keyword.operator.function.powerquery"
        },
        "2": {
          "name": "keyword.operator.assignment-or-comparison.powerquery"
        },
        "3": {
          "name": "keyword.operator.comparison.powerquery"
        },
        "4": {
          "name": "keyword.operator.combination.powerquery"
        },
        "5": {
          "name": "keyword.operator.arithmetic.powerquery"
        },
        "6": {
          "name": "keyword.operator.sectionaccess.powerquery"
        },
        "7": {
          "name": "keyword.operator.optional.powerquery"
        }
      }
    },
    "DotOperators": {
      "match": "(?<!\\.)(?:(\\.\\.\\.)|(\\.\\.))(?!\\.)",
      "captures": {
        "1": {
          "name": "keyword.operator.ellipsis.powerquery"
        },
        "2": {
          "name": "keyword.operator.list.powerquery"
        }
      }
    },
    "RecordExpression": {
      "begin": "\\[",
      "beginCaptures": {
        "0": {
          "name": "punctuation.section.brackets.begin.powerquery"
        }
      },
      "end": "\\]",
      "endCaptures": {
        "0": {
          "name": "punctuation.section.brackets.end.powerquery"
        }
      },
      "patterns": [
        {
          "include": "$self"
        }
      ],
      "contentName": "meta.recordexpression.powerquery"
    },
    "Punctuation": {
      "match": "(,)|(\\()|(\\))|({)|(})",
      "captures": {
        "1": {
          "name": "punctuation.separator.powerquery"
        },
        "2": {
          "name": "punctuation.section.parens.begin.powerquery"
        },
        "3": {
          "name": "punctuation.section.parens.end.powerquery"
        },
        "4": {
          "name": "punctuation.section.braces.begin.powerquery"
        },
        "5": {
          "name": "punctuation.section.braces.end.powerquery"
        }
      }
    },
    "ImplicitVariable": {
      "match": "\\b_\\b",
      "name": "keyword.operator.implicitvariable.powerquery"
    },
    "IntrinsicVariable": {
      "match": "(?<![\\d\\w])(#sections|#shared)\\b",
      "captures": {
        "1": {
          "name": "constant.language.intrinsicvariable.powerquery"
        }
      }
    }
  }
}
