{ "information_for_contributors": [ "This file has been converted from https://github.com/MagicStack/MagicPython/blob/master/grammars/MagicPython.tmLanguage", "If you want to provide a fix or improvement, please create a pull request against the original repository.", "Once accepted there, we are happy to receive an update request." ], "version": "https://github.com/MagicStack/MagicPython/commit/7d0f2b22a5ad8fccbd7341bc7b7a715169283044", "name": "MagicPython", "scopeName": "source.python", "patterns": [ { "include": "#statement" }, { "include": "#expression" } ], "repository": { "impossible": { "comment": "This is a special rule that should be used where no match is desired. It is not a good idea to match something like '1{0}' because in some cases that can result in infinite loops in token generation. So the rule instead matches and impossible expression to allow a match to fail and move to the next token.", "match": "$.^" }, "statement": { "patterns": [ { "include": "#import" }, { "include": "#class-declaration" }, { "include": "#function-declaration" }, { "include": "#generator" }, { "include": "#statement-keyword" }, { "include": "#assignment-operator" }, { "include": "#decorator" }, { "include": "#docstring-statement" }, { "include": "#semicolon" } ] }, "semicolon": { "patterns": [ { "name": "invalid.deprecated.semicolon.python", "match": "\\;$" } ] }, "comments": { "patterns": [ { "name": "comment.line.number-sign.python", "contentName": "meta.typehint.comment.python", "begin": "(?x)\n (?:\n \\# \\s* (type:)\n \\s*+ (?# we want `\\s*+` which is possessive quantifier since\n we do not actually want to backtrack when matching\n whitespace here)\n (?! $ | \\#)\n )\n", "end": "(?:$|(?=\\#))", "beginCaptures": { "0": { "name": "meta.typehint.comment.python" }, "1": { "name": "comment.typehint.directive.notation.python" } }, "patterns": [ { "name": "comment.typehint.ignore.notation.python", "match": "(?x)\n \\G ignore\n (?= \\s* (?: $ | \\#))\n" }, { "name": "comment.typehint.type.notation.python", "match": "(?x)\n (?))" }, { "name": "comment.typehint.variable.notation.python", "match": "([[:alpha:]_]\\w*)" } ] }, { "include": "#comments-base" } ] }, "docstring-statement": { "begin": "^(?=\\s*[rR]?(\\'\\'\\'|\\\"\\\"\\\"|\\'|\\\"))", "comment": "the string either terminates correctly or by the beginning of a new line (this is for single line docstrings that aren't terminated) AND it's not followed by another docstring", "end": "((?<=\\1)|^)(?!\\s*[rR]?(\\'\\'\\'|\\\"\\\"\\\"|\\'|\\\"))", "patterns": [ { "include": "#docstring" } ] }, "docstring": { "patterns": [ { "name": "string.quoted.docstring.multi.python", "begin": "(\\'\\'\\'|\\\"\\\"\\\")", "end": "(\\1)", "beginCaptures": { "1": { "name": "punctuation.definition.string.begin.python" } }, "endCaptures": { "1": { "name": "punctuation.definition.string.end.python" } }, "patterns": [ { "include": "#docstring-prompt" }, { "include": "#codetags" }, { "include": "#docstring-guts-unicode" } ] }, { "name": "string.quoted.docstring.raw.multi.python", "begin": "([rR])(\\'\\'\\'|\\\"\\\"\\\")", "end": "(\\2)", "beginCaptures": { "1": { "name": "storage.type.string.python" }, "2": { "name": "punctuation.definition.string.begin.python" } }, "endCaptures": { "1": { "name": "punctuation.definition.string.end.python" } }, "patterns": [ { "include": "#string-consume-escape" }, { "include": "#docstring-prompt" }, { "include": "#codetags" } ] }, { "name": "string.quoted.docstring.single.python", "begin": "(\\'|\\\")", "end": "(\\1)|(\\n)", "beginCaptures": { "1": { "name": "punctuation.definition.string.begin.python" } }, "endCaptures": { "1": { "name": "punctuation.definition.string.end.python" }, "2": { "name": "invalid.illegal.newline.python" } }, "patterns": [ { "include": "#codetags" }, { "include": "#docstring-guts-unicode" } ] }, { "name": "string.quoted.docstring.raw.single.python", "begin": "([rR])(\\'|\\\")", "end": "(\\2)|(\\n)", "beginCaptures": { "1": { "name": "storage.type.string.python" }, "2": { "name": "punctuation.definition.string.begin.python" } }, "endCaptures": { "1": { "name": "punctuation.definition.string.end.python" }, "2": { "name": "invalid.illegal.newline.python" } }, "patterns": [ { "include": "#string-consume-escape" }, { "include": "#codetags" } ] } ] }, "docstring-guts-unicode": { "patterns": [ { "include": "#escape-sequence-unicode" }, { "include": "#escape-sequence" }, { "include": "#string-line-continuation" } ] }, "docstring-prompt": { "match": "(?x)\n (?:\n (?:^|\\G) \\s* (?# '\\G' is necessary for ST)\n ((?:>>>|\\.\\.\\.) \\s) (?=\\s*\\S)\n )\n", "captures": { "1": { "name": "keyword.control.flow.python" } } }, "statement-keyword": { "patterns": [ { "name": "storage.type.function.python", "match": "\\b((async\\s+)?\\s*def)\\b" }, { "name": "keyword.control.flow.python", "comment": "if `as` is eventually followed by `:` or line continuation\nit's probably control flow like:\n with foo as bar, \\\n Foo as Bar:\n try:\n do_stuff()\n except Exception as e:\n pass\n", "match": "\\b(?>= | //= | \\*\\*=\n | \\+= | -= | /= | @=\n | \\*= | %= | ~= | \\^= | &= | \\|=\n | =(?!=)\n" }, "operator": { "match": "(?x)\n \\b(?> | & | \\| | \\^ | ~) (?# 3)\n\n | (\\*\\* | \\* | \\+ | - | % | // | / | @) (?# 4)\n\n | (!= | == | >= | <= | < | >) (?# 5)\n\n | (:=) (?# 6)\n", "captures": { "1": { "name": "keyword.operator.logical.python" }, "2": { "name": "keyword.control.flow.python" }, "3": { "name": "keyword.operator.bitwise.python" }, "4": { "name": "keyword.operator.arithmetic.python" }, "5": { "name": "keyword.operator.comparison.python" }, "6": { "name": "keyword.operator.assignment.python" } } }, "punctuation": { "patterns": [ { "name": "punctuation.separator.colon.python", "match": ":" }, { "name": "punctuation.separator.element.python", "match": "," } ] }, "literal": { "patterns": [ { "name": "constant.language.python", "match": "\\b(True|False|None|NotImplemented|Ellipsis)\\b" }, { "include": "#number" } ] }, "number": { "name": "constant.numeric.python", "patterns": [ { "include": "#number-float" }, { "include": "#number-dec" }, { "include": "#number-hex" }, { "include": "#number-oct" }, { "include": "#number-bin" }, { "include": "#number-long" }, { "name": "invalid.illegal.name.python", "match": "\\b[0-9]+\\w+" } ] }, "number-float": { "name": "constant.numeric.float.python", "match": "(?x)\n (?=^]? [-+ ]? \\#?\n \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )?\n })\n )\n", "captures": { "1": { "name": "constant.character.format.placeholder.other.python" }, "3": { "name": "storage.type.format.python" }, "4": { "name": "storage.type.format.python" } } }, { "name": "meta.format.brace.python", "match": "(?x)\n (\n {\n \\w* (\\.[[:alpha:]_]\\w* | \\[[^\\]'\"]+\\])*\n (![rsa])?\n (:)\n [^'\"{}\\n]* (?:\n \\{ [^'\"}\\n]*? \\} [^'\"{}\\n]*\n )*\n }\n )\n", "captures": { "1": { "name": "constant.character.format.placeholder.other.python" }, "3": { "name": "storage.type.format.python" }, "4": { "name": "storage.type.format.python" } } } ] }, "fstring-formatting": { "patterns": [ { "include": "#fstring-formatting-braces" }, { "include": "#fstring-formatting-singe-brace" } ] }, "fstring-formatting-singe-brace": { "name": "invalid.illegal.brace.python", "match": "(}(?!}))" }, "import": { "comment": "Import statements used to correctly mark `from`, `import`, and `as`\n", "patterns": [ { "begin": "\\b(?)", "end": "(?=:)", "beginCaptures": { "1": { "name": "punctuation.separator.annotation.result.python" } }, "patterns": [ { "include": "#expression" } ] }, "item-access": { "patterns": [ { "name": "meta.item-access.python", "begin": "(?x)\n \\b(?=\n [[:alpha:]_]\\w* \\s* \\[\n )\n", "end": "(\\])", "endCaptures": { "1": { "name": "punctuation.definition.arguments.end.python" } }, "patterns": [ { "include": "#item-name" }, { "include": "#item-index" }, { "include": "#expression" } ] } ] }, "item-name": { "patterns": [ { "include": "#special-variables" }, { "include": "#builtin-functions" }, { "include": "#special-names" }, { "name": "meta.indexed-name.python", "match": "(?x)\n \\b ([[:alpha:]_]\\w*) \\b\n" } ] }, "item-index": { "begin": "(\\[)", "end": "(?=\\])", "beginCaptures": { "1": { "name": "punctuation.definition.arguments.begin.python" } }, "contentName": "meta.item-access.arguments.python", "patterns": [ { "name": "punctuation.separator.slice.python", "match": ":" }, { "include": "#expression" } ] }, "decorator": { "name": "meta.function.decorator.python", "begin": "(?x)\n ^\\s*\n ((@)) \\s* (?=[[:alpha:]_]\\w*)\n", "end": "(?x)\n ( \\) )\n # trailing whitespace and comments are legal\n (?: (.*?) (?=\\s*(?:\\#|$)) )\n | (?=\\n|\\#)\n", "beginCaptures": { "1": { "name": "entity.name.function.decorator.python" }, "2": { "name": "punctuation.definition.decorator.python" } }, "endCaptures": { "1": { "name": "punctuation.definition.arguments.end.python" }, "2": { "name": "invalid.illegal.decorator.python" } }, "patterns": [ { "include": "#decorator-name" }, { "include": "#function-arguments" } ] }, "decorator-name": { "patterns": [ { "include": "#builtin-callables" }, { "include": "#illegal-object-name" }, { "name": "entity.name.function.decorator.python", "match": "(?x)\n ([[:alpha:]_]\\w*) | (\\.)\n", "captures": { "2": { "name": "punctuation.separator.period.python" } } }, { "include": "#line-continuation" }, { "name": "invalid.illegal.decorator.python", "match": "(?x)\n \\s* ([^([:alpha:]\\s_\\.#\\\\] .*?) (?=\\#|$)\n", "captures": { "1": { "name": "invalid.illegal.decorator.python" } } } ] }, "call-wrapper-inheritance": { "comment": "same as a function call, but in inheritance context", "name": "meta.function-call.python", "begin": "(?x)\n \\b(?=\n ([[:alpha:]_]\\w*) \\s* (\\()\n )\n", "end": "(\\))", "endCaptures": { "1": { "name": "punctuation.definition.arguments.end.python" } }, "patterns": [ { "include": "#inheritance-name" }, { "include": "#function-arguments" } ] }, "inheritance-name": { "patterns": [ { "include": "#lambda-incomplete" }, { "include": "#builtin-possible-callables" }, { "include": "#inheritance-identifier" } ] }, "function-call": { "name": "meta.function-call.python", "comment": "Regular function call of the type \"name(args)\"", "begin": "(?x)\n \\b(?=\n ([[:alpha:]_]\\w*) \\s* (\\()\n )\n", "end": "(\\))", "endCaptures": { "1": { "name": "punctuation.definition.arguments.end.python" } }, "patterns": [ { "include": "#special-variables" }, { "include": "#function-name" }, { "include": "#function-arguments" } ] }, "function-name": { "patterns": [ { "include": "#builtin-possible-callables" }, { "comment": "Some color schemas support meta.function-call.generic scope", "name": "meta.function-call.generic.python", "match": "(?x)\n \\b ([[:alpha:]_]\\w*) \\b\n" } ] }, "function-arguments": { "begin": "(\\()", "end": "(?=\\))(?!\\)\\s*\\()", "beginCaptures": { "1": { "name": "punctuation.definition.arguments.begin.python" } }, "contentName": "meta.function-call.arguments.python", "patterns": [ { "name": "punctuation.separator.arguments.python", "match": "(,)" }, { "match": "(?x)\n (?:(?<=[,(])|^) \\s* (\\*{1,2})\n", "captures": { "1": { "name": "keyword.operator.unpacking.arguments.python" } } }, { "include": "#lambda-incomplete" }, { "include": "#illegal-names" }, { "match": "\\b([[:alpha:]_]\\w*)\\s*(=)(?!=)", "captures": { "1": { "name": "variable.parameter.function-call.python" }, "2": { "name": "keyword.operator.assignment.python" } } }, { "name": "keyword.operator.assignment.python", "match": "=(?!=)" }, { "include": "#expression" }, { "match": "\\s*(\\))\\s*(\\()", "captures": { "1": { "name": "punctuation.definition.arguments.end.python" }, "2": { "name": "punctuation.definition.arguments.begin.python" } } } ] }, "builtin-callables": { "patterns": [ { "include": "#illegal-names" }, { "include": "#illegal-object-name" }, { "include": "#builtin-exceptions" }, { "include": "#builtin-functions" }, { "include": "#builtin-types" } ] }, "builtin-possible-callables": { "patterns": [ { "include": "#builtin-callables" }, { "include": "#magic-names" } ] }, "builtin-exceptions": { "name": "support.type.exception.python", "match": "(?x) (?" }, "regexp-base-expression": { "patterns": [ { "include": "#regexp-quantifier" }, { "include": "#regexp-base-common" } ] }, "fregexp-base-expression": { "patterns": [ { "include": "#fregexp-quantifier" }, { "include": "#fstring-formatting-braces" }, { "match": "\\{.*?\\}" }, { "include": "#regexp-base-common" } ] }, "fstring-formatting-braces": { "patterns": [ { "comment": "empty braces are illegal", "match": "({)(\\s*?)(})", "captures": { "1": { "name": "constant.character.format.placeholder.other.python" }, "2": { "name": "invalid.illegal.brace.python" }, "3": { "name": "constant.character.format.placeholder.other.python" } } }, { "name": "constant.character.escape.python", "match": "({{|}})" } ] }, "regexp-base-common": { "patterns": [ { "name": "support.other.match.any.regexp", "match": "\\." }, { "name": "support.other.match.begin.regexp", "match": "\\^" }, { "name": "support.other.match.end.regexp", "match": "\\$" }, { "name": "keyword.operator.quantifier.regexp", "match": "[+*?]\\??" }, { "name": "keyword.operator.disjunction.regexp", "match": "\\|" }, { "include": "#regexp-escape-sequence" } ] }, "regexp-quantifier": { "name": "keyword.operator.quantifier.regexp", "match": "(?x)\n \\{(\n \\d+ | \\d+,(\\d+)? | ,\\d+\n )\\}\n" }, "fregexp-quantifier": { "name": "keyword.operator.quantifier.regexp", "match": "(?x)\n \\{\\{(\n \\d+ | \\d+,(\\d+)? | ,\\d+\n )\\}\\}\n" }, "regexp-backreference-number": { "name": "meta.backreference.regexp", "match": "(\\\\[1-9]\\d?)", "captures": { "1": { "name": "entity.name.tag.backreference.regexp" } } }, "regexp-backreference": { "name": "meta.backreference.named.regexp", "match": "(?x)\n (\\() (\\?P= \\w+(?:\\s+[[:alnum:]]+)?) (\\))\n", "captures": { "1": { "name": "support.other.parenthesis.regexp punctuation.parenthesis.backreference.named.begin.regexp" }, "2": { "name": "entity.name.tag.named.backreference.regexp" }, "3": { "name": "support.other.parenthesis.regexp punctuation.parenthesis.backreference.named.end.regexp" } } }, "regexp-flags": { "name": "storage.modifier.flag.regexp", "match": "\\(\\?[aiLmsux]+\\)" }, "regexp-escape-special": { "name": "support.other.escape.special.regexp", "match": "\\\\([AbBdDsSwWZ])" }, "regexp-escape-character": { "name": "constant.character.escape.regexp", "match": "(?x)\n \\\\ (\n x[0-9A-Fa-f]{2}\n | 0[0-7]{1,2}\n | [0-7]{3}\n )\n" }, "regexp-escape-unicode": { "name": "constant.character.unicode.regexp", "match": "(?x)\n \\\\ (\n u[0-9A-Fa-f]{4}\n | U[0-9A-Fa-f]{8}\n )\n" }, "regexp-escape-catchall": { "name": "constant.character.escape.regexp", "match": "\\\\(.|\\n)" }, "regexp-escape-sequence": { "patterns": [ { "include": "#regexp-escape-special" }, { "include": "#regexp-escape-character" }, { "include": "#regexp-escape-unicode" }, { "include": "#regexp-backreference-number" }, { "include": "#regexp-escape-catchall" } ] }, "regexp-charecter-set-escapes": { "patterns": [ { "name": "constant.character.escape.regexp", "match": "\\\\[abfnrtv\\\\]" }, { "include": "#regexp-escape-special" }, { "name": "constant.character.escape.regexp", "match": "\\\\([0-7]{1,3})" }, { "include": "#regexp-escape-character" }, { "include": "#regexp-escape-unicode" }, { "include": "#regexp-escape-catchall" } ] }, "codetags": { "match": "(?:\\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\\b)", "captures": { "1": { "name": "keyword.codetag.notation.python" } } }, "comments-base": { "name": "comment.line.number-sign.python", "begin": "(\\#)", "beginCaptures": { "1": { "name": "punctuation.definition.comment.python" } }, "end": "($)", "patterns": [ { "include": "#codetags" } ] }, "comments-string-single-three": { "name": "comment.line.number-sign.python", "begin": "(\\#)", "beginCaptures": { "1": { "name": "punctuation.definition.comment.python" } }, "end": "($|(?='''))", "patterns": [ { "include": "#codetags" } ] }, "comments-string-double-three": { "name": "comment.line.number-sign.python", "begin": "(\\#)", "beginCaptures": { "1": { "name": "punctuation.definition.comment.python" } }, "end": "($|(?=\"\"\"))", "patterns": [ { "include": "#codetags" } ] }, "single-one-regexp-expression": { "patterns": [ { "include": "#regexp-base-expression" }, { "include": "#single-one-regexp-character-set" }, { "include": "#single-one-regexp-comments" }, { "include": "#regexp-flags" }, { "include": "#single-one-regexp-named-group" }, { "include": "#regexp-backreference" }, { "include": "#single-one-regexp-lookahead" }, { "include": "#single-one-regexp-lookahead-negative" }, { "include": "#single-one-regexp-lookbehind" }, { "include": "#single-one-regexp-lookbehind-negative" }, { "include": "#single-one-regexp-conditional" }, { "include": "#single-one-regexp-parentheses-non-capturing" }, { "include": "#single-one-regexp-parentheses" } ] }, "single-one-regexp-character-set": { "patterns": [ { "match": "(?x)\n \\[ \\^? \\] (?! .*?\\])\n" }, { "name": "meta.character.set.regexp", "begin": "(\\[)(\\^)?(\\])?", "end": "(\\]|(?=\\'))|((?=(?)\n", "end": "(\\)|(?=\\'))|((?=(?)\n", "end": "(\\)|(?=\\'\\'\\'))", "beginCaptures": { "1": { "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp" }, "2": { "name": "entity.name.tag.named.group.regexp" } }, "endCaptures": { "1": { "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.end.regexp" }, "2": { "name": "invalid.illegal.newline.python" } }, "patterns": [ { "include": "#single-three-regexp-expression" }, { "include": "#comments-string-single-three" } ] }, "single-three-regexp-comments": { "name": "comment.regexp", "begin": "\\(\\?#", "end": "(\\)|(?=\\'\\'\\'))", "beginCaptures": { "0": { "name": "punctuation.comment.begin.regexp" } }, "endCaptures": { "1": { "name": "punctuation.comment.end.regexp" }, "2": { "name": "invalid.illegal.newline.python" } }, "patterns": [ { "include": "#codetags" } ] }, "single-three-regexp-lookahead": { "begin": "(\\()\\?=", "end": "(\\)|(?=\\'\\'\\'))", "beginCaptures": { "0": { "name": "keyword.operator.lookahead.regexp" }, "1": { "name": "punctuation.parenthesis.lookahead.begin.regexp" } }, "endCaptures": { "1": { "name": "keyword.operator.lookahead.regexp punctuation.parenthesis.lookahead.end.regexp" }, "2": { "name": "invalid.illegal.newline.python" } }, "patterns": [ { "include": "#single-three-regexp-expression" }, { "include": "#comments-string-single-three" } ] }, "single-three-regexp-lookahead-negative": { "begin": "(\\()\\?!", "end": "(\\)|(?=\\'\\'\\'))", "beginCaptures": { "0": { "name": "keyword.operator.lookahead.negative.regexp" }, "1": { "name": "punctuation.parenthesis.lookahead.begin.regexp" } }, "endCaptures": { "1": { "name": "keyword.operator.lookahead.negative.regexp punctuation.parenthesis.lookahead.end.regexp" }, "2": { "name": "invalid.illegal.newline.python" } }, "patterns": [ { "include": "#single-three-regexp-expression" }, { "include": "#comments-string-single-three" } ] }, "single-three-regexp-lookbehind": { "begin": "(\\()\\?<=", "end": "(\\)|(?=\\'\\'\\'))", "beginCaptures": { "0": { "name": "keyword.operator.lookbehind.regexp" }, "1": { "name": "punctuation.parenthesis.lookbehind.begin.regexp" } }, "endCaptures": { "1": { "name": "keyword.operator.lookbehind.regexp punctuation.parenthesis.lookbehind.end.regexp" }, "2": { "name": "invalid.illegal.newline.python" } }, "patterns": [ { "include": "#single-three-regexp-expression" }, { "include": "#comments-string-single-three" } ] }, "single-three-regexp-lookbehind-negative": { "begin": "(\\()\\?)\n", "end": "(\\)|(?=\"))|((?=(?)\n", "end": "(\\)|(?=\"\"\"))", "beginCaptures": { "1": { "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp" }, "2": { "name": "entity.name.tag.named.group.regexp" } }, "endCaptures": { "1": { "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.end.regexp" }, "2": { "name": "invalid.illegal.newline.python" } }, "patterns": [ { "include": "#double-three-regexp-expression" }, { "include": "#comments-string-double-three" } ] }, "double-three-regexp-comments": { "name": "comment.regexp", "begin": "\\(\\?#", "end": "(\\)|(?=\"\"\"))", "beginCaptures": { "0": { "name": "punctuation.comment.begin.regexp" } }, "endCaptures": { "1": { "name": "punctuation.comment.end.regexp" }, "2": { "name": "invalid.illegal.newline.python" } }, "patterns": [ { "include": "#codetags" } ] }, "double-three-regexp-lookahead": { "begin": "(\\()\\?=", "end": "(\\)|(?=\"\"\"))", "beginCaptures": { "0": { "name": "keyword.operator.lookahead.regexp" }, "1": { "name": "punctuation.parenthesis.lookahead.begin.regexp" } }, "endCaptures": { "1": { "name": "keyword.operator.lookahead.regexp punctuation.parenthesis.lookahead.end.regexp" }, "2": { "name": "invalid.illegal.newline.python" } }, "patterns": [ { "include": "#double-three-regexp-expression" }, { "include": "#comments-string-double-three" } ] }, "double-three-regexp-lookahead-negative": { "begin": "(\\()\\?!", "end": "(\\)|(?=\"\"\"))", "beginCaptures": { "0": { "name": "keyword.operator.lookahead.negative.regexp" }, "1": { "name": "punctuation.parenthesis.lookahead.begin.regexp" } }, "endCaptures": { "1": { "name": "keyword.operator.lookahead.negative.regexp punctuation.parenthesis.lookahead.end.regexp" }, "2": { "name": "invalid.illegal.newline.python" } }, "patterns": [ { "include": "#double-three-regexp-expression" }, { "include": "#comments-string-double-three" } ] }, "double-three-regexp-lookbehind": { "begin": "(\\()\\?<=", "end": "(\\)|(?=\"\"\"))", "beginCaptures": { "0": { "name": "keyword.operator.lookbehind.regexp" }, "1": { "name": "punctuation.parenthesis.lookbehind.begin.regexp" } }, "endCaptures": { "1": { "name": "keyword.operator.lookbehind.regexp punctuation.parenthesis.lookbehind.end.regexp" }, "2": { "name": "invalid.illegal.newline.python" } }, "patterns": [ { "include": "#double-three-regexp-expression" }, { "include": "#comments-string-double-three" } ] }, "double-three-regexp-lookbehind-negative": { "begin": "(\\()\\?=^]? [-+ ]? \\#?\n \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )(?=})\n", "captures": { "1": { "name": "storage.type.format.python" }, "2": { "name": "storage.type.format.python" } } }, { "include": "#fstring-terminator-single-tail" } ] }, "fstring-terminator-single-tail": { "begin": "((?:=?)(?:![rsa])?)(:)(?=.*?{)", "end": "(?=})|(?=\\n)", "beginCaptures": { "1": { "name": "storage.type.format.python" }, "2": { "name": "storage.type.format.python" } }, "patterns": [ { "include": "#fstring-illegal-single-brace" }, { "include": "#fstring-single-brace" }, { "name": "storage.type.format.python", "match": "([bcdeEfFgGnosxX%])(?=})" }, { "name": "storage.type.format.python", "match": "(\\.\\d+)" }, { "name": "storage.type.format.python", "match": "(,)" }, { "name": "storage.type.format.python", "match": "(\\d+)" }, { "name": "storage.type.format.python", "match": "(\\#)" }, { "name": "storage.type.format.python", "match": "([-+ ])" }, { "name": "storage.type.format.python", "match": "([<>=^])" }, { "name": "storage.type.format.python", "match": "(\\w)" } ] }, "fstring-fnorm-quoted-multi-line": { "name": "meta.fstring.python", "begin": "(\\b[fF])([bBuU])?('''|\"\"\")", "end": "(\\3)", "beginCaptures": { "1": { "name": "string.interpolated.python string.quoted.multi.python storage.type.string.python" }, "2": { "name": "invalid.illegal.prefix.python" }, "3": { "name": "punctuation.definition.string.begin.python string.interpolated.python string.quoted.multi.python" } }, "endCaptures": { "1": { "name": "punctuation.definition.string.end.python string.interpolated.python string.quoted.multi.python" }, "2": { "name": "invalid.illegal.newline.python" } }, "patterns": [ { "include": "#fstring-guts" }, { "include": "#fstring-illegal-multi-brace" }, { "include": "#fstring-multi-brace" }, { "include": "#fstring-multi-core" } ] }, "fstring-normf-quoted-multi-line": { "name": "meta.fstring.python", "begin": "(\\b[bBuU])([fF])('''|\"\"\")", "end": "(\\3)", "beginCaptures": { "1": { "name": "invalid.illegal.prefix.python" }, "2": { "name": "string.interpolated.python string.quoted.multi.python storage.type.string.python" }, "3": { "name": "punctuation.definition.string.begin.python string.quoted.multi.python" } }, "endCaptures": { "1": { "name": "punctuation.definition.string.end.python string.interpolated.python string.quoted.multi.python" }, "2": { "name": "invalid.illegal.newline.python" } }, "patterns": [ { "include": "#fstring-guts" }, { "include": "#fstring-illegal-multi-brace" }, { "include": "#fstring-multi-brace" }, { "include": "#fstring-multi-core" } ] }, "fstring-raw-quoted-multi-line": { "name": "meta.fstring.python", "begin": "(\\b(?:[rR][fF]|[fF][rR]))('''|\"\"\")", "end": "(\\2)", "beginCaptures": { "1": { "name": "string.interpolated.python string.quoted.raw.multi.python storage.type.string.python" }, "2": { "name": "punctuation.definition.string.begin.python string.quoted.raw.multi.python" } }, "endCaptures": { "1": { "name": "punctuation.definition.string.end.python string.interpolated.python string.quoted.raw.multi.python" }, "2": { "name": "invalid.illegal.newline.python" } }, "patterns": [ { "include": "#fstring-raw-guts" }, { "include": "#fstring-illegal-multi-brace" }, { "include": "#fstring-multi-brace" }, { "include": "#fstring-raw-multi-core" } ] }, "fstring-multi-core": { "name": "string.interpolated.python string.quoted.multi.python", "match": "(?x)\n (.+?)\n (\n (?# .* and .*? in multi-line match need special handling of\n newlines otherwise SublimeText and Atom will match slightly\n differently.\n\n The guard for newlines has to be separate from the\n lookahead because of special $ matching rule.)\n ($\\n?)\n |\n (?=[\\\\\\}\\{]|'''|\"\"\")\n )\n (?# due to how multiline regexps are matched we need a special case\n for matching a newline character)\n | \\n\n" }, "fstring-raw-multi-core": { "name": "string.interpolated.python string.quoted.raw.multi.python", "match": "(?x)\n (.+?)\n (\n (?# .* and .*? in multi-line match need special handling of\n newlines otherwise SublimeText and Atom will match slightly\n differently.\n\n The guard for newlines has to be separate from the\n lookahead because of special $ matching rule.)\n ($\\n?)\n |\n (?=[\\\\\\}\\{]|'''|\"\"\")\n )\n (?# due to how multiline regexps are matched we need a special case\n for matching a newline character)\n | \\n\n" }, "fstring-multi-brace": { "comment": "value interpolation using { ... }", "begin": "(\\{)", "end": "(?x)\n (\\})\n", "beginCaptures": { "1": { "name": "constant.character.format.placeholder.other.python" } }, "endCaptures": { "1": { "name": "constant.character.format.placeholder.other.python" } }, "patterns": [ { "include": "#fstring-terminator-multi" }, { "include": "#f-expression" } ] }, "fstring-terminator-multi": { "patterns": [ { "name": "storage.type.format.python", "match": "(=(![rsa])?)(?=})" }, { "name": "storage.type.format.python", "match": "(=?![rsa])(?=})" }, { "match": "(?x)\n ( (?: =?) (?: ![rsa])? )\n ( : \\w? [<>=^]? [-+ ]? \\#?\n \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )(?=})\n", "captures": { "1": { "name": "storage.type.format.python" }, "2": { "name": "storage.type.format.python" } } }, { "include": "#fstring-terminator-multi-tail" } ] }, "fstring-terminator-multi-tail": { "begin": "((?:=?)(?:![rsa])?)(:)(?=.*?{)", "end": "(?=})", "beginCaptures": { "1": { "name": "storage.type.format.python" }, "2": { "name": "storage.type.format.python" } }, "patterns": [ { "include": "#fstring-illegal-multi-brace" }, { "include": "#fstring-multi-brace" }, { "name": "storage.type.format.python", "match": "([bcdeEfFgGnosxX%])(?=})" }, { "name": "storage.type.format.python", "match": "(\\.\\d+)" }, { "name": "storage.type.format.python", "match": "(,)" }, { "name": "storage.type.format.python", "match": "(\\d+)" }, { "name": "storage.type.format.python", "match": "(\\#)" }, { "name": "storage.type.format.python", "match": "([-+ ])" }, { "name": "storage.type.format.python", "match": "([<>=^])" }, { "name": "storage.type.format.python", "match": "(\\w)" } ] } } }