%YAML 1.2 --- name: Python file_extensions: - py - rpy - pyw - cpy - SConstruct - Sconstruct - sconstruct - SConscript - gyp - gypi - Snakefile first_line_match: ^#!/.*\bpython\d?\b scope: source.python variables: # We support unicode here because Python 3 is the future identifier_continue: '[[:alnum:]_]' identifier: '\b[[:alpha:]_]{{identifier_continue}}*\b' path: '({{identifier}}\.)*{{identifier}}' sql_indicator: \s*(?:SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER)\b contexts: main: - include: statements statements: - include: classes - include: functions - include: decorators - include: expressions expressions: - include: comments - include: constants - include: numbers - include: modifiers - include: keywords - include: operators - include: lambda - include: function-calls - include: item-access - include: late-keywords - include: line_continuation - include: language_variables - include: string_quoted_single - include: string_quoted_double - include: dotted_name - match: \( scope: punctuation.definition.group.begin.python push: - meta_scope: meta.group.python - match: \) scope: punctuation.definition.group.end.python pop: true - include: expressions - match: \) scope: invalid.illegal.stray.brace.round.python - include: lists - include: dictionaries comments: - match: "#" scope: punctuation.definition.comment.python push: - meta_scope: comment.line.number-sign.python - match: \n pop: true constants: - match: \b(None|True|False|Ellipsis|NotImplemented)\b scope: constant.language.python numbers: - match: \b(?i:(0x\h*)L) scope: constant.numeric.integer.long.hexadecimal.python - match: \b(?i:(0x\h*)) scope: constant.numeric.integer.hexadecimal.python - match: '\b(?i:(0[0-7]+)L)' scope: constant.numeric.integer.long.octal.python - match: '\b(0[0-7]+)' scope: constant.numeric.integer.octal.python - match: '\b(?i:(((\d+(\.(?=[^a-zA-Z_])\d*)?|\.\d+)(e[\-\+]?\d+)?))J)' scope: constant.numeric.complex.python - match: '\b(?i:(\d+\.\d*(e[\-\+]?\d+)?))(?=[^a-zA-Z_])' scope: constant.numeric.float.python - match: '(?i:(\.\d+(e[\-\+]?\d+)?))' scope: constant.numeric.float.python - match: '\b(?i:(\d+e[\-\+]?\d+))' scope: constant.numeric.float.python - match: '\b(?i:([1-9]+[0-9]*|0)L)' scope: constant.numeric.integer.long.decimal.python - match: '\b([1-9]+[0-9]*|0)' scope: constant.numeric.integer.decimal.python modifiers: - match: \b(global)\b scope: storage.modifier.global.python - match: \b(nonlocal)\b scope: storage.modifier.nonlocal.python keywords: - match: \b(?:(import)|(from))\b captures: 1: keyword.control.import.python 2: keyword.control.import.from.python - match: \b(yield)\b(?:\s+(from))? captures: 1: keyword.control.flow.python 2: keyword.control.flow.python - match: \b(elif|else|except|finally|for|if|try|while|with|break|continue|pass|raise|return)\b comment: keywords that delimit flow blocks or alter flow from within a block scope: keyword.control.flow.python - match: \b(and|in|is|not|or)\b comment: keyword operators that evaluate to True or False scope: keyword.operator.logical.python - match: \b(as|assert|del|exec|print)\b comment: keywords that haven't fit into other groups (yet). scope: keyword.other.python operators: - match: <> scope: invalid.deprecated.operator.python - match: <\=|>\=|\=\=|<|>|\!\= scope: keyword.operator.comparison.python - match: \+\=|-\=|\*\=|/\=|//\=|%\=|&\=|\|\=|\^\=|>>\=|<<\=|\*\*\= scope: keyword.operator.assignment.augmented.python - match: \+|\-|\*|\*\*|/|//|%|<<|>>|&|\||\^|~ scope: keyword.operator.arithmetic.python - match: \= scope: keyword.operator.assignment.python classes: - match: '^\s*(class)\s+(?={{identifier}})' captures: 1: storage.type.class.python push: - meta_scope: meta.class.python - match: ':' scope: punctuation.section.class.begin.python pop: true - match: '$\n?' scope: invalid.illegal.missing-section-begin.python pop: true - match: "(?={{identifier}})" push: - meta_content_scope: entity.name.type.class.python - include: entity_name_class - match: '{{identifier}}' - match: '' pop: true - match: \( scope: punctuation.definition.inheritance.begin.python push: - meta_content_scope: meta.class.inheritance.python - match: \) scope: punctuation.definition.inheritance.end.python pop: true - match: '(?=:|$)' pop: true - match: ',' scope: punctuation.separator.python - match: '(?={{path}})' push: - meta_scope: entity.other.inherited-class.python - include: identifier-parts - match: '{{identifier}}' - match: '' pop: true - include: expressions functions: - match: '^\s*(def)\s+(?={{identifier}}\s*\()' captures: 1: storage.type.function.python push: - meta_scope: meta.function.python - match: (\))\s*(?:(\:)|(.*$\n?)) captures: 1: punctuation.definition.parameters.end.python 2: punctuation.section.function.begin.python 3: invalid.illegal.missing-section-begin.python pop: true - match: "(?={{identifier}})" push: - meta_content_scope: entity.name.function.python - match: "(?!{{identifier_continue}})" pop: true - include: entity_name_function - match: \( scope: punctuation.definition.parameters.begin.python push: - meta_content_scope: meta.function.parameters.python - match: (?=\)\s*\:) pop: true - include: keyword_arguments - match: "#" scope: punctuation.definition.comment.python push: - meta_scope: comment.line.number-sign.python - match: \n pop: true - match: '({{identifier}})\s*(?:(,)|(?=[\n\)]))' captures: 1: variable.parameter.function.python 2: punctuation.separator.parameters.python - match: '^\s*(def)\s+(?={{identifier}})' captures: 1: storage.type.function.python push: - meta_scope: meta.function.python - match: (\()|\s*($\n?|#.*$\n?) captures: 1: punctuation.definition.parameters.begin.python 2: invalid.illegal.missing-parameters.python pop: true - match: "(?={{identifier}})" push: - meta_content_scope: entity.name.function.python - match: "(?!{{identifier_continue}})" pop: true - include: entity_name_function decorators: - match: '^\s*(?=@\s*{{identifier}}(?:\.{{identifier}})*\s*\()' comment: a decorator may be a function call which returns a decorator. push: - meta_scope: meta.function.decorator.python - match: \) scope: punctuation.definition.arguments.end.python pop: true - match: '(?=(@)\s*{{identifier}}(?:\.{{identifier}})*\s*\()' captures: 1: punctuation.definition.decorator.python push: - meta_content_scope: entity.name.function.decorator.python - match: (?=\s*\() pop: true - include: dotted_name - match: \( scope: punctuation.definition.arguments.begin.python push: - meta_content_scope: meta.function.decorator.arguments.python - match: (?=\)) pop: true - include: keyword_arguments - include: expressions - match: '^\s*(?=@\s*{{identifier}}(?:\.{{identifier}})*)' push: - meta_scope: meta.function.decorator.python - meta_content_scope: entity.name.function.decorator.python - match: (?=\s|$\n?|#) pop: true - match: '(?=(@)\s*{{identifier}}(\.{{identifier}})*)' captures: 1: punctuation.definition.decorator.python push: - match: (?=\s|$\n?|#) pop: true - include: dotted_name item-access: - match: '(?={{identifier}}(?:\.{{identifier}})*\s*\[)' push: - meta_scope: meta.item-access.python - match: \] scope: punctuation.definition.arguments.end.python pop: true - match: '(?={{identifier}}(?:\.{{identifier}})*\s*\[)' push: - match: '(?=\s*\[)' pop: true - include: dotted_name - match: \[ scope: punctuation.definition.arguments.begin.python push: - meta_content_scope: meta.item-access.arguments.python - match: '(?=\])' pop: true - include: expressions - match: '(?<=\)|\])\s*(\[)' captures: 1: punctuation.definition.arguments.begin.python push: - meta_scope: meta.item-access.python - meta_content_scope: meta.item-access.arguments.python - match: \] scope: punctuation.definition.arguments.end.python pop: true - include: expressions function-calls: - match: '(?<=\)|\])\s*(\()' captures: 1: punctuation.definition.arguments.begin.python push: - meta_scope: meta.function-call.python - meta_content_scope: meta.function-call.arguments.python - match: \) scope: punctuation.definition.arguments.end.python pop: true - include: keyword_arguments - include: expressions - match: '(?={{identifier}}(?:\.{{identifier}})*\s*\()' push: - meta_scope: meta.function-call.python - match: \) scope: punctuation.definition.arguments.end.python pop: true - match: '(?={{identifier}}(?:\.{{identifier}})*\s*\()' push: - match: (?=\s*\() pop: true - include: dotted_name - match: \( scope: punctuation.definition.arguments.begin.python push: - meta_content_scope: meta.function-call.arguments.python - match: (?=\)) pop: true - include: keyword_arguments - include: expressions lambda: - match: \b(lambda)(?=\s+) scope: storage.type.function.inline.python push: - meta_scope: meta.function.inline.python - match: '\:' scope: punctuation.section.function.begin.python pop: true - match: \s+ push: - meta_content_scope: meta.function.inline.parameters.python - match: (?=\:) pop: true - include: keyword_arguments - match: '({{identifier}})\s*(?:(,)|(?=[\n\)\:]))' captures: 1: variable.parameter.function.python 2: punctuation.separator.parameters.python late-keywords: - match: \b(def|lambda)\b scope: storage.type.function.python - match: \b(class)\b scope: storage.type.class.python lists: - match: '(\[)(\s*(\]))\b' captures: 1: punctuation.definition.list.begin.python 2: meta.empty-list.python 3: punctuation.definition.list.end.python - match: \[ scope: punctuation.definition.list.begin.python push: - meta_scope: meta.structure.list.python - match: \] scope: punctuation.definition.list.end.python pop: true - match: ',' scope: punctuation.separator.list.python - include: expressions dictionaries: - match: '(\{)(\s*(\}))' scope: meta.structure.dictionary.python captures: 1: punctuation.definition.dictionary.begin.python 2: meta.empty-dictionary.python 3: punctuation.definition.dictionary.end.python - match: \{ scope: punctuation.definition.dictionary.begin.python push: - meta_scope: meta.structure.dictionary.python - match: \} scope: punctuation.definition.dictionary.end.python pop: true - match: ',' scope: punctuation.separator.dictionary.python - match: ':' scope: punctuation.separator.key-value.python - include: expressions identifier-parts: - match: '{{identifier}}(\.)' captures: 1: punctuation.accessor.python builtin_exceptions: - match: |- (?x)\b( ( Arithmetic|Assertion|Attribute|BlockingIO|BrokenPipe|Buffer|ChildProcess| Connection(Aborted|Refused|Reset)?|EOF|Environment|FileExists| FileNotFound|FloatingPoint|Interrupted|IO|IsADirectoryError| Import|Indentation|Index|Key|Lookup|Memory|Name|NotADirectory| NotImplemented|OS|Overflow|Permission|ProcessLookup|Reference| Runtime|Standard|Syntax|System|Tab|Timeout|Type|UnboundLocal| Unicode(Encode|Decode|Translate)?|Value|VMS|Windows|ZeroDivision )Error| ((Pending)?Deprecation|Runtime|Syntax|User|Future|Import|Unicode|Bytes)?Warning| (Base)?Exception| SystemExit|StopIteration|NotImplemented|KeyboardInterrupt|GeneratorExit )\b scope: support.type.exception.python builtin_functions: - match: |- (?x)\b( __import__|all|abs|any|apply|ascii|bin|callable|chr|classmethod|cmp|coerce| compile|delattr|dir|divmod|enumerate|eval|execfile|filter|format|getattr| globals|hasattr|hash|help|hex|id|input|intern|isinstance|issubclass|iter| len|locals|map|max|min|next|oct|open|ord|pow|print|property|range| raw_input|reduce|reload|repr|reversed|round|setattr|sorted|staticmethod| sum|super|type|unichr|vars|zip )\b scope: support.function.builtin.python builtin_types: - match: |- (?x)\b( basestring|bool|buffer|bytearray|bytes|complex|dict|float|frozenset|int| list|long|memoryview|object|range|set|slice|str|tuple|unicode|xrange )\b scope: support.type.python constant_placeholder: - match: '(?i:(%(\([a-z_]+\))?#?0?\-?[ ]?\+?([0-9]*|\*)(\.([0-9]*|\*))?[hL]?[a-z%])|(\{([!\[\].:\w ]+)?\}))' scope: constant.other.placeholder.python docstrings: - match: '^\s*(?=[uU]?[rR]?""")' push: - meta_scope: comment.block.python - match: (?<=""") pop: true - include: string_quoted_double - match: ^\s*(?=[uU]?[rR]?''') push: - meta_scope: comment.block.python - match: (?<=''') pop: true - include: string_quoted_single dotted_name: - match: '(?={{identifier}}(?:\.{{identifier}})*)' push: - match: '(?![{{identifier_continue}}\.])' pop: true - match: '(\.)(?={{identifier}})' push: - match: "(?!{{identifier_continue}})" pop: true - include: magic_function_names - include: magic_variable_names - include: illegal_names - include: generic_names - match: '(?={{identifier}})' push: - match: "(?!{{identifier_continue}})" pop: true - include: builtin_functions - include: builtin_types - include: builtin_exceptions - include: illegal_names - include: magic_function_names - include: magic_variable_names - include: language_variables - include: generic_names entity_name_class: - include: illegal_names - include: generic_names entity_name_function: - include: magic_function_names - include: illegal_names - include: generic_names escaped_char: - match: '(\\x\h{2})|(\\[0-7]{3})|(\\[\\"''abfnrtv])' captures: 1: constant.character.escape.hex.python 2: constant.character.escape.octal.python 3: constant.character.escape.python escaped_unicode_char: - match: '(\\U\h{8})|(\\u\h{4})|(\\N\{[a-zA-Z ]+\})' captures: 1: constant.character.escape.unicode.16-bit-hex.python 2: constant.character.escape.unicode.32-bit-hex.python 3: constant.character.escape.unicode.name.python function_name: - include: magic_function_names - include: magic_variable_names - include: builtin_exceptions - include: builtin_functions - include: builtin_types - include: generic_names generic_names: - match: "{{identifier}}" illegal_names: - match: \b(and|as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|raise|return|try|while|with|yield)\b scope: invalid.illegal.name.python keyword_arguments: - match: '({{identifier}})\s*(=)(?!=)' captures: 1: variable.parameter.function.python 2: keyword.operator.assignment.python push: - match: '\s*(?:(,)|(?=$\n?|[\)\:]))' captures: 1: punctuation.separator.parameters.python pop: true - include: expressions language_variables: - match: \b(self|cls)\b scope: variable.language.python line_continuation: - match: (\\)(.*)$\n? captures: 1: punctuation.separator.continuation.line.python 2: invalid.illegal.unexpected-text.python magic_function_names: - match: |- (?x)\b(__(?: abs|add|and|call|cmp|coerce|complex|contains|del|delattr| delete|delitem|delslice|div|divmod|enter|eq|exit|float| floordiv|ge|get|getattr|getattribute|getitem|getslice|gt| hash|hex|iadd|iand|idiv|ifloordiv|ilshift|imod|imul|init| int|invert|ior|ipow|irshift|isub|iter|itruediv|ixor|le|len| long|lshift|lt|mod|mul|ne|neg|new|nonzero|oct|or|pos|pow| radd|rand|rdiv|rdivmod|repr|rfloordiv|rlshift|rmod|rmul|ror| rpow|rrshift|rshift|rsub|rtruediv|rxor|set|setattr|setitem| setslice|str|sub|truediv|unicode|xor )__)\b comment: these methods have magic interpretation by python and are generally called indirectly through syntactic constructs scope: support.function.magic.python magic_variable_names: - match: \b__(all|bases|class|debug|dict|doc|file|members|metaclass|methods|name|slots|weakref)__\b comment: magic variables which a class/module may have. scope: support.variable.magic.python string_quoted_double: # Triple-quoted capital R raw string, unicode or not, no syntax embedding - match: '([uU]?R)(""")' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.double.block.python - match: '"""' scope: punctuation.definition.string.end.python pop: true - include: escaped_unicode_char # Triple-quoted capital R raw string, bytes, no syntax embedding - match: '([bB]R|R[bB])(""")' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.double.block.python - match: '"""' scope: punctuation.definition.string.end.python pop: true # Triple-quoted raw string, unicode or not, will detect SQL, otherwise regex - match: '([uU]?r)(""")' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.double.block.python - match: '(?={{sql_indicator}})' set: - meta_scope: string.quoted.double.block.python - match: '"""' scope: punctuation.definition.string.end.python pop: true - match: '' with_prototype: - match: '(?=""")' pop: true - include: escaped_unicode_char - include: constant_placeholder push: 'scope:source.sql' - match: '(?=\S)' set: - meta_scope: string.quoted.double.block.python - match: '"""' scope: punctuation.definition.string.end.python pop: true - match: '' with_prototype: - match: '(?=""")' pop: true - include: escaped_unicode_char push: 'scope:source.regexp.python' # Triple-quoted raw string, bytes, will use regex - match: '([bB]r|r[bB])(""")' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.double.block.python - match: '"""' scope: punctuation.definition.string.end.python pop: true - match: '' with_prototype: - match: '(?=""")' pop: true push: 'scope:source.regexp.python' # Triple-quoted string, unicode or not, will detect SQL - match: '([uU]?)(""")' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.double.block.python - match: '(?={{sql_indicator}})' set: - meta_scope: string.quoted.double.block.python - match: '"""' scope: punctuation.definition.string.end.python pop: true - match: '' with_prototype: - match: '(?=""")' pop: true - include: escaped_unicode_char - include: escaped_char - include: constant_placeholder push: 'scope:source.sql' - match: '(?=\S)' set: - meta_scope: string.quoted.double.block.python - match: '"""' scope: punctuation.definition.string.end.python pop: true - include: escaped_unicode_char - include: escaped_char - include: constant_placeholder # Triple-quoted string, bytes, no syntax embedding - match: '([bB])(""")' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.double.block.python - match: '"""' scope: punctuation.definition.string.end.python pop: true - include: escaped_char - include: constant_placeholder # Single-line capital R raw string, unicode or not, no syntax embedding - match: '([uU]?R)(")' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.double.block.python - match: '(")|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true - include: escaped_unicode_char # Single-line capital R raw string, bytes, no syntax embedding - match: '([bB]R|R[bB])(")' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.double.block.python - match: '(")|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true # Single-line raw string, unicode or not, starting with a SQL keyword - match: '([uU]?r)(")(?={{sql_indicator}})' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.double.block.python - match: '(")|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true - match: '' with_prototype: - match: '(?="|\n)' pop: true - include: escaped_unicode_char - include: constant_placeholder push: 'scope:source.sql' # Single-line raw string, unicode or not, treated as regex - match: '([uU]?r)(")' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.double.block.python - match: '(")|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true - match: '' with_prototype: - match: '(?="|\n)' pop: true - include: escaped_unicode_char push: 'scope:source.regexp.python' # Single-line raw string, bytes, treated as regex - match: '([bB]r|r[bB])(")' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.double.block.python - match: '(")|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true - match: '' with_prototype: - match: '(?="|\n)' pop: true push: 'scope:source.regexp.python' # Single-line string, unicode or not, starting with a SQL keyword - match: '([uU]?)(")(?={{sql_indicator}})' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.double.block.python - match: '(")|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true - match: '' with_prototype: - match: '(?="|\n)' pop: true - include: escaped_unicode_char - include: escaped_char - include: constant_placeholder push: 'scope:source.sql' # Single-line string, unicode or not - match: '([uU]?)(")' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.double.block.python - match: '(")|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true - include: escaped_unicode_char - include: escaped_char - include: constant_placeholder # Single-line string, bytes - match: '([bB])(")' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.double.block.python - match: '(")|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true - include: escaped_char - include: constant_placeholder string_quoted_single: # Triple-quoted capital R raw string, unicode or not, no syntax embedding - match: ([uU]?R)(''') captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.single.block.python - match: "'''" scope: punctuation.definition.string.end.python pop: true - include: escaped_unicode_char # Triple-quoted capital R raw string, bytes, no syntax embedding - match: ([bB]R|R[bB])(''') captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.single.block.python - match: "'''" scope: punctuation.definition.string.end.python pop: true # Triple-quoted raw string, unicode or not, will detect SQL, otherwise regex - match: ([uU]?r)(''') captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.single.block.python - match: '(?={{sql_indicator}})' set: - meta_scope: string.quoted.single.block.python - match: "'''" scope: punctuation.definition.string.end.python pop: true - match: '' with_prototype: - match: (?=''') pop: true - include: escaped_unicode_char - include: constant_placeholder push: 'scope:source.sql' - match: '(?=\S)' set: - meta_scope: string.quoted.single.block.python - match: "'''" scope: punctuation.definition.string.end.python pop: true - match: '' with_prototype: - match: (?=''') pop: true - include: escaped_unicode_char push: 'scope:source.regexp.python' # Triple-quoted raw string, bytes, will use regex - match: ([bB]r|r[bB])(''') captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.single.block.python - match: "'''" scope: punctuation.definition.string.end.python pop: true - match: '' with_prototype: - match: (?=''') pop: true push: 'scope:source.regexp.python' # Triple-quoted string, unicode or not, will detect SQL - match: ([uU]?)(''') captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.single.block.python - match: '(?={{sql_indicator}})' set: - meta_scope: string.quoted.single.block.python - match: "'''" scope: punctuation.definition.string.end.python pop: true - match: '' with_prototype: - match: (?=''') pop: true - include: escaped_unicode_char - include: escaped_char - include: constant_placeholder push: 'scope:source.sql' - match: '(?=\S)' set: - meta_scope: string.quoted.single.block.python - match: "'''" scope: punctuation.definition.string.end.python pop: true - include: escaped_unicode_char - include: escaped_char - include: constant_placeholder # Triple-quoted string, bytes, no syntax embedding - match: ([bB])(''') captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.single.block.python - match: "'''" scope: punctuation.definition.string.end.python pop: true - include: escaped_char - include: constant_placeholder # Single-line capital R raw string, unicode or not, no syntax embedding - match: '([uU]?R)('')' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.single.block.python - match: '('')|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true - include: escaped_unicode_char # Single-line capital R raw string, bytes, no syntax embedding - match: '([bB]R|R[bB])('')' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.single.block.python - match: '('')|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true # Single-line raw string, unicode or not, starting with a SQL keyword - match: '([uU]?r)('')(?={{sql_indicator}})' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.single.block.python - match: '('')|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true - match: '' with_prototype: - match: '(?=''|\n)' pop: true - include: escaped_unicode_char - include: constant_placeholder push: 'scope:source.sql' # Single-line raw string, unicode or not, treated as regex - match: '([uU]?r)('')' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.single.block.python - match: '('')|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true - match: '' with_prototype: - match: '(?=''|\n)' pop: true - include: escaped_unicode_char push: 'scope:source.regexp.python' # Single-line raw string, bytes, treated as regex - match: '([bB]r|r[bB])('')' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.single.block.python - match: '('')|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true - match: '' with_prototype: - match: '(?=''|\n)' pop: true push: 'scope:source.regexp.python' # Single-line string, unicode or not, starting with a SQL keyword - match: '([uU]?)('')(?={{sql_indicator}})' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.single.block.python - match: '('')|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true - match: '' with_prototype: - match: '(?=''|\n)' pop: true - include: escaped_unicode_char - include: escaped_char - include: constant_placeholder push: 'scope:source.sql' # Single-line string, unicode or not - match: '([uU]?)('')' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.single.block.python - match: '('')|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true - include: escaped_unicode_char - include: escaped_char - include: constant_placeholder # Single-line string, bytes - match: '([bB])('')' captures: 1: storage.type.string.python 2: punctuation.definition.string.begin.python push: - meta_scope: string.quoted.single.block.python - match: '('')|(\n)' captures: 1: punctuation.definition.string.end.python 2: invalid.illegal.unclosed-string.python pop: true - include: escaped_char - include: constant_placeholder strings: - include: string_quoted_double - include: string_quoted_single