diff --git a/.gitignore b/.gitignore index 4377bfda..e17b261b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ node_modules .DS_Store *.cache *.pyc - +package-lock.json diff --git a/Makefile b/Makefile index 2d09f37c..21b1edbf 100644 --- a/Makefile +++ b/Makefile @@ -15,11 +15,16 @@ ci-test: release ] ; \ then echo "Error: package.version != git.tag" && exit 1 ; fi +update-test: +# Run tests and overwrite the output + ./node_modules/.bin/syntaxdev test --tests test/**/*.py --syntax grammars/src/MagicPython.syntax.yaml --overwrite-tests + ./node_modules/.bin/syntaxdev test --tests test/**/*.re --syntax grammars/src/MagicRegExp.syntax.yaml --overwrite-tests + test: ci-test - atom -t . + atom -t test/atom-spec devenv: - npm install syntaxdev@0.0.16 + npm install --dev release: ./node_modules/.bin/syntaxdev build-plist --in grammars/src/MagicPython.syntax.yaml --out grammars/MagicPython.tmLanguage diff --git a/README.md b/README.md index 41a48420..64d9eb43 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ with [Sublime Text](http://www.sublimetext.com), [Atom](http://atom.io) and [Visual Studio Code](http://code.visualstudio.com). It is meant to be a drop-in replacement for the default Python package. -We are proud to say that MagicPython is used by GitHub to highlight Python. - **Attention VSCode users**: MagicPython is used as the _default_ Python highlighter in Visual Studio Code. Don't install it unless you want or need the cutting edge version of it. You will likely see no diff --git a/grammars/MagicPython.cson b/grammars/MagicPython.cson index 526b2873..d837d6a3 100644 --- a/grammars/MagicPython.cson +++ b/grammars/MagicPython.cson @@ -17,9 +17,9 @@ fileTypes: [ "wsgi" "kv" "Snakefile" + "smk" "tac" ] -first_line_match: "^#![ \\t]*/.*\\bpython[\\d\\.]*\\b" firstLineMatch: "^#![ \\t]*/.*\\bpython[\\d\\.]*\\b" uuid: "742deb57-6e38-4192-bed6-410746efd85d" patterns: [ @@ -45,6 +45,9 @@ repository: { include: "#function-declaration" } + { + include: "#generator" + } { include: "#statement-keyword" } @@ -129,7 +132,8 @@ repository: ] "docstring-statement": begin: "^(?=\\s*[rR]?(\\'\\'\\'|\\\"\\\"\\\"|\\'|\\\"))" - end: "(?<=\\'\\'\\'|\\\"\\\"\\\"|\\'|\\\")" + 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" @@ -186,7 +190,7 @@ repository: { name: "string.quoted.docstring.single.python" begin: "(\\'|\\\")" - end: "(\\1)|((?= | <= | < | >) (?# 5) + | (:=) (?# 6) + ''' captures: "1": @@ -567,6 +645,8 @@ repository: name: "keyword.operator.arithmetic.python" "5": name: "keyword.operator.comparison.python" + "6": + name: "keyword.operator.assignment.python" punctuation: patterns: [ { @@ -654,8 +734,6 @@ repository: name: "storage.type.imaginary.number.python" "2": name: "invalid.illegal.dec.python" - "3": - name: "invalid.illegal.dec.python" "number-hex": name: "constant.numeric.hex.python" match: ''' @@ -719,18 +797,6 @@ repository: { include: "#regexp-double-one-line" } - { - include: "#fregexp-single-three-line" - } - { - include: "#fregexp-double-three-line" - } - { - include: "#fregexp-single-one-line" - } - { - include: "#fregexp-double-one-line" - } ] string: patterns: [ @@ -873,7 +939,7 @@ repository: } ] "f-expression": - comment: "All valid Python expressions, except comments and line cont" + comment: "All valid Python expressions, except comments and line continuation" patterns: [ { include: "#expression-bare" @@ -916,27 +982,32 @@ repository: name: "constant.language.python" match: "\\\\$" "string-formatting": - name: "constant.character.format.placeholder.other.python" + name: "meta.format.percent.python" match: ''' (?x) - % (\\([\\w\\s]*\\))? - [-+#0 ]* - (\\d+|\\*)? (\\.(\\d+|\\*))? - ([hlL])? - [diouxXeEfFgGcrsa%] + ( + % (\\([\\w\\s]*\\))? + [-+#0 ]* + (\\d+|\\*)? (\\.(\\d+|\\*))? + ([hlL])? + [diouxXeEfFgGcrsab%] + ) ''' + captures: + "1": + name: "constant.character.format.placeholder.other.python" "string-brace-formatting": patterns: [ { - name: "constant.character.format.placeholder.other.python" + name: "meta.format.brace.python" match: ''' (?x) - (?: + ( {{ | }} | (?: { - \\w*? (\\.[[:alpha:]_]\\w*? | \\[[^\\]'"]+\\])*? + \\w* (\\.[[:alpha:]_]\\w* | \\[[^\\]'"]+\\])* (![rsa])? ( : \\w? [<>=^]? [-+ ]? \\#? \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )? @@ -945,36 +1016,36 @@ repository: ''' captures: - "2": - name: "storage.type.format.python" + "1": + name: "constant.character.format.placeholder.other.python" "3": name: "storage.type.format.python" + "4": + name: "storage.type.format.python" } { - name: "constant.character.format.placeholder.other.python" - begin: ''' + name: "meta.format.brace.python" + match: ''' (?x) - \\{ - \\w*? (\\.[[:alpha:]_]\\w*? | \\[[^\\]'"]+\\])*? + ( + { + \\w* (\\.[[:alpha:]_]\\w* | \\[[^\\]'"]+\\])* (![rsa])? (:) - (?=[^'"}\\n]*\\}) + [^'"{}\\n]* (?: + \\{ [^'"}\\n]*? \\} [^'"{}\\n]* + )* + } + ) ''' - end: "\\}" - beginCaptures: - "2": - name: "storage.type.format.python" + captures: + "1": + name: "constant.character.format.placeholder.other.python" "3": name: "storage.type.format.python" - patterns: [ - { - match: ''' - (?x) \\{ [^'"}\\n]*? \\} (?=.*?\\}) - - ''' - } - ] + "4": + name: "storage.type.format.python" } ] "fstring-formatting": @@ -991,27 +1062,41 @@ repository: match: "(}(?!}))" import: comment: ''' - Import statements + Import statements used to correctly mark `from`, `import`, and `as` ''' patterns: [ { - match: ''' - (?x) - \\s* \\b(from)\\b \\s*(\\.+)\\s* (import)? - - ''' - captures: + begin: "\\b(?) - - ''' - end: "(\\)|(?=\\'))|((?=(?) - - ''' - end: "(\\)|(?=\\'\\'\\'))" - beginCaptures: - "1": - name: "punctuation.parenthesis.named.begin.regexp support.other.parenthesis.regexp" - "2": - name: "entity.name.tag.named.group.regexp" - endCaptures: - "1": - name: "punctuation.parenthesis.named.end.regexp support.other.parenthesis.regexp" - "2": - name: "invalid.illegal.newline.python" - patterns: [ - { - include: "#single-three-fregexp-expression" - } - { - include: "#comments-string-single-three" - } - ] - "single-three-fregexp-lookahead": - begin: "(\\()\\?=" - end: "(\\)|(?=\\'\\'\\'))" - beginCaptures: - "0": - name: "keyword.operator.lookahead.regexp" - "1": - name: "punctuation.parenthesis.lookahead.begin.regexp" - endCaptures: - "1": - name: "punctuation.parenthesis.lookahead.end.regexp keyword.operator.lookahead.regexp" - "2": - name: "invalid.illegal.newline.python" - patterns: [ - { - include: "#single-three-fregexp-expression" - } - { - include: "#comments-string-single-three" - } - ] - "single-three-fregexp-lookahead-negative": - begin: "(\\()\\?!" - end: "(\\)|(?=\\'\\'\\'))" - beginCaptures: - "0": - name: "keyword.operator.lookahead.negative.regexp" - "1": - name: "punctuation.parenthesis.lookahead.begin.regexp" - endCaptures: - "1": - name: "punctuation.parenthesis.lookahead.end.regexp keyword.operator.lookahead.negative.regexp" - "2": - name: "invalid.illegal.newline.python" - patterns: [ - { - include: "#single-three-fregexp-expression" - } - { - include: "#comments-string-single-three" - } - ] - "single-three-fregexp-lookbehind": - begin: "(\\()\\?<=" - end: "(\\)|(?=\\'\\'\\'))" - beginCaptures: - "0": - name: "keyword.operator.lookbehind.regexp" - "1": - name: "punctuation.parenthesis.lookbehind.begin.regexp" - endCaptures: - "1": - name: "punctuation.parenthesis.lookbehind.end.regexp keyword.operator.lookbehind.regexp" - "2": - name: "invalid.illegal.newline.python" - patterns: [ - { - include: "#single-three-fregexp-expression" - } - { - include: "#comments-string-single-three" - } - ] - "single-three-fregexp-lookbehind-negative": - begin: "(\\()\\?) - - ''' - end: "(\\)|(?=\"))|((?=(?) - - ''' - end: "(\\)|(?=\"\"\"))" - beginCaptures: - "1": - name: "punctuation.parenthesis.named.begin.regexp support.other.parenthesis.regexp" - "2": - name: "entity.name.tag.named.group.regexp" - endCaptures: - "1": - name: "punctuation.parenthesis.named.end.regexp support.other.parenthesis.regexp" - "2": - name: "invalid.illegal.newline.python" - patterns: [ - { - include: "#double-three-fregexp-expression" - } - { - include: "#comments-string-double-three" - } - ] - "double-three-fregexp-lookahead": - begin: "(\\()\\?=" - end: "(\\)|(?=\"\"\"))" - beginCaptures: - "0": - name: "keyword.operator.lookahead.regexp" - "1": - name: "punctuation.parenthesis.lookahead.begin.regexp" - endCaptures: - "1": - name: "punctuation.parenthesis.lookahead.end.regexp keyword.operator.lookahead.regexp" - "2": - name: "invalid.illegal.newline.python" - patterns: [ - { - include: "#double-three-fregexp-expression" - } - { - include: "#comments-string-double-three" - } - ] - "double-three-fregexp-lookahead-negative": - begin: "(\\()\\?!" - end: "(\\)|(?=\"\"\"))" - beginCaptures: - "0": - name: "keyword.operator.lookahead.negative.regexp" - "1": - name: "punctuation.parenthesis.lookahead.begin.regexp" - endCaptures: - "1": - name: "punctuation.parenthesis.lookahead.end.regexp keyword.operator.lookahead.negative.regexp" - "2": - name: "invalid.illegal.newline.python" - patterns: [ - { - include: "#double-three-fregexp-expression" - } - { - include: "#comments-string-double-three" - } - ] - "double-three-fregexp-lookbehind": - begin: "(\\()\\?<=" - end: "(\\)|(?=\"\"\"))" - beginCaptures: - "0": - name: "keyword.operator.lookbehind.regexp" - "1": - name: "punctuation.parenthesis.lookbehind.begin.regexp" - endCaptures: - "1": - name: "punctuation.parenthesis.lookbehind.end.regexp keyword.operator.lookbehind.regexp" - "2": - name: "invalid.illegal.newline.python" - patterns: [ - { - include: "#double-three-fregexp-expression" - } - { - include: "#comments-string-double-three" - } - ] - "double-three-fregexp-lookbehind-negative": - begin: "(\\()\\?=^]? [-+ ]? \\#? \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )(?=}) @@ -4635,7 +3868,7 @@ repository: } ] "fstring-terminator-single-tail": - begin: "(![rsa])?(:)(?=.*?{)" + begin: "((?:=?)(?:![rsa])?)(:)(?=.*?{)" end: "(?=})|(?=\\n)" beginCaptures: "1": @@ -4744,7 +3977,7 @@ repository: ] "fstring-raw-quoted-multi-line": name: "meta.fstring.python" - begin: "(\\b(?:[R][fF]|[fF][R]))('''|\"\"\")" + begin: "(\\b(?:[rR][fF]|[fF][rR]))('''|\"\"\")" end: "(\\2)" beginCaptures: "1": @@ -4838,12 +4071,16 @@ repository: patterns: [ { name: "storage.type.format.python" - match: "(![rsa])(?=})" + match: "(=(![rsa])?)(?=})" + } + { + name: "storage.type.format.python" + match: "(=?![rsa])(?=})" } { match: ''' (?x) - (![rsa])? + ( (?: =?) (?: ![rsa])? ) ( : \\w? [<>=^]? [-+ ]? \\#? \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )(?=}) @@ -4859,7 +4096,7 @@ repository: } ] "fstring-terminator-multi-tail": - begin: "(![rsa])?(:)(?=.*?{)" + begin: "((?:=?)(?:![rsa])?)(:)(?=.*?{)" end: "(?=})" beginCaptures: "1": diff --git a/grammars/MagicPython.tmLanguage b/grammars/MagicPython.tmLanguage index ae03ed0e..a1c3f8e7 100644 --- a/grammars/MagicPython.tmLanguage +++ b/grammars/MagicPython.tmLanguage @@ -1,7 +1,7 @@ - + name MagicPython @@ -24,10 +24,9 @@ wsgi kv Snakefile + smk tac - first_line_match - ^#![ \t]*/.*\bpython[\d\.]*\b firstLineMatch ^#![ \t]*/.*\bpython[\d\.]*\b uuid @@ -68,6 +67,10 @@ include #function-declaration + + include + #generator + include #statement-keyword @@ -184,8 +187,10 @@ 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 @@ -287,7 +292,7 @@ begin (\'|\") end - (\1)|((?<!\\)\n) + (\1)|(\n) beginCaptures 1 @@ -327,7 +332,7 @@ begin ([rR])(\'|\") end - (\2)|((?<!\\)\n) + (\2)|(\n) beginCaptures 1 @@ -414,13 +419,37 @@ match \b((async\s+)?\s*def)\b + + name + keyword.control.flow.python + comment + if `as` is eventually followed by `:` or line continuation +it's probably control flow like: + with foo as bar, \ + Foo as Bar: + try: + do_stuff() + except Exception as e: + pass + + match + \b(?<!\.)as\b(?=.*[:\\]) + + + name + keyword.control.import.python + comment + other legal use of `as` is in an import + match + \b(?<!\.)as\b + name keyword.control.flow.python match (?x) \b(?<!\.)( - as | async | continue | del | assert | break | finally | for + async | continue | del | assert | break | finally | for | from | elif | else | if | except | pass | raise | return | try | while | with )\b @@ -442,6 +471,22 @@ match \b(?<!\.)(class)\b + + match + (?x) + ^\s*( + case | match + )(?=\s*([-+\w\d(\[{'":#]|$))\b + + captures + + 1 + + name + keyword.control.flow.python + + + expression-bare @@ -474,6 +519,10 @@ include #lambda + + include + #generator + include #illegal-operator @@ -494,6 +543,10 @@ include #list + + include + #odd-function-call + include #round-braces @@ -588,6 +641,8 @@ member-access + name + meta.member.access.python begin (\.)\s*(?!\.) end @@ -618,6 +673,10 @@ include #member-access-base + + include + #member-access-attribute + member-access-base @@ -650,6 +709,17 @@ + member-access-attribute + + comment + Highlight attribute access in otherwise non-specialized cases. + name + meta.attribute.python + match + (?x) + \b ([[:alpha:]_]\w*) \b + + special-names name @@ -735,6 +805,36 @@ + odd-function-call + + comment + A bit obscured function call where there may have been an +arbitrary number of other operations to get the function. +E.g. "arr[idx](args)" + + begin + (?x) + (?<= \] | \) ) \s* + (?=\() + + end + (\)) + endCaptures + + 1 + + name + punctuation.definition.arguments.end.python + + + patterns + + + include + #function-arguments + + + round-braces begin @@ -849,6 +949,8 @@ | (\*\* | \* | \+ | - | % | // | / | @) (?# 4) | (!= | == | >= | <= | < | >) (?# 5) + + | (:=) (?# 6) captures @@ -877,6 +979,11 @@ name keyword.operator.comparison.python + 6 + + name + keyword.operator.assignment.python + punctuation @@ -1006,11 +1113,6 @@ name invalid.illegal.dec.python - 3 - - name - invalid.illegal.dec.python - number-hex @@ -1111,22 +1213,6 @@ include #regexp-double-one-line - - include - #fregexp-single-three-line - - - include - #fregexp-double-three-line - - - include - #fregexp-single-one-line - - - include - #fregexp-double-one-line - string @@ -1349,7 +1435,7 @@ f-expression comment - All valid Python expressions, except comments and line cont + All valid Python expressions, except comments and line continuation patterns @@ -1409,15 +1495,25 @@ string-formatting name - constant.character.format.placeholder.other.python + meta.format.percent.python match (?x) - % (\([\w\s]*\))? - [-+#0 ]* - (\d+|\*)? (\.(\d+|\*))? - ([hlL])? - [diouxXeEfFgGcrsa%] + ( + % (\([\w\s]*\))? + [-+#0 ]* + (\d+|\*)? (\.(\d+|\*))? + ([hlL])? + [diouxXeEfFgGcrsab%] + ) + captures + + 1 + + name + constant.character.format.placeholder.other.python + + string-brace-formatting @@ -1425,14 +1521,14 @@ name - constant.character.format.placeholder.other.python + meta.format.brace.python match (?x) - (?: + ( {{ | }} | (?: { - \w*? (\.[[:alpha:]_]\w*? | \[[^\]'"]+\])*? + \w* (\.[[:alpha:]_]\w* | \[[^\]'"]+\])* (![rsa])? ( : \w? [<>=^]? [-+ ]? \#? \d* ,? (\.\d+)? [bcdeEfFgGnosxX%]? )? @@ -1441,52 +1537,57 @@ captures - 2 + 1 name - storage.type.format.python + constant.character.format.placeholder.other.python 3 name storage.type.format.python + 4 + + name + storage.type.format.python + name - constant.character.format.placeholder.other.python - begin + meta.format.brace.python + match (?x) - \{ - \w*? (\.[[:alpha:]_]\w*? | \[[^\]'"]+\])*? + ( + { + \w* (\.[[:alpha:]_]\w* | \[[^\]'"]+\])* (![rsa])? (:) - (?=[^'"}\n]*\}) + [^'"{}\n]* (?: + \{ [^'"}\n]*? \} [^'"{}\n]* + )* + } + ) - end - \} - beginCaptures + captures - 2 + 1 name - storage.type.format.python + constant.character.format.placeholder.other.python 3 name storage.type.format.python - - patterns - + 4 - match - (?x) \{ [^'"}\n]*? \} (?=.*?\}) - + name + storage.type.format.python - + @@ -1514,39 +1615,63 @@ import comment - Import statements + Import statements used to correctly mark `from`, `import`, and `as` patterns - match - (?x) - \s* \b(from)\b \s*(\.+)\s* (import)? - - captures + begin + \b(?<!\.)(from)\b(?=.+import) + end + $|(?=import) + beginCaptures 1 name keyword.control.import.python - 2 + + patterns + name punctuation.separator.period.python + match + \.+ - 3 + + include + #expression + + + + + begin + \b(?<!\.)(import)\b + end + $ + beginCaptures + + 1 name keyword.control.import.python - - - name - keyword.control.import.python - match - \b(?<!\.)import\b + patterns + + + name + keyword.control.import.python + match + \b(?<!\.)as\b + + + include + #expression + + @@ -1731,6 +1856,8 @@ member-access-class + name + meta.member.access.python begin (\.)\s*(?!\.) end @@ -1816,6 +1943,12 @@ meta.function.lambda.parameters.python patterns + + name + keyword.operator.positional.parameter.python + match + / + name keyword.operator.unpacking.parameter.python @@ -1927,6 +2060,40 @@ + generator + + comment + Match "for ... in" construct used in generators and for loops to +correctly identify the "in" as a control flow keyword. + + begin + \bfor\b + beginCaptures + + 0 + + name + keyword.control.flow.python + + + end + \bin\b + endCaptures + + 0 + + name + keyword.control.flow.python + + + patterns + + + include + #expression + + + function-declaration name @@ -2030,6 +2197,12 @@ patterns + + name + keyword.operator.positional.parameter.python + match + / + name keyword.operator.unpacking.parameter.python @@ -2270,6 +2443,8 @@ #special-names + name + meta.indexed-name.python match (?x) \b ([[:alpha:]_]\w*) \b @@ -2314,7 +2489,7 @@ begin (?x) ^\s* - (@) \s* (?=[[:alpha:]_]\w*) + ((@)) \s* (?=[[:alpha:]_]\w*) end (?x) @@ -2330,6 +2505,11 @@ name entity.name.function.decorator.python + 2 + + name + punctuation.definition.decorator.python + endCaptures @@ -2373,8 +2553,16 @@ entity.name.function.decorator.python match (?x) - ([[:alpha:]_]\w*) | \. + ([[:alpha:]_]\w*) | (\.) + captures + + 2 + + name + punctuation.separator.period.python + + include @@ -2454,6 +2642,8 @@ name meta.function-call.python + comment + Regular function call of the type "name(args)" begin (?x) \b(?= @@ -2509,12 +2699,7 @@ function-arguments begin - (?x) - (?: - (\() - (?:\s*(\*\*|\*))? - ) - + (\() end (?=\))(?!\)\s*\() beginCaptures @@ -2524,32 +2709,25 @@ name punctuation.definition.arguments.begin.python - 2 - - name - keyword.operator.unpacking.arguments.python - contentName meta.function-call.arguments.python patterns + + name + punctuation.separator.arguments.python + match + (,) + match (?x) - (?: - (,) - (?:\s*(\*\*|\*))? - ) + (?:(?<=[,(])|^) \s* (\*{1,2}) captures 1 - - name - punctuation.separator.arguments.python - - 2 name keyword.operator.unpacking.arguments.python @@ -2690,14 +2868,14 @@ match (?x) (?<!\.) \b( - __import__ | abs | all | any | ascii | bin | callable - | chr | compile | copyright | credits | delattr | dir | divmod - | enumerate | eval | exec | exit | filter | format | getattr - | globals | hasattr | hash | help | hex | id | input - | isinstance | issubclass | iter | len | license | locals | map - | max | memoryview | min | next | oct | open | ord | pow | print - | quit | range | reload | repr | reversed | round - | setattr | sorted | sum | vars | zip + __import__ | abs | aiter | all | any | anext | ascii | bin + | breakpoint | callable | chr | compile | copyright | credits + | delattr | dir | divmod | enumerate | eval | exec | exit + | filter | format | getattr | globals | hasattr | hash | help + | hex | id | input | isinstance | issubclass | iter | len + | license | locals | map | max | memoryview | min | next + | oct | open | ord | pow | print | quit | range | reload | repr + | reversed | round | setattr | sorted | sum | vars | zip )\b @@ -2742,24 +2920,29 @@ indirectly through syntactic constructs (?x) \b( __(?: - abs | add | aenter | aexit | aiter | and | anext | await - | bool | call | ceil | cmp | coerce | complex | contains - | copy | deepcopy | del | delattr | delete | delitem - | delslice | dir | div | divmod | enter | eq | exit | float - | floor | floordiv | format | ge | get | getattr - | getattribute | getinitargs | getitem | getnewargs - | getslice | getstate | gt | hash | hex | iadd | iand | idiv - | ifloordiv | ilshift | imod | imul | index | init - | instancecheck | int | invert | ior | ipow | irshift | isub - | iter | itruediv | ixor | le | len | long | lshift | lt - | missing | mod | mul | ne | neg | new | next | nonzero | oct | or - | pos | pow | radd | rand | rdiv | rdivmod | reduce - | reduce_ex | repr | reversed | rfloordiv | rlshift | rmod - | rmul | ror | round | rpow | rrshift | rshift | rsub - | rtruediv | rxor | set | setattr | setitem | setslice - | setstate | sizeof | str | sub | subclasscheck | truediv - | trunc | unicode | xor | matmul | rmatmul | imatmul - | init_subclass | set_name | fspath | bytes | prepare + abs | add | aenter | aexit | aiter | and | anext + | await | bool | call | ceil | class_getitem + | cmp | coerce | complex | contains | copy + | deepcopy | del | delattr | delete | delitem + | delslice | dir | div | divmod | enter | eq + | exit | float | floor | floordiv | format | ge + | get | getattr | getattribute | getinitargs + | getitem | getnewargs | getslice | getstate | gt + | hash | hex | iadd | iand | idiv | ifloordiv | + | ilshift | imod | imul | index | init + | instancecheck | int | invert | ior | ipow + | irshift | isub | iter | itruediv | ixor | le + | len | long | lshift | lt | missing | mod | mul + | ne | neg | new | next | nonzero | oct | or | pos + | pow | radd | rand | rdiv | rdivmod | reduce + | reduce_ex | repr | reversed | rfloordiv | + | rlshift | rmod | rmul | ror | round | rpow + | rrshift | rshift | rsub | rtruediv | rxor | set + | setattr | setitem | set_name | setslice + | setstate | sizeof | str | sub | subclasscheck + | truediv | trunc | unicode | xor | matmul + | rmatmul | imatmul | init_subclass | set_name + | fspath | bytes | prepare | length_hint )__ )\b @@ -2780,12 +2963,12 @@ indirectly through syntactic constructs (?x) \b( __(?: - all | bases | builtins | class | code | debug | defaults | dict - | doc | file | func | kwdefaults | members - | metaclass | methods | module | mro | name - | qualname | self | signature | slots | subclasses - | version | weakref | wrapped | annotations | classcell - | spec | path | package | future | traceback + all | annotations | bases | builtins | class + | closure | code | debug | defaults | dict | doc | file | func + | globals | kwdefaults | match_args | members | metaclass | methods + | module | mro | mro_entries | name | qualname | post_init | self + | signature | slots | subclasses | version | weakref | wrapped + | classcell | spec | path | package | future | traceback )__ )\b @@ -2814,18 +2997,33 @@ indirectly through syntactic constructs illegal-names - name - keyword.control.flow.python match (?x) - \b( - and | as | assert | async | await | break | class | continue | def - | del | elif | else | except | exec | finally | for | from | global - | if | import | in | is | (?<=\.)lambda | lambda(?=\s*[\.=]) - | nonlocal | not | or | pass | raise | return | try | while | with - | yield + \b(?: + ( + and | assert | async | await | break | class | continue | def + | del | elif | else | except | finally | for | from | global + | if | in | is | (?<=\.)lambda | lambda(?=\s*[\.=]) + | nonlocal | not | or | pass | raise | return | try | while | with + | yield + ) | ( + as | import + ) )\b + captures + + 1 + + name + keyword.control.flow.python + + 2 + + name + keyword.control.import.python + + special-variables @@ -5453,85 +5651,30 @@ indirectly through syntactic constructs - single-one-fregexp-expression - - patterns - - - include - #fregexp-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-fregexp-lookahead - - - include - #single-one-fregexp-lookahead-negative - - - include - #single-one-fregexp-lookbehind - - - include - #single-one-fregexp-lookbehind-negative - - - include - #single-one-fregexp-conditional - - - include - #single-one-fregexp-parentheses-non-capturing - - - include - #single-one-fregexp-parentheses - - - - single-one-fregexp-named-group + string-raw-quoted-single-line name - meta.named.regexp + string.quoted.raw.single.python begin - (?x) - (\() (\?P <\w+(?:\s+[[:alnum:]]+)?>) - + \b(([uU]R)|(R))((['"])) end - (\)|(?=\'))|((?=(?<!\\)\n)) + (\4)|((?<!\\)\n) beginCaptures - 1 + 2 name - support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp + invalid.deprecated.prefix.python - 2 + 3 name - entity.name.tag.named.group.regexp + storage.type.string.python + + 4 + + name + punctuation.definition.string.begin.python endCaptures @@ -5539,7 +5682,7 @@ indirectly through syntactic constructs 1 name - support.other.parenthesis.regexp punctuation.parenthesis.named.end.regexp + punctuation.definition.string.end.python 2 @@ -5551,27 +5694,37 @@ indirectly through syntactic constructs include - #single-one-fregexp-expression + #string-single-bad-brace1-formatting-raw + + + include + #string-single-bad-brace2-formatting-raw + + + include + #string-raw-guts - single-one-fregexp-lookahead + string-bin-quoted-single-line + name + string.quoted.binary.single.python begin - (\()\?= + (\b[bB])((['"])) end - (\)|(?=\'))|((?=(?<!\\)\n)) + (\2)|((?<!\\)\n) beginCaptures - 0 + 1 name - keyword.operator.lookahead.regexp + storage.type.string.python - 1 + 2 name - punctuation.parenthesis.lookahead.begin.regexp + punctuation.definition.string.begin.python endCaptures @@ -5579,7 +5732,7 @@ indirectly through syntactic constructs 1 name - keyword.operator.lookahead.regexp punctuation.parenthesis.lookahead.end.regexp + punctuation.definition.string.end.python 2 @@ -5591,27 +5744,29 @@ indirectly through syntactic constructs include - #single-one-fregexp-expression + #string-entity - single-one-fregexp-lookahead-negative + string-raw-bin-quoted-single-line + name + string.quoted.raw.binary.single.python begin - (\()\?! + (\b(?:R[bB]|[bB]R))((['"])) end - (\)|(?=\'))|((?=(?<!\\)\n)) + (\2)|((?<!\\)\n) beginCaptures - 0 + 1 name - keyword.operator.lookahead.negative.regexp + storage.type.string.python - 1 + 2 name - punctuation.parenthesis.lookahead.begin.regexp + punctuation.definition.string.begin.python endCaptures @@ -5619,7 +5774,7 @@ indirectly through syntactic constructs 1 name - keyword.operator.lookahead.negative.regexp punctuation.parenthesis.lookahead.end.regexp + punctuation.definition.string.end.python 2 @@ -5631,27 +5786,34 @@ indirectly through syntactic constructs include - #single-one-fregexp-expression + #string-raw-bin-guts - single-one-fregexp-lookbehind + string-quoted-single-line + name + string.quoted.single.python begin - (\()\?<= + (?:\b([rR])(?=[uU]))?([uU])?((['"])) end - (\)|(?=\'))|((?=(?<!\\)\n)) + (\3)|((?<!\\)\n) beginCaptures - 0 + 1 name - keyword.operator.lookbehind.regexp + invalid.illegal.prefix.python - 1 + 2 name - punctuation.parenthesis.lookbehind.begin.regexp + storage.type.string.python + + 3 + + name + punctuation.definition.string.begin.python endCaptures @@ -5659,7 +5821,7 @@ indirectly through syntactic constructs 1 name - keyword.operator.lookbehind.regexp punctuation.parenthesis.lookbehind.end.regexp + punctuation.definition.string.end.python 2 @@ -5671,1814 +5833,82 @@ indirectly through syntactic constructs include - #single-one-fregexp-expression + #string-single-bad-brace1-formatting-unicode + + + include + #string-single-bad-brace2-formatting-unicode + + + include + #string-unicode-guts - single-one-fregexp-lookbehind-negative + string-single-bad-brace1-formatting-unicode + comment + template using {% ... %} begin - (\()\?<! + (?x) + (?= \{% + ( .*? (?!(['"])|((?<!\\)\n)) ) + %\} + ) + end - (\)|(?=\'))|((?=(?<!\\)\n)) - beginCaptures - - 0 - - name - keyword.operator.lookbehind.negative.regexp - - 1 - - name - punctuation.parenthesis.lookbehind.begin.regexp - - - endCaptures - - 1 + (?=(['"])|((?<!\\)\n)) + patterns + - name - keyword.operator.lookbehind.negative.regexp punctuation.parenthesis.lookbehind.end.regexp + include + #escape-sequence-unicode - 2 - name - invalid.illegal.newline.python + include + #escape-sequence - - patterns - include - #single-one-fregexp-expression + #string-line-continuation - single-one-fregexp-conditional + string-single-bad-brace1-formatting-raw + comment + template using {% ... %} begin - (\()\?\((\w+(?:\s+[[:alnum:]]+)?|\d+)\) + (?x) + (?= \{% + ( .*? (?!(['"])|((?<!\\)\n)) ) + %\} + ) + end - (\)|(?=\'))|((?=(?<!\\)\n)) - beginCaptures - - 0 - - name - keyword.operator.conditional.regexp - - 1 - - name - punctuation.parenthesis.conditional.begin.regexp - - - endCaptures - - 1 - - name - keyword.operator.conditional.negative.regexp punctuation.parenthesis.conditional.end.regexp - - 2 - - name - invalid.illegal.newline.python - - + (?=(['"])|((?<!\\)\n)) patterns include - #single-one-fregexp-expression + #string-consume-escape - single-one-fregexp-parentheses-non-capturing + string-single-bad-brace2-formatting-unicode + comment + odd format or format-like syntax begin - \(\?: - end - (\)|(?=\'))|((?=(?<!\\)\n)) - beginCaptures - - 0 - - name - support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.begin.regexp - - - endCaptures - - 1 - - name - support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.end.regexp - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #single-one-fregexp-expression - - - - single-one-fregexp-parentheses - - begin - \( - end - (\)|(?=\'))|((?=(?<!\\)\n)) - beginCaptures - - 0 - - name - support.other.parenthesis.regexp punctuation.parenthesis.begin.regexp - - - endCaptures - - 1 - - name - support.other.parenthesis.regexp punctuation.parenthesis.end.regexp - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #single-one-fregexp-expression - - - - single-three-fregexp-expression - - patterns - - - include - #fregexp-base-expression - - - include - #single-three-regexp-character-set - - - include - #single-three-regexp-comments - - - include - #regexp-flags - - - include - #single-three-regexp-named-group - - - include - #regexp-backreference - - - include - #single-three-fregexp-lookahead - - - include - #single-three-fregexp-lookahead-negative - - - include - #single-three-fregexp-lookbehind - - - include - #single-three-fregexp-lookbehind-negative - - - include - #single-three-fregexp-conditional - - - include - #single-three-fregexp-parentheses-non-capturing - - - include - #single-three-fregexp-parentheses - - - include - #comments-string-single-three - - - - single-three-fregexp-named-group - - name - meta.named.regexp - begin - (?x) - (\() (\?P <\w+(?:\s+[[:alnum:]]+)?>) - - 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-fregexp-expression - - - include - #comments-string-single-three - - - - single-three-fregexp-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-fregexp-expression - - - include - #comments-string-single-three - - - - single-three-fregexp-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-fregexp-expression - - - include - #comments-string-single-three - - - - single-three-fregexp-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-fregexp-expression - - - include - #comments-string-single-three - - - - single-three-fregexp-lookbehind-negative - - begin - (\()\?<! - end - (\)|(?=\'\'\')) - beginCaptures - - 0 - - name - keyword.operator.lookbehind.negative.regexp - - 1 - - name - punctuation.parenthesis.lookbehind.begin.regexp - - - endCaptures - - 1 - - name - keyword.operator.lookbehind.negative.regexp punctuation.parenthesis.lookbehind.end.regexp - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #single-three-fregexp-expression - - - include - #comments-string-single-three - - - - single-three-fregexp-conditional - - begin - (\()\?\((\w+(?:\s+[[:alnum:]]+)?|\d+)\) - end - (\)|(?=\'\'\')) - beginCaptures - - 0 - - name - keyword.operator.conditional.regexp - - 1 - - name - punctuation.parenthesis.conditional.begin.regexp - - - endCaptures - - 1 - - name - keyword.operator.conditional.negative.regexp punctuation.parenthesis.conditional.end.regexp - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #single-three-fregexp-expression - - - include - #comments-string-single-three - - - - single-three-fregexp-parentheses-non-capturing - - begin - \(\?: - end - (\)|(?=\'\'\')) - beginCaptures - - 0 - - name - support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.begin.regexp - - - endCaptures - - 1 - - name - support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.end.regexp - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #single-three-fregexp-expression - - - include - #comments-string-single-three - - - - single-three-fregexp-parentheses - - begin - \( - end - (\)|(?=\'\'\')) - beginCaptures - - 0 - - name - support.other.parenthesis.regexp punctuation.parenthesis.begin.regexp - - - endCaptures - - 1 - - name - support.other.parenthesis.regexp punctuation.parenthesis.end.regexp - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #single-three-fregexp-expression - - - include - #comments-string-single-three - - - - double-one-fregexp-expression - - patterns - - - include - #fregexp-base-expression - - - include - #double-one-regexp-character-set - - - include - #double-one-regexp-comments - - - include - #regexp-flags - - - include - #double-one-regexp-named-group - - - include - #regexp-backreference - - - include - #double-one-fregexp-lookahead - - - include - #double-one-fregexp-lookahead-negative - - - include - #double-one-fregexp-lookbehind - - - include - #double-one-fregexp-lookbehind-negative - - - include - #double-one-fregexp-conditional - - - include - #double-one-fregexp-parentheses-non-capturing - - - include - #double-one-fregexp-parentheses - - - - double-one-fregexp-named-group - - name - meta.named.regexp - begin - (?x) - (\() (\?P <\w+(?:\s+[[:alnum:]]+)?>) - - end - (\)|(?="))|((?=(?<!\\)\n)) - 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-one-fregexp-expression - - - - double-one-fregexp-lookahead - - begin - (\()\?= - end - (\)|(?="))|((?=(?<!\\)\n)) - 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-one-fregexp-expression - - - - double-one-fregexp-lookahead-negative - - begin - (\()\?! - end - (\)|(?="))|((?=(?<!\\)\n)) - 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-one-fregexp-expression - - - - double-one-fregexp-lookbehind - - begin - (\()\?<= - end - (\)|(?="))|((?=(?<!\\)\n)) - 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-one-fregexp-expression - - - - double-one-fregexp-lookbehind-negative - - begin - (\()\?<! - end - (\)|(?="))|((?=(?<!\\)\n)) - beginCaptures - - 0 - - name - keyword.operator.lookbehind.negative.regexp - - 1 - - name - punctuation.parenthesis.lookbehind.begin.regexp - - - endCaptures - - 1 - - name - keyword.operator.lookbehind.negative.regexp punctuation.parenthesis.lookbehind.end.regexp - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #double-one-fregexp-expression - - - - double-one-fregexp-conditional - - begin - (\()\?\((\w+(?:\s+[[:alnum:]]+)?|\d+)\) - end - (\)|(?="))|((?=(?<!\\)\n)) - beginCaptures - - 0 - - name - keyword.operator.conditional.regexp - - 1 - - name - punctuation.parenthesis.conditional.begin.regexp - - - endCaptures - - 1 - - name - keyword.operator.conditional.negative.regexp punctuation.parenthesis.conditional.end.regexp - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #double-one-fregexp-expression - - - - double-one-fregexp-parentheses-non-capturing - - begin - \(\?: - end - (\)|(?="))|((?=(?<!\\)\n)) - beginCaptures - - 0 - - name - support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.begin.regexp - - - endCaptures - - 1 - - name - support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.end.regexp - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #double-one-fregexp-expression - - - - double-one-fregexp-parentheses - - begin - \( - end - (\)|(?="))|((?=(?<!\\)\n)) - beginCaptures - - 0 - - name - support.other.parenthesis.regexp punctuation.parenthesis.begin.regexp - - - endCaptures - - 1 - - name - support.other.parenthesis.regexp punctuation.parenthesis.end.regexp - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #double-one-fregexp-expression - - - - double-three-fregexp-expression - - patterns - - - include - #fregexp-base-expression - - - include - #double-three-regexp-character-set - - - include - #double-three-regexp-comments - - - include - #regexp-flags - - - include - #double-three-regexp-named-group - - - include - #regexp-backreference - - - include - #double-three-fregexp-lookahead - - - include - #double-three-fregexp-lookahead-negative - - - include - #double-three-fregexp-lookbehind - - - include - #double-three-fregexp-lookbehind-negative - - - include - #double-three-fregexp-conditional - - - include - #double-three-fregexp-parentheses-non-capturing - - - include - #double-three-fregexp-parentheses - - - include - #comments-string-double-three - - - - double-three-fregexp-named-group - - name - meta.named.regexp - begin - (?x) - (\() (\?P <\w+(?:\s+[[:alnum:]]+)?>) - - 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-fregexp-expression - - - include - #comments-string-double-three - - - - double-three-fregexp-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-fregexp-expression - - - include - #comments-string-double-three - - - - double-three-fregexp-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-fregexp-expression - - - include - #comments-string-double-three - - - - double-three-fregexp-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-fregexp-expression - - - include - #comments-string-double-three - - - - double-three-fregexp-lookbehind-negative - - begin - (\()\?<! - end - (\)|(?=""")) - beginCaptures - - 0 - - name - keyword.operator.lookbehind.negative.regexp - - 1 - - name - punctuation.parenthesis.lookbehind.begin.regexp - - - endCaptures - - 1 - - name - keyword.operator.lookbehind.negative.regexp punctuation.parenthesis.lookbehind.end.regexp - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #double-three-fregexp-expression - - - include - #comments-string-double-three - - - - double-three-fregexp-conditional - - begin - (\()\?\((\w+(?:\s+[[:alnum:]]+)?|\d+)\) - end - (\)|(?=""")) - beginCaptures - - 0 - - name - keyword.operator.conditional.regexp - - 1 - - name - punctuation.parenthesis.conditional.begin.regexp - - - endCaptures - - 1 - - name - keyword.operator.conditional.negative.regexp punctuation.parenthesis.conditional.end.regexp - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #double-three-fregexp-expression - - - include - #comments-string-double-three - - - - double-three-fregexp-parentheses-non-capturing - - begin - \(\?: - end - (\)|(?=""")) - beginCaptures - - 0 - - name - support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.begin.regexp - - - endCaptures - - 1 - - name - support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.end.regexp - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #double-three-fregexp-expression - - - include - #comments-string-double-three - - - - double-three-fregexp-parentheses - - begin - \( - end - (\)|(?=""")) - beginCaptures - - 0 - - name - support.other.parenthesis.regexp punctuation.parenthesis.begin.regexp - - - endCaptures - - 1 - - name - support.other.parenthesis.regexp punctuation.parenthesis.end.regexp - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #double-three-fregexp-expression - - - include - #comments-string-double-three - - - - fregexp-single-one-line - - name - string.interpolated.python string.regexp.quoted.single.python - begin - \b(([uU]r)|([fF]r)|(r[fF]?))(\') - end - (\')|(?<!\\)(\n) - beginCaptures - - 2 - - name - invalid.deprecated.prefix.python - - 3 - - name - storage.type.string.python - - 4 - - name - storage.type.string.python - - 5 - - name - punctuation.definition.string.begin.python - - - endCaptures - - 1 - - name - punctuation.definition.string.end.python - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #single-one-fregexp-expression - - - - fregexp-single-three-line - - name - string.interpolated.python string.regexp.quoted.multi.python - begin - \b(([uU]r)|([fF]r)|(r[fF]?))(\'\'\') - end - (\'\'\') - beginCaptures - - 2 - - name - invalid.deprecated.prefix.python - - 3 - - name - storage.type.string.python - - 4 - - name - storage.type.string.python - - 5 - - name - punctuation.definition.string.begin.python - - - endCaptures - - 1 - - name - punctuation.definition.string.end.python - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #single-three-fregexp-expression - - - - fregexp-double-one-line - - name - string.interpolated.python string.regexp.quoted.single.python - begin - \b(([uU]r)|([fF]r)|(r[fF]?))(") - end - (")|(?<!\\)(\n) - beginCaptures - - 2 - - name - invalid.deprecated.prefix.python - - 3 - - name - storage.type.string.python - - 4 - - name - storage.type.string.python - - 5 - - name - punctuation.definition.string.begin.python - - - endCaptures - - 1 - - name - punctuation.definition.string.end.python - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #double-one-fregexp-expression - - - - fregexp-double-three-line - - name - string.interpolated.python string.regexp.quoted.multi.python - begin - \b(([uU]r)|([fF]r)|(r[fF]?))(""") - end - (""") - beginCaptures - - 2 - - name - invalid.deprecated.prefix.python - - 3 - - name - storage.type.string.python - - 4 - - name - storage.type.string.python - - 5 - - name - punctuation.definition.string.begin.python - - - endCaptures - - 1 - - name - punctuation.definition.string.end.python - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #double-three-fregexp-expression - - - - string-raw-quoted-single-line - - name - string.quoted.raw.single.python - begin - \b(([uU]R)|(R))((['"])) - end - (\4)|((?<!\\)\n) - beginCaptures - - 2 - - name - invalid.deprecated.prefix.python - - 3 - - name - storage.type.string.python - - 4 - - name - punctuation.definition.string.begin.python - - - endCaptures - - 1 - - name - punctuation.definition.string.end.python - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #string-single-bad-brace1-formatting-raw - - - include - #string-single-bad-brace2-formatting-raw - - - include - #string-raw-guts - - - - string-bin-quoted-single-line - - name - string.quoted.binary.single.python - begin - (\b[bB])((['"])) - 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-entity - - - - string-raw-bin-quoted-single-line - - name - string.quoted.raw.binary.single.python - begin - (\b(?:R[bB]|[bB]R))((['"])) - 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-raw-bin-guts - - - - string-quoted-single-line - - name - string.quoted.single.python - begin - (\b[rR](?=[uU]))?([uU])?((['"])) - end - (\3)|((?<!\\)\n) - beginCaptures - - 1 - - name - invalid.illegal.prefix.python - - 2 - - name - storage.type.string.python - - 3 - - name - punctuation.definition.string.begin.python - - - endCaptures - - 1 - - name - punctuation.definition.string.end.python - - 2 - - name - invalid.illegal.newline.python - - - patterns - - - include - #string-single-bad-brace1-formatting-unicode - - - include - #string-single-bad-brace2-formatting-unicode - - - include - #string-unicode-guts - - - - string-single-bad-brace1-formatting-unicode - - comment - template using {% ... %} - begin - (?x) - (?= \{% - ( .*? (?!(['"])|((?<!\\)\n)) ) - %\} - ) - - end - (?=(['"])|((?<!\\)\n)) - patterns - - - include - #escape-sequence-unicode - - - include - #escape-sequence - - - include - #string-line-continuation - - - - string-single-bad-brace1-formatting-raw - - comment - template using {% ... %} - begin - (?x) - (?= \{% - ( .*? (?!(['"])|((?<!\\)\n)) ) - %\} - ) - - end - (?=(['"])|((?<!\\)\n)) - patterns - - - include - #string-consume-escape - - - - string-single-bad-brace2-formatting-unicode - - comment - odd format or format-like syntax - begin - (?x) - (?!\{\{) - (?= \{ ( - \w*? (?!(['"])|((?<!\\)\n)) [^!:\.\[}\w] - ) - .*?(?!(['"])|((?<!\\)\n)) - \} - ) - + (?x) + (?!\{\{) + (?= \{ ( + \w*? (?!(['"])|((?<!\\)\n)) [^!:\.\[}\w] + ) + .*?(?!(['"])|((?<!\\)\n)) + \} + ) + end (?=(['"])|((?<!\\)\n)) patterns @@ -7665,7 +6095,7 @@ indirectly through syntactic constructs name string.quoted.multi.python begin - (\b[rR](?=[uU]))?([uU])?('''|""") + (?:\b([rR])(?=[uU]))?([uU])?('''|""") end (\3) beginCaptures @@ -7944,7 +6374,7 @@ indirectly through syntactic constructs name meta.fstring.python begin - (\b(?:[R][fF]|[fF][R]))((['"])) + (\b(?:[rR][fF]|[fF][rR]))((['"])) end (\2)|((?<!\\)\n) beginCaptures @@ -8085,12 +6515,18 @@ indirectly through syntactic constructs name storage.type.format.python match - (![rsa])(?=}) + (=(![rsa])?)(?=}) + + + name + storage.type.format.python + match + (=?![rsa])(?=}) match (?x) - (![rsa])? + ( (?: =?) (?: ![rsa])? ) ( : \w? [<>=^]? [-+ ]? \#? \d* ,? (\.\d+)? [bcdeEfFgGnosxX%]? )(?=}) @@ -8117,7 +6553,7 @@ indirectly through syntactic constructs fstring-terminator-single-tail begin - (![rsa])?(:)(?=.*?{) + ((?:=?)(?:![rsa])?)(:)(?=.*?{) end (?=})|(?=\n) beginCaptures @@ -8316,7 +6752,7 @@ indirectly through syntactic constructs name meta.fstring.python begin - (\b(?:[R][fF]|[fF][R]))('''|""") + (\b(?:[rR][fF]|[fF][rR]))('''|""") end (\2) beginCaptures @@ -8457,12 +6893,18 @@ indirectly through syntactic constructs name storage.type.format.python match - (![rsa])(?=}) + (=(![rsa])?)(?=}) + + + name + storage.type.format.python + match + (=?![rsa])(?=}) match (?x) - (![rsa])? + ( (?: =?) (?: ![rsa])? ) ( : \w? [<>=^]? [-+ ]? \#? \d* ,? (\.\d+)? [bcdeEfFgGnosxX%]? )(?=}) @@ -8489,7 +6931,7 @@ indirectly through syntactic constructs fstring-terminator-multi-tail begin - (![rsa])?(:)(?=.*?{) + ((?:=?)(?:![rsa])?)(:)(?=.*?{) end (?=}) beginCaptures diff --git a/grammars/MagicRegExp.tmLanguage b/grammars/MagicRegExp.tmLanguage index 3d19e058..3ddacc70 100644 --- a/grammars/MagicRegExp.tmLanguage +++ b/grammars/MagicRegExp.tmLanguage @@ -1,7 +1,7 @@ - + name MagicRegExp diff --git a/grammars/src/MagicPython.syntax.yaml b/grammars/src/MagicPython.syntax.yaml index 43009579..ebfccdaf 100644 --- a/grammars/src/MagicPython.syntax.yaml +++ b/grammars/src/MagicPython.syntax.yaml @@ -4,8 +4,7 @@ scopeName: source.python # NOTE: remember to update package.json with VSCode file types. fileTypes: [py, py3, rpy, pyw, cpy, pyi, SConstruct, Sconstruct, sconstruct, SConscript, - gyp, gypi, wsgi, kv, Snakefile, tac] -first_line_match: ^#![ \t]*/.*\bpython[\d\.]*\b + gyp, gypi, wsgi, kv, Snakefile, smk, tac] firstLineMatch: ^#![ \t]*/.*\bpython[\d\.]*\b uuid: 742deb57-6e38-4192-bed6-410746efd85d @@ -104,82 +103,6 @@ repository: bquote: '(""")' equote: '(""")' - - file: 'regexp.inc.syntax.yaml' - vars: - prefix: 'single-one-' - basename: 'fregexp' - marker: "|(?=\\')" - nested: '' - guard: "|((?=(?= | <= | < | >) (?# 5) + | (:=) (?# 6) + 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: @@ -605,7 +583,6 @@ repository: captures: '1': {name: storage.type.imaginary.number.python} '2': {name: invalid.illegal.dec.python} - '3': {name: invalid.illegal.dec.python} number-hex: name: constant.numeric.hex.python @@ -654,10 +631,6 @@ repository: - include: '#regexp-double-three-line' - include: '#regexp-single-one-line' - include: '#regexp-double-one-line' - - include: '#fregexp-single-three-line' - - include: '#fregexp-double-three-line' - - include: '#fregexp-single-one-line' - - include: '#fregexp-double-one-line' string: patterns: @@ -732,7 +705,7 @@ repository: - include: '#impossible' f-expression: - comment: All valid Python expressions, except comments and line cont + comment: All valid Python expressions, except comments and line continuation patterns: - include: '#expression-bare' - include: '#member-access' @@ -765,25 +738,29 @@ repository: match: \\$ string-formatting: - name: constant.character.format.placeholder.other.python + name: meta.format.percent.python match: | (?x) - % (\([\w\s]*\))? - [-+#0 ]* - (\d+|\*)? (\.(\d+|\*))? - ([hlL])? - [diouxXeEfFgGcrsa%] + ( + % (\([\w\s]*\))? + [-+#0 ]* + (\d+|\*)? (\.(\d+|\*))? + ([hlL])? + [diouxXeEfFgGcrsab%] + ) + captures: + '1': {name: constant.character.format.placeholder.other.python} string-brace-formatting: patterns: - - name: constant.character.format.placeholder.other.python + - name: meta.format.brace.python match: | (?x) - (?: + ( {{ | }} | (?: { - \w*? (\.[[:alpha:]_]\w*? | \[[^\]'"]+\])*? + \w* (\.[[:alpha:]_]\w* | \[[^\]'"]+\])* (![rsa])? ( : \w? [<>=^]? [-+ ]? \#? \d* ,? (\.\d+)? [bcdeEfFgGnosxX%]? )? @@ -797,24 +774,31 @@ repository: # "storage.type..." is more likely to have special # highlighting in any given color scheme than # "support.other..." - # - '2': {name: storage.type.format.python} + '1': {name: constant.character.format.placeholder.other.python} '3': {name: storage.type.format.python} - - name: constant.character.format.placeholder.other.python - begin: | + '4': {name: storage.type.format.python} + + # The reason for 2 separate rules is to establish which one + # should be matched with a higher priority. The rule below is + # more generic, so it should be matched only if the specific one + # didn't. + - name: meta.format.brace.python + match: | (?x) - \{ - \w*? (\.[[:alpha:]_]\w*? | \[[^\]'"]+\])*? + ( + { + \w* (\.[[:alpha:]_]\w* | \[[^\]'"]+\])* (![rsa])? (:) - (?=[^'"}\n]*\}) - end: \} - beginCaptures: - '2': {name: storage.type.format.python} + [^'"{}\n]* (?: + \{ [^'"}\n]*? \} [^'"{}\n]* + )* + } + ) + captures: + '1': {name: constant.character.format.placeholder.other.python} '3': {name: storage.type.format.python} - patterns: - - match: | - (?x) \{ [^'"}\n]*? \} (?=.*?\}) + '4': {name: storage.type.format.python} fstring-formatting: patterns: @@ -827,17 +811,25 @@ repository: import: comment: | - Import statements + Import statements used to correctly mark `from`, `import`, and `as` patterns: - - match: | - (?x) - \s* \b(from)\b \s*(\.+)\s* (import)? - captures: + - begin: \b(?=^]? [-+ ]? \#? - \d* ,? (\.\d+)? [bcdeEfFgGnosxX%]? )(?=}) - captures: - # We use this awkward scope name instead of perhaps more - # elegant "support.other.format.python" because it appears - # that by default it gives a better visual result in various - # systems (e.g. GitHub). This is due to the fact that - # "storage.type..." is more likely to have special - # highlighting in any given color scheme than - # "support.other..." - # - '1': {name: storage.type.format.python} - '2': {name: storage.type.format.python} +fstring-terminator-${line}: + patterns: + - name: storage.type.format.python + match: (=(![rsa])?)(?=}) + - name: storage.type.format.python + match: (=?![rsa])(?=}) + - match: | + (?x) + ( (?: =?) (?: ![rsa])? ) + ( : \w? [<>=^]? [-+ ]? \#? + \d* ,? (\.\d+)? [bcdeEfFgGnosxX%]? )(?=}) + captures: + # We use this awkward scope name instead of perhaps more + # elegant "support.other.format.python" because it appears + # that by default it gives a better visual result in various + # systems (e.g. GitHub). This is due to the fact that + # "storage.type..." is more likely to have special + # highlighting in any given color scheme than + # "support.other..." + # + '1': {name: storage.type.format.python} + '2': {name: storage.type.format.python} - - include: '#fstring-terminator-${line}-tail' + - include: '#fstring-terminator-${line}-tail' - fstring-terminator-${line}-tail: - begin: (![rsa])?(:)(?=.*?{) - end: (?=})${fguard} - beginCaptures: - '1': {name: storage.type.format.python} - '2': {name: storage.type.format.python} +fstring-terminator-${line}-tail: + begin: ((?:=?)(?:![rsa])?)(:)(?=.*?{) + end: (?=})${fguard} + beginCaptures: + '1': {name: storage.type.format.python} + '2': {name: storage.type.format.python} - patterns: - - include: '#fstring-illegal-${line}-brace' - - include: '#fstring-${line}-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) + patterns: + - include: '#fstring-illegal-${line}-brace' + - include: '#fstring-${line}-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) ... diff --git a/grammars/src/pystring.inc.syntax.yaml b/grammars/src/pystring.inc.syntax.yaml index 36e0bd1b..5127ae72 100644 --- a/grammars/src/pystring.inc.syntax.yaml +++ b/grammars/src/pystring.inc.syntax.yaml @@ -1,118 +1,117 @@ --- -repository: - string-raw-quoted-${line}-line: - name: string.quoted.raw.${line}.python - begin: \b(([uU]R)|(R))(${marker}) - end: (\4)${guard} - beginCaptures: - '2': {name: invalid.deprecated.prefix.python} - '3': {name: storage.type.string.python} - '4': {name: punctuation.definition.string.begin.python} - endCaptures: - '1': {name: punctuation.definition.string.end.python} - '2': {name: invalid.illegal.newline.python} - patterns: - - include: '#string-${line}-bad-brace1-formatting-raw' - - include: '#string-${line}-bad-brace2-formatting-raw' - - include: '#string-raw-guts' +string-raw-quoted-${line}-line: + name: string.quoted.raw.${line}.python + begin: \b(([uU]R)|(R))(${marker}) + end: (\4)${guard} + beginCaptures: + '2': {name: invalid.deprecated.prefix.python} + '3': {name: storage.type.string.python} + '4': {name: punctuation.definition.string.begin.python} + endCaptures: + '1': {name: punctuation.definition.string.end.python} + '2': {name: invalid.illegal.newline.python} + patterns: + - include: '#string-${line}-bad-brace1-formatting-raw' + - include: '#string-${line}-bad-brace2-formatting-raw' + - include: '#string-raw-guts' - string-bin-quoted-${line}-line: - name: string.quoted.binary.${line}.python - begin: (\b[bB])(${marker}) - end: (\2)${guard} - 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-entity' +string-bin-quoted-${line}-line: + name: string.quoted.binary.${line}.python + begin: (\b[bB])(${marker}) + end: (\2)${guard} + 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-entity' - string-raw-bin-quoted-${line}-line: - name: string.quoted.raw.binary.${line}.python - begin: (\b(?:R[bB]|[bB]R))(${marker}) - end: (\2)${guard} - 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-raw-bin-guts' +string-raw-bin-quoted-${line}-line: + name: string.quoted.raw.binary.${line}.python + begin: (\b(?:R[bB]|[bB]R))(${marker}) + end: (\2)${guard} + 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-raw-bin-guts' - string-quoted-${line}-line: - name: string.quoted.${line}.python - begin: (\b[rR](?=[uU]))?([uU])?(${marker}) - end: (\3)${guard} - beginCaptures: - '1': {name: invalid.illegal.prefix.python} - '2': {name: storage.type.string.python} - '3': {name: punctuation.definition.string.begin.python} - endCaptures: - '1': {name: punctuation.definition.string.end.python} - '2': {name: invalid.illegal.newline.python} - patterns: - - include: '#string-${line}-bad-brace1-formatting-unicode' - - include: '#string-${line}-bad-brace2-formatting-unicode' - - include: '#string-unicode-guts' +string-quoted-${line}-line: + name: string.quoted.${line}.python + begin: (?:\b([rR])(?=[uU]))?([uU])?(${marker}) + end: (\3)${guard} + beginCaptures: + '1': {name: invalid.illegal.prefix.python} + '2': {name: storage.type.string.python} + '3': {name: punctuation.definition.string.begin.python} + endCaptures: + '1': {name: punctuation.definition.string.end.python} + '2': {name: invalid.illegal.newline.python} + patterns: + - include: '#string-${line}-bad-brace1-formatting-unicode' + - include: '#string-${line}-bad-brace2-formatting-unicode' + - include: '#string-unicode-guts' - string-${line}-bad-brace1-formatting-unicode: - comment: template using {% ... %} - begin: | - (?x) - (?= \{% - ( .*? (?!${marker}${guard}) ) - %\} - ) - end: (?=${marker}${guard}) - patterns: - - include: '#escape-sequence-unicode' - - include: '#escape-sequence' - - include: '#string-line-continuation' +string-${line}-bad-brace1-formatting-unicode: + comment: template using {% ... %} + begin: | + (?x) + (?= \{% + ( .*? (?!${marker}${guard}) ) + %\} + ) + end: (?=${marker}${guard}) + patterns: + - include: '#escape-sequence-unicode' + - include: '#escape-sequence' + - include: '#string-line-continuation' - string-${line}-bad-brace1-formatting-raw: - comment: template using {% ... %} - begin: | - (?x) - (?= \{% - ( .*? (?!${marker}${guard}) ) - %\} - ) - end: (?=${marker}${guard}) - patterns: - - include: '#string-consume-escape' +string-${line}-bad-brace1-formatting-raw: + comment: template using {% ... %} + begin: | + (?x) + (?= \{% + ( .*? (?!${marker}${guard}) ) + %\} + ) + end: (?=${marker}${guard}) + patterns: + - include: '#string-consume-escape' - string-${line}-bad-brace2-formatting-unicode: - comment: odd format or format-like syntax - begin: | - (?x) - (?!\{\{) - (?= \{ ( - \w*? (?!${marker}${guard}) [^!:\.\[}\w] - ) - .*?(?!${marker}${guard}) - \} - ) - end: (?=${marker}${guard}) - patterns: - - include: '#escape-sequence-unicode' - - include: '#string-entity' +string-${line}-bad-brace2-formatting-unicode: + comment: odd format or format-like syntax + begin: | + (?x) + (?!\{\{) + (?= \{ ( + \w*? (?!${marker}${guard}) [^!:\.\[}\w] + ) + .*?(?!${marker}${guard}) + \} + ) + end: (?=${marker}${guard}) + patterns: + - include: '#escape-sequence-unicode' + - include: '#string-entity' - string-${line}-bad-brace2-formatting-raw: - comment: odd format or format-like syntax - begin: | - (?x) - (?!\{\{) - (?= \{ ( - \w*? (?!${marker}${guard}) [^!:\.\[}\w] - ) - .*?(?!${marker}${guard}) - \} - ) - end: (?=${marker}${guard}) - patterns: - - include: '#string-consume-escape' - - include: '#string-formatting' +string-${line}-bad-brace2-formatting-raw: + comment: odd format or format-like syntax + begin: | + (?x) + (?!\{\{) + (?= \{ ( + \w*? (?!${marker}${guard}) [^!:\.\[}\w] + ) + .*?(?!${marker}${guard}) + \} + ) + end: (?=${marker}${guard}) + patterns: + - include: '#string-consume-escape' + - include: '#string-formatting' ... diff --git a/grammars/src/regexp-common.inc.syntax.yaml b/grammars/src/regexp-common.inc.syntax.yaml index e367af87..828a630b 100644 --- a/grammars/src/regexp-common.inc.syntax.yaml +++ b/grammars/src/regexp-common.inc.syntax.yaml @@ -1,128 +1,127 @@ --- -repository: - regexp-base-expression: - patterns: - - include: '#regexp-quantifier' - - include: '#regexp-base-common' +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' +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: ({{|}}) +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-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) - \{( - \d+ | \d+,(\d+)? | ,\d+ - )\} +regexp-quantifier: + name: keyword.operator.quantifier.regexp + match: | + (?x) + \{( + \d+ | \d+,(\d+)? | ,\d+ + )\} - fregexp-quantifier: - name: keyword.operator.quantifier.regexp - match: | - (?x) - \{\{( - \d+ | \d+,(\d+)? | ,\d+ - )\}\} +fregexp-quantifier: + name: keyword.operator.quantifier.regexp + match: | + (?x) + \{\{( + \d+ | \d+,(\d+)? | ,\d+ + )\}\} - regexp-backreference-number: - name: meta.backreference.regexp - match: (\\[1-9]\d?) - captures: - '1': {name: entity.name.tag.backreference.regexp} +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) - (\() (\?P= \w+(?:\s+[[:alnum:]]+)?) (\)) - captures: - '1': {name: punctuation.parenthesis.backreference.named.begin.regexp - support.other.parenthesis.regexp} - '2': {name: entity.name.tag.named.backreference.regexp} - '3': {name: punctuation.parenthesis.backreference.named.end.regexp - support.other.parenthesis.regexp} +regexp-backreference: + name: meta.backreference.named.regexp + match: | + (?x) + (\() (\?P= \w+(?:\s+[[:alnum:]]+)?) (\)) + captures: + '1': {name: punctuation.parenthesis.backreference.named.begin.regexp + support.other.parenthesis.regexp} + '2': {name: entity.name.tag.named.backreference.regexp} + '3': {name: punctuation.parenthesis.backreference.named.end.regexp + support.other.parenthesis.regexp} - regexp-flags: - name: storage.modifier.flag.regexp - match: \(\?[aiLmsux]+\) +regexp-flags: + name: storage.modifier.flag.regexp + match: \(\?[aiLmsux]+\) - regexp-escape-special: - name: support.other.escape.special.regexp - match: \\([AbBdDsSwWZ]) +regexp-escape-special: + name: support.other.escape.special.regexp + match: \\([AbBdDsSwWZ]) - regexp-escape-character: - name: constant.character.escape.regexp - match: | - (?x) - \\ ( - x[0-9A-Fa-f]{2} - | 0[0-7]{1,2} - | [0-7]{3} - ) +regexp-escape-character: + name: constant.character.escape.regexp + match: | + (?x) + \\ ( + x[0-9A-Fa-f]{2} + | 0[0-7]{1,2} + | [0-7]{3} + ) - regexp-escape-unicode: - name: constant.character.unicode.regexp - match: | - (?x) - \\ ( - u[0-9A-Fa-f]{4} - | U[0-9A-Fa-f]{8} - ) +regexp-escape-unicode: + name: constant.character.unicode.regexp + match: | + (?x) + \\ ( + u[0-9A-Fa-f]{4} + | U[0-9A-Fa-f]{8} + ) - regexp-escape-catchall: - name: constant.character.escape.regexp - match: \\(.|\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-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' +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} +codetags: + match: (?:\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\b) + captures: + '1': {name: keyword.codetag.notation.python} ... diff --git a/grammars/src/regexp.inc.syntax.yaml b/grammars/src/regexp.inc.syntax.yaml index ea55ff55..aac9e286 100644 --- a/grammars/src/regexp.inc.syntax.yaml +++ b/grammars/src/regexp.inc.syntax.yaml @@ -1,170 +1,169 @@ --- -repository: - ${prefix}${basename}-expression: - patterns: - - include: '#${basename}-base-expression' - - include: '#${prefix}regexp-character-set' - - include: '#${prefix}regexp-comments' - - include: '#regexp-flags' - - include: '#${prefix}regexp-named-group' - - include: '#regexp-backreference' - - include: '#${prefix}${basename}-lookahead' - - include: '#${prefix}${basename}-lookahead-negative' - - include: '#${prefix}${basename}-lookbehind' - - include: '#${prefix}${basename}-lookbehind-negative' - - include: '#${prefix}${basename}-conditional' - - include: '#${prefix}${basename}-parentheses-non-capturing' - - include: '#${prefix}${basename}-parentheses' - ${nested} +${prefix}${basename}-expression: + patterns: + - include: '#${basename}-base-expression' + - include: '#${prefix}regexp-character-set' + - include: '#${prefix}regexp-comments' + - include: '#regexp-flags' + - include: '#${prefix}regexp-named-group' + - include: '#regexp-backreference' + - include: '#${prefix}${basename}-lookahead' + - include: '#${prefix}${basename}-lookahead-negative' + - include: '#${prefix}${basename}-lookbehind' + - include: '#${prefix}${basename}-lookbehind-negative' + - include: '#${prefix}${basename}-conditional' + - include: '#${prefix}${basename}-parentheses-non-capturing' + - include: '#${prefix}${basename}-parentheses' + ${nested} - ${prefix}regexp-character-set: - patterns: - - match: | - (?x) - \[ \^? \] (?! .*?\]) - - name: meta.character.set.regexp - begin: (\[)(\^)?(\])? - end: (\]${marker})${guard} - beginCaptures: - '1': {name: constant.other.set.regexp - punctuation.character.set.begin.regexp} - '2': {name: keyword.operator.negation.regexp} - '3': {name: constant.character.set.regexp} - endCaptures: - '1': {name: constant.other.set.regexp - punctuation.character.set.end.regexp} - '2': {name: invalid.illegal.newline.python} - patterns: - - include: '#regexp-charecter-set-escapes' - - name: constant.character.set.regexp - match: '[^\n]' +${prefix}regexp-character-set: + patterns: + - match: | + (?x) + \[ \^? \] (?! .*?\]) + - name: meta.character.set.regexp + begin: (\[)(\^)?(\])? + end: (\]${marker})${guard} + beginCaptures: + '1': {name: constant.other.set.regexp + punctuation.character.set.begin.regexp} + '2': {name: keyword.operator.negation.regexp} + '3': {name: constant.character.set.regexp} + endCaptures: + '1': {name: constant.other.set.regexp + punctuation.character.set.end.regexp} + '2': {name: invalid.illegal.newline.python} + patterns: + - include: '#regexp-charecter-set-escapes' + - name: constant.character.set.regexp + match: '[^\n]' - ${prefix}${basename}-named-group: - name: meta.named.regexp - begin: | - (?x) - (\() (\?P <\w+(?:\s+[[:alnum:]]+)?>) - end: (\)${marker})${guard} - beginCaptures: - '1': {name: punctuation.parenthesis.named.begin.regexp - support.other.parenthesis.regexp} - '2': {name: entity.name.tag.named.group.regexp} - endCaptures: - '1': {name: punctuation.parenthesis.named.end.regexp - support.other.parenthesis.regexp} - '2': {name: invalid.illegal.newline.python} - patterns: - - include: '#${prefix}${basename}-expression' - ${nested} +${prefix}${basename}-named-group: + name: meta.named.regexp + begin: | + (?x) + (\() (\?P <\w+(?:\s+[[:alnum:]]+)?>) + end: (\)${marker})${guard} + beginCaptures: + '1': {name: punctuation.parenthesis.named.begin.regexp + support.other.parenthesis.regexp} + '2': {name: entity.name.tag.named.group.regexp} + endCaptures: + '1': {name: punctuation.parenthesis.named.end.regexp + support.other.parenthesis.regexp} + '2': {name: invalid.illegal.newline.python} + patterns: + - include: '#${prefix}${basename}-expression' + ${nested} - ${prefix}regexp-comments: - name: comment.regexp - begin: \(\?# - end: (\)${marker})${guard} - beginCaptures: - '0': {name: punctuation.comment.begin.regexp} - endCaptures: - '1': {name: punctuation.comment.end.regexp} - '2': {name: invalid.illegal.newline.python} - patterns: - - include: '#codetags' +${prefix}regexp-comments: + name: comment.regexp + begin: \(\?# + end: (\)${marker})${guard} + beginCaptures: + '0': {name: punctuation.comment.begin.regexp} + endCaptures: + '1': {name: punctuation.comment.end.regexp} + '2': {name: invalid.illegal.newline.python} + patterns: + - include: '#codetags' - ${prefix}${basename}-lookahead: - begin: '(\()\?=' - end: (\)${marker})${guard} - beginCaptures: - '0': {name: keyword.operator.lookahead.regexp} - '1': {name: punctuation.parenthesis.lookahead.begin.regexp} - endCaptures: - '1': {name: punctuation.parenthesis.lookahead.end.regexp - keyword.operator.lookahead.regexp} - '2': {name: invalid.illegal.newline.python} - patterns: - - include: '#${prefix}${basename}-expression' - ${nested} +${prefix}${basename}-lookahead: + begin: '(\()\?=' + end: (\)${marker})${guard} + beginCaptures: + '0': {name: keyword.operator.lookahead.regexp} + '1': {name: punctuation.parenthesis.lookahead.begin.regexp} + endCaptures: + '1': {name: punctuation.parenthesis.lookahead.end.regexp + keyword.operator.lookahead.regexp} + '2': {name: invalid.illegal.newline.python} + patterns: + - include: '#${prefix}${basename}-expression' + ${nested} - ${prefix}${basename}-lookahead-negative: - begin: '(\()\?!' - end: (\)${marker})${guard} - beginCaptures: - '0': {name: keyword.operator.lookahead.negative.regexp} - '1': {name: punctuation.parenthesis.lookahead.begin.regexp} - endCaptures: - '1': {name: punctuation.parenthesis.lookahead.end.regexp - keyword.operator.lookahead.negative.regexp} - '2': {name: invalid.illegal.newline.python} - patterns: - - include: '#${prefix}${basename}-expression' - ${nested} +${prefix}${basename}-lookahead-negative: + begin: '(\()\?!' + end: (\)${marker})${guard} + beginCaptures: + '0': {name: keyword.operator.lookahead.negative.regexp} + '1': {name: punctuation.parenthesis.lookahead.begin.regexp} + endCaptures: + '1': {name: punctuation.parenthesis.lookahead.end.regexp + keyword.operator.lookahead.negative.regexp} + '2': {name: invalid.illegal.newline.python} + patterns: + - include: '#${prefix}${basename}-expression' + ${nested} - ${prefix}${basename}-lookbehind: - begin: '(\()\?<=' - end: (\)${marker})${guard} - beginCaptures: - '0': {name: keyword.operator.lookbehind.regexp} - '1': {name: punctuation.parenthesis.lookbehind.begin.regexp} - endCaptures: - '1': {name: punctuation.parenthesis.lookbehind.end.regexp - keyword.operator.lookbehind.regexp} - '2': {name: invalid.illegal.newline.python} - patterns: - - include: '#${prefix}${basename}-expression' - ${nested} +${prefix}${basename}-lookbehind: + begin: '(\()\?<=' + end: (\)${marker})${guard} + beginCaptures: + '0': {name: keyword.operator.lookbehind.regexp} + '1': {name: punctuation.parenthesis.lookbehind.begin.regexp} + endCaptures: + '1': {name: punctuation.parenthesis.lookbehind.end.regexp + keyword.operator.lookbehind.regexp} + '2': {name: invalid.illegal.newline.python} + patterns: + - include: '#${prefix}${basename}-expression' + ${nested} - ${prefix}${basename}-lookbehind-negative: - begin: '(\()\? List[str]: async with db.transaction(): result = await db.query(...) - print(f'Result: {result!r}') + print(f'Result: {result!r} {a=} {b=!r}') + print(Rf'data: {c=}') + print(rf'data: {c=}') mapping = None # type: Dict[int, Any] # PEP 484 @@ -41,8 +43,14 @@ async def coroutine(db:aio_db.DatabaseConnection) -> List[str]: # NOTE Numbers with leading zeros are invalid in Python 3, # use 0o... answer = func(0xdeadbeef + 0b00100001 + 0123 + 0o123 + - 1_005_123 + # PEP 515 + 1_005_123 + # PEP 515 # complex numbers .10e12 + 2j) @ mat + # walrus operator + filtered_data = [y for x in data if (y := f(x)) is not None] + + # position-only params + bar = lambda q, w, /, e, r: (q + w + e + r) + return R'''No escapes '\' in this \one''' diff --git a/misc/scopes b/misc/scopes index 128a673c..8eec651e 100644 --- a/misc/scopes +++ b/misc/scopes @@ -56,23 +56,29 @@ keyword.operator.lookahead.regexp keyword.operator.lookbehind.negative.regexp keyword.operator.lookbehind.regexp keyword.operator.negation.regexp +keyword.operator.positional.parameter.python keyword.operator.python keyword.operator.quantifier.regexp keyword.operator.unpacking.arguments.python keyword.operator.unpacking.parameter.python +meta.attribute.python meta.backreference.named.regexp meta.backreference.regexp meta.character.set.regexp meta.class.inheritance.python meta.class.python +meta.format.brace.python +meta.format.percent.python meta.fstring.python meta.function-call.generic.python meta.function-call.python meta.function.decorator.python meta.function.parameters.python meta.function.python +meta.indexed-name.python meta.item-access.python meta.lambda-function.python +meta.member.access.python meta.named.regexp meta.typehint.comment.python punctuation.character.set.begin.regexp @@ -82,6 +88,7 @@ punctuation.comment.end.regexp punctuation.definition.arguments.begin.python punctuation.definition.arguments.end.python punctuation.definition.comment.python +punctuation.definition.decorator.python punctuation.definition.dict.begin.python punctuation.definition.dict.end.python punctuation.definition.inheritance.begin.python diff --git a/package.json b/package.json index 7673f4fd..a974bd74 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "MagicPython", - "version": "1.0.12", + "version": "1.1.1", "engines": { "atom": "*", "node": "*", @@ -55,7 +55,11 @@ ".SConscript", ".gyp", ".gypi", - ".wsgi" + ".wsgi", + ".kv", + "Snakefile", + ".smk", + ".tac" ] } ], @@ -66,5 +70,10 @@ "path": "./grammars/MagicPython.tmLanguage" } ] - } + }, + "devDependencies": { + "oniguruma": "^7.0.0", + "syntaxdev": "^0.1.3" + }, + "dependencies": {} } diff --git a/settings/atom.cson b/settings/atom.cson index ef9a58d1..e66d6044 100644 --- a/settings/atom.cson +++ b/settings/atom.cson @@ -35,7 +35,7 @@ 'autoIndentOnPaste': false 'softTabs': true 'tabLength': 4 - 'foldEndPattern': '^\\s*"""\\s*$' + 'foldEndPattern': '^\\s*\\}|^\\s*\\]|^\\s*\\)' 'commentStart': '# ' 'increaseIndentPattern': '^\\s*(class|((async\\s+)?(def|with|for))|elif|else|except|finally|if|try|while)\\b.*:\\s*$' 'decreaseIndentPattern': '^\\s*(elif|else|except|finally)\\b.*:' diff --git a/snippets/sublime/Try-Except-Else-Finally.sublime-snippet b/snippets/sublime/Try-Except-Else-Finally.sublime-snippet index 00c41fb9..ff120922 100644 --- a/snippets/sublime/Try-Except-Else-Finally.sublime-snippet +++ b/snippets/sublime/Try-Except-Else-Finally.sublime-snippet @@ -1,7 +1,7 @@ diff --git a/snippets/sublime/Try-Except-Finally.sublime-snippet b/snippets/sublime/Try-Except-Finally.sublime-snippet index 0ee74a40..b088cbe6 100644 --- a/snippets/sublime/Try-Except-Finally.sublime-snippet +++ b/snippets/sublime/Try-Except-Finally.sublime-snippet @@ -1,7 +1,7 @@ diff --git a/snippets/sublime/Try-Except.sublime-snippet b/snippets/sublime/Try-Except.sublime-snippet index bdf36a88..58f38d1b 100644 --- a/snippets/sublime/Try-Except.sublime-snippet +++ b/snippets/sublime/Try-Except.sublime-snippet @@ -1,7 +1,7 @@ try source.python diff --git a/test/atom-spec/python-spec.js b/test/atom-spec/python-spec.js index c0d65218..79edf0a0 100644 --- a/test/atom-spec/python-spec.js +++ b/test/atom-spec/python-spec.js @@ -16,7 +16,7 @@ describe("Grammar Tests", function() { it("test/builtins/builtins1.py", function() { - tokens = grammar.tokenizeLines("AttributeError ConnectionAbortedError\nPendingDeprecationWarning\nModuleNotFoundError\nSystemExit\nNotImplemented True None False Ellipsis\nWarning\nException BaseException\nsum oct abs type object print") + tokens = grammar.tokenizeLines("AttributeError ConnectionAbortedError\nPendingDeprecationWarning\nModuleNotFoundError\nSystemExit\nNotImplemented True None False Ellipsis\nWarning\nException BaseException\nsum oct abs type object print exec") expect(tokens[0][0].value).toBe("AttributeError"); expect(tokens[0][0].scopes).toEqual(["source.python","support.type.exception.python"]); expect(tokens[0][1].value).toBe(" "); @@ -77,6 +77,10 @@ describe("Grammar Tests", function() { expect(tokens[7][9].scopes).toEqual(["source.python"]); expect(tokens[7][10].value).toBe("print"); expect(tokens[7][10].scopes).toEqual(["source.python","support.function.builtin.python"]); + expect(tokens[7][11].value).toBe(" "); + expect(tokens[7][11].scopes).toEqual(["source.python"]); + expect(tokens[7][12].value).toBe("exec"); + expect(tokens[7][12].scopes).toEqual(["source.python","support.function.builtin.python"]); }); it("test/builtins/builtins2.py", @@ -130,7 +134,7 @@ describe("Grammar Tests", function() { it("test/builtins/builtins3.py", function() { - tokens = grammar.tokenizeLines("__all__ = ['bar', 'baz']\nsome.__bases__\nsome.__class__\nassert __debug__\n__builtins__\n__builtins__.len\nprint(__builtins__)\nsome.__dict__\nsome.__doc__\nsome.__file__\nsome.__members__\nsome.__metaclass__\nsome.__methods__\nsome.__module__\nsome.__mro__\nsome.__name__\nsome.__slots__\nsome.__subclasses__\nsome.__version__\nsome.__weakref__\nsome.__qualname__\nsome.__code__\nsome.__wrapped__\nsome.__signature__\nsome.__defaults__\nsome.__func__\nsome.__self__\nsome.__kwdefaults__\nsome.__matmul__\nsome.__imatmul__\nsome.__rmatmul__\nsome.__annotations__\nsome.__init_subclass__\nsome.__set_name__\nsome.__fspath__\nsome.__classcell__\nsome.__bytes__\nsome.__spec__\nsome.__path__\nsome.__prepare__\nsome.__package__\nsome.__traceback__\nsome.__notspecial__") + tokens = grammar.tokenizeLines("__all__ = ['bar', 'baz']\nsome.__bases__\nsome.__class__\nassert __debug__\n__builtins__\n__builtins__.len\nprint(__builtins__)\nsome.__dict__\nsome.__doc__\nsome.__file__\nsome.__members__\nsome.__metaclass__\nsome.__methods__\nsome.__module__\nsome.__mro__\nsome.__name__\nsome.__slots__\nsome.__subclasses__\nsome.__version__\nsome.__weakref__\nsome.__qualname__\nsome.__code__\nsome.__wrapped__\nsome.__signature__\nsome.__defaults__\nsome.__func__\nsome.__self__\nsome.__kwdefaults__\nsome.__matmul__\nsome.__imatmul__\nsome.__rmatmul__\nsome.__annotations__\nsome.__init_subclass__\nsome.__set_name__\nsome.__fspath__\nsome.__classcell__\nsome.__bytes__\nsome.__spec__\nsome.__path__\nsome.__prepare__\nsome.__package__\nsome.__traceback__\nsome.__closure__\nsome.__globals__\nsome.__match_args__\nsome.__notspecial__") expect(tokens[0][0].value).toBe("__all__"); expect(tokens[0][0].scopes).toEqual(["source.python","support.variable.magic.python"]); expect(tokens[0][1].value).toBe(" "); @@ -162,15 +166,15 @@ describe("Grammar Tests", function() { expect(tokens[1][0].value).toBe("some"); expect(tokens[1][0].scopes).toEqual(["source.python"]); expect(tokens[1][1].value).toBe("."); - expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[1][2].value).toBe("__bases__"); - expect(tokens[1][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[2][0].value).toBe("some"); expect(tokens[2][0].scopes).toEqual(["source.python"]); expect(tokens[2][1].value).toBe("."); - expect(tokens[2][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[2][2].value).toBe("__class__"); - expect(tokens[2][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[3][0].value).toBe("assert"); expect(tokens[3][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); expect(tokens[3][1].value).toBe(" "); @@ -182,9 +186,9 @@ describe("Grammar Tests", function() { expect(tokens[5][0].value).toBe("__builtins__"); expect(tokens[5][0].scopes).toEqual(["source.python","support.variable.magic.python"]); expect(tokens[5][1].value).toBe("."); - expect(tokens[5][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[5][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[5][2].value).toBe("len"); - expect(tokens[5][2].scopes).toEqual(["source.python"]); + expect(tokens[5][2].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[6][0].value).toBe("print"); expect(tokens[6][0].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); expect(tokens[6][1].value).toBe("("); @@ -196,219 +200,237 @@ describe("Grammar Tests", function() { expect(tokens[7][0].value).toBe("some"); expect(tokens[7][0].scopes).toEqual(["source.python"]); expect(tokens[7][1].value).toBe("."); - expect(tokens[7][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[7][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[7][2].value).toBe("__dict__"); - expect(tokens[7][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[7][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[8][0].value).toBe("some"); expect(tokens[8][0].scopes).toEqual(["source.python"]); expect(tokens[8][1].value).toBe("."); - expect(tokens[8][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[8][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[8][2].value).toBe("__doc__"); - expect(tokens[8][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[8][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[9][0].value).toBe("some"); expect(tokens[9][0].scopes).toEqual(["source.python"]); expect(tokens[9][1].value).toBe("."); - expect(tokens[9][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[9][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[9][2].value).toBe("__file__"); - expect(tokens[9][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[9][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[10][0].value).toBe("some"); expect(tokens[10][0].scopes).toEqual(["source.python"]); expect(tokens[10][1].value).toBe("."); - expect(tokens[10][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[10][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[10][2].value).toBe("__members__"); - expect(tokens[10][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[10][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[11][0].value).toBe("some"); expect(tokens[11][0].scopes).toEqual(["source.python"]); expect(tokens[11][1].value).toBe("."); - expect(tokens[11][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[11][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[11][2].value).toBe("__metaclass__"); - expect(tokens[11][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[11][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[12][0].value).toBe("some"); expect(tokens[12][0].scopes).toEqual(["source.python"]); expect(tokens[12][1].value).toBe("."); - expect(tokens[12][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[12][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[12][2].value).toBe("__methods__"); - expect(tokens[12][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[12][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[13][0].value).toBe("some"); expect(tokens[13][0].scopes).toEqual(["source.python"]); expect(tokens[13][1].value).toBe("."); - expect(tokens[13][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[13][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[13][2].value).toBe("__module__"); - expect(tokens[13][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[13][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[14][0].value).toBe("some"); expect(tokens[14][0].scopes).toEqual(["source.python"]); expect(tokens[14][1].value).toBe("."); - expect(tokens[14][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[14][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[14][2].value).toBe("__mro__"); - expect(tokens[14][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[14][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[15][0].value).toBe("some"); expect(tokens[15][0].scopes).toEqual(["source.python"]); expect(tokens[15][1].value).toBe("."); - expect(tokens[15][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[15][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[15][2].value).toBe("__name__"); - expect(tokens[15][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[15][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[16][0].value).toBe("some"); expect(tokens[16][0].scopes).toEqual(["source.python"]); expect(tokens[16][1].value).toBe("."); - expect(tokens[16][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[16][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[16][2].value).toBe("__slots__"); - expect(tokens[16][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[16][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[17][0].value).toBe("some"); expect(tokens[17][0].scopes).toEqual(["source.python"]); expect(tokens[17][1].value).toBe("."); - expect(tokens[17][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[17][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[17][2].value).toBe("__subclasses__"); - expect(tokens[17][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[17][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[18][0].value).toBe("some"); expect(tokens[18][0].scopes).toEqual(["source.python"]); expect(tokens[18][1].value).toBe("."); - expect(tokens[18][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[18][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[18][2].value).toBe("__version__"); - expect(tokens[18][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[18][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[19][0].value).toBe("some"); expect(tokens[19][0].scopes).toEqual(["source.python"]); expect(tokens[19][1].value).toBe("."); - expect(tokens[19][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[19][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[19][2].value).toBe("__weakref__"); - expect(tokens[19][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[19][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[20][0].value).toBe("some"); expect(tokens[20][0].scopes).toEqual(["source.python"]); expect(tokens[20][1].value).toBe("."); - expect(tokens[20][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[20][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[20][2].value).toBe("__qualname__"); - expect(tokens[20][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[20][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[21][0].value).toBe("some"); expect(tokens[21][0].scopes).toEqual(["source.python"]); expect(tokens[21][1].value).toBe("."); - expect(tokens[21][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[21][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[21][2].value).toBe("__code__"); - expect(tokens[21][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[21][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[22][0].value).toBe("some"); expect(tokens[22][0].scopes).toEqual(["source.python"]); expect(tokens[22][1].value).toBe("."); - expect(tokens[22][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[22][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[22][2].value).toBe("__wrapped__"); - expect(tokens[22][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[22][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[23][0].value).toBe("some"); expect(tokens[23][0].scopes).toEqual(["source.python"]); expect(tokens[23][1].value).toBe("."); - expect(tokens[23][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[23][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[23][2].value).toBe("__signature__"); - expect(tokens[23][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[23][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[24][0].value).toBe("some"); expect(tokens[24][0].scopes).toEqual(["source.python"]); expect(tokens[24][1].value).toBe("."); - expect(tokens[24][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[24][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[24][2].value).toBe("__defaults__"); - expect(tokens[24][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[24][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[25][0].value).toBe("some"); expect(tokens[25][0].scopes).toEqual(["source.python"]); expect(tokens[25][1].value).toBe("."); - expect(tokens[25][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[25][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[25][2].value).toBe("__func__"); - expect(tokens[25][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[25][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[26][0].value).toBe("some"); expect(tokens[26][0].scopes).toEqual(["source.python"]); expect(tokens[26][1].value).toBe("."); - expect(tokens[26][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[26][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[26][2].value).toBe("__self__"); - expect(tokens[26][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[26][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[27][0].value).toBe("some"); expect(tokens[27][0].scopes).toEqual(["source.python"]); expect(tokens[27][1].value).toBe("."); - expect(tokens[27][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[27][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[27][2].value).toBe("__kwdefaults__"); - expect(tokens[27][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[27][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[28][0].value).toBe("some"); expect(tokens[28][0].scopes).toEqual(["source.python"]); expect(tokens[28][1].value).toBe("."); - expect(tokens[28][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[28][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[28][2].value).toBe("__matmul__"); - expect(tokens[28][2].scopes).toEqual(["source.python","support.function.magic.python"]); + expect(tokens[28][2].scopes).toEqual(["source.python","meta.member.access.python","support.function.magic.python"]); expect(tokens[29][0].value).toBe("some"); expect(tokens[29][0].scopes).toEqual(["source.python"]); expect(tokens[29][1].value).toBe("."); - expect(tokens[29][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[29][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[29][2].value).toBe("__imatmul__"); - expect(tokens[29][2].scopes).toEqual(["source.python","support.function.magic.python"]); + expect(tokens[29][2].scopes).toEqual(["source.python","meta.member.access.python","support.function.magic.python"]); expect(tokens[30][0].value).toBe("some"); expect(tokens[30][0].scopes).toEqual(["source.python"]); expect(tokens[30][1].value).toBe("."); - expect(tokens[30][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[30][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[30][2].value).toBe("__rmatmul__"); - expect(tokens[30][2].scopes).toEqual(["source.python","support.function.magic.python"]); + expect(tokens[30][2].scopes).toEqual(["source.python","meta.member.access.python","support.function.magic.python"]); expect(tokens[31][0].value).toBe("some"); expect(tokens[31][0].scopes).toEqual(["source.python"]); expect(tokens[31][1].value).toBe("."); - expect(tokens[31][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[31][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[31][2].value).toBe("__annotations__"); - expect(tokens[31][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[31][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[32][0].value).toBe("some"); expect(tokens[32][0].scopes).toEqual(["source.python"]); expect(tokens[32][1].value).toBe("."); - expect(tokens[32][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[32][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[32][2].value).toBe("__init_subclass__"); - expect(tokens[32][2].scopes).toEqual(["source.python","support.function.magic.python"]); + expect(tokens[32][2].scopes).toEqual(["source.python","meta.member.access.python","support.function.magic.python"]); expect(tokens[33][0].value).toBe("some"); expect(tokens[33][0].scopes).toEqual(["source.python"]); expect(tokens[33][1].value).toBe("."); - expect(tokens[33][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[33][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[33][2].value).toBe("__set_name__"); - expect(tokens[33][2].scopes).toEqual(["source.python","support.function.magic.python"]); + expect(tokens[33][2].scopes).toEqual(["source.python","meta.member.access.python","support.function.magic.python"]); expect(tokens[34][0].value).toBe("some"); expect(tokens[34][0].scopes).toEqual(["source.python"]); expect(tokens[34][1].value).toBe("."); - expect(tokens[34][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[34][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[34][2].value).toBe("__fspath__"); - expect(tokens[34][2].scopes).toEqual(["source.python","support.function.magic.python"]); + expect(tokens[34][2].scopes).toEqual(["source.python","meta.member.access.python","support.function.magic.python"]); expect(tokens[35][0].value).toBe("some"); expect(tokens[35][0].scopes).toEqual(["source.python"]); expect(tokens[35][1].value).toBe("."); - expect(tokens[35][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[35][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[35][2].value).toBe("__classcell__"); - expect(tokens[35][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[35][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[36][0].value).toBe("some"); expect(tokens[36][0].scopes).toEqual(["source.python"]); expect(tokens[36][1].value).toBe("."); - expect(tokens[36][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[36][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[36][2].value).toBe("__bytes__"); - expect(tokens[36][2].scopes).toEqual(["source.python","support.function.magic.python"]); + expect(tokens[36][2].scopes).toEqual(["source.python","meta.member.access.python","support.function.magic.python"]); expect(tokens[37][0].value).toBe("some"); expect(tokens[37][0].scopes).toEqual(["source.python"]); expect(tokens[37][1].value).toBe("."); - expect(tokens[37][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[37][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[37][2].value).toBe("__spec__"); - expect(tokens[37][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[37][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[38][0].value).toBe("some"); expect(tokens[38][0].scopes).toEqual(["source.python"]); expect(tokens[38][1].value).toBe("."); - expect(tokens[38][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[38][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[38][2].value).toBe("__path__"); - expect(tokens[38][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[38][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[39][0].value).toBe("some"); expect(tokens[39][0].scopes).toEqual(["source.python"]); expect(tokens[39][1].value).toBe("."); - expect(tokens[39][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[39][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[39][2].value).toBe("__prepare__"); - expect(tokens[39][2].scopes).toEqual(["source.python","support.function.magic.python"]); + expect(tokens[39][2].scopes).toEqual(["source.python","meta.member.access.python","support.function.magic.python"]); expect(tokens[40][0].value).toBe("some"); expect(tokens[40][0].scopes).toEqual(["source.python"]); expect(tokens[40][1].value).toBe("."); - expect(tokens[40][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[40][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[40][2].value).toBe("__package__"); - expect(tokens[40][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[40][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[41][0].value).toBe("some"); expect(tokens[41][0].scopes).toEqual(["source.python"]); expect(tokens[41][1].value).toBe("."); - expect(tokens[41][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[41][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[41][2].value).toBe("__traceback__"); - expect(tokens[41][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[41][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[42][0].value).toBe("some"); expect(tokens[42][0].scopes).toEqual(["source.python"]); expect(tokens[42][1].value).toBe("."); - expect(tokens[42][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[42][2].value).toBe("__notspecial__"); - expect(tokens[42][2].scopes).toEqual(["source.python"]); + expect(tokens[42][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); + expect(tokens[42][2].value).toBe("__closure__"); + expect(tokens[42][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); + expect(tokens[43][0].value).toBe("some"); + expect(tokens[43][0].scopes).toEqual(["source.python"]); + expect(tokens[43][1].value).toBe("."); + expect(tokens[43][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); + expect(tokens[43][2].value).toBe("__globals__"); + expect(tokens[43][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); + expect(tokens[44][0].value).toBe("some"); + expect(tokens[44][0].scopes).toEqual(["source.python"]); + expect(tokens[44][1].value).toBe("."); + expect(tokens[44][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); + expect(tokens[44][2].value).toBe("__match_args__"); + expect(tokens[44][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); + expect(tokens[45][0].value).toBe("some"); + expect(tokens[45][0].scopes).toEqual(["source.python"]); + expect(tokens[45][1].value).toBe("."); + expect(tokens[45][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); + expect(tokens[45][2].value).toBe("__notspecial__"); + expect(tokens[45][2].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); }); it("test/builtins/builtins4.py", @@ -417,39 +439,39 @@ describe("Grammar Tests", function() { expect(tokens[0][0].value).toBe("some"); expect(tokens[0][0].scopes).toEqual(["source.python"]); expect(tokens[0][1].value).toBe("."); - expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][2].value).toBe("int"); - expect(tokens[0][2].scopes).toEqual(["source.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[1][0].value).toBe("some"); expect(tokens[1][0].scopes).toEqual(["source.python"]); expect(tokens[1][1].value).toBe("."); - expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[1][2].value).toBe("sum"); - expect(tokens[1][2].scopes).toEqual(["source.python"]); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[2][0].value).toBe("some"); expect(tokens[2][0].scopes).toEqual(["source.python"]); expect(tokens[2][1].value).toBe("."); - expect(tokens[2][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[2][2].value).toBe("super"); - expect(tokens[2][2].scopes).toEqual(["source.python"]); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[3][0].value).toBe("some"); expect(tokens[3][0].scopes).toEqual(["source.python"]); expect(tokens[3][1].value).toBe("."); - expect(tokens[3][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[3][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[3][2].value).toBe("unicode"); - expect(tokens[3][2].scopes).toEqual(["source.python"]); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[4][0].value).toBe("some"); expect(tokens[4][0].scopes).toEqual(["source.python"]); expect(tokens[4][1].value).toBe("."); - expect(tokens[4][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[4][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[4][2].value).toBe("foo"); - expect(tokens[4][2].scopes).toEqual(["source.python"]); + expect(tokens[4][2].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[5][0].value).toBe("some"); expect(tokens[5][0].scopes).toEqual(["source.python"]); expect(tokens[5][1].value).toBe("."); - expect(tokens[5][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[5][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[5][2].value).toBe("Exception"); - expect(tokens[5][2].scopes).toEqual(["source.python"]); + expect(tokens[5][2].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); }); it("test/builtins/builtins5.py", @@ -458,37 +480,79 @@ describe("Grammar Tests", function() { expect(tokens[0][0].value).toBe("some"); expect(tokens[0][0].scopes).toEqual(["source.python"]); expect(tokens[0][1].value).toBe("."); - expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][2].value).toBe(" "); - expect(tokens[0][2].scopes).toEqual(["source.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[0][3].value).toBe("True"); - expect(tokens[0][3].scopes).toEqual(["source.python","keyword.illegal.name.python"]); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.member.access.python","keyword.illegal.name.python"]); expect(tokens[1][0].value).toBe("some"); expect(tokens[1][0].scopes).toEqual(["source.python"]); expect(tokens[1][1].value).toBe("."); - expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[1][2].value).toBe(" "); - expect(tokens[1][2].scopes).toEqual(["source.python"]); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[1][3].value).toBe("\\"); - expect(tokens[1][3].scopes).toEqual(["source.python","punctuation.separator.continuation.line.python"]); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.continuation.line.python"]); expect(tokens[1][4].value).toBe(""); - expect(tokens[1][4].scopes).toEqual(["source.python"]); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[2][0].value).toBe(" "); - expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[2][0].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[2][1].value).toBe("True"); - expect(tokens[2][1].scopes).toEqual(["source.python","keyword.illegal.name.python"]); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.member.access.python","keyword.illegal.name.python"]); expect(tokens[3][0].value).toBe("True"); expect(tokens[3][0].scopes).toEqual(["source.python","constant.language.python"]); expect(tokens[4][0].value).toBe("some"); expect(tokens[4][0].scopes).toEqual(["source.python"]); expect(tokens[4][1].value).toBe("."); - expect(tokens[4][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[4][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[4][2].value).toBe(""); - expect(tokens[4][2].scopes).toEqual(["source.python"]); + expect(tokens[4][2].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[5][0].value).toBe(" "); - expect(tokens[5][0].scopes).toEqual(["source.python"]); + expect(tokens[5][0].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[5][1].value).toBe("True"); - expect(tokens[5][1].scopes).toEqual(["source.python","keyword.illegal.name.python"]); + expect(tokens[5][1].scopes).toEqual(["source.python","meta.member.access.python","keyword.illegal.name.python"]); + }); + + it("test/builtins/builtins6.py", + function() { + tokens = grammar.tokenizeLines("exec()\nexec(code_obj)") + expect(tokens[0][0].value).toBe("exec"); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[0][1].value).toBe("("); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[0][2].value).toBe(")"); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[1][0].value).toBe("exec"); + expect(tokens[1][0].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[1][1].value).toBe("("); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[1][2].value).toBe("code_obj"); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[1][3].value).toBe(")"); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + }); + + it("test/builtins/builtins7.py", + function() { + tokens = grammar.tokenizeLines("breakpoint()\naiter()\nanext()") + expect(tokens[0][0].value).toBe("breakpoint"); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[0][1].value).toBe("("); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[0][2].value).toBe(")"); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[1][0].value).toBe("aiter"); + expect(tokens[1][0].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[1][1].value).toBe("("); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[1][2].value).toBe(")"); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[2][0].value).toBe("anext"); + expect(tokens[2][0].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[2][1].value).toBe("("); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[2][2].value).toBe(")"); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); }); it("test/calls/call1.py", @@ -511,7 +575,7 @@ describe("Grammar Tests", function() { expect(tokens[0][7].value).toBe(" "); expect(tokens[0][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[0][8].value).toBe("c"); - expect(tokens[0][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.item-access.python"]); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.item-access.python","meta.indexed-name.python"]); expect(tokens[0][9].value).toBe("["); expect(tokens[0][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.item-access.python","punctuation.definition.arguments.begin.python"]); expect(tokens[0][10].value).toBe("1"); @@ -566,6 +630,128 @@ describe("Grammar Tests", function() { expect(tokens[0][34].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); }); + it("test/calls/call10.py", + function() { + tokens = grammar.tokenizeLines("x = foo(True,\n 3 * 4,\n *a,\n **bar)") + expect(tokens[0][0].value).toBe("x"); + expect(tokens[0][0].scopes).toEqual(["source.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("="); + expect(tokens[0][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("foo"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[0][5].value).toBe("("); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[0][6].value).toBe("True"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.language.python"]); + expect(tokens[0][7].value).toBe(","); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[1][0].value).toBe(" "); + expect(tokens[1][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[1][1].value).toBe("3"); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[1][2].value).toBe(" "); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[1][3].value).toBe("*"); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.arithmetic.python"]); + expect(tokens[1][4].value).toBe(" "); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[1][5].value).toBe("4"); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[1][6].value).toBe(","); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[2][0].value).toBe(" "); + expect(tokens[2][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[2][1].value).toBe("*"); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.unpacking.arguments.python"]); + expect(tokens[2][2].value).toBe("a"); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[2][3].value).toBe(","); + expect(tokens[2][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[3][0].value).toBe(" "); + expect(tokens[3][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[3][1].value).toBe("**"); + expect(tokens[3][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.unpacking.arguments.python"]); + expect(tokens[3][2].value).toBe("bar"); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[3][3].value).toBe(")"); + expect(tokens[3][3].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + }); + + it("test/calls/call11.py", + function() { + tokens = grammar.tokenizeLines("id = Field[uuid.UUID] (\n uuid.UUID,\n inheritable=False,\n simpledelta=False,\n allow_ddl_set=True,\n)") + expect(tokens[0][0].value).toBe("id"); + expect(tokens[0][0].scopes).toEqual(["source.python","support.function.builtin.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("="); + expect(tokens[0][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("Field"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.item-access.python","meta.indexed-name.python"]); + expect(tokens[0][5].value).toBe("["); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.item-access.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[0][6].value).toBe("uuid"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.item-access.python","meta.item-access.arguments.python"]); + expect(tokens[0][7].value).toBe("."); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.item-access.python","meta.item-access.arguments.python","meta.member.access.python","punctuation.separator.period.python"]); + expect(tokens[0][8].value).toBe("UUID"); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.item-access.python","meta.item-access.arguments.python","meta.member.access.python","constant.other.caps.python"]); + expect(tokens[0][9].value).toBe("]"); + expect(tokens[0][9].scopes).toEqual(["source.python","meta.item-access.python","punctuation.definition.arguments.end.python"]); + expect(tokens[0][10].value).toBe(" "); + expect(tokens[0][10].scopes).toEqual(["source.python"]); + expect(tokens[0][11].value).toBe("("); + expect(tokens[0][11].scopes).toEqual(["source.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[1][0].value).toBe(" "); + expect(tokens[1][0].scopes).toEqual(["source.python","meta.function-call.arguments.python"]); + expect(tokens[1][1].value).toBe("uuid"); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.function-call.arguments.python"]); + expect(tokens[1][2].value).toBe("."); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.function-call.arguments.python","meta.member.access.python","punctuation.separator.period.python"]); + expect(tokens[1][3].value).toBe("UUID"); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.function-call.arguments.python","meta.member.access.python","constant.other.caps.python"]); + expect(tokens[1][4].value).toBe(","); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[2][0].value).toBe(" "); + expect(tokens[2][0].scopes).toEqual(["source.python","meta.function-call.arguments.python"]); + expect(tokens[2][1].value).toBe("inheritable"); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[2][2].value).toBe("="); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[2][3].value).toBe("False"); + expect(tokens[2][3].scopes).toEqual(["source.python","meta.function-call.arguments.python","constant.language.python"]); + expect(tokens[2][4].value).toBe(","); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[3][0].value).toBe(" "); + expect(tokens[3][0].scopes).toEqual(["source.python","meta.function-call.arguments.python"]); + expect(tokens[3][1].value).toBe("simpledelta"); + expect(tokens[3][1].scopes).toEqual(["source.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[3][2].value).toBe("="); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[3][3].value).toBe("False"); + expect(tokens[3][3].scopes).toEqual(["source.python","meta.function-call.arguments.python","constant.language.python"]); + expect(tokens[3][4].value).toBe(","); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[4][0].value).toBe(" "); + expect(tokens[4][0].scopes).toEqual(["source.python","meta.function-call.arguments.python"]); + expect(tokens[4][1].value).toBe("allow_ddl_set"); + expect(tokens[4][1].scopes).toEqual(["source.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[4][2].value).toBe("="); + expect(tokens[4][2].scopes).toEqual(["source.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[4][3].value).toBe("True"); + expect(tokens[4][3].scopes).toEqual(["source.python","meta.function-call.arguments.python","constant.language.python"]); + expect(tokens[4][4].value).toBe(","); + expect(tokens[4][4].scopes).toEqual(["source.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[5][0].value).toBe(")"); + expect(tokens[5][0].scopes).toEqual(["source.python","punctuation.definition.arguments.end.python"]); + }); + it("test/calls/call2.py", function() { tokens = grammar.tokenizeLines("foo(from=1)") @@ -589,31 +775,31 @@ describe("Grammar Tests", function() { expect(tokens[0][0].value).toBe("foo"); expect(tokens[0][0].scopes).toEqual(["source.python"]); expect(tokens[0][1].value).toBe("."); - expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][2].value).toBe("class"); - expect(tokens[0][2].scopes).toEqual(["source.python","meta.function-call.python","keyword.control.flow.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","keyword.control.flow.python"]); expect(tokens[0][3].value).toBe("("); - expect(tokens[0][3].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[0][4].value).toBe("a"); - expect(tokens[0][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[0][5].value).toBe(")"); - expect(tokens[0][5].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[1][0].value).toBe("foo"); expect(tokens[1][0].scopes).toEqual(["source.python"]); expect(tokens[1][1].value).toBe("."); - expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[1][2].value).toBe("and"); - expect(tokens[1][2].scopes).toEqual(["source.python","meta.function-call.python","keyword.control.flow.python"]); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","keyword.control.flow.python"]); expect(tokens[1][3].value).toBe("("); - expect(tokens[1][3].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[1][4].value).toBe(")"); - expect(tokens[1][4].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[2][0].value).toBe("foo"); expect(tokens[2][0].scopes).toEqual(["source.python"]); expect(tokens[2][1].value).toBe("."); - expect(tokens[2][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[2][2].value).toBe("if"); - expect(tokens[2][2].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.member.access.python","keyword.control.flow.python"]); }); it("test/calls/call4.py", @@ -622,9 +808,9 @@ describe("Grammar Tests", function() { expect(tokens[0][0].value).toBe("foo"); expect(tokens[0][0].scopes).toEqual(["source.python"]); expect(tokens[0][1].value).toBe("."); - expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][2].value).toBe("1"); - expect(tokens[0][2].scopes).toEqual(["source.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[1][0].value).toBe("foo"); expect(tokens[1][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); expect(tokens[1][1].value).toBe("("); @@ -650,9 +836,9 @@ describe("Grammar Tests", function() { expect(tokens[2][0].value).toBe("foo"); expect(tokens[2][0].scopes).toEqual(["source.python"]); expect(tokens[2][1].value).toBe("."); - expect(tokens[2][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[2][2].value).toBe("None"); - expect(tokens[2][2].scopes).toEqual(["source.python","keyword.illegal.name.python"]); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.member.access.python","keyword.illegal.name.python"]); expect(tokens[2][3].value).toBe(" "); expect(tokens[2][3].scopes).toEqual(["source.python"]); expect(tokens[2][4].value).toBe("and"); @@ -662,13 +848,13 @@ describe("Grammar Tests", function() { expect(tokens[2][6].value).toBe("foo"); expect(tokens[2][6].scopes).toEqual(["source.python"]); expect(tokens[2][7].value).toBe("."); - expect(tokens[2][7].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[2][7].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[2][8].value).toBe("None"); - expect(tokens[2][8].scopes).toEqual(["source.python","keyword.illegal.name.python"]); + expect(tokens[2][8].scopes).toEqual(["source.python","meta.member.access.python","keyword.illegal.name.python"]); expect(tokens[2][9].value).toBe("."); - expect(tokens[2][9].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[2][9].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[2][10].value).toBe("baz"); - expect(tokens[2][10].scopes).toEqual(["source.python"]); + expect(tokens[2][10].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); }); it("test/calls/call5.py", @@ -679,7 +865,7 @@ describe("Grammar Tests", function() { expect(tokens[0][1].value).toBe("("); expect(tokens[0][1].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[0][2].value).toBe("*"); - expect(tokens[0][2].scopes).toEqual(["source.python","meta.function-call.python","keyword.operator.unpacking.arguments.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.unpacking.arguments.python"]); expect(tokens[0][3].value).toBe("a"); expect(tokens[0][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[0][4].value).toBe(")"); @@ -689,7 +875,7 @@ describe("Grammar Tests", function() { expect(tokens[1][1].value).toBe("("); expect(tokens[1][1].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[1][2].value).toBe("**"); - expect(tokens[1][2].scopes).toEqual(["source.python","meta.function-call.python","keyword.operator.unpacking.arguments.python"]); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.unpacking.arguments.python"]); expect(tokens[1][3].value).toBe("a"); expect(tokens[1][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[1][4].value).toBe(")"); @@ -704,9 +890,9 @@ describe("Grammar Tests", function() { expect(tokens[0][1].value).toBe("("); expect(tokens[0][1].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[0][2].value).toBe(" "); - expect(tokens[0][2].scopes).toEqual(["source.python","meta.function-call.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[0][3].value).toBe("*"); - expect(tokens[0][3].scopes).toEqual(["source.python","meta.function-call.python","keyword.operator.unpacking.arguments.python"]); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.unpacking.arguments.python"]); expect(tokens[0][4].value).toBe("a"); expect(tokens[0][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[0][5].value).toBe(" "); @@ -728,9 +914,9 @@ describe("Grammar Tests", function() { expect(tokens[1][1].value).toBe("("); expect(tokens[1][1].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[1][2].value).toBe(" "); - expect(tokens[1][2].scopes).toEqual(["source.python","meta.function-call.python"]); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[1][3].value).toBe("**"); - expect(tokens[1][3].scopes).toEqual(["source.python","meta.function-call.python","keyword.operator.unpacking.arguments.python"]); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.unpacking.arguments.python"]); expect(tokens[1][4].value).toBe("a"); expect(tokens[1][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[1][5].value).toBe(" "); @@ -755,79 +941,79 @@ describe("Grammar Tests", function() { expect(tokens[0][0].value).toBe("foo"); expect(tokens[0][0].scopes).toEqual(["source.python"]); expect(tokens[0][1].value).toBe("."); - expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][2].value).toBe("__class__"); - expect(tokens[0][2].scopes).toEqual(["source.python","meta.function-call.python","support.variable.magic.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","support.variable.magic.python"]); expect(tokens[0][3].value).toBe(" "); - expect(tokens[0][3].scopes).toEqual(["source.python","meta.function-call.python"]); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python"]); expect(tokens[0][4].value).toBe("("); - expect(tokens[0][4].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[0][5].value).toBe("foo"); - expect(tokens[0][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); expect(tokens[0][6].value).toBe("="); - expect(tokens[0][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); expect(tokens[0][7].value).toBe("bar"); - expect(tokens[0][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[0][8].value).toBe(")"); - expect(tokens[0][8].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[1][0].value).toBe("foo"); expect(tokens[1][0].scopes).toEqual(["source.python"]); expect(tokens[1][1].value).toBe("."); - expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[1][2].value).toBe("__class__"); - expect(tokens[1][2].scopes).toEqual(["source.python","meta.function-call.python","support.variable.magic.python"]); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","support.variable.magic.python"]); expect(tokens[1][3].value).toBe("("); - expect(tokens[1][3].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[1][4].value).toBe("foo"); - expect(tokens[1][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); expect(tokens[1][5].value).toBe("="); - expect(tokens[1][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); expect(tokens[1][6].value).toBe("bar"); - expect(tokens[1][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[1][7].value).toBe(")"); - expect(tokens[1][7].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[1][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[2][0].value).toBe("foo"); expect(tokens[2][0].scopes).toEqual(["source.python"]); expect(tokens[2][1].value).toBe("."); - expect(tokens[2][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[2][2].value).toBe("__add__"); - expect(tokens[2][2].scopes).toEqual(["source.python","meta.function-call.python","support.function.magic.python"]); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","support.function.magic.python"]); expect(tokens[2][3].value).toBe(" "); - expect(tokens[2][3].scopes).toEqual(["source.python","meta.function-call.python"]); + expect(tokens[2][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python"]); expect(tokens[2][4].value).toBe("("); - expect(tokens[2][4].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[2][5].value).toBe("foo"); - expect(tokens[2][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); expect(tokens[2][6].value).toBe("="); - expect(tokens[2][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); expect(tokens[2][7].value).toBe("bar"); - expect(tokens[2][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[2][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[2][8].value).toBe(")"); - expect(tokens[2][8].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[2][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[3][0].value).toBe("foo"); expect(tokens[3][0].scopes).toEqual(["source.python"]); expect(tokens[3][1].value).toBe("."); - expect(tokens[3][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[3][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[3][2].value).toBe("__add__"); - expect(tokens[3][2].scopes).toEqual(["source.python","meta.function-call.python","support.function.magic.python"]); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","support.function.magic.python"]); expect(tokens[3][3].value).toBe("("); - expect(tokens[3][3].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[3][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[3][4].value).toBe("foo"); - expect(tokens[3][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); expect(tokens[3][5].value).toBe("="); - expect(tokens[3][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[3][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); expect(tokens[3][6].value).toBe("bar"); - expect(tokens[3][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[3][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[3][7].value).toBe(")"); - expect(tokens[3][7].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[3][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[4][0].value).toBe(""); expect(tokens[4][0].scopes).toEqual(["source.python"]); expect(tokens[5][0].value).toBe("foo"); expect(tokens[5][0].scopes).toEqual(["source.python"]); expect(tokens[5][1].value).toBe("."); - expect(tokens[5][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[5][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[5][2].value).toBe("__class__"); - expect(tokens[5][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[5][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[5][3].value).toBe(" "); expect(tokens[5][3].scopes).toEqual(["source.python"]); expect(tokens[5][4].value).toBe("1"); @@ -840,79 +1026,79 @@ describe("Grammar Tests", function() { expect(tokens[0][0].value).toBe("foo"); expect(tokens[0][0].scopes).toEqual(["source.python"]); expect(tokens[0][1].value).toBe("."); - expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][2].value).toBe(" "); - expect(tokens[0][2].scopes).toEqual(["source.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[0][3].value).toBe("__class__"); - expect(tokens[0][3].scopes).toEqual(["source.python","meta.function-call.python","support.variable.magic.python"]); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","support.variable.magic.python"]); expect(tokens[0][4].value).toBe("("); - expect(tokens[0][4].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[0][5].value).toBe("foo"); - expect(tokens[0][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); expect(tokens[0][6].value).toBe("="); - expect(tokens[0][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); expect(tokens[0][7].value).toBe("bar"); - expect(tokens[0][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[0][8].value).toBe(")"); - expect(tokens[0][8].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[1][0].value).toBe("foo"); expect(tokens[1][0].scopes).toEqual(["source.python"]); expect(tokens[1][1].value).toBe("."); - expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[1][2].value).toBe(" "); - expect(tokens[1][2].scopes).toEqual(["source.python"]); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[1][3].value).toBe("__class__"); - expect(tokens[1][3].scopes).toEqual(["source.python","meta.function-call.python","support.variable.magic.python"]); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","support.variable.magic.python"]); expect(tokens[1][4].value).toBe(" "); - expect(tokens[1][4].scopes).toEqual(["source.python","meta.function-call.python"]); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python"]); expect(tokens[1][5].value).toBe("("); - expect(tokens[1][5].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[1][6].value).toBe("foo"); - expect(tokens[1][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); expect(tokens[1][7].value).toBe("="); - expect(tokens[1][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[1][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); expect(tokens[1][8].value).toBe("bar"); - expect(tokens[1][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[1][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[1][9].value).toBe(")"); - expect(tokens[1][9].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[1][9].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[2][0].value).toBe("foo"); expect(tokens[2][0].scopes).toEqual(["source.python"]); expect(tokens[2][1].value).toBe("."); - expect(tokens[2][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[2][2].value).toBe(" "); - expect(tokens[2][2].scopes).toEqual(["source.python"]); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[2][3].value).toBe("__add__"); - expect(tokens[2][3].scopes).toEqual(["source.python","meta.function-call.python","support.function.magic.python"]); + expect(tokens[2][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","support.function.magic.python"]); expect(tokens[2][4].value).toBe(" "); - expect(tokens[2][4].scopes).toEqual(["source.python","meta.function-call.python"]); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python"]); expect(tokens[2][5].value).toBe("("); - expect(tokens[2][5].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[2][6].value).toBe("foo"); - expect(tokens[2][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); expect(tokens[2][7].value).toBe("="); - expect(tokens[2][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[2][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); expect(tokens[2][8].value).toBe("bar"); - expect(tokens[2][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[2][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[2][9].value).toBe(")"); - expect(tokens[2][9].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[2][9].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[3][0].value).toBe("foo"); expect(tokens[3][0].scopes).toEqual(["source.python"]); expect(tokens[3][1].value).toBe("."); - expect(tokens[3][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[3][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[3][2].value).toBe(" "); - expect(tokens[3][2].scopes).toEqual(["source.python"]); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[3][3].value).toBe("__add__"); - expect(tokens[3][3].scopes).toEqual(["source.python","meta.function-call.python","support.function.magic.python"]); + expect(tokens[3][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","support.function.magic.python"]); expect(tokens[3][4].value).toBe("("); - expect(tokens[3][4].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[3][5].value).toBe("foo"); - expect(tokens[3][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[3][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); expect(tokens[3][6].value).toBe("="); - expect(tokens[3][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[3][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); expect(tokens[3][7].value).toBe("bar"); - expect(tokens[3][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[3][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[3][8].value).toBe(")"); - expect(tokens[3][8].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[3][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); }); it("test/calls/call9.py", @@ -1024,9 +1210,9 @@ describe("Grammar Tests", function() { expect(tokens[6][3].value).toBe("sys"); expect(tokens[6][3].scopes).toEqual(["source.python"]); expect(tokens[6][4].value).toBe("."); - expect(tokens[6][4].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[6][4].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[6][5].value).toBe("stderr"); - expect(tokens[6][5].scopes).toEqual(["source.python"]); + expect(tokens[6][5].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[6][6].value).toBe(","); expect(tokens[6][6].scopes).toEqual(["source.python","punctuation.separator.element.python"]); expect(tokens[6][7].value).toBe(" "); @@ -1058,9 +1244,9 @@ describe("Grammar Tests", function() { expect(tokens[7][9].value).toBe("sys"); expect(tokens[7][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[7][10].value).toBe("."); - expect(tokens[7][10].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.period.python"]); + expect(tokens[7][10].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[7][11].value).toBe("stderr"); - expect(tokens[7][11].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[7][11].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[7][12].value).toBe(")"); expect(tokens[7][12].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[8][0].value).toBe("print"); @@ -1229,9 +1415,9 @@ describe("Grammar Tests", function() { expect(tokens[2][1].value).toBe("self"); expect(tokens[2][1].scopes).toEqual(["source.python","variable.language.special.self.python"]); expect(tokens[2][2].value).toBe("."); - expect(tokens[2][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[2][3].value).toBe("a"); - expect(tokens[2][3].scopes).toEqual(["source.python"]); + expect(tokens[2][3].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[2][4].value).toBe(" "); expect(tokens[2][4].scopes).toEqual(["source.python"]); expect(tokens[2][5].value).toBe("="); @@ -1245,9 +1431,9 @@ describe("Grammar Tests", function() { expect(tokens[3][1].value).toBe("self"); expect(tokens[3][1].scopes).toEqual(["source.python","variable.language.special.self.python"]); expect(tokens[3][2].value).toBe("."); - expect(tokens[3][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[3][3].value).toBe("b"); - expect(tokens[3][3].scopes).toEqual(["source.python"]); + expect(tokens[3][3].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[3][4].value).toBe(" "); expect(tokens[3][4].scopes).toEqual(["source.python"]); expect(tokens[3][5].value).toBe("="); @@ -1279,9 +1465,9 @@ describe("Grammar Tests", function() { expect(tokens[6][1].value).toBe("a"); expect(tokens[6][1].scopes).toEqual(["source.python"]); expect(tokens[6][2].value).toBe("."); - expect(tokens[6][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[6][2].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[6][3].value).toBe("self"); - expect(tokens[6][3].scopes).toEqual(["source.python"]); + expect(tokens[6][3].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[6][4].value).toBe(" "); expect(tokens[6][4].scopes).toEqual(["source.python"]); expect(tokens[6][5].value).toBe("="); @@ -1295,13 +1481,13 @@ describe("Grammar Tests", function() { expect(tokens[7][1].value).toBe("a"); expect(tokens[7][1].scopes).toEqual(["source.python"]); expect(tokens[7][2].value).toBe("."); - expect(tokens[7][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[7][2].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[7][3].value).toBe("self"); - expect(tokens[7][3].scopes).toEqual(["source.python"]); + expect(tokens[7][3].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[7][4].value).toBe("."); - expect(tokens[7][4].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[7][4].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[7][5].value).toBe("bar"); - expect(tokens[7][5].scopes).toEqual(["source.python"]); + expect(tokens[7][5].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[7][6].value).toBe(" "); expect(tokens[7][6].scopes).toEqual(["source.python"]); expect(tokens[7][7].value).toBe("="); @@ -1336,7 +1522,7 @@ describe("Grammar Tests", function() { expect(tokens[1][0].value).toBe(" "); expect(tokens[1][0].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[1][1].value).toBe("@"); - expect(tokens[1][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[1][2].value).toBe("classmethod"); expect(tokens[1][2].scopes).toEqual(["source.python","meta.function.decorator.python","support.type.python"]); expect(tokens[2][0].value).toBe(" "); @@ -1376,9 +1562,9 @@ describe("Grammar Tests", function() { expect(tokens[3][1].value).toBe("cls"); expect(tokens[3][1].scopes).toEqual(["source.python","variable.language.special.cls.python"]); expect(tokens[3][2].value).toBe("."); - expect(tokens[3][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[3][3].value).toBe("a"); - expect(tokens[3][3].scopes).toEqual(["source.python"]); + expect(tokens[3][3].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[3][4].value).toBe(" "); expect(tokens[3][4].scopes).toEqual(["source.python"]); expect(tokens[3][5].value).toBe("="); @@ -1392,9 +1578,9 @@ describe("Grammar Tests", function() { expect(tokens[4][1].value).toBe("cls"); expect(tokens[4][1].scopes).toEqual(["source.python","variable.language.special.cls.python"]); expect(tokens[4][2].value).toBe("."); - expect(tokens[4][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[4][2].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[4][3].value).toBe("b"); - expect(tokens[4][3].scopes).toEqual(["source.python"]); + expect(tokens[4][3].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[4][4].value).toBe(" "); expect(tokens[4][4].scopes).toEqual(["source.python"]); expect(tokens[4][5].value).toBe("="); @@ -1438,9 +1624,9 @@ describe("Grammar Tests", function() { expect(tokens[8][1].value).toBe("a"); expect(tokens[8][1].scopes).toEqual(["source.python"]); expect(tokens[8][2].value).toBe("."); - expect(tokens[8][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[8][2].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[8][3].value).toBe("cls"); - expect(tokens[8][3].scopes).toEqual(["source.python"]); + expect(tokens[8][3].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[8][4].value).toBe(" "); expect(tokens[8][4].scopes).toEqual(["source.python"]); expect(tokens[8][5].value).toBe("="); @@ -1454,13 +1640,13 @@ describe("Grammar Tests", function() { expect(tokens[9][1].value).toBe("a"); expect(tokens[9][1].scopes).toEqual(["source.python"]); expect(tokens[9][2].value).toBe("."); - expect(tokens[9][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[9][2].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[9][3].value).toBe("cls"); - expect(tokens[9][3].scopes).toEqual(["source.python"]); + expect(tokens[9][3].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[9][4].value).toBe("."); - expect(tokens[9][4].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[9][4].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[9][5].value).toBe("__name__"); - expect(tokens[9][5].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[9][5].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); expect(tokens[10][0].value).toBe(" "); expect(tokens[10][0].scopes).toEqual(["source.python"]); expect(tokens[10][1].value).toBe("cls"); @@ -1520,9 +1706,9 @@ describe("Grammar Tests", function() { expect(tokens[0][4].value).toBe("f"); expect(tokens[0][4].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","entity.other.inherited-class.python"]); expect(tokens[0][5].value).toBe("."); - expect(tokens[0][5].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","punctuation.separator.period.python"]); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][6].value).toBe("Exception"); - expect(tokens[0][6].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","entity.other.inherited-class.python"]); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","meta.member.access.python","entity.other.inherited-class.python"]); expect(tokens[0][7].value).toBe(","); expect(tokens[0][7].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","punctuation.separator.inheritance.python"]); expect(tokens[0][8].value).toBe(" "); @@ -1530,9 +1716,9 @@ describe("Grammar Tests", function() { expect(tokens[0][9].value).toBe("f"); expect(tokens[0][9].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","entity.other.inherited-class.python"]); expect(tokens[0][10].value).toBe("."); - expect(tokens[0][10].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","punctuation.separator.period.python"]); + expect(tokens[0][10].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][11].value).toBe("type"); - expect(tokens[0][11].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","entity.other.inherited-class.python"]); + expect(tokens[0][11].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","meta.member.access.python","entity.other.inherited-class.python"]); expect(tokens[0][12].value).toBe(","); expect(tokens[0][12].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","punctuation.separator.inheritance.python"]); expect(tokens[0][13].value).toBe(" "); @@ -1546,9 +1732,9 @@ describe("Grammar Tests", function() { expect(tokens[0][17].value).toBe("Exception"); expect(tokens[0][17].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","support.type.exception.python"]); expect(tokens[0][18].value).toBe("."); - expect(tokens[0][18].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","punctuation.separator.period.python"]); + expect(tokens[0][18].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][19].value).toBe("a"); - expect(tokens[0][19].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","entity.other.inherited-class.python"]); + expect(tokens[0][19].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","meta.member.access.python","entity.other.inherited-class.python"]); expect(tokens[0][20].value).toBe(","); expect(tokens[0][20].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","punctuation.separator.inheritance.python"]); expect(tokens[0][21].value).toBe(" "); @@ -1655,7 +1841,7 @@ describe("Grammar Tests", function() { function() { tokens = grammar.tokenizeLines("@dec\n# Bar.name=... is not legal, but the test is for highlighter not breaking badly\nclass Spam(Foo.Bar, Bar.name={'very': 'odd'}):\n pass") expect(tokens[0][0].value).toBe("@"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[0][1].value).toBe("dec"); expect(tokens[0][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[1][0].value).toBe("#"); @@ -1673,9 +1859,9 @@ describe("Grammar Tests", function() { expect(tokens[2][4].value).toBe("Foo"); expect(tokens[2][4].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","entity.other.inherited-class.python"]); expect(tokens[2][5].value).toBe("."); - expect(tokens[2][5].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","punctuation.separator.period.python"]); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[2][6].value).toBe("Bar"); - expect(tokens[2][6].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","entity.other.inherited-class.python"]); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","meta.member.access.python","entity.other.inherited-class.python"]); expect(tokens[2][7].value).toBe(","); expect(tokens[2][7].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","punctuation.separator.inheritance.python"]); expect(tokens[2][8].value).toBe(" "); @@ -1683,9 +1869,9 @@ describe("Grammar Tests", function() { expect(tokens[2][9].value).toBe("Bar"); expect(tokens[2][9].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","entity.other.inherited-class.python"]); expect(tokens[2][10].value).toBe("."); - expect(tokens[2][10].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","punctuation.separator.period.python"]); + expect(tokens[2][10].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[2][11].value).toBe("name"); - expect(tokens[2][11].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","entity.other.inherited-class.python"]); + expect(tokens[2][11].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","meta.member.access.python","entity.other.inherited-class.python"]); expect(tokens[2][12].value).toBe("="); expect(tokens[2][12].scopes).toEqual(["source.python","meta.class.python","meta.class.inheritance.python","keyword.operator.assignment.python"]); expect(tokens[2][13].value).toBe("{"); @@ -1900,7 +2086,7 @@ describe("Grammar Tests", function() { it("test/classes/class9.py", function() { - tokens = grammar.tokenizeLines("class Foo:\n __slots__ = ()") + tokens = grammar.tokenizeLines("class Foo:\n __slots__ = ()\n __match_args__ = ('key', 'name')") expect(tokens[0][0].value).toBe("class"); expect(tokens[0][0].scopes).toEqual(["source.python","meta.class.python","storage.type.class.python"]); expect(tokens[0][1].value).toBe(" "); @@ -1923,6 +2109,36 @@ describe("Grammar Tests", function() { expect(tokens[1][5].scopes).toEqual(["source.python","punctuation.parenthesis.begin.python"]); expect(tokens[1][6].value).toBe(")"); expect(tokens[1][6].scopes).toEqual(["source.python","punctuation.parenthesis.end.python"]); + expect(tokens[2][0].value).toBe(" "); + expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[2][1].value).toBe("__match_args__"); + expect(tokens[2][1].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[2][2].value).toBe(" "); + expect(tokens[2][2].scopes).toEqual(["source.python"]); + expect(tokens[2][3].value).toBe("="); + expect(tokens[2][3].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[2][4].value).toBe(" "); + expect(tokens[2][4].scopes).toEqual(["source.python"]); + expect(tokens[2][5].value).toBe("("); + expect(tokens[2][5].scopes).toEqual(["source.python","punctuation.parenthesis.begin.python"]); + expect(tokens[2][6].value).toBe("'"); + expect(tokens[2][6].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[2][7].value).toBe("key"); + expect(tokens[2][7].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[2][8].value).toBe("'"); + expect(tokens[2][8].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[2][9].value).toBe(","); + expect(tokens[2][9].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[2][10].value).toBe(" "); + expect(tokens[2][10].scopes).toEqual(["source.python"]); + expect(tokens[2][11].value).toBe("'"); + expect(tokens[2][11].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[2][12].value).toBe("name"); + expect(tokens[2][12].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[2][13].value).toBe("'"); + expect(tokens[2][13].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[2][14].value).toBe(")"); + expect(tokens[2][14].scopes).toEqual(["source.python","punctuation.parenthesis.end.python"]); }); it("test/classes/super1.py", @@ -1961,19 +2177,19 @@ describe("Grammar Tests", function() { expect(tokens[2][3].value).toBe(")"); expect(tokens[2][3].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[2][4].value).toBe("."); - expect(tokens[2][4].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[2][5].value).toBe("__init__"); - expect(tokens[2][5].scopes).toEqual(["source.python","meta.function-call.python","support.function.magic.python"]); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","support.function.magic.python"]); expect(tokens[2][6].value).toBe("("); - expect(tokens[2][6].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[2][7].value).toBe("foo"); - expect(tokens[2][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[2][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); expect(tokens[2][8].value).toBe("="); - expect(tokens[2][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[2][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); expect(tokens[2][9].value).toBe("1"); - expect(tokens[2][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[2][9].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); expect(tokens[2][10].value).toBe(")"); - expect(tokens[2][10].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[2][10].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[3][0].value).toBe(" "); expect(tokens[3][0].scopes).toEqual(["source.python"]); expect(tokens[3][1].value).toBe("super"); @@ -1983,21 +2199,21 @@ describe("Grammar Tests", function() { expect(tokens[3][3].value).toBe(")"); expect(tokens[3][3].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[3][4].value).toBe("."); - expect(tokens[3][4].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[3][5].value).toBe(" "); - expect(tokens[3][5].scopes).toEqual(["source.python"]); + expect(tokens[3][5].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[3][6].value).toBe("__init__"); - expect(tokens[3][6].scopes).toEqual(["source.python","meta.function-call.python","support.function.magic.python"]); + expect(tokens[3][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","support.function.magic.python"]); expect(tokens[3][7].value).toBe("("); - expect(tokens[3][7].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[3][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[3][8].value).toBe("foo"); - expect(tokens[3][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[3][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); expect(tokens[3][9].value).toBe("="); - expect(tokens[3][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[3][9].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); expect(tokens[3][10].value).toBe("1"); - expect(tokens[3][10].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[3][10].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); expect(tokens[3][11].value).toBe(")"); - expect(tokens[3][11].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[3][11].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[4][0].value).toBe(" "); expect(tokens[4][0].scopes).toEqual(["source.python"]); expect(tokens[4][1].value).toBe("super"); @@ -2007,25 +2223,25 @@ describe("Grammar Tests", function() { expect(tokens[4][3].value).toBe(")"); expect(tokens[4][3].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[4][4].value).toBe("."); - expect(tokens[4][4].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[4][4].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[4][5].value).toBe(" "); - expect(tokens[4][5].scopes).toEqual(["source.python"]); + expect(tokens[4][5].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[4][6].value).toBe("\\"); - expect(tokens[4][6].scopes).toEqual(["source.python","punctuation.separator.continuation.line.python"]); + expect(tokens[4][6].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.continuation.line.python"]); expect(tokens[4][7].value).toBe(""); - expect(tokens[4][7].scopes).toEqual(["source.python"]); + expect(tokens[4][7].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[5][0].value).toBe("__init__"); - expect(tokens[5][0].scopes).toEqual(["source.python","meta.function-call.python","support.function.magic.python"]); + expect(tokens[5][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","support.function.magic.python"]); expect(tokens[5][1].value).toBe("("); - expect(tokens[5][1].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[5][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[5][2].value).toBe("foo"); - expect(tokens[5][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[5][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); expect(tokens[5][3].value).toBe("="); - expect(tokens[5][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[5][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); expect(tokens[5][4].value).toBe("1"); - expect(tokens[5][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[5][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); expect(tokens[5][5].value).toBe(")"); - expect(tokens[5][5].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[5][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[6][0].value).toBe(" "); expect(tokens[6][0].scopes).toEqual(["source.python"]); expect(tokens[6][1].value).toBe("__init__"); @@ -2047,19 +2263,19 @@ describe("Grammar Tests", function() { expect(tokens[8][1].value).toBe("foo"); expect(tokens[8][1].scopes).toEqual(["source.python"]); expect(tokens[8][2].value).toBe("."); - expect(tokens[8][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[8][2].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[8][3].value).toBe("__init__"); - expect(tokens[8][3].scopes).toEqual(["source.python","meta.function-call.python","support.function.magic.python"]); + expect(tokens[8][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","support.function.magic.python"]); expect(tokens[8][4].value).toBe("("); - expect(tokens[8][4].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[8][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[8][5].value).toBe("bar"); - expect(tokens[8][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[8][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); expect(tokens[8][6].value).toBe("="); - expect(tokens[8][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[8][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); expect(tokens[8][7].value).toBe("1"); - expect(tokens[8][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[8][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); expect(tokens[8][8].value).toBe(")"); - expect(tokens[8][8].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[8][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[9][0].value).toBe(" "); expect(tokens[9][0].scopes).toEqual(["source.python"]); expect(tokens[9][1].value).toBe("__init__"); @@ -2856,7 +3072,7 @@ describe("Grammar Tests", function() { it("test/docstrings/continuation2.py", function() { - tokens = grammar.tokenizeLines("'\n'") + tokens = grammar.tokenizeLines("'\n'\n# comment") expect(tokens[0][0].value).toBe("'"); expect(tokens[0][0].scopes).toEqual(["source.python","string.quoted.docstring.single.python","punctuation.definition.string.begin.python"]); expect(tokens[0][1].value).toBe(""); @@ -2865,6 +3081,10 @@ describe("Grammar Tests", function() { expect(tokens[1][0].scopes).toEqual(["source.python","string.quoted.docstring.single.python","punctuation.definition.string.begin.python"]); expect(tokens[1][1].value).toBe(""); expect(tokens[1][1].scopes).toEqual(["source.python","string.quoted.docstring.single.python","invalid.illegal.newline.python"]); + expect(tokens[2][0].value).toBe("#"); + expect(tokens[2][0].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[2][1].value).toBe(" comment"); + expect(tokens[2][1].scopes).toEqual(["source.python","comment.line.number-sign.python"]); }); it("test/docstrings/continuation3.py", @@ -3035,6 +3255,73 @@ describe("Grammar Tests", function() { expect(tokens[12][1].scopes).toEqual(["source.python","string.quoted.docstring.raw.multi.python","punctuation.definition.string.end.python"]); }); + it("test/docstrings/continuation5.py", + function() { + tokens = grammar.tokenizeLines("'implicit ' \"concatenation\"\n\n'''implicit\n''' 'concatenation'\n\n'''implicit\n''' \"\"\"\nconcatenation\n\"\"\"\n\n'implicit' '''\nconcatenation\n'''") + expect(tokens[0][0].value).toBe("'"); + expect(tokens[0][0].scopes).toEqual(["source.python","string.quoted.docstring.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[0][1].value).toBe("implicit "); + expect(tokens[0][1].scopes).toEqual(["source.python","string.quoted.docstring.single.python"]); + expect(tokens[0][2].value).toBe("'"); + expect(tokens[0][2].scopes).toEqual(["source.python","string.quoted.docstring.single.python","punctuation.definition.string.end.python"]); + expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("\""); + expect(tokens[0][4].scopes).toEqual(["source.python","string.quoted.docstring.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[0][5].value).toBe("concatenation"); + expect(tokens[0][5].scopes).toEqual(["source.python","string.quoted.docstring.single.python"]); + expect(tokens[0][6].value).toBe("\""); + expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.docstring.single.python","punctuation.definition.string.end.python"]); + expect(tokens[1][0].value).toBe(""); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[2][0].value).toBe("'''"); + expect(tokens[2][0].scopes).toEqual(["source.python","string.quoted.docstring.multi.python","punctuation.definition.string.begin.python"]); + expect(tokens[2][1].value).toBe("implicit"); + expect(tokens[2][1].scopes).toEqual(["source.python","string.quoted.docstring.multi.python"]); + expect(tokens[3][0].value).toBe("'''"); + expect(tokens[3][0].scopes).toEqual(["source.python","string.quoted.docstring.multi.python","punctuation.definition.string.end.python"]); + expect(tokens[3][1].value).toBe(" "); + expect(tokens[3][1].scopes).toEqual(["source.python"]); + expect(tokens[3][2].value).toBe("'"); + expect(tokens[3][2].scopes).toEqual(["source.python","string.quoted.docstring.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[3][3].value).toBe("concatenation"); + expect(tokens[3][3].scopes).toEqual(["source.python","string.quoted.docstring.single.python"]); + expect(tokens[3][4].value).toBe("'"); + expect(tokens[3][4].scopes).toEqual(["source.python","string.quoted.docstring.single.python","punctuation.definition.string.end.python"]); + expect(tokens[4][0].value).toBe(""); + expect(tokens[4][0].scopes).toEqual(["source.python"]); + expect(tokens[5][0].value).toBe("'''"); + expect(tokens[5][0].scopes).toEqual(["source.python","string.quoted.docstring.multi.python","punctuation.definition.string.begin.python"]); + expect(tokens[5][1].value).toBe("implicit"); + expect(tokens[5][1].scopes).toEqual(["source.python","string.quoted.docstring.multi.python"]); + expect(tokens[6][0].value).toBe("'''"); + expect(tokens[6][0].scopes).toEqual(["source.python","string.quoted.docstring.multi.python","punctuation.definition.string.end.python"]); + expect(tokens[6][1].value).toBe(" "); + expect(tokens[6][1].scopes).toEqual(["source.python"]); + expect(tokens[6][2].value).toBe("\"\"\""); + expect(tokens[6][2].scopes).toEqual(["source.python","string.quoted.docstring.multi.python","punctuation.definition.string.begin.python"]); + expect(tokens[7][0].value).toBe("concatenation"); + expect(tokens[7][0].scopes).toEqual(["source.python","string.quoted.docstring.multi.python"]); + expect(tokens[8][0].value).toBe("\"\"\""); + expect(tokens[8][0].scopes).toEqual(["source.python","string.quoted.docstring.multi.python","punctuation.definition.string.end.python"]); + expect(tokens[9][0].value).toBe(""); + expect(tokens[9][0].scopes).toEqual(["source.python"]); + expect(tokens[10][0].value).toBe("'"); + expect(tokens[10][0].scopes).toEqual(["source.python","string.quoted.docstring.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[10][1].value).toBe("implicit"); + expect(tokens[10][1].scopes).toEqual(["source.python","string.quoted.docstring.single.python"]); + expect(tokens[10][2].value).toBe("'"); + expect(tokens[10][2].scopes).toEqual(["source.python","string.quoted.docstring.single.python","punctuation.definition.string.end.python"]); + expect(tokens[10][3].value).toBe(" "); + expect(tokens[10][3].scopes).toEqual(["source.python"]); + expect(tokens[10][4].value).toBe("'''"); + expect(tokens[10][4].scopes).toEqual(["source.python","string.quoted.docstring.multi.python","punctuation.definition.string.begin.python"]); + expect(tokens[11][0].value).toBe("concatenation"); + expect(tokens[11][0].scopes).toEqual(["source.python","string.quoted.docstring.multi.python"]); + expect(tokens[12][0].value).toBe("'''"); + expect(tokens[12][0].scopes).toEqual(["source.python","string.quoted.docstring.multi.python","punctuation.definition.string.end.python"]); + }); + it("test/docstrings/def1.py", function() { tokens = grammar.tokenizeLines("def foo():\n '''TE\\'''ST'''\n\ndef foo():\n r'''TE\\'''ST'''\n\ndef foo():\n R'''TE\\'''ST'''\n\ndef foo():\n u'''TEST'''\n\ndef foo():\n U'''TEST'''\n\ndef foo():\n b'''TEST'''\n\ndef foo():\n B'''TEST'''") @@ -4868,7 +5155,7 @@ describe("Grammar Tests", function() { expect(tokens[1][0].value).toBe(" "); expect(tokens[1][0].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[1][1].value).toBe("@"); - expect(tokens[1][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[1][2].value).toBe("asd"); expect(tokens[1][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[2][0].value).toBe(" "); @@ -4913,17 +5200,17 @@ describe("Grammar Tests", function() { expect(tokens[0][8].value).toBe("QQQ"); expect(tokens[0][8].scopes).toEqual(["source.python","constant.other.caps.python"]); expect(tokens[0][9].value).toBe("."); - expect(tokens[0][9].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][9].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][10].value).toBe("bar"); - expect(tokens[0][10].scopes).toEqual(["source.python"]); + expect(tokens[0][10].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[0][11].value).toBe(" "); expect(tokens[0][11].scopes).toEqual(["source.python"]); expect(tokens[0][12].value).toBe("baz"); expect(tokens[0][12].scopes).toEqual(["source.python"]); expect(tokens[0][13].value).toBe("."); - expect(tokens[0][13].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][13].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][14].value).toBe("AA_a"); - expect(tokens[0][14].scopes).toEqual(["source.python","constant.other.caps.python"]); + expect(tokens[0][14].scopes).toEqual(["source.python","meta.member.access.python","constant.other.caps.python"]); expect(tokens[0][15].value).toBe(" "); expect(tokens[0][15].scopes).toEqual(["source.python"]); expect(tokens[0][16].value).toBe("_AAA"); @@ -4933,9 +5220,9 @@ describe("Grammar Tests", function() { expect(tokens[0][18].value).toBe("foo"); expect(tokens[0][18].scopes).toEqual(["source.python"]); expect(tokens[0][19].value).toBe("."); - expect(tokens[0][19].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][19].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][20].value).toBe("_AAA"); - expect(tokens[0][20].scopes).toEqual(["source.python","constant.other.caps.python"]); + expect(tokens[0][20].scopes).toEqual(["source.python","meta.member.access.python","constant.other.caps.python"]); expect(tokens[1][0].value).toBe("QQQq"); expect(tokens[1][0].scopes).toEqual(["source.python"]); expect(tokens[1][1].value).toBe(" "); @@ -4947,13 +5234,13 @@ describe("Grammar Tests", function() { expect(tokens[1][4].value).toBe("self"); expect(tokens[1][4].scopes).toEqual(["source.python","variable.language.special.self.python"]); expect(tokens[1][5].value).toBe("."); - expect(tokens[1][5].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[1][6].value).toBe("FOOO"); - expect(tokens[1][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.generic.python"]); expect(tokens[1][7].value).toBe("("); - expect(tokens[1][7].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[1][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[1][8].value).toBe(")"); - expect(tokens[1][8].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[1][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[1][9].value).toBe(" "); expect(tokens[1][9].scopes).toEqual(["source.python"]); expect(tokens[1][10].value).toBe("_"); @@ -5217,9 +5504,9 @@ describe("Grammar Tests", function() { expect(tokens[3][0].value).toBe("..."); expect(tokens[3][0].scopes).toEqual(["source.python","constant.other.ellipsis.python"]); expect(tokens[3][1].value).toBe("."); - expect(tokens[3][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[3][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[3][2].value).toBe("__class__"); - expect(tokens[3][2].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.member.access.python","support.variable.magic.python"]); }); it("test/expressions/expr11.py", @@ -5236,19 +5523,19 @@ describe("Grammar Tests", function() { expect(tokens[0][4].value).toBe("self"); expect(tokens[0][4].scopes).toEqual(["source.python","variable.language.special.self.python"]); expect(tokens[0][5].value).toBe("."); - expect(tokens[0][5].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][6].value).toBe("some_list"); - expect(tokens[0][6].scopes).toEqual(["source.python","meta.item-access.python"]); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.member.access.python","meta.item-access.python","meta.indexed-name.python"]); expect(tokens[0][7].value).toBe("["); - expect(tokens[0][7].scopes).toEqual(["source.python","meta.item-access.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.member.access.python","meta.item-access.python","punctuation.definition.arguments.begin.python"]); expect(tokens[0][8].value).toBe("1"); - expect(tokens[0][8].scopes).toEqual(["source.python","meta.item-access.python","meta.item-access.arguments.python","constant.numeric.dec.python"]); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.member.access.python","meta.item-access.python","meta.item-access.arguments.python","constant.numeric.dec.python"]); expect(tokens[0][9].value).toBe(":"); - expect(tokens[0][9].scopes).toEqual(["source.python","meta.item-access.python","meta.item-access.arguments.python","punctuation.separator.slice.python"]); + expect(tokens[0][9].scopes).toEqual(["source.python","meta.member.access.python","meta.item-access.python","meta.item-access.arguments.python","punctuation.separator.slice.python"]); expect(tokens[0][10].value).toBe("2"); - expect(tokens[0][10].scopes).toEqual(["source.python","meta.item-access.python","meta.item-access.arguments.python","constant.numeric.dec.python"]); + expect(tokens[0][10].scopes).toEqual(["source.python","meta.member.access.python","meta.item-access.python","meta.item-access.arguments.python","constant.numeric.dec.python"]); expect(tokens[0][11].value).toBe("]"); - expect(tokens[0][11].scopes).toEqual(["source.python","meta.item-access.python","punctuation.definition.arguments.end.python"]); + expect(tokens[0][11].scopes).toEqual(["source.python","meta.member.access.python","meta.item-access.python","punctuation.definition.arguments.end.python"]); }); it("test/expressions/expr12.py", @@ -5312,9 +5599,9 @@ describe("Grammar Tests", function() { expect(tokens[0][0].value).toBe("foofrom"); expect(tokens[0][0].scopes).toEqual(["source.python"]); expect(tokens[0][1].value).toBe("."); - expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][2].value).toBe("something"); - expect(tokens[0][2].scopes).toEqual(["source.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); }); it("test/expressions/expr16.py", @@ -5383,15 +5670,15 @@ describe("Grammar Tests", function() { expect(tokens[0][0].value).toBe("a"); expect(tokens[0][0].scopes).toEqual(["source.python"]); expect(tokens[0][1].value).toBe("."); - expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][2].value).toBe("Exception"); - expect(tokens[0][2].scopes).toEqual(["source.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); expect(tokens[1][0].value).toBe("Exception"); expect(tokens[1][0].scopes).toEqual(["source.python","support.type.exception.python"]); expect(tokens[1][1].value).toBe("."); - expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[1][2].value).toBe("a"); - expect(tokens[1][2].scopes).toEqual(["source.python"]); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.member.access.python","meta.attribute.python"]); }); it("test/expressions/expr19.py", @@ -5400,9 +5687,9 @@ describe("Grammar Tests", function() { expect(tokens[0][0].value).toBe("a"); expect(tokens[0][0].scopes).toEqual(["source.python"]); expect(tokens[0][1].value).toBe("."); - expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][2].value).toBe(" "); - expect(tokens[0][2].scopes).toEqual(["source.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[0][3].value).toBe("#"); expect(tokens[0][3].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); expect(tokens[0][4].value).toBe("foo"); @@ -5410,9 +5697,9 @@ describe("Grammar Tests", function() { expect(tokens[1][0].value).toBe("a"); expect(tokens[1][0].scopes).toEqual(["source.python"]); expect(tokens[1][1].value).toBe("."); - expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[1][2].value).toBe(""); - expect(tokens[1][2].scopes).toEqual(["source.python"]); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[2][0].value).toBe("#"); expect(tokens[2][0].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); expect(tokens[2][1].value).toBe("foo"); @@ -5420,13 +5707,13 @@ describe("Grammar Tests", function() { expect(tokens[3][0].value).toBe("a"); expect(tokens[3][0].scopes).toEqual(["source.python"]); expect(tokens[3][1].value).toBe("."); - expect(tokens[3][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[3][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[3][2].value).toBe(" "); - expect(tokens[3][2].scopes).toEqual(["source.python"]); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[3][3].value).toBe("\\"); - expect(tokens[3][3].scopes).toEqual(["source.python","punctuation.separator.continuation.line.python"]); + expect(tokens[3][3].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.continuation.line.python"]); expect(tokens[3][4].value).toBe(""); - expect(tokens[3][4].scopes).toEqual(["source.python"]); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[4][0].value).toBe("#"); expect(tokens[4][0].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); expect(tokens[4][1].value).toBe("foo"); @@ -5434,9 +5721,9 @@ describe("Grammar Tests", function() { expect(tokens[5][0].value).toBe("a"); expect(tokens[5][0].scopes).toEqual(["source.python"]); expect(tokens[5][1].value).toBe("."); - expect(tokens[5][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[5][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[5][2].value).toBe(" "); - expect(tokens[5][2].scopes).toEqual(["source.python"]); + expect(tokens[5][2].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[5][3].value).toBe("'"); expect(tokens[5][3].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); expect(tokens[5][4].value).toBe("bar"); @@ -5446,9 +5733,9 @@ describe("Grammar Tests", function() { expect(tokens[6][0].value).toBe("a"); expect(tokens[6][0].scopes).toEqual(["source.python"]); expect(tokens[6][1].value).toBe("."); - expect(tokens[6][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[6][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[6][2].value).toBe(""); - expect(tokens[6][2].scopes).toEqual(["source.python"]); + expect(tokens[6][2].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[7][0].value).toBe("'"); expect(tokens[7][0].scopes).toEqual(["source.python","string.quoted.docstring.single.python","punctuation.definition.string.begin.python"]); expect(tokens[7][1].value).toBe("bar"); @@ -5458,19 +5745,19 @@ describe("Grammar Tests", function() { expect(tokens[8][0].value).toBe("a"); expect(tokens[8][0].scopes).toEqual(["source.python"]); expect(tokens[8][1].value).toBe("."); - expect(tokens[8][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[8][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[8][2].value).toBe(" "); - expect(tokens[8][2].scopes).toEqual(["source.python"]); + expect(tokens[8][2].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[8][3].value).toBe("\\"); - expect(tokens[8][3].scopes).toEqual(["source.python","punctuation.separator.continuation.line.python"]); + expect(tokens[8][3].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.continuation.line.python"]); expect(tokens[8][4].value).toBe(""); - expect(tokens[8][4].scopes).toEqual(["source.python"]); + expect(tokens[8][4].scopes).toEqual(["source.python","meta.member.access.python"]); expect(tokens[9][0].value).toBe("'"); - expect(tokens[9][0].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[9][0].scopes).toEqual(["source.python","meta.member.access.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); expect(tokens[9][1].value).toBe("bar"); - expect(tokens[9][1].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[9][1].scopes).toEqual(["source.python","meta.member.access.python","string.quoted.single.python"]); expect(tokens[9][2].value).toBe("'"); - expect(tokens[9][2].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[9][2].scopes).toEqual(["source.python","meta.member.access.python","string.quoted.single.python","punctuation.definition.string.end.python"]); }); it("test/expressions/expr2.py", @@ -5573,26 +5860,154 @@ describe("Grammar Tests", function() { expect(tokens[5][4].scopes).toEqual(["source.python"]); }); - it("test/expressions/expr3.py", + it("test/expressions/expr21.py", function() { - tokens = grammar.tokenizeLines("(a, *rest, b) = range(5)") - expect(tokens[0][0].value).toBe("("); - expect(tokens[0][0].scopes).toEqual(["source.python","punctuation.parenthesis.begin.python"]); - expect(tokens[0][1].value).toBe("a"); + tokens = grammar.tokenizeLines("while chunk := file.read(8192):\n process(chunk)\n y0 = (y1 := f(x))") + expect(tokens[0][0].value).toBe("while"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[0][1].value).toBe(" "); expect(tokens[0][1].scopes).toEqual(["source.python"]); - expect(tokens[0][2].value).toBe(","); - expect(tokens[0][2].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[0][2].value).toBe("chunk"); + expect(tokens[0][2].scopes).toEqual(["source.python"]); expect(tokens[0][3].value).toBe(" "); expect(tokens[0][3].scopes).toEqual(["source.python"]); - expect(tokens[0][4].value).toBe("*"); - expect(tokens[0][4].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]); - expect(tokens[0][5].value).toBe("rest"); + expect(tokens[0][4].value).toBe(":="); + expect(tokens[0][4].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[0][5].value).toBe(" "); expect(tokens[0][5].scopes).toEqual(["source.python"]); - expect(tokens[0][6].value).toBe(","); - expect(tokens[0][6].scopes).toEqual(["source.python","punctuation.separator.element.python"]); - expect(tokens[0][7].value).toBe(" "); - expect(tokens[0][7].scopes).toEqual(["source.python"]); - expect(tokens[0][8].value).toBe("b"); + expect(tokens[0][6].value).toBe("file"); + expect(tokens[0][6].scopes).toEqual(["source.python","variable.legacy.builtin.python"]); + expect(tokens[0][7].value).toBe("."); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); + expect(tokens[0][8].value).toBe("read"); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[0][9].value).toBe("("); + expect(tokens[0][9].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[0][10].value).toBe("8192"); + expect(tokens[0][10].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[0][11].value).toBe(")"); + expect(tokens[0][11].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[0][12].value).toBe(":"); + expect(tokens[0][12].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[1][0].value).toBe(" "); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe("process"); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[1][2].value).toBe("("); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[1][3].value).toBe("chunk"); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[1][4].value).toBe(")"); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[2][0].value).toBe(" "); + expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[2][1].value).toBe("y0"); + expect(tokens[2][1].scopes).toEqual(["source.python"]); + expect(tokens[2][2].value).toBe(" "); + expect(tokens[2][2].scopes).toEqual(["source.python"]); + expect(tokens[2][3].value).toBe("="); + expect(tokens[2][3].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[2][4].value).toBe(" "); + expect(tokens[2][4].scopes).toEqual(["source.python"]); + expect(tokens[2][5].value).toBe("("); + expect(tokens[2][5].scopes).toEqual(["source.python","punctuation.parenthesis.begin.python"]); + expect(tokens[2][6].value).toBe("y1"); + expect(tokens[2][6].scopes).toEqual(["source.python"]); + expect(tokens[2][7].value).toBe(" "); + expect(tokens[2][7].scopes).toEqual(["source.python"]); + expect(tokens[2][8].value).toBe(":="); + expect(tokens[2][8].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[2][9].value).toBe(" "); + expect(tokens[2][9].scopes).toEqual(["source.python"]); + expect(tokens[2][10].value).toBe("f"); + expect(tokens[2][10].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[2][11].value).toBe("("); + expect(tokens[2][11].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[2][12].value).toBe("x"); + expect(tokens[2][12].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[2][13].value).toBe(")"); + expect(tokens[2][13].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[2][14].value).toBe(")"); + expect(tokens[2][14].scopes).toEqual(["source.python","punctuation.parenthesis.end.python"]); + }); + + it("test/expressions/expr22.py", + function() { + tokens = grammar.tokenizeLines("match = 13\ncase = 12\nif case == 4:\n return match * 5") + expect(tokens[0][0].value).toBe("match"); + expect(tokens[0][0].scopes).toEqual(["source.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("="); + expect(tokens[0][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("13"); + expect(tokens[0][4].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[1][0].value).toBe("case"); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe(" "); + expect(tokens[1][1].scopes).toEqual(["source.python"]); + expect(tokens[1][2].value).toBe("="); + expect(tokens[1][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[1][3].value).toBe(" "); + expect(tokens[1][3].scopes).toEqual(["source.python"]); + expect(tokens[1][4].value).toBe("12"); + expect(tokens[1][4].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[2][0].value).toBe("if"); + expect(tokens[2][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[2][1].value).toBe(" "); + expect(tokens[2][1].scopes).toEqual(["source.python"]); + expect(tokens[2][2].value).toBe("case"); + expect(tokens[2][2].scopes).toEqual(["source.python"]); + expect(tokens[2][3].value).toBe(" "); + expect(tokens[2][3].scopes).toEqual(["source.python"]); + expect(tokens[2][4].value).toBe("=="); + expect(tokens[2][4].scopes).toEqual(["source.python","keyword.operator.comparison.python"]); + expect(tokens[2][5].value).toBe(" "); + expect(tokens[2][5].scopes).toEqual(["source.python"]); + expect(tokens[2][6].value).toBe("4"); + expect(tokens[2][6].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[2][7].value).toBe(":"); + expect(tokens[2][7].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[3][0].value).toBe(" "); + expect(tokens[3][0].scopes).toEqual(["source.python"]); + expect(tokens[3][1].value).toBe("return"); + expect(tokens[3][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[3][2].value).toBe(" "); + expect(tokens[3][2].scopes).toEqual(["source.python"]); + expect(tokens[3][3].value).toBe("match"); + expect(tokens[3][3].scopes).toEqual(["source.python"]); + expect(tokens[3][4].value).toBe(" "); + expect(tokens[3][4].scopes).toEqual(["source.python"]); + expect(tokens[3][5].value).toBe("*"); + expect(tokens[3][5].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]); + expect(tokens[3][6].value).toBe(" "); + expect(tokens[3][6].scopes).toEqual(["source.python"]); + expect(tokens[3][7].value).toBe("5"); + expect(tokens[3][7].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + }); + + it("test/expressions/expr3.py", + function() { + tokens = grammar.tokenizeLines("(a, *rest, b) = range(5)") + expect(tokens[0][0].value).toBe("("); + expect(tokens[0][0].scopes).toEqual(["source.python","punctuation.parenthesis.begin.python"]); + expect(tokens[0][1].value).toBe("a"); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe(","); + expect(tokens[0][2].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("*"); + expect(tokens[0][4].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]); + expect(tokens[0][5].value).toBe("rest"); + expect(tokens[0][5].scopes).toEqual(["source.python"]); + expect(tokens[0][6].value).toBe(","); + expect(tokens[0][6].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[0][7].value).toBe(" "); + expect(tokens[0][7].scopes).toEqual(["source.python"]); + expect(tokens[0][8].value).toBe("b"); expect(tokens[0][8].scopes).toEqual(["source.python"]); expect(tokens[0][9].value).toBe(")"); expect(tokens[0][9].scopes).toEqual(["source.python","punctuation.parenthesis.end.python"]); @@ -5638,7 +6053,7 @@ describe("Grammar Tests", function() { expect(tokens[0][10].value).toBe(" "); expect(tokens[0][10].scopes).toEqual(["source.python"]); expect(tokens[0][11].value).toBe("in"); - expect(tokens[0][11].scopes).toEqual(["source.python","keyword.operator.logical.python"]); + expect(tokens[0][11].scopes).toEqual(["source.python","keyword.control.flow.python"]); expect(tokens[0][12].value).toBe(" "); expect(tokens[0][12].scopes).toEqual(["source.python"]); expect(tokens[0][13].value).toBe("range"); @@ -5731,7 +6146,7 @@ describe("Grammar Tests", function() { expect(tokens[2][8].value).toBe("{"); expect(tokens[2][8].scopes).toEqual(["source.python","punctuation.definition.dict.begin.python"]); expect(tokens[2][9].value).toBe("import"); - expect(tokens[2][9].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[2][9].scopes).toEqual(["source.python","keyword.control.import.python"]); expect(tokens[2][10].value).toBe(":"); expect(tokens[2][10].scopes).toEqual(["source.python","punctuation.separator.dict.python"]); expect(tokens[2][11].value).toBe(" "); @@ -5843,9 +6258,9 @@ describe("Grammar Tests", function() { expect(tokens[0][0].value).toBe("a"); expect(tokens[0][0].scopes).toEqual(["source.python"]); expect(tokens[0][1].value).toBe("."); - expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][2].value).toBe("True"); - expect(tokens[0][2].scopes).toEqual(["source.python","keyword.illegal.name.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.member.access.python","keyword.illegal.name.python"]); expect(tokens[0][3].value).toBe(" "); expect(tokens[0][3].scopes).toEqual(["source.python"]); expect(tokens[0][4].value).toBe("="); @@ -5855,9 +6270,9 @@ describe("Grammar Tests", function() { expect(tokens[0][6].value).toBe("b"); expect(tokens[0][6].scopes).toEqual(["source.python"]); expect(tokens[0][7].value).toBe("."); - expect(tokens[0][7].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][8].value).toBe("False"); - expect(tokens[0][8].scopes).toEqual(["source.python","keyword.illegal.name.python"]); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.member.access.python","keyword.illegal.name.python"]); expect(tokens[0][9].value).toBe(" "); expect(tokens[0][9].scopes).toEqual(["source.python"]); expect(tokens[0][10].value).toBe("="); @@ -5867,9 +6282,9 @@ describe("Grammar Tests", function() { expect(tokens[0][12].value).toBe("d"); expect(tokens[0][12].scopes).toEqual(["source.python"]); expect(tokens[0][13].value).toBe("."); - expect(tokens[0][13].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][13].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][14].value).toBe("None"); - expect(tokens[0][14].scopes).toEqual(["source.python","keyword.illegal.name.python"]); + expect(tokens[0][14].scopes).toEqual(["source.python","meta.member.access.python","keyword.illegal.name.python"]); }); it("test/expressions/expr8.py", @@ -5920,9 +6335,9 @@ describe("Grammar Tests", function() { it("test/expressions/keywords.py", function() { - tokens = grammar.tokenizeLines("as async await continue del assert break finally for\nfrom elif else if import except pass raise\nreturn try while with\n\nnonlocal global class def") + tokens = grammar.tokenizeLines("as async await continue del assert break finally\nfrom elif else if import except pass raise\nreturn try while with\n\nnonlocal global class def\n\nfor") expect(tokens[0][0].value).toBe("as"); - expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]); expect(tokens[0][1].value).toBe(" "); expect(tokens[0][1].scopes).toEqual(["source.python"]); expect(tokens[0][2].value).toBe("async"); @@ -5951,12 +6366,8 @@ describe("Grammar Tests", function() { expect(tokens[0][13].scopes).toEqual(["source.python"]); expect(tokens[0][14].value).toBe("finally"); expect(tokens[0][14].scopes).toEqual(["source.python","keyword.control.flow.python"]); - expect(tokens[0][15].value).toBe(" "); - expect(tokens[0][15].scopes).toEqual(["source.python"]); - expect(tokens[0][16].value).toBe("for"); - expect(tokens[0][16].scopes).toEqual(["source.python","keyword.control.flow.python"]); expect(tokens[1][0].value).toBe("from"); - expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.import.python"]); expect(tokens[1][1].value).toBe(" "); expect(tokens[1][1].scopes).toEqual(["source.python"]); expect(tokens[1][2].value).toBe("elif"); @@ -6013,6 +6424,10 @@ describe("Grammar Tests", function() { expect(tokens[4][4].scopes).toEqual(["source.python","storage.type.class.python"]); expect(tokens[4][5].value).toBe(" def"); expect(tokens[4][5].scopes).toEqual(["source.python","storage.type.function.python"]); + expect(tokens[5][0].value).toBe(""); + expect(tokens[5][0].scopes).toEqual(["source.python"]); + expect(tokens[6][0].value).toBe("for"); + expect(tokens[6][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); }); it("test/expressions/special1.py", @@ -6032,6 +6447,31 @@ describe("Grammar Tests", function() { expect(tokens[1][0].scopes).toEqual(["source.python"]); }); + it("test/expressions/special2.py", + function() { + tokens = grammar.tokenizeLines("__post_init__\ndef __class_getitem__(): pass\n__mro_entries__") + expect(tokens[0][0].value).toBe("__post_init__"); + expect(tokens[0][0].scopes).toEqual(["source.python","support.variable.magic.python"]); + expect(tokens[1][0].value).toBe("def"); + expect(tokens[1][0].scopes).toEqual(["source.python","meta.function.python","storage.type.function.python"]); + expect(tokens[1][1].value).toBe(" "); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.function.python"]); + expect(tokens[1][2].value).toBe("__class_getitem__"); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.function.python","support.function.magic.python"]); + expect(tokens[1][3].value).toBe("("); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.definition.parameters.begin.python"]); + expect(tokens[1][4].value).toBe(")"); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.definition.parameters.end.python"]); + expect(tokens[1][5].value).toBe(":"); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.function.python","punctuation.section.function.begin.python"]); + expect(tokens[1][6].value).toBe(" "); + expect(tokens[1][6].scopes).toEqual(["source.python"]); + expect(tokens[1][7].value).toBe("pass"); + expect(tokens[1][7].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[2][0].value).toBe("__mro_entries__"); + expect(tokens[2][0].scopes).toEqual(["source.python","support.variable.magic.python"]); + }); + it("test/fstrings/comment1.py", function() { tokens = grammar.tokenizeLines("f'prefix{10 # comment, making the string technically illegal\ndef foo(): pass") @@ -6173,71 +6613,71 @@ describe("Grammar Tests", function() { expect(tokens[0][0].value).toBe("self"); expect(tokens[0][0].scopes).toEqual(["source.python","variable.language.special.self.python"]); expect(tokens[0][1].value).toBe("."); - expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][2].value).toBe("assertEqual"); - expect(tokens[0][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.generic.python"]); expect(tokens[0][3].value).toBe("("); - expect(tokens[0][3].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[0][4].value).toBe("f"); - expect(tokens[0][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); expect(tokens[0][5].value).toBe("'"); - expect(tokens[0][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); expect(tokens[0][6].value).toBe("{"); - expect(tokens[0][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][7].value).toBe("10"); - expect(tokens[0][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.numeric.dec.python"]); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.numeric.dec.python"]); expect(tokens[0][8].value).toBe(":"); - expect(tokens[0][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.format.python"]); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.format.python"]); expect(tokens[0][9].value).toBe("#"); - expect(tokens[0][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.format.python"]); + expect(tokens[0][9].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.format.python"]); expect(tokens[0][10].value).toBe("{"); - expect(tokens[0][10].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][10].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][11].value).toBe("3"); - expect(tokens[0][11].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.numeric.dec.python"]); + expect(tokens[0][11].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.numeric.dec.python"]); expect(tokens[0][12].value).toBe(" "); - expect(tokens[0][12].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); + expect(tokens[0][12].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); expect(tokens[0][13].value).toBe("!="); - expect(tokens[0][13].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","keyword.operator.comparison.python"]); + expect(tokens[0][13].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","keyword.operator.comparison.python"]); expect(tokens[0][14].value).toBe(" "); - expect(tokens[0][14].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); + expect(tokens[0][14].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); expect(tokens[0][15].value).toBe("{"); - expect(tokens[0][15].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","punctuation.definition.dict.begin.python"]); + expect(tokens[0][15].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","punctuation.definition.dict.begin.python"]); expect(tokens[0][16].value).toBe("4"); - expect(tokens[0][16].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.numeric.dec.python"]); + expect(tokens[0][16].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.numeric.dec.python"]); expect(tokens[0][17].value).toBe(":"); - expect(tokens[0][17].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","punctuation.separator.dict.python"]); + expect(tokens[0][17].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","punctuation.separator.dict.python"]); expect(tokens[0][18].value).toBe("5"); - expect(tokens[0][18].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.numeric.dec.python"]); + expect(tokens[0][18].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.numeric.dec.python"]); expect(tokens[0][19].value).toBe("}"); - expect(tokens[0][19].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","punctuation.definition.dict.end.python"]); + expect(tokens[0][19].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","punctuation.definition.dict.end.python"]); expect(tokens[0][20].value).toBe(" "); - expect(tokens[0][20].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); + expect(tokens[0][20].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); expect(tokens[0][21].value).toBe("and"); - expect(tokens[0][21].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","keyword.operator.logical.python"]); + expect(tokens[0][21].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","keyword.operator.logical.python"]); expect(tokens[0][22].value).toBe(" "); - expect(tokens[0][22].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); + expect(tokens[0][22].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); expect(tokens[0][23].value).toBe("width"); - expect(tokens[0][23].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); + expect(tokens[0][23].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); expect(tokens[0][24].value).toBe("}"); - expect(tokens[0][24].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][24].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][25].value).toBe("x"); - expect(tokens[0][25].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.format.python"]); + expect(tokens[0][25].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.format.python"]); expect(tokens[0][26].value).toBe("}"); - expect(tokens[0][26].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][26].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][27].value).toBe("'"); - expect(tokens[0][27].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[0][27].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); expect(tokens[0][28].value).toBe(","); - expect(tokens[0][28].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[0][28].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); expect(tokens[0][29].value).toBe(" "); - expect(tokens[0][29].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[0][29].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); expect(tokens[0][30].value).toBe("'"); - expect(tokens[0][30].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[0][30].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); expect(tokens[0][31].value).toBe(" 0xa"); - expect(tokens[0][31].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python"]); + expect(tokens[0][31].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python"]); expect(tokens[0][32].value).toBe("'"); - expect(tokens[0][32].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[0][32].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.end.python"]); expect(tokens[0][33].value).toBe(")"); - expect(tokens[0][33].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[0][33].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); }); it("test/fstrings/empty1.py", @@ -6287,346 +6727,48 @@ describe("Grammar Tests", function() { function() { tokens = grammar.tokenizeLines("rf\"{} { }\"\nrf\"\"\"{}\n{ }\n\"\"\"") expect(tokens[0][0].value).toBe("rf"); - expect(tokens[0][0].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","storage.type.string.python"]); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); expect(tokens[0][1].value).toBe("\""); - expect(tokens[0][1].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","punctuation.definition.string.begin.python"]); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); expect(tokens[0][2].value).toBe("{"); - expect(tokens[0][2].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][3].value).toBe("}"); - expect(tokens[0][3].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][4].value).toBe(" "); - expect(tokens[0][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python"]); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); expect(tokens[0][5].value).toBe("{"); - expect(tokens[0][5].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][6].value).toBe(" "); - expect(tokens[0][6].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","invalid.illegal.brace.python"]); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.brace.python"]); expect(tokens[0][7].value).toBe("}"); - expect(tokens[0][7].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][8].value).toBe("\""); - expect(tokens[0][8].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","punctuation.definition.string.end.python"]); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); expect(tokens[1][0].value).toBe("rf"); - expect(tokens[1][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python string.interpolated.python","storage.type.string.python"]); + expect(tokens[1][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.multi.python string.interpolated.python"]); expect(tokens[1][1].value).toBe("\"\"\""); - expect(tokens[1][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python string.interpolated.python","punctuation.definition.string.begin.python"]); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python punctuation.definition.string.begin.python"]); expect(tokens[1][2].value).toBe("{"); - expect(tokens[1][2].scopes).toEqual(["source.python","string.regexp.quoted.multi.python string.interpolated.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); expect(tokens[1][3].value).toBe("}"); - expect(tokens[1][3].scopes).toEqual(["source.python","string.regexp.quoted.multi.python string.interpolated.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][4].value).toBe(""); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python string.interpolated.python"]); expect(tokens[2][0].value).toBe("{"); - expect(tokens[2][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python string.interpolated.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][0].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); expect(tokens[2][1].value).toBe(" "); - expect(tokens[2][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python string.interpolated.python","invalid.illegal.brace.python"]); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.brace.python"]); expect(tokens[2][2].value).toBe("}"); - expect(tokens[2][2].scopes).toEqual(["source.python","string.regexp.quoted.multi.python string.interpolated.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][3].value).toBe(""); + expect(tokens[2][3].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python string.interpolated.python"]); expect(tokens[3][0].value).toBe("\"\"\""); - expect(tokens[3][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python string.interpolated.python","punctuation.definition.string.end.python"]); - }); - - it("test/fstrings/nested1.py", - function() { - tokens = grammar.tokenizeLines("f'''\n prefix {\n foo(f\"\"\"\n inner prefix\n { bar[\"q\"] + f'insane{42 + 9000}stuff{def aaa(): pass}111'}\n inner suffix\n \"\"\")\n } suffix\n'''") - expect(tokens[0][0].value).toBe("f"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.multi.python string.interpolated.python"]); - expect(tokens[0][1].value).toBe("'''"); - expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[0][2].value).toBe(""); - expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); - expect(tokens[1][0].value).toBe(" prefix "); - expect(tokens[1][0].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); - expect(tokens[1][1].value).toBe("{"); - expect(tokens[1][1].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[2][0].value).toBe(" "); - expect(tokens[2][0].scopes).toEqual(["source.python","meta.fstring.python"]); - expect(tokens[2][1].value).toBe("foo"); - expect(tokens[2][1].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.generic.python"]); - expect(tokens[2][2].value).toBe("("); - expect(tokens[2][2].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); - expect(tokens[2][3].value).toBe("f"); - expect(tokens[2][3].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.string.python string.quoted.multi.python string.interpolated.python"]); - expect(tokens[2][4].value).toBe("\"\"\""); - expect(tokens[2][4].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[2][5].value).toBe(""); - expect(tokens[2][5].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); - expect(tokens[3][0].value).toBe(" inner prefix"); - expect(tokens[3][0].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); - expect(tokens[4][0].value).toBe(" "); - expect(tokens[4][0].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); - expect(tokens[4][1].value).toBe("{"); - expect(tokens[4][1].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[4][2].value).toBe(" "); - expect(tokens[4][2].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); - expect(tokens[4][3].value).toBe("bar"); - expect(tokens[4][3].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.item-access.python"]); - expect(tokens[4][4].value).toBe("["); - expect(tokens[4][4].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.item-access.python","punctuation.definition.arguments.begin.python"]); - expect(tokens[4][5].value).toBe("\""); - expect(tokens[4][5].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.item-access.python","meta.item-access.arguments.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); - expect(tokens[4][6].value).toBe("q"); - expect(tokens[4][6].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.item-access.python","meta.item-access.arguments.python","string.quoted.single.python"]); - expect(tokens[4][7].value).toBe("\""); - expect(tokens[4][7].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.item-access.python","meta.item-access.arguments.python","string.quoted.single.python","punctuation.definition.string.end.python"]); - expect(tokens[4][8].value).toBe("]"); - expect(tokens[4][8].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.item-access.python","punctuation.definition.arguments.end.python"]); - expect(tokens[4][9].value).toBe(" "); - expect(tokens[4][9].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); - expect(tokens[4][10].value).toBe("+"); - expect(tokens[4][10].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","keyword.operator.arithmetic.python"]); - expect(tokens[4][11].value).toBe(" "); - expect(tokens[4][11].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); - expect(tokens[4][12].value).toBe("f"); - expect(tokens[4][12].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); - expect(tokens[4][13].value).toBe("'"); - expect(tokens[4][13].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[4][14].value).toBe("insane"); - expect(tokens[4][14].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); - expect(tokens[4][15].value).toBe("{"); - expect(tokens[4][15].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[4][16].value).toBe("42"); - expect(tokens[4][16].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","constant.numeric.dec.python"]); - expect(tokens[4][17].value).toBe(" "); - expect(tokens[4][17].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python"]); - expect(tokens[4][18].value).toBe("+"); - expect(tokens[4][18].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","keyword.operator.arithmetic.python"]); - expect(tokens[4][19].value).toBe(" "); - expect(tokens[4][19].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python"]); - expect(tokens[4][20].value).toBe("9000"); - expect(tokens[4][20].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","constant.numeric.dec.python"]); - expect(tokens[4][21].value).toBe("}"); - expect(tokens[4][21].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[4][22].value).toBe("stuff"); - expect(tokens[4][22].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); - expect(tokens[4][23].value).toBe("{"); - expect(tokens[4][23].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[4][24].value).toBe("def"); - expect(tokens[4][24].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","keyword.control.flow.python"]); - expect(tokens[4][25].value).toBe(" "); - expect(tokens[4][25].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python"]); - expect(tokens[4][26].value).toBe("aaa"); - expect(tokens[4][26].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","meta.function-call.python","meta.function-call.generic.python"]); - expect(tokens[4][27].value).toBe("("); - expect(tokens[4][27].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); - expect(tokens[4][28].value).toBe(")"); - expect(tokens[4][28].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); - expect(tokens[4][29].value).toBe(":"); - expect(tokens[4][29].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","punctuation.separator.colon.python"]); - expect(tokens[4][30].value).toBe(" "); - expect(tokens[4][30].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python"]); - expect(tokens[4][31].value).toBe("pass"); - expect(tokens[4][31].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","keyword.control.flow.python"]); - expect(tokens[4][32].value).toBe("}"); - expect(tokens[4][32].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[4][33].value).toBe("111"); - expect(tokens[4][33].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); - expect(tokens[4][34].value).toBe("'"); - expect(tokens[4][34].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); - expect(tokens[4][35].value).toBe("}"); - expect(tokens[4][35].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[4][36].value).toBe(""); - expect(tokens[4][36].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); - expect(tokens[5][0].value).toBe(" inner suffix"); - expect(tokens[5][0].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); - expect(tokens[6][0].value).toBe(" "); - expect(tokens[6][0].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); - expect(tokens[6][1].value).toBe("\"\"\""); - expect(tokens[6][1].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.end.python"]); - expect(tokens[6][2].value).toBe(")"); - expect(tokens[6][2].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); - expect(tokens[7][0].value).toBe(" "); - expect(tokens[7][0].scopes).toEqual(["source.python","meta.fstring.python"]); - expect(tokens[7][1].value).toBe("}"); - expect(tokens[7][1].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[7][2].value).toBe(" suffix"); - expect(tokens[7][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); - expect(tokens[8][0].value).toBe("'''"); - expect(tokens[8][0].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[3][0].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python string.interpolated.python punctuation.definition.string.end.python"]); }); - it("test/fstrings/nested2.py", + it("test/fstrings/fraw1.py", function() { - tokens = grammar.tokenizeLines("f\"result: {value:{60}.{16!s:2}{'qwerty'[2]}}\"") - expect(tokens[0][0].value).toBe("f"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); - expect(tokens[0][1].value).toBe("\""); - expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[0][2].value).toBe("result: "); - expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); - expect(tokens[0][3].value).toBe("{"); - expect(tokens[0][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][4].value).toBe("value"); - expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python"]); - expect(tokens[0][5].value).toBe(":"); - expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); - expect(tokens[0][6].value).toBe("{"); - expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][7].value).toBe("60"); - expect(tokens[0][7].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); - expect(tokens[0][8].value).toBe("}"); - expect(tokens[0][8].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][9].value).toBe("."); - expect(tokens[0][9].scopes).toEqual(["source.python","meta.fstring.python"]); - expect(tokens[0][10].value).toBe("{"); - expect(tokens[0][10].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][11].value).toBe("16"); - expect(tokens[0][11].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); - expect(tokens[0][12].value).toBe("!s"); - expect(tokens[0][12].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); - expect(tokens[0][13].value).toBe(":2"); - expect(tokens[0][13].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); - expect(tokens[0][14].value).toBe("}"); - expect(tokens[0][14].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][15].value).toBe("{"); - expect(tokens[0][15].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][16].value).toBe("'"); - expect(tokens[0][16].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); - expect(tokens[0][17].value).toBe("qwerty"); - expect(tokens[0][17].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python"]); - expect(tokens[0][18].value).toBe("'"); - expect(tokens[0][18].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python","punctuation.definition.string.end.python"]); - expect(tokens[0][19].value).toBe("["); - expect(tokens[0][19].scopes).toEqual(["source.python","meta.fstring.python","punctuation.definition.list.begin.python"]); - expect(tokens[0][20].value).toBe("2"); - expect(tokens[0][20].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); - expect(tokens[0][21].value).toBe("]"); - expect(tokens[0][21].scopes).toEqual(["source.python","meta.fstring.python","punctuation.definition.list.end.python"]); - expect(tokens[0][22].value).toBe("}"); - expect(tokens[0][22].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][23].value).toBe("}"); - expect(tokens[0][23].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][24].value).toBe("\""); - expect(tokens[0][24].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); - }); - - it("test/fstrings/nested3.py", - function() { - tokens = grammar.tokenizeLines("f\"result: {value:{60}.{16!s:2}{'qwerty'\n[2]}}\"") - expect(tokens[0][0].value).toBe("f"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); - expect(tokens[0][1].value).toBe("\""); - expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[0][2].value).toBe("result: "); - expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); - expect(tokens[0][3].value).toBe("{"); - expect(tokens[0][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][4].value).toBe("value"); - expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python"]); - expect(tokens[0][5].value).toBe(":"); - expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); - expect(tokens[0][6].value).toBe("{"); - expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][7].value).toBe("60"); - expect(tokens[0][7].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); - expect(tokens[0][8].value).toBe("}"); - expect(tokens[0][8].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][9].value).toBe("."); - expect(tokens[0][9].scopes).toEqual(["source.python","meta.fstring.python"]); - expect(tokens[0][10].value).toBe("{"); - expect(tokens[0][10].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][11].value).toBe("16"); - expect(tokens[0][11].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); - expect(tokens[0][12].value).toBe("!s"); - expect(tokens[0][12].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); - expect(tokens[0][13].value).toBe(":2"); - expect(tokens[0][13].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); - expect(tokens[0][14].value).toBe("}"); - expect(tokens[0][14].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][15].value).toBe("{"); - expect(tokens[0][15].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][16].value).toBe("'"); - expect(tokens[0][16].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); - expect(tokens[0][17].value).toBe("qwerty"); - expect(tokens[0][17].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python"]); - expect(tokens[0][18].value).toBe("'"); - expect(tokens[0][18].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python","punctuation.definition.string.end.python"]); - expect(tokens[0][19].value).toBe(""); - expect(tokens[0][19].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.newline.python"]); - expect(tokens[1][0].value).toBe("["); - expect(tokens[1][0].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); - expect(tokens[1][1].value).toBe("2"); - expect(tokens[1][1].scopes).toEqual(["source.python","constant.numeric.dec.python"]); - expect(tokens[1][2].value).toBe("]"); - expect(tokens[1][2].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); - expect(tokens[1][3].value).toBe("}}"); - expect(tokens[1][3].scopes).toEqual(["source.python"]); - expect(tokens[1][4].value).toBe("\""); - expect(tokens[1][4].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); - expect(tokens[1][5].value).toBe(""); - expect(tokens[1][5].scopes).toEqual(["source.python","string.quoted.single.python","invalid.illegal.newline.python"]); - }); - - it("test/fstrings/nested4.py", - function() { - tokens = grammar.tokenizeLines("f\"\"\"result: {value:{60}.{16!s:2}{'qwerty'\n[2]}}\"\"\"\ndef foo(): pass") - expect(tokens[0][0].value).toBe("f"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.multi.python string.interpolated.python"]); - expect(tokens[0][1].value).toBe("\"\"\""); - expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[0][2].value).toBe("result: "); - expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); - expect(tokens[0][3].value).toBe("{"); - expect(tokens[0][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][4].value).toBe("value"); - expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python"]); - expect(tokens[0][5].value).toBe(":"); - expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); - expect(tokens[0][6].value).toBe("{"); - expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][7].value).toBe("60"); - expect(tokens[0][7].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); - expect(tokens[0][8].value).toBe("}"); - expect(tokens[0][8].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][9].value).toBe("."); - expect(tokens[0][9].scopes).toEqual(["source.python","meta.fstring.python"]); - expect(tokens[0][10].value).toBe("{"); - expect(tokens[0][10].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][11].value).toBe("16"); - expect(tokens[0][11].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); - expect(tokens[0][12].value).toBe("!s"); - expect(tokens[0][12].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); - expect(tokens[0][13].value).toBe(":2"); - expect(tokens[0][13].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); - expect(tokens[0][14].value).toBe("}"); - expect(tokens[0][14].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][15].value).toBe("{"); - expect(tokens[0][15].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][16].value).toBe("'"); - expect(tokens[0][16].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); - expect(tokens[0][17].value).toBe("qwerty"); - expect(tokens[0][17].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python"]); - expect(tokens[0][18].value).toBe("'"); - expect(tokens[0][18].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python","punctuation.definition.string.end.python"]); - expect(tokens[1][0].value).toBe("["); - expect(tokens[1][0].scopes).toEqual(["source.python","meta.fstring.python","punctuation.definition.list.begin.python"]); - expect(tokens[1][1].value).toBe("2"); - expect(tokens[1][1].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); - expect(tokens[1][2].value).toBe("]"); - expect(tokens[1][2].scopes).toEqual(["source.python","meta.fstring.python","punctuation.definition.list.end.python"]); - expect(tokens[1][3].value).toBe("}"); - expect(tokens[1][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[1][4].value).toBe("}"); - expect(tokens[1][4].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[1][5].value).toBe("\"\"\""); - expect(tokens[1][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.end.python"]); - expect(tokens[2][0].value).toBe("def"); - expect(tokens[2][0].scopes).toEqual(["source.python","meta.function.python","storage.type.function.python"]); - expect(tokens[2][1].value).toBe(" "); - expect(tokens[2][1].scopes).toEqual(["source.python","meta.function.python"]); - expect(tokens[2][2].value).toBe("foo"); - expect(tokens[2][2].scopes).toEqual(["source.python","meta.function.python","entity.name.function.python"]); - expect(tokens[2][3].value).toBe("("); - expect(tokens[2][3].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.definition.parameters.begin.python"]); - expect(tokens[2][4].value).toBe(")"); - expect(tokens[2][4].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.definition.parameters.end.python"]); - expect(tokens[2][5].value).toBe(":"); - expect(tokens[2][5].scopes).toEqual(["source.python","meta.function.python","punctuation.section.function.begin.python"]); - expect(tokens[2][6].value).toBe(" "); - expect(tokens[2][6].scopes).toEqual(["source.python"]); - expect(tokens[2][7].value).toBe("pass"); - expect(tokens[2][7].scopes).toEqual(["source.python","keyword.control.flow.python"]); - }); - - it("test/fstrings/prefixes1.py", - function() { - tokens = grammar.tokenizeLines("a = f's t r'\na = f\"s t r\"\na = F's t r'\na = F\"s t r\"\na = f'''s t r'''\na = F\"\"\"s t r\"\"\"") + tokens = grammar.tokenizeLines("a = fr'[a-z]'\na = Fr'[a-z]'\na = rf'[a-z]'\na = rF'[a-z]'") expect(tokens[0][0].value).toBe("a"); expect(tokens[0][0].scopes).toEqual(["source.python"]); expect(tokens[0][1].value).toBe(" "); @@ -6635,14 +6777,14 @@ describe("Grammar Tests", function() { expect(tokens[0][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); expect(tokens[0][3].value).toBe(" "); expect(tokens[0][3].scopes).toEqual(["source.python"]); - expect(tokens[0][4].value).toBe("f"); - expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][4].value).toBe("fr"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); expect(tokens[0][5].value).toBe("'"); - expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[0][6].value).toBe("s t r"); - expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[0][6].value).toBe("[a-z]"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); expect(tokens[0][7].value).toBe("'"); - expect(tokens[0][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); expect(tokens[1][0].value).toBe("a"); expect(tokens[1][0].scopes).toEqual(["source.python"]); expect(tokens[1][1].value).toBe(" "); @@ -6651,14 +6793,14 @@ describe("Grammar Tests", function() { expect(tokens[1][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); expect(tokens[1][3].value).toBe(" "); expect(tokens[1][3].scopes).toEqual(["source.python"]); - expect(tokens[1][4].value).toBe("f"); - expect(tokens[1][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); - expect(tokens[1][5].value).toBe("\""); - expect(tokens[1][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[1][6].value).toBe("s t r"); - expect(tokens[1][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); - expect(tokens[1][7].value).toBe("\""); - expect(tokens[1][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[1][4].value).toBe("Fr"); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[1][5].value).toBe("'"); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[1][6].value).toBe("[a-z]"); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[1][7].value).toBe("'"); + expect(tokens[1][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); expect(tokens[2][0].value).toBe("a"); expect(tokens[2][0].scopes).toEqual(["source.python"]); expect(tokens[2][1].value).toBe(" "); @@ -6667,14 +6809,14 @@ describe("Grammar Tests", function() { expect(tokens[2][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); expect(tokens[2][3].value).toBe(" "); expect(tokens[2][3].scopes).toEqual(["source.python"]); - expect(tokens[2][4].value).toBe("F"); - expect(tokens[2][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[2][4].value).toBe("rf"); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); expect(tokens[2][5].value).toBe("'"); - expect(tokens[2][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[2][6].value).toBe("s t r"); - expect(tokens[2][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[2][6].value).toBe("[a-z]"); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); expect(tokens[2][7].value).toBe("'"); - expect(tokens[2][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[2][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); expect(tokens[3][0].value).toBe("a"); expect(tokens[3][0].scopes).toEqual(["source.python"]); expect(tokens[3][1].value).toBe(" "); @@ -6683,272 +6825,864 @@ describe("Grammar Tests", function() { expect(tokens[3][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); expect(tokens[3][3].value).toBe(" "); expect(tokens[3][3].scopes).toEqual(["source.python"]); - expect(tokens[3][4].value).toBe("F"); - expect(tokens[3][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); - expect(tokens[3][5].value).toBe("\""); - expect(tokens[3][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[3][6].value).toBe("s t r"); - expect(tokens[3][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); - expect(tokens[3][7].value).toBe("\""); - expect(tokens[3][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); - expect(tokens[4][0].value).toBe("a"); - expect(tokens[4][0].scopes).toEqual(["source.python"]); - expect(tokens[4][1].value).toBe(" "); - expect(tokens[4][1].scopes).toEqual(["source.python"]); - expect(tokens[4][2].value).toBe("="); - expect(tokens[4][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[4][3].value).toBe(" "); - expect(tokens[4][3].scopes).toEqual(["source.python"]); - expect(tokens[4][4].value).toBe("f"); - expect(tokens[4][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.multi.python string.interpolated.python"]); - expect(tokens[4][5].value).toBe("'''"); - expect(tokens[4][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[4][6].value).toBe("s t r"); - expect(tokens[4][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); - expect(tokens[4][7].value).toBe("'''"); - expect(tokens[4][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.end.python"]); - expect(tokens[5][0].value).toBe("a"); - expect(tokens[5][0].scopes).toEqual(["source.python"]); - expect(tokens[5][1].value).toBe(" "); - expect(tokens[5][1].scopes).toEqual(["source.python"]); - expect(tokens[5][2].value).toBe("="); - expect(tokens[5][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[5][3].value).toBe(" "); - expect(tokens[5][3].scopes).toEqual(["source.python"]); - expect(tokens[5][4].value).toBe("F"); - expect(tokens[5][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.multi.python string.interpolated.python"]); - expect(tokens[5][5].value).toBe("\"\"\""); - expect(tokens[5][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[5][6].value).toBe("s t r"); - expect(tokens[5][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); - expect(tokens[5][7].value).toBe("\"\"\""); - expect(tokens[5][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[3][4].value).toBe("rF"); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[3][5].value).toBe("'"); + expect(tokens[3][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[3][6].value).toBe("[a-z]"); + expect(tokens[3][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[3][7].value).toBe("'"); + expect(tokens[3][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); }); - it("test/fstrings/prefixes2.py", + it("test/fstrings/fraw2.py", function() { - tokens = grammar.tokenizeLines("f'some {obj}'\nF'some {obj}'\nrf'some {obj}'\nrF'some {obj}'\nRf'some {obj}'\nRF'some {obj}'") - expect(tokens[0][0].value).toBe("f"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + tokens = grammar.tokenizeLines("rf'fo{{2}}'\nrf\"fo{{2}}\"\nrf'''fo{{2}}'''\nrf\"\"\"fo{{2}}\"\"\"") + expect(tokens[0][0].value).toBe("rf"); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); expect(tokens[0][1].value).toBe("'"); - expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[0][2].value).toBe("some "); - expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[0][2].value).toBe("fo"); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[0][3].value).toBe("{{"); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.escape.python"]); + expect(tokens[0][4].value).toBe("2"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[0][5].value).toBe("}}"); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.escape.python"]); + expect(tokens[0][6].value).toBe("'"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[1][0].value).toBe("rf"); + expect(tokens[1][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[1][1].value).toBe("\""); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[1][2].value).toBe("fo"); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[1][3].value).toBe("{{"); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.escape.python"]); + expect(tokens[1][4].value).toBe("2"); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[1][5].value).toBe("}}"); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.escape.python"]); + expect(tokens[1][6].value).toBe("\""); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[2][0].value).toBe("rf"); + expect(tokens[2][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.multi.python string.interpolated.python"]); + expect(tokens[2][1].value).toBe("'''"); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python punctuation.definition.string.begin.python"]); + expect(tokens[2][2].value).toBe("fo"); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python string.interpolated.python"]); + expect(tokens[2][3].value).toBe("{{"); + expect(tokens[2][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.escape.python"]); + expect(tokens[2][4].value).toBe("2"); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python string.interpolated.python"]); + expect(tokens[2][5].value).toBe("}}"); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.escape.python"]); + expect(tokens[2][6].value).toBe("'''"); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[3][0].value).toBe("rf"); + expect(tokens[3][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.multi.python string.interpolated.python"]); + expect(tokens[3][1].value).toBe("\"\"\""); + expect(tokens[3][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python punctuation.definition.string.begin.python"]); + expect(tokens[3][2].value).toBe("fo"); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python string.interpolated.python"]); + expect(tokens[3][3].value).toBe("{{"); + expect(tokens[3][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.escape.python"]); + expect(tokens[3][4].value).toBe("2"); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python string.interpolated.python"]); + expect(tokens[3][5].value).toBe("}}"); + expect(tokens[3][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.escape.python"]); + expect(tokens[3][6].value).toBe("\"\"\""); + expect(tokens[3][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python string.interpolated.python punctuation.definition.string.end.python"]); + }); + + it("test/fstrings/fraw3.py", + function() { + tokens = grammar.tokenizeLines("rf'fo{2}'\nrf\"fo{2}\"\nrf'''fo{2}'''\nrf\"\"\"fo{2}\"\"\"") + expect(tokens[0][0].value).toBe("rf"); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[0][1].value).toBe("'"); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[0][2].value).toBe("fo"); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); expect(tokens[0][3].value).toBe("{"); expect(tokens[0][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][4].value).toBe("obj"); - expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[0][4].value).toBe("2"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); expect(tokens[0][5].value).toBe("}"); expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][6].value).toBe("'"); - expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); - expect(tokens[1][0].value).toBe("F"); - expect(tokens[1][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); - expect(tokens[1][1].value).toBe("'"); - expect(tokens[1][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[1][2].value).toBe("some "); - expect(tokens[1][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[1][0].value).toBe("rf"); + expect(tokens[1][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[1][1].value).toBe("\""); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[1][2].value).toBe("fo"); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); expect(tokens[1][3].value).toBe("{"); expect(tokens[1][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[1][4].value).toBe("obj"); - expect(tokens[1][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[1][4].value).toBe("2"); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); expect(tokens[1][5].value).toBe("}"); expect(tokens[1][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[1][6].value).toBe("'"); - expect(tokens[1][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[1][6].value).toBe("\""); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); expect(tokens[2][0].value).toBe("rf"); - expect(tokens[2][0].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","storage.type.string.python"]); - expect(tokens[2][1].value).toBe("'"); - expect(tokens[2][1].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","punctuation.definition.string.begin.python"]); - expect(tokens[2][2].value).toBe("some "); - expect(tokens[2][2].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python"]); - expect(tokens[2][3].value).toBe("{obj}"); - expect(tokens[2][3].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python"]); - expect(tokens[2][4].value).toBe("'"); - expect(tokens[2][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","punctuation.definition.string.end.python"]); - expect(tokens[3][0].value).toBe("rF"); - expect(tokens[3][0].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","storage.type.string.python"]); - expect(tokens[3][1].value).toBe("'"); - expect(tokens[3][1].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","punctuation.definition.string.begin.python"]); - expect(tokens[3][2].value).toBe("some "); - expect(tokens[3][2].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python"]); - expect(tokens[3][3].value).toBe("{obj}"); - expect(tokens[3][3].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python"]); - expect(tokens[3][4].value).toBe("'"); - expect(tokens[3][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","punctuation.definition.string.end.python"]); - expect(tokens[4][0].value).toBe("Rf"); - expect(tokens[4][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); - expect(tokens[4][1].value).toBe("'"); - expect(tokens[4][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); - expect(tokens[4][2].value).toBe("some "); - expect(tokens[4][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); - expect(tokens[4][3].value).toBe("{"); - expect(tokens[4][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[4][4].value).toBe("obj"); - expect(tokens[4][4].scopes).toEqual(["source.python","meta.fstring.python"]); - expect(tokens[4][5].value).toBe("}"); - expect(tokens[4][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[4][6].value).toBe("'"); - expect(tokens[4][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); - expect(tokens[5][0].value).toBe("RF"); - expect(tokens[5][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); - expect(tokens[5][1].value).toBe("'"); - expect(tokens[5][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); - expect(tokens[5][2].value).toBe("some "); - expect(tokens[5][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); - expect(tokens[5][3].value).toBe("{"); - expect(tokens[5][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[5][4].value).toBe("obj"); - expect(tokens[5][4].scopes).toEqual(["source.python","meta.fstring.python"]); - expect(tokens[5][5].value).toBe("}"); - expect(tokens[5][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[5][6].value).toBe("'"); - expect(tokens[5][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); - }); - - it("test/fstrings/prefixes3.py", - function() { - tokens = grammar.tokenizeLines("fr'some {obj}'\nFr'some {obj}'\nfR'some {obj}'\nFR'some {obj}'") - expect(tokens[0][0].value).toBe("fr"); - expect(tokens[0][0].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","storage.type.string.python"]); - expect(tokens[0][1].value).toBe("'"); - expect(tokens[0][1].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","punctuation.definition.string.begin.python"]); - expect(tokens[0][2].value).toBe("some "); - expect(tokens[0][2].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python"]); - expect(tokens[0][3].value).toBe("{obj}"); - expect(tokens[0][3].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python"]); - expect(tokens[0][4].value).toBe("'"); - expect(tokens[0][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","punctuation.definition.string.end.python"]); - expect(tokens[1][0].value).toBe("Fr"); - expect(tokens[1][0].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","storage.type.string.python"]); - expect(tokens[1][1].value).toBe("'"); - expect(tokens[1][1].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","punctuation.definition.string.begin.python"]); - expect(tokens[1][2].value).toBe("some "); - expect(tokens[1][2].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python"]); - expect(tokens[1][3].value).toBe("{obj}"); - expect(tokens[1][3].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python"]); - expect(tokens[1][4].value).toBe("'"); - expect(tokens[1][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","punctuation.definition.string.end.python"]); - expect(tokens[2][0].value).toBe("fR"); - expect(tokens[2][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); - expect(tokens[2][1].value).toBe("'"); - expect(tokens[2][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); - expect(tokens[2][2].value).toBe("some "); - expect(tokens[2][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[2][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.multi.python string.interpolated.python"]); + expect(tokens[2][1].value).toBe("'''"); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python punctuation.definition.string.begin.python"]); + expect(tokens[2][2].value).toBe("fo"); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python string.interpolated.python"]); expect(tokens[2][3].value).toBe("{"); expect(tokens[2][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[2][4].value).toBe("obj"); - expect(tokens[2][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[2][4].value).toBe("2"); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); expect(tokens[2][5].value).toBe("}"); expect(tokens[2][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[2][6].value).toBe("'"); - expect(tokens[2][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); - expect(tokens[3][0].value).toBe("FR"); - expect(tokens[3][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); - expect(tokens[3][1].value).toBe("'"); - expect(tokens[3][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); - expect(tokens[3][2].value).toBe("some "); - expect(tokens[3][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[2][6].value).toBe("'''"); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[3][0].value).toBe("rf"); + expect(tokens[3][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.multi.python string.interpolated.python"]); + expect(tokens[3][1].value).toBe("\"\"\""); + expect(tokens[3][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python punctuation.definition.string.begin.python"]); + expect(tokens[3][2].value).toBe("fo"); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python string.interpolated.python"]); expect(tokens[3][3].value).toBe("{"); expect(tokens[3][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[3][4].value).toBe("obj"); - expect(tokens[3][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[3][4].value).toBe("2"); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); expect(tokens[3][5].value).toBe("}"); expect(tokens[3][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[3][6].value).toBe("'"); - expect(tokens[3][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[3][6].value).toBe("\"\"\""); + expect(tokens[3][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.multi.python string.interpolated.python punctuation.definition.string.end.python"]); }); - it("test/fstrings/prefixes4.py", + it("test/fstrings/fraw4.py", function() { - tokens = grammar.tokenizeLines("fu'some {obj}'\nFu'some {obj}'\nfU'some {obj}'\nFU'some {obj}'\n\nuf'some {obj}'\nuF'some {obj}'\nUf'some {obj}'\nUF'some {obj}'") + tokens = grammar.tokenizeLines("a = rf'fo{{{2}}}'\na = rf'fo{{{bar}}}'\na = rf'fo{{2}}'") + expect(tokens[0][0].value).toBe("a"); + expect(tokens[0][0].scopes).toEqual(["source.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("="); + expect(tokens[0][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("rf"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[0][5].value).toBe("'"); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[0][6].value).toBe("fo"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[0][7].value).toBe("{{"); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.fstring.python","constant.character.escape.python"]); + expect(tokens[0][8].value).toBe("{"); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][9].value).toBe("2"); + expect(tokens[0][9].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); + expect(tokens[0][10].value).toBe("}"); + expect(tokens[0][10].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][11].value).toBe("}}"); + expect(tokens[0][11].scopes).toEqual(["source.python","meta.fstring.python","constant.character.escape.python"]); + expect(tokens[0][12].value).toBe("'"); + expect(tokens[0][12].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[1][0].value).toBe("a"); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe(" "); + expect(tokens[1][1].scopes).toEqual(["source.python"]); + expect(tokens[1][2].value).toBe("="); + expect(tokens[1][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[1][3].value).toBe(" "); + expect(tokens[1][3].scopes).toEqual(["source.python"]); + expect(tokens[1][4].value).toBe("rf"); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[1][5].value).toBe("'"); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[1][6].value).toBe("fo"); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[1][7].value).toBe("{{"); + expect(tokens[1][7].scopes).toEqual(["source.python","meta.fstring.python","constant.character.escape.python"]); + expect(tokens[1][8].value).toBe("{"); + expect(tokens[1][8].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][9].value).toBe("bar"); + expect(tokens[1][9].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[1][10].value).toBe("}"); + expect(tokens[1][10].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][11].value).toBe("}}"); + expect(tokens[1][11].scopes).toEqual(["source.python","meta.fstring.python","constant.character.escape.python"]); + expect(tokens[1][12].value).toBe("'"); + expect(tokens[1][12].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[2][0].value).toBe("a"); + expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[2][1].value).toBe(" "); + expect(tokens[2][1].scopes).toEqual(["source.python"]); + expect(tokens[2][2].value).toBe("="); + expect(tokens[2][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[2][3].value).toBe(" "); + expect(tokens[2][3].scopes).toEqual(["source.python"]); + expect(tokens[2][4].value).toBe("rf"); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[2][5].value).toBe("'"); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[2][6].value).toBe("fo"); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[2][7].value).toBe("{{"); + expect(tokens[2][7].scopes).toEqual(["source.python","meta.fstring.python","constant.character.escape.python"]); + expect(tokens[2][8].value).toBe("2"); + expect(tokens[2][8].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[2][9].value).toBe("}}"); + expect(tokens[2][9].scopes).toEqual(["source.python","meta.fstring.python","constant.character.escape.python"]); + expect(tokens[2][10].value).toBe("'"); + expect(tokens[2][10].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); + }); + + it("test/fstrings/nested1.py", + function() { + tokens = grammar.tokenizeLines("f'''\n prefix {\n foo(f\"\"\"\n inner prefix\n { bar[\"q\"] + f'insane{42 + 9000}stuff{def aaa(): pass}111'}\n inner suffix\n \"\"\")\n } suffix\n'''") expect(tokens[0][0].value).toBe("f"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); - expect(tokens[0][1].value).toBe("u"); - expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.prefix.python"]); - expect(tokens[0][2].value).toBe("'"); - expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[0][3].value).toBe("some "); - expect(tokens[0][3].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); - expect(tokens[0][4].value).toBe("{"); - expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][5].value).toBe("obj"); - expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python"]); - expect(tokens[0][6].value).toBe("}"); - expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][7].value).toBe("'"); - expect(tokens[0][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); - expect(tokens[1][0].value).toBe("F"); - expect(tokens[1][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); - expect(tokens[1][1].value).toBe("u"); - expect(tokens[1][1].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.prefix.python"]); - expect(tokens[1][2].value).toBe("'"); - expect(tokens[1][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[1][3].value).toBe("some "); - expect(tokens[1][3].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); - expect(tokens[1][4].value).toBe("{"); - expect(tokens[1][4].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[1][5].value).toBe("obj"); - expect(tokens[1][5].scopes).toEqual(["source.python","meta.fstring.python"]); - expect(tokens[1][6].value).toBe("}"); - expect(tokens[1][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[1][7].value).toBe("'"); - expect(tokens[1][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); - expect(tokens[2][0].value).toBe("f"); - expect(tokens[2][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); - expect(tokens[2][1].value).toBe("U"); - expect(tokens[2][1].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.prefix.python"]); - expect(tokens[2][2].value).toBe("'"); - expect(tokens[2][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[2][3].value).toBe("some "); - expect(tokens[2][3].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); - expect(tokens[2][4].value).toBe("{"); - expect(tokens[2][4].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[2][5].value).toBe("obj"); - expect(tokens[2][5].scopes).toEqual(["source.python","meta.fstring.python"]); - expect(tokens[2][6].value).toBe("}"); - expect(tokens[2][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[2][7].value).toBe("'"); - expect(tokens[2][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); - expect(tokens[3][0].value).toBe("F"); - expect(tokens[3][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); - expect(tokens[3][1].value).toBe("U"); - expect(tokens[3][1].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.prefix.python"]); - expect(tokens[3][2].value).toBe("'"); - expect(tokens[3][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); - expect(tokens[3][3].value).toBe("some "); - expect(tokens[3][3].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); - expect(tokens[3][4].value).toBe("{"); - expect(tokens[3][4].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[3][5].value).toBe("obj"); - expect(tokens[3][5].scopes).toEqual(["source.python","meta.fstring.python"]); - expect(tokens[3][6].value).toBe("}"); - expect(tokens[3][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[3][7].value).toBe("'"); - expect(tokens[3][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); - expect(tokens[4][0].value).toBe(""); - expect(tokens[4][0].scopes).toEqual(["source.python"]); - expect(tokens[5][0].value).toBe("u"); - expect(tokens[5][0].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.prefix.python"]); - expect(tokens[5][1].value).toBe("f"); - expect(tokens[5][1].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); - expect(tokens[5][2].value).toBe("'"); - expect(tokens[5][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python punctuation.definition.string.begin.python"]); - expect(tokens[5][3].value).toBe("some "); - expect(tokens[5][3].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); - expect(tokens[5][4].value).toBe("{"); - expect(tokens[5][4].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[5][5].value).toBe("obj"); - expect(tokens[5][5].scopes).toEqual(["source.python","meta.fstring.python"]); - expect(tokens[5][6].value).toBe("}"); - expect(tokens[5][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); - expect(tokens[5][7].value).toBe("'"); - expect(tokens[5][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); - expect(tokens[6][0].value).toBe("u"); - expect(tokens[6][0].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.prefix.python"]); - expect(tokens[6][1].value).toBe("F"); - expect(tokens[6][1].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); - expect(tokens[6][2].value).toBe("'"); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.multi.python string.interpolated.python"]); + expect(tokens[0][1].value).toBe("'''"); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[0][2].value).toBe(""); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); + expect(tokens[1][0].value).toBe(" prefix "); + expect(tokens[1][0].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); + expect(tokens[1][1].value).toBe("{"); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][0].value).toBe(" "); + expect(tokens[2][0].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[2][1].value).toBe("foo"); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[2][2].value).toBe("("); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[2][3].value).toBe("f"); + expect(tokens[2][3].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.string.python string.quoted.multi.python string.interpolated.python"]); + expect(tokens[2][4].value).toBe("\"\"\""); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[2][5].value).toBe(""); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); + expect(tokens[3][0].value).toBe(" inner prefix"); + expect(tokens[3][0].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); + expect(tokens[4][0].value).toBe(" "); + expect(tokens[4][0].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); + expect(tokens[4][1].value).toBe("{"); + expect(tokens[4][1].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[4][2].value).toBe(" "); + expect(tokens[4][2].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); + expect(tokens[4][3].value).toBe("bar"); + expect(tokens[4][3].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.item-access.python","meta.indexed-name.python"]); + expect(tokens[4][4].value).toBe("["); + expect(tokens[4][4].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.item-access.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[4][5].value).toBe("\""); + expect(tokens[4][5].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.item-access.python","meta.item-access.arguments.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[4][6].value).toBe("q"); + expect(tokens[4][6].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.item-access.python","meta.item-access.arguments.python","string.quoted.single.python"]); + expect(tokens[4][7].value).toBe("\""); + expect(tokens[4][7].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.item-access.python","meta.item-access.arguments.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[4][8].value).toBe("]"); + expect(tokens[4][8].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.item-access.python","punctuation.definition.arguments.end.python"]); + expect(tokens[4][9].value).toBe(" "); + expect(tokens[4][9].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); + expect(tokens[4][10].value).toBe("+"); + expect(tokens[4][10].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","keyword.operator.arithmetic.python"]); + expect(tokens[4][11].value).toBe(" "); + expect(tokens[4][11].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python"]); + expect(tokens[4][12].value).toBe("f"); + expect(tokens[4][12].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[4][13].value).toBe("'"); + expect(tokens[4][13].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[4][14].value).toBe("insane"); + expect(tokens[4][14].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[4][15].value).toBe("{"); + expect(tokens[4][15].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[4][16].value).toBe("42"); + expect(tokens[4][16].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","constant.numeric.dec.python"]); + expect(tokens[4][17].value).toBe(" "); + expect(tokens[4][17].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python"]); + expect(tokens[4][18].value).toBe("+"); + expect(tokens[4][18].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","keyword.operator.arithmetic.python"]); + expect(tokens[4][19].value).toBe(" "); + expect(tokens[4][19].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python"]); + expect(tokens[4][20].value).toBe("9000"); + expect(tokens[4][20].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","constant.numeric.dec.python"]); + expect(tokens[4][21].value).toBe("}"); + expect(tokens[4][21].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[4][22].value).toBe("stuff"); + expect(tokens[4][22].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[4][23].value).toBe("{"); + expect(tokens[4][23].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[4][24].value).toBe("def"); + expect(tokens[4][24].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","keyword.control.flow.python"]); + expect(tokens[4][25].value).toBe(" "); + expect(tokens[4][25].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python"]); + expect(tokens[4][26].value).toBe("aaa"); + expect(tokens[4][26].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[4][27].value).toBe("("); + expect(tokens[4][27].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[4][28].value).toBe(")"); + expect(tokens[4][28].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[4][29].value).toBe(":"); + expect(tokens[4][29].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","punctuation.separator.colon.python"]); + expect(tokens[4][30].value).toBe(" "); + expect(tokens[4][30].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python"]); + expect(tokens[4][31].value).toBe("pass"); + expect(tokens[4][31].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","keyword.control.flow.python"]); + expect(tokens[4][32].value).toBe("}"); + expect(tokens[4][32].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[4][33].value).toBe("111"); + expect(tokens[4][33].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[4][34].value).toBe("'"); + expect(tokens[4][34].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[4][35].value).toBe("}"); + expect(tokens[4][35].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[4][36].value).toBe(""); + expect(tokens[4][36].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); + expect(tokens[5][0].value).toBe(" inner suffix"); + expect(tokens[5][0].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); + expect(tokens[6][0].value).toBe(" "); + expect(tokens[6][0].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); + expect(tokens[6][1].value).toBe("\"\"\""); + expect(tokens[6][1].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[6][2].value).toBe(")"); + expect(tokens[6][2].scopes).toEqual(["source.python","meta.fstring.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[7][0].value).toBe(" "); + expect(tokens[7][0].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[7][1].value).toBe("}"); + expect(tokens[7][1].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[7][2].value).toBe(" suffix"); + expect(tokens[7][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); + expect(tokens[8][0].value).toBe("'''"); + expect(tokens[8][0].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.end.python"]); + }); + + it("test/fstrings/nested2.py", + function() { + tokens = grammar.tokenizeLines("f\"result: {value:{60}.{16!s:2}{'qwerty'[2]}}\"") + expect(tokens[0][0].value).toBe("f"); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][1].value).toBe("\""); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[0][2].value).toBe("result: "); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][3].value).toBe("{"); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][4].value).toBe("value"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[0][5].value).toBe(":"); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); + expect(tokens[0][6].value).toBe("{"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][7].value).toBe("60"); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); + expect(tokens[0][8].value).toBe("}"); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][9].value).toBe("."); + expect(tokens[0][9].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[0][10].value).toBe("{"); + expect(tokens[0][10].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][11].value).toBe("16"); + expect(tokens[0][11].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); + expect(tokens[0][12].value).toBe("!s"); + expect(tokens[0][12].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); + expect(tokens[0][13].value).toBe(":2"); + expect(tokens[0][13].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); + expect(tokens[0][14].value).toBe("}"); + expect(tokens[0][14].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][15].value).toBe("{"); + expect(tokens[0][15].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][16].value).toBe("'"); + expect(tokens[0][16].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[0][17].value).toBe("qwerty"); + expect(tokens[0][17].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python"]); + expect(tokens[0][18].value).toBe("'"); + expect(tokens[0][18].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[0][19].value).toBe("["); + expect(tokens[0][19].scopes).toEqual(["source.python","meta.fstring.python","punctuation.definition.list.begin.python"]); + expect(tokens[0][20].value).toBe("2"); + expect(tokens[0][20].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); + expect(tokens[0][21].value).toBe("]"); + expect(tokens[0][21].scopes).toEqual(["source.python","meta.fstring.python","punctuation.definition.list.end.python"]); + expect(tokens[0][22].value).toBe("}"); + expect(tokens[0][22].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][23].value).toBe("}"); + expect(tokens[0][23].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][24].value).toBe("\""); + expect(tokens[0][24].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + }); + + it("test/fstrings/nested3.py", + function() { + tokens = grammar.tokenizeLines("f\"result: {value:{60}.{16!s:2}{'qwerty'\n[2]}}\"\n# comment") + expect(tokens[0][0].value).toBe("f"); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][1].value).toBe("\""); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[0][2].value).toBe("result: "); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][3].value).toBe("{"); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][4].value).toBe("value"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[0][5].value).toBe(":"); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); + expect(tokens[0][6].value).toBe("{"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][7].value).toBe("60"); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); + expect(tokens[0][8].value).toBe("}"); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][9].value).toBe("."); + expect(tokens[0][9].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[0][10].value).toBe("{"); + expect(tokens[0][10].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][11].value).toBe("16"); + expect(tokens[0][11].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); + expect(tokens[0][12].value).toBe("!s"); + expect(tokens[0][12].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); + expect(tokens[0][13].value).toBe(":2"); + expect(tokens[0][13].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); + expect(tokens[0][14].value).toBe("}"); + expect(tokens[0][14].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][15].value).toBe("{"); + expect(tokens[0][15].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][16].value).toBe("'"); + expect(tokens[0][16].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[0][17].value).toBe("qwerty"); + expect(tokens[0][17].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python"]); + expect(tokens[0][18].value).toBe("'"); + expect(tokens[0][18].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[0][19].value).toBe(""); + expect(tokens[0][19].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.newline.python"]); + expect(tokens[1][0].value).toBe("["); + expect(tokens[1][0].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); + expect(tokens[1][1].value).toBe("2"); + expect(tokens[1][1].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[1][2].value).toBe("]"); + expect(tokens[1][2].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); + expect(tokens[1][3].value).toBe("}}"); + expect(tokens[1][3].scopes).toEqual(["source.python"]); + expect(tokens[1][4].value).toBe("\""); + expect(tokens[1][4].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[1][5].value).toBe(""); + expect(tokens[1][5].scopes).toEqual(["source.python","string.quoted.single.python","invalid.illegal.newline.python"]); + expect(tokens[2][0].value).toBe("#"); + expect(tokens[2][0].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[2][1].value).toBe(" comment"); + expect(tokens[2][1].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + }); + + it("test/fstrings/nested4.py", + function() { + tokens = grammar.tokenizeLines("f\"\"\"result: {value:{60}.{16!s:2}{'qwerty'\n[2]}}\"\"\"\ndef foo(): pass") + expect(tokens[0][0].value).toBe("f"); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.multi.python string.interpolated.python"]); + expect(tokens[0][1].value).toBe("\"\"\""); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[0][2].value).toBe("result: "); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); + expect(tokens[0][3].value).toBe("{"); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][4].value).toBe("value"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[0][5].value).toBe(":"); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); + expect(tokens[0][6].value).toBe("{"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][7].value).toBe("60"); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); + expect(tokens[0][8].value).toBe("}"); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][9].value).toBe("."); + expect(tokens[0][9].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[0][10].value).toBe("{"); + expect(tokens[0][10].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][11].value).toBe("16"); + expect(tokens[0][11].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); + expect(tokens[0][12].value).toBe("!s"); + expect(tokens[0][12].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); + expect(tokens[0][13].value).toBe(":2"); + expect(tokens[0][13].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); + expect(tokens[0][14].value).toBe("}"); + expect(tokens[0][14].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][15].value).toBe("{"); + expect(tokens[0][15].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][16].value).toBe("'"); + expect(tokens[0][16].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[0][17].value).toBe("qwerty"); + expect(tokens[0][17].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python"]); + expect(tokens[0][18].value).toBe("'"); + expect(tokens[0][18].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[1][0].value).toBe("["); + expect(tokens[1][0].scopes).toEqual(["source.python","meta.fstring.python","punctuation.definition.list.begin.python"]); + expect(tokens[1][1].value).toBe("2"); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.fstring.python","constant.numeric.dec.python"]); + expect(tokens[1][2].value).toBe("]"); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.fstring.python","punctuation.definition.list.end.python"]); + expect(tokens[1][3].value).toBe("}"); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][4].value).toBe("}"); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][5].value).toBe("\"\"\""); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[2][0].value).toBe("def"); + expect(tokens[2][0].scopes).toEqual(["source.python","meta.function.python","storage.type.function.python"]); + expect(tokens[2][1].value).toBe(" "); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.function.python"]); + expect(tokens[2][2].value).toBe("foo"); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.function.python","entity.name.function.python"]); + expect(tokens[2][3].value).toBe("("); + expect(tokens[2][3].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.definition.parameters.begin.python"]); + expect(tokens[2][4].value).toBe(")"); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.definition.parameters.end.python"]); + expect(tokens[2][5].value).toBe(":"); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.function.python","punctuation.section.function.begin.python"]); + expect(tokens[2][6].value).toBe(" "); + expect(tokens[2][6].scopes).toEqual(["source.python"]); + expect(tokens[2][7].value).toBe("pass"); + expect(tokens[2][7].scopes).toEqual(["source.python","keyword.control.flow.python"]); + }); + + it("test/fstrings/prefixes1.py", + function() { + tokens = grammar.tokenizeLines("a = f's t r'\na = f\"s t r\"\na = F's t r'\na = F\"s t r\"\na = f'''s t r'''\na = F\"\"\"s t r\"\"\"") + expect(tokens[0][0].value).toBe("a"); + expect(tokens[0][0].scopes).toEqual(["source.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("="); + expect(tokens[0][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("f"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][5].value).toBe("'"); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[0][6].value).toBe("s t r"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][7].value).toBe("'"); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[1][0].value).toBe("a"); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe(" "); + expect(tokens[1][1].scopes).toEqual(["source.python"]); + expect(tokens[1][2].value).toBe("="); + expect(tokens[1][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[1][3].value).toBe(" "); + expect(tokens[1][3].scopes).toEqual(["source.python"]); + expect(tokens[1][4].value).toBe("f"); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[1][5].value).toBe("\""); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[1][6].value).toBe("s t r"); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[1][7].value).toBe("\""); + expect(tokens[1][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[2][0].value).toBe("a"); + expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[2][1].value).toBe(" "); + expect(tokens[2][1].scopes).toEqual(["source.python"]); + expect(tokens[2][2].value).toBe("="); + expect(tokens[2][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[2][3].value).toBe(" "); + expect(tokens[2][3].scopes).toEqual(["source.python"]); + expect(tokens[2][4].value).toBe("F"); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[2][5].value).toBe("'"); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[2][6].value).toBe("s t r"); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[2][7].value).toBe("'"); + expect(tokens[2][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[3][0].value).toBe("a"); + expect(tokens[3][0].scopes).toEqual(["source.python"]); + expect(tokens[3][1].value).toBe(" "); + expect(tokens[3][1].scopes).toEqual(["source.python"]); + expect(tokens[3][2].value).toBe("="); + expect(tokens[3][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[3][3].value).toBe(" "); + expect(tokens[3][3].scopes).toEqual(["source.python"]); + expect(tokens[3][4].value).toBe("F"); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[3][5].value).toBe("\""); + expect(tokens[3][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[3][6].value).toBe("s t r"); + expect(tokens[3][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[3][7].value).toBe("\""); + expect(tokens[3][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[4][0].value).toBe("a"); + expect(tokens[4][0].scopes).toEqual(["source.python"]); + expect(tokens[4][1].value).toBe(" "); + expect(tokens[4][1].scopes).toEqual(["source.python"]); + expect(tokens[4][2].value).toBe("="); + expect(tokens[4][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[4][3].value).toBe(" "); + expect(tokens[4][3].scopes).toEqual(["source.python"]); + expect(tokens[4][4].value).toBe("f"); + expect(tokens[4][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.multi.python string.interpolated.python"]); + expect(tokens[4][5].value).toBe("'''"); + expect(tokens[4][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[4][6].value).toBe("s t r"); + expect(tokens[4][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); + expect(tokens[4][7].value).toBe("'''"); + expect(tokens[4][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[5][0].value).toBe("a"); + expect(tokens[5][0].scopes).toEqual(["source.python"]); + expect(tokens[5][1].value).toBe(" "); + expect(tokens[5][1].scopes).toEqual(["source.python"]); + expect(tokens[5][2].value).toBe("="); + expect(tokens[5][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[5][3].value).toBe(" "); + expect(tokens[5][3].scopes).toEqual(["source.python"]); + expect(tokens[5][4].value).toBe("F"); + expect(tokens[5][4].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.multi.python string.interpolated.python"]); + expect(tokens[5][5].value).toBe("\"\"\""); + expect(tokens[5][5].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[5][6].value).toBe("s t r"); + expect(tokens[5][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python"]); + expect(tokens[5][7].value).toBe("\"\"\""); + expect(tokens[5][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.multi.python string.interpolated.python punctuation.definition.string.end.python"]); + }); + + it("test/fstrings/prefixes2.py", + function() { + tokens = grammar.tokenizeLines("f'some {obj}'\nF'some {obj}'\nrf'some {obj}'\nrF'some {obj}'\nRf'some {obj}'\nRF'some {obj}'") + expect(tokens[0][0].value).toBe("f"); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][1].value).toBe("'"); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[0][2].value).toBe("some "); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][3].value).toBe("{"); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][4].value).toBe("obj"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[0][5].value).toBe("}"); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][6].value).toBe("'"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[1][0].value).toBe("F"); + expect(tokens[1][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[1][1].value).toBe("'"); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[1][2].value).toBe("some "); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[1][3].value).toBe("{"); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][4].value).toBe("obj"); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[1][5].value).toBe("}"); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][6].value).toBe("'"); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[2][0].value).toBe("rf"); + expect(tokens[2][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[2][1].value).toBe("'"); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[2][2].value).toBe("some "); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[2][3].value).toBe("{"); + expect(tokens[2][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][4].value).toBe("obj"); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[2][5].value).toBe("}"); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][6].value).toBe("'"); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[3][0].value).toBe("rF"); + expect(tokens[3][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[3][1].value).toBe("'"); + expect(tokens[3][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[3][2].value).toBe("some "); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[3][3].value).toBe("{"); + expect(tokens[3][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[3][4].value).toBe("obj"); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[3][5].value).toBe("}"); + expect(tokens[3][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[3][6].value).toBe("'"); + expect(tokens[3][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[4][0].value).toBe("Rf"); + expect(tokens[4][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[4][1].value).toBe("'"); + expect(tokens[4][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[4][2].value).toBe("some "); + expect(tokens[4][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[4][3].value).toBe("{"); + expect(tokens[4][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[4][4].value).toBe("obj"); + expect(tokens[4][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[4][5].value).toBe("}"); + expect(tokens[4][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[4][6].value).toBe("'"); + expect(tokens[4][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[5][0].value).toBe("RF"); + expect(tokens[5][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[5][1].value).toBe("'"); + expect(tokens[5][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[5][2].value).toBe("some "); + expect(tokens[5][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[5][3].value).toBe("{"); + expect(tokens[5][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[5][4].value).toBe("obj"); + expect(tokens[5][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[5][5].value).toBe("}"); + expect(tokens[5][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[5][6].value).toBe("'"); + expect(tokens[5][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); + }); + + it("test/fstrings/prefixes3.py", + function() { + tokens = grammar.tokenizeLines("fr'some {obj}'\nFr'some {obj}'\nfR'some {obj}'\nFR'some {obj}'") + expect(tokens[0][0].value).toBe("fr"); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[0][1].value).toBe("'"); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[0][2].value).toBe("some "); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[0][3].value).toBe("{"); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][4].value).toBe("obj"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[0][5].value).toBe("}"); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][6].value).toBe("'"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[1][0].value).toBe("Fr"); + expect(tokens[1][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[1][1].value).toBe("'"); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[1][2].value).toBe("some "); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[1][3].value).toBe("{"); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][4].value).toBe("obj"); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[1][5].value).toBe("}"); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][6].value).toBe("'"); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[2][0].value).toBe("fR"); + expect(tokens[2][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[2][1].value).toBe("'"); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[2][2].value).toBe("some "); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[2][3].value).toBe("{"); + expect(tokens[2][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][4].value).toBe("obj"); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[2][5].value).toBe("}"); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][6].value).toBe("'"); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[3][0].value).toBe("FR"); + expect(tokens[3][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[3][1].value).toBe("'"); + expect(tokens[3][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python punctuation.definition.string.begin.python"]); + expect(tokens[3][2].value).toBe("some "); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python"]); + expect(tokens[3][3].value).toBe("{"); + expect(tokens[3][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[3][4].value).toBe("obj"); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[3][5].value).toBe("}"); + expect(tokens[3][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[3][6].value).toBe("'"); + expect(tokens[3][6].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.raw.single.python string.interpolated.python punctuation.definition.string.end.python"]); + }); + + it("test/fstrings/prefixes4.py", + function() { + tokens = grammar.tokenizeLines("fu'some {obj}'\nFu'some {obj}'\nfU'some {obj}'\nFU'some {obj}'\n\nuf'some {obj}'\nuF'some {obj}'\nUf'some {obj}'\nUF'some {obj}'") + expect(tokens[0][0].value).toBe("f"); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][1].value).toBe("u"); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.prefix.python"]); + expect(tokens[0][2].value).toBe("'"); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[0][3].value).toBe("some "); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][4].value).toBe("{"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][5].value).toBe("obj"); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[0][6].value).toBe("}"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][7].value).toBe("'"); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[1][0].value).toBe("F"); + expect(tokens[1][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[1][1].value).toBe("u"); + expect(tokens[1][1].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.prefix.python"]); + expect(tokens[1][2].value).toBe("'"); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[1][3].value).toBe("some "); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[1][4].value).toBe("{"); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][5].value).toBe("obj"); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[1][6].value).toBe("}"); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][7].value).toBe("'"); + expect(tokens[1][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[2][0].value).toBe("f"); + expect(tokens[2][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[2][1].value).toBe("U"); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.prefix.python"]); + expect(tokens[2][2].value).toBe("'"); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[2][3].value).toBe("some "); + expect(tokens[2][3].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[2][4].value).toBe("{"); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][5].value).toBe("obj"); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[2][6].value).toBe("}"); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][7].value).toBe("'"); + expect(tokens[2][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[3][0].value).toBe("F"); + expect(tokens[3][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[3][1].value).toBe("U"); + expect(tokens[3][1].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.prefix.python"]); + expect(tokens[3][2].value).toBe("'"); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[3][3].value).toBe("some "); + expect(tokens[3][3].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[3][4].value).toBe("{"); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[3][5].value).toBe("obj"); + expect(tokens[3][5].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[3][6].value).toBe("}"); + expect(tokens[3][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[3][7].value).toBe("'"); + expect(tokens[3][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[4][0].value).toBe(""); + expect(tokens[4][0].scopes).toEqual(["source.python"]); + expect(tokens[5][0].value).toBe("u"); + expect(tokens[5][0].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.prefix.python"]); + expect(tokens[5][1].value).toBe("f"); + expect(tokens[5][1].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[5][2].value).toBe("'"); + expect(tokens[5][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python punctuation.definition.string.begin.python"]); + expect(tokens[5][3].value).toBe("some "); + expect(tokens[5][3].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[5][4].value).toBe("{"); + expect(tokens[5][4].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[5][5].value).toBe("obj"); + expect(tokens[5][5].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[5][6].value).toBe("}"); + expect(tokens[5][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[5][7].value).toBe("'"); + expect(tokens[5][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[6][0].value).toBe("u"); + expect(tokens[6][0].scopes).toEqual(["source.python","meta.fstring.python","invalid.illegal.prefix.python"]); + expect(tokens[6][1].value).toBe("F"); + expect(tokens[6][1].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[6][2].value).toBe("'"); expect(tokens[6][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python punctuation.definition.string.begin.python"]); expect(tokens[6][3].value).toBe("some "); expect(tokens[6][3].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); @@ -7234,6 +7968,37 @@ describe("Grammar Tests", function() { expect(tokens[2][20].scopes).toEqual(["source.python","comment.line.number-sign.python"]); }); + it("test/fstrings/simple10.py", + function() { + tokens = grammar.tokenizeLines("f'values: {a=} {b=!r}'") + expect(tokens[0][0].value).toBe("f"); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][1].value).toBe("'"); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[0][2].value).toBe("values: "); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][3].value).toBe("{"); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][4].value).toBe("a"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[0][5].value).toBe("="); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); + expect(tokens[0][6].value).toBe("}"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][7].value).toBe(" "); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[0][8].value).toBe("{"); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][9].value).toBe("b"); + expect(tokens[0][9].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[0][10].value).toBe("=!r"); + expect(tokens[0][10].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); + expect(tokens[0][11].value).toBe("}"); + expect(tokens[0][11].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][12].value).toBe("'"); + expect(tokens[0][12].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + }); + it("test/fstrings/simple2.py", function() { tokens = grammar.tokenizeLines("a = f\"normal {{ normal }} normal } {10!r} normal {fo.__add__!s}\"") @@ -7278,9 +8043,9 @@ describe("Grammar Tests", function() { expect(tokens[0][19].value).toBe("fo"); expect(tokens[0][19].scopes).toEqual(["source.python","meta.fstring.python"]); expect(tokens[0][20].value).toBe("."); - expect(tokens[0][20].scopes).toEqual(["source.python","meta.fstring.python","punctuation.separator.period.python"]); + expect(tokens[0][20].scopes).toEqual(["source.python","meta.fstring.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][21].value).toBe("__add__"); - expect(tokens[0][21].scopes).toEqual(["source.python","meta.fstring.python","support.function.magic.python"]); + expect(tokens[0][21].scopes).toEqual(["source.python","meta.fstring.python","meta.member.access.python","support.function.magic.python"]); expect(tokens[0][22].value).toBe("!s"); expect(tokens[0][22].scopes).toEqual(["source.python","meta.fstring.python","storage.type.format.python"]); expect(tokens[0][23].value).toBe("}"); @@ -7674,7 +8439,7 @@ describe("Grammar Tests", function() { function() { tokens = grammar.tokenizeLines("@foo\nasync def foo():\n a = 1\n async for a, b, c in b:\n async with b as d, c:\n await func(a, b=1)") expect(tokens[0][0].value).toBe("@"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[0][1].value).toBe("foo"); expect(tokens[0][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[1][0].value).toBe("async"); @@ -7732,7 +8497,7 @@ describe("Grammar Tests", function() { expect(tokens[3][12].value).toBe(" "); expect(tokens[3][12].scopes).toEqual(["source.python"]); expect(tokens[3][13].value).toBe("in"); - expect(tokens[3][13].scopes).toEqual(["source.python","keyword.operator.logical.python"]); + expect(tokens[3][13].scopes).toEqual(["source.python","keyword.control.flow.python"]); expect(tokens[3][14].value).toBe(" "); expect(tokens[3][14].scopes).toEqual(["source.python"]); expect(tokens[3][15].value).toBe("b"); @@ -8245,6 +9010,67 @@ describe("Grammar Tests", function() { expect(tokens[14][9].scopes).toEqual(["source.python","constant.numeric.dec.python"]); }); + it("test/functions/decl15.py", + function() { + tokens = grammar.tokenizeLines("def showcase(a, b, /, c, d, *, e, f):\n return") + expect(tokens[0][0].value).toBe("def"); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.python","storage.type.function.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.function.python"]); + expect(tokens[0][2].value).toBe("showcase"); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.function.python","entity.name.function.python"]); + expect(tokens[0][3].value).toBe("("); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.definition.parameters.begin.python"]); + expect(tokens[0][4].value).toBe("a"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","variable.parameter.function.language.python"]); + expect(tokens[0][5].value).toBe(","); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.separator.parameters.python"]); + expect(tokens[0][6].value).toBe(" "); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python"]); + expect(tokens[0][7].value).toBe("b"); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","variable.parameter.function.language.python"]); + expect(tokens[0][8].value).toBe(","); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.separator.parameters.python"]); + expect(tokens[0][9].value).toBe(" "); + expect(tokens[0][9].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python"]); + expect(tokens[0][10].value).toBe("/"); + expect(tokens[0][10].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","keyword.operator.positional.parameter.python"]); + expect(tokens[0][11].value).toBe(", "); + expect(tokens[0][11].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python"]); + expect(tokens[0][12].value).toBe("c"); + expect(tokens[0][12].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","variable.parameter.function.language.python"]); + expect(tokens[0][13].value).toBe(","); + expect(tokens[0][13].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.separator.parameters.python"]); + expect(tokens[0][14].value).toBe(" "); + expect(tokens[0][14].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python"]); + expect(tokens[0][15].value).toBe("d"); + expect(tokens[0][15].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","variable.parameter.function.language.python"]); + expect(tokens[0][16].value).toBe(","); + expect(tokens[0][16].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.separator.parameters.python"]); + expect(tokens[0][17].value).toBe(" "); + expect(tokens[0][17].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python"]); + expect(tokens[0][18].value).toBe("*"); + expect(tokens[0][18].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","keyword.operator.unpacking.parameter.python"]); + expect(tokens[0][19].value).toBe(", "); + expect(tokens[0][19].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python"]); + expect(tokens[0][20].value).toBe("e"); + expect(tokens[0][20].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","variable.parameter.function.language.python"]); + expect(tokens[0][21].value).toBe(","); + expect(tokens[0][21].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.separator.parameters.python"]); + expect(tokens[0][22].value).toBe(" "); + expect(tokens[0][22].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python"]); + expect(tokens[0][23].value).toBe("f"); + expect(tokens[0][23].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","variable.parameter.function.language.python"]); + expect(tokens[0][24].value).toBe(")"); + expect(tokens[0][24].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.definition.parameters.end.python"]); + expect(tokens[0][25].value).toBe(":"); + expect(tokens[0][25].scopes).toEqual(["source.python","meta.function.python","punctuation.section.function.begin.python"]); + expect(tokens[1][0].value).toBe(" "); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe("return"); + expect(tokens[1][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + }); + it("test/functions/decl2.py", function() { tokens = grammar.tokenizeLines("def result_annot(lambda, lambda=) -> qqq[None]:\n pass") @@ -8273,7 +9099,7 @@ describe("Grammar Tests", function() { expect(tokens[0][11].value).toBe(" "); expect(tokens[0][11].scopes).toEqual(["source.python","meta.function.python"]); expect(tokens[0][12].value).toBe("qqq"); - expect(tokens[0][12].scopes).toEqual(["source.python","meta.function.python","meta.item-access.python"]); + expect(tokens[0][12].scopes).toEqual(["source.python","meta.function.python","meta.item-access.python","meta.indexed-name.python"]); expect(tokens[0][13].value).toBe("["); expect(tokens[0][13].scopes).toEqual(["source.python","meta.function.python","meta.item-access.python","punctuation.definition.arguments.begin.python"]); expect(tokens[0][14].value).toBe("None"); @@ -8479,7 +9305,7 @@ describe("Grammar Tests", function() { expect(tokens[4][7].value).toBe(" "); expect(tokens[4][7].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python"]); expect(tokens[4][8].value).toBe("in"); - expect(tokens[4][8].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","keyword.operator.logical.python"]); + expect(tokens[4][8].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","keyword.control.flow.python"]); expect(tokens[5][0].value).toBe(" "); expect(tokens[5][0].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python"]); expect(tokens[5][1].value).toBe("("); @@ -8775,7 +9601,7 @@ describe("Grammar Tests", function() { function() { tokens = grammar.tokenizeLines("@some_decorator # with comment\n@some.class.decorator\n@some_decorator(1)\n@some.decorator (1, 3)\n@some_decorator(a=2, b={'q': 42}, **kwargs)\n@classmethod\ndef decorated(a): pass") expect(tokens[0][0].value).toBe("@"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[0][1].value).toBe("some_decorator"); expect(tokens[0][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[0][2].value).toBe(" "); @@ -8785,19 +9611,19 @@ describe("Grammar Tests", function() { expect(tokens[0][4].value).toBe(" with comment"); expect(tokens[0][4].scopes).toEqual(["source.python","comment.line.number-sign.python"]); expect(tokens[1][0].value).toBe("@"); - expect(tokens[1][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[1][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[1][1].value).toBe("some"); expect(tokens[1][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[1][2].value).toBe("."); - expect(tokens[1][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[1][3].value).toBe("class"); expect(tokens[1][3].scopes).toEqual(["source.python","meta.function.decorator.python","keyword.control.flow.python"]); expect(tokens[1][4].value).toBe("."); - expect(tokens[1][4].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[1][5].value).toBe("decorator"); expect(tokens[1][5].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[2][0].value).toBe("@"); - expect(tokens[2][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[2][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[2][1].value).toBe("some_decorator"); expect(tokens[2][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[2][2].value).toBe("("); @@ -8807,11 +9633,11 @@ describe("Grammar Tests", function() { expect(tokens[2][4].value).toBe(")"); expect(tokens[2][4].scopes).toEqual(["source.python","meta.function.decorator.python","punctuation.definition.arguments.end.python"]); expect(tokens[3][0].value).toBe("@"); - expect(tokens[3][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[3][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[3][1].value).toBe("some"); expect(tokens[3][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[3][2].value).toBe("."); - expect(tokens[3][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[3][3].value).toBe("decorator"); expect(tokens[3][3].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[3][4].value).toBe(" "); @@ -8829,7 +9655,7 @@ describe("Grammar Tests", function() { expect(tokens[3][10].value).toBe(")"); expect(tokens[3][10].scopes).toEqual(["source.python","meta.function.decorator.python","punctuation.definition.arguments.end.python"]); expect(tokens[4][0].value).toBe("@"); - expect(tokens[4][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[4][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[4][1].value).toBe("some_decorator"); expect(tokens[4][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[4][2].value).toBe("("); @@ -8875,7 +9701,7 @@ describe("Grammar Tests", function() { expect(tokens[4][22].value).toBe(")"); expect(tokens[4][22].scopes).toEqual(["source.python","meta.function.decorator.python","punctuation.definition.arguments.end.python"]); expect(tokens[5][0].value).toBe("@"); - expect(tokens[5][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[5][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[5][1].value).toBe("classmethod"); expect(tokens[5][1].scopes).toEqual(["source.python","meta.function.decorator.python","support.type.python"]); expect(tokens[6][0].value).toBe("def"); @@ -8902,7 +9728,7 @@ describe("Grammar Tests", function() { function() { tokens = grammar.tokenizeLines("@ f . bar . a . b\ndef foo(): pass") expect(tokens[0][0].value).toBe("@"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[0][1].value).toBe(" "); expect(tokens[0][1].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[0][2].value).toBe("f"); @@ -8910,7 +9736,7 @@ describe("Grammar Tests", function() { expect(tokens[0][3].value).toBe(" "); expect(tokens[0][3].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[0][4].value).toBe("."); - expect(tokens[0][4].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[0][5].value).toBe(" "); expect(tokens[0][5].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[0][6].value).toBe("bar"); @@ -8918,7 +9744,7 @@ describe("Grammar Tests", function() { expect(tokens[0][7].value).toBe(" "); expect(tokens[0][7].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[0][8].value).toBe("."); - expect(tokens[0][8].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[0][9].value).toBe(" "); expect(tokens[0][9].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[0][10].value).toBe("a"); @@ -8926,7 +9752,7 @@ describe("Grammar Tests", function() { expect(tokens[0][11].value).toBe(" "); expect(tokens[0][11].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[0][12].value).toBe("."); - expect(tokens[0][12].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][12].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[0][13].value).toBe(" "); expect(tokens[0][13].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[0][14].value).toBe("b"); @@ -8953,7 +9779,7 @@ describe("Grammar Tests", function() { function() { tokens = grammar.tokenizeLines("@ f . bar (baz = 1)\ndef foo(): pass") expect(tokens[0][0].value).toBe("@"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[0][1].value).toBe(" "); expect(tokens[0][1].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[0][2].value).toBe("f"); @@ -8961,7 +9787,7 @@ describe("Grammar Tests", function() { expect(tokens[0][3].value).toBe(" "); expect(tokens[0][3].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[0][4].value).toBe("."); - expect(tokens[0][4].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[0][5].value).toBe(" "); expect(tokens[0][5].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[0][6].value).toBe("bar"); @@ -9004,23 +9830,23 @@ describe("Grammar Tests", function() { function() { tokens = grammar.tokenizeLines("@a.b.c.None.z\ndef foo(): pass") expect(tokens[0][0].value).toBe("@"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[0][1].value).toBe("a"); expect(tokens[0][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[0][2].value).toBe("."); - expect(tokens[0][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[0][3].value).toBe("b"); expect(tokens[0][3].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[0][4].value).toBe("."); - expect(tokens[0][4].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[0][5].value).toBe("c"); expect(tokens[0][5].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[0][6].value).toBe("."); - expect(tokens[0][6].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[0][7].value).toBe("None"); expect(tokens[0][7].scopes).toEqual(["source.python","meta.function.decorator.python","keyword.illegal.name.python"]); expect(tokens[0][8].value).toBe("."); - expect(tokens[0][8].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[0][9].value).toBe("z"); expect(tokens[0][9].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[1][0].value).toBe("def"); @@ -9045,11 +9871,11 @@ describe("Grammar Tests", function() { function() { tokens = grammar.tokenizeLines("@a. \\\n b . \\\n c.None.z \\\n baz(q=1)\n@foo.ok\ndef foo(): pass") expect(tokens[0][0].value).toBe("@"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[0][1].value).toBe("a"); expect(tokens[0][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[0][2].value).toBe("."); - expect(tokens[0][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[0][3].value).toBe(" "); expect(tokens[0][3].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[0][4].value).toBe("\\"); @@ -9063,7 +9889,7 @@ describe("Grammar Tests", function() { expect(tokens[1][2].value).toBe(" "); expect(tokens[1][2].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[1][3].value).toBe("."); - expect(tokens[1][3].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[1][4].value).toBe(" "); expect(tokens[1][4].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[1][5].value).toBe("\\"); @@ -9075,11 +9901,11 @@ describe("Grammar Tests", function() { expect(tokens[2][1].value).toBe("c"); expect(tokens[2][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[2][2].value).toBe("."); - expect(tokens[2][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[2][3].value).toBe("None"); expect(tokens[2][3].scopes).toEqual(["source.python","meta.function.decorator.python","keyword.illegal.name.python"]); expect(tokens[2][4].value).toBe("."); - expect(tokens[2][4].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[2][5].value).toBe("z"); expect(tokens[2][5].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[2][6].value).toBe(" "); @@ -9103,11 +9929,11 @@ describe("Grammar Tests", function() { expect(tokens[3][6].value).toBe(")"); expect(tokens[3][6].scopes).toEqual(["source.python","meta.function.decorator.python","punctuation.definition.arguments.end.python"]); expect(tokens[4][0].value).toBe("@"); - expect(tokens[4][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[4][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[4][1].value).toBe("foo"); expect(tokens[4][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[4][2].value).toBe("."); - expect(tokens[4][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[4][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[4][3].value).toBe("ok"); expect(tokens[4][3].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[5][0].value).toBe("def"); @@ -9132,11 +9958,11 @@ describe("Grammar Tests", function() { function() { tokens = grammar.tokenizeLines("@a. b . \\\n c.None.z(foo=BAR). \\\n baz[1:2]\n@foo.class.bar[]\n@foo.ok '''\ndef foo(): pass") expect(tokens[0][0].value).toBe("@"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[0][1].value).toBe("a"); expect(tokens[0][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[0][2].value).toBe("."); - expect(tokens[0][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[0][3].value).toBe(" "); expect(tokens[0][3].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[0][4].value).toBe("b"); @@ -9144,7 +9970,7 @@ describe("Grammar Tests", function() { expect(tokens[0][5].value).toBe(" "); expect(tokens[0][5].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[0][6].value).toBe("."); - expect(tokens[0][6].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[0][7].value).toBe(" "); expect(tokens[0][7].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[0][8].value).toBe("\\"); @@ -9156,11 +9982,11 @@ describe("Grammar Tests", function() { expect(tokens[1][1].value).toBe("c"); expect(tokens[1][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[1][2].value).toBe("."); - expect(tokens[1][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[1][3].value).toBe("None"); expect(tokens[1][3].scopes).toEqual(["source.python","meta.function.decorator.python","keyword.illegal.name.python"]); expect(tokens[1][4].value).toBe("."); - expect(tokens[1][4].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[1][5].value).toBe("z"); expect(tokens[1][5].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[1][6].value).toBe("("); @@ -9178,7 +10004,7 @@ describe("Grammar Tests", function() { expect(tokens[2][0].value).toBe(" "); expect(tokens[2][0].scopes).toEqual(["source.python"]); expect(tokens[2][1].value).toBe("baz"); - expect(tokens[2][1].scopes).toEqual(["source.python","meta.item-access.python"]); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.item-access.python","meta.indexed-name.python"]); expect(tokens[2][2].value).toBe("["); expect(tokens[2][2].scopes).toEqual(["source.python","meta.item-access.python","punctuation.definition.arguments.begin.python"]); expect(tokens[2][3].value).toBe("1"); @@ -9190,25 +10016,25 @@ describe("Grammar Tests", function() { expect(tokens[2][6].value).toBe("]"); expect(tokens[2][6].scopes).toEqual(["source.python","meta.item-access.python","punctuation.definition.arguments.end.python"]); expect(tokens[3][0].value).toBe("@"); - expect(tokens[3][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[3][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[3][1].value).toBe("foo"); expect(tokens[3][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[3][2].value).toBe("."); - expect(tokens[3][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[3][3].value).toBe("class"); expect(tokens[3][3].scopes).toEqual(["source.python","meta.function.decorator.python","keyword.control.flow.python"]); expect(tokens[3][4].value).toBe("."); - expect(tokens[3][4].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[3][5].value).toBe("bar"); expect(tokens[3][5].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[3][6].value).toBe("[]"); expect(tokens[3][6].scopes).toEqual(["source.python","meta.function.decorator.python","invalid.illegal.decorator.python","invalid.illegal.decorator.python"]); expect(tokens[4][0].value).toBe("@"); - expect(tokens[4][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[4][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[4][1].value).toBe("foo"); expect(tokens[4][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[4][2].value).toBe("."); - expect(tokens[4][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[4][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.separator.period.python"]); expect(tokens[4][3].value).toBe("ok"); expect(tokens[4][3].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[4][4].value).toBe(" "); @@ -9245,13 +10071,13 @@ describe("Grammar Tests", function() { expect(tokens[1][1].value).toBe(" DO NOT DELETE TRAILING WHITESTAPCE IN THIS FILE"); expect(tokens[1][1].scopes).toEqual(["source.python","comment.line.number-sign.python"]); expect(tokens[2][0].value).toBe("@"); - expect(tokens[2][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[2][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[2][1].value).toBe("foo"); expect(tokens[2][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[2][2].value).toBe(" "); expect(tokens[2][2].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[3][0].value).toBe("@"); - expect(tokens[3][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[3][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[3][1].value).toBe("foo"); expect(tokens[3][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[3][2].value).toBe("("); @@ -9261,13 +10087,13 @@ describe("Grammar Tests", function() { expect(tokens[3][4].value).toBe(" "); expect(tokens[3][4].scopes).toEqual(["source.python"]); expect(tokens[4][0].value).toBe("@"); - expect(tokens[4][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[4][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[4][1].value).toBe("bar"); expect(tokens[4][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[4][2].value).toBe("\t"); expect(tokens[4][2].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[5][0].value).toBe("@"); - expect(tokens[5][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[5][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[5][1].value).toBe("bar"); expect(tokens[5][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[5][2].value).toBe("("); @@ -9277,7 +10103,7 @@ describe("Grammar Tests", function() { expect(tokens[5][4].value).toBe("\t"); expect(tokens[5][4].scopes).toEqual(["source.python"]); expect(tokens[6][0].value).toBe("@"); - expect(tokens[6][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[6][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[6][1].value).toBe("bar"); expect(tokens[6][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[6][2].value).toBe("("); @@ -9293,7 +10119,7 @@ describe("Grammar Tests", function() { expect(tokens[6][7].value).toBe(" legal"); expect(tokens[6][7].scopes).toEqual(["source.python","comment.line.number-sign.python"]); expect(tokens[7][0].value).toBe("@"); - expect(tokens[7][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[7][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[7][1].value).toBe("bar"); expect(tokens[7][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[7][2].value).toBe("("); @@ -9326,7 +10152,7 @@ describe("Grammar Tests", function() { function() { tokens = grammar.tokenizeLines("@deco().abc # SyntaxError: invalid syntax\ndef foo(): pass") expect(tokens[0][0].value).toBe("@"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[0][1].value).toBe("deco"); expect(tokens[0][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[0][2].value).toBe("("); @@ -9376,6 +10202,71 @@ describe("Grammar Tests", function() { expect(tokens[1][3].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); }); + it("test/functions/lambda10.py", + function() { + tokens = grammar.tokenizeLines("showcase = lambda a, /, b, *, c: (a + b + c)") + expect(tokens[0][0].value).toBe("showcase"); + expect(tokens[0][0].scopes).toEqual(["source.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("="); + expect(tokens[0][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("lambda"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.lambda-function.python","storage.type.function.lambda.python"]); + expect(tokens[0][5].value).toBe(" "); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.lambda-function.python","meta.function.lambda.parameters.python"]); + expect(tokens[0][6].value).toBe("a"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.lambda-function.python","meta.function.lambda.parameters.python","variable.parameter.function.language.python"]); + expect(tokens[0][7].value).toBe(","); + expect(tokens[0][7].scopes).toEqual(["source.python","meta.lambda-function.python","meta.function.lambda.parameters.python","punctuation.separator.parameters.python"]); + expect(tokens[0][8].value).toBe(" "); + expect(tokens[0][8].scopes).toEqual(["source.python","meta.lambda-function.python","meta.function.lambda.parameters.python"]); + expect(tokens[0][9].value).toBe("/"); + expect(tokens[0][9].scopes).toEqual(["source.python","meta.lambda-function.python","meta.function.lambda.parameters.python","keyword.operator.positional.parameter.python"]); + expect(tokens[0][10].value).toBe(", "); + expect(tokens[0][10].scopes).toEqual(["source.python","meta.lambda-function.python","meta.function.lambda.parameters.python"]); + expect(tokens[0][11].value).toBe("b"); + expect(tokens[0][11].scopes).toEqual(["source.python","meta.lambda-function.python","meta.function.lambda.parameters.python","variable.parameter.function.language.python"]); + expect(tokens[0][12].value).toBe(","); + expect(tokens[0][12].scopes).toEqual(["source.python","meta.lambda-function.python","meta.function.lambda.parameters.python","punctuation.separator.parameters.python"]); + expect(tokens[0][13].value).toBe(" "); + expect(tokens[0][13].scopes).toEqual(["source.python","meta.lambda-function.python","meta.function.lambda.parameters.python"]); + expect(tokens[0][14].value).toBe("*"); + expect(tokens[0][14].scopes).toEqual(["source.python","meta.lambda-function.python","meta.function.lambda.parameters.python","keyword.operator.unpacking.parameter.python"]); + expect(tokens[0][15].value).toBe(", "); + expect(tokens[0][15].scopes).toEqual(["source.python","meta.lambda-function.python","meta.function.lambda.parameters.python"]); + expect(tokens[0][16].value).toBe("c"); + expect(tokens[0][16].scopes).toEqual(["source.python","meta.lambda-function.python","meta.function.lambda.parameters.python","variable.parameter.function.language.python"]); + expect(tokens[0][17].value).toBe(":"); + expect(tokens[0][17].scopes).toEqual(["source.python","meta.lambda-function.python","punctuation.section.function.lambda.begin.python"]); + expect(tokens[0][18].value).toBe(" "); + expect(tokens[0][18].scopes).toEqual(["source.python"]); + expect(tokens[0][19].value).toBe("("); + expect(tokens[0][19].scopes).toEqual(["source.python","punctuation.parenthesis.begin.python"]); + expect(tokens[0][20].value).toBe("a"); + expect(tokens[0][20].scopes).toEqual(["source.python"]); + expect(tokens[0][21].value).toBe(" "); + expect(tokens[0][21].scopes).toEqual(["source.python"]); + expect(tokens[0][22].value).toBe("+"); + expect(tokens[0][22].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]); + expect(tokens[0][23].value).toBe(" "); + expect(tokens[0][23].scopes).toEqual(["source.python"]); + expect(tokens[0][24].value).toBe("b"); + expect(tokens[0][24].scopes).toEqual(["source.python"]); + expect(tokens[0][25].value).toBe(" "); + expect(tokens[0][25].scopes).toEqual(["source.python"]); + expect(tokens[0][26].value).toBe("+"); + expect(tokens[0][26].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]); + expect(tokens[0][27].value).toBe(" "); + expect(tokens[0][27].scopes).toEqual(["source.python"]); + expect(tokens[0][28].value).toBe("c"); + expect(tokens[0][28].scopes).toEqual(["source.python"]); + expect(tokens[0][29].value).toBe(")"); + expect(tokens[0][29].scopes).toEqual(["source.python","punctuation.parenthesis.end.python"]); + }); + it("test/functions/lambda2.py", function() { tokens = grammar.tokenizeLines("lll(lambda=1)") @@ -9790,7 +10681,7 @@ describe("Grammar Tests", function() { it("test/illegals/backticks3.py", function() { - tokens = grammar.tokenizeLines("a = lambda `123`") + tokens = grammar.tokenizeLines("a = lambda `123`\n# comment") expect(tokens[0][0].value).toBe("a"); expect(tokens[0][0].scopes).toEqual(["source.python"]); expect(tokens[0][1].value).toBe(" "); @@ -9811,6 +10702,10 @@ describe("Grammar Tests", function() { expect(tokens[0][8].scopes).toEqual(["source.python","meta.lambda-function.python","meta.function.lambda.parameters.python","invalid.deprecated.backtick.python"]); expect(tokens[0][9].value).toBe(""); expect(tokens[0][9].scopes).toEqual(["source.python","meta.lambda-function.python"]); + expect(tokens[1][0].value).toBe("#"); + expect(tokens[1][0].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[1][1].value).toBe(" comment"); + expect(tokens[1][1].scopes).toEqual(["source.python","comment.line.number-sign.python"]); }); it("test/illegals/illegal1.py", @@ -9855,19 +10750,19 @@ describe("Grammar Tests", function() { expect(tokens[4][7].value).toBe(")"); expect(tokens[4][7].scopes).toEqual(["source.python","punctuation.parenthesis.end.python"]); expect(tokens[4][8].value).toBe("."); - expect(tokens[4][8].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[4][8].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[4][9].value).toBe("fuuuu"); - expect(tokens[4][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[4][9].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.generic.python"]); expect(tokens[4][10].value).toBe("("); - expect(tokens[4][10].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[4][10].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[4][11].value).toBe("baz"); - expect(tokens[4][11].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[4][11].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); expect(tokens[4][12].value).toBe("="); - expect(tokens[4][12].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[4][12].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); expect(tokens[4][13].value).toBe("1"); - expect(tokens[4][13].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[4][13].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); expect(tokens[4][14].value).toBe(")"); - expect(tokens[4][14].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[4][14].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); expect(tokens[5][0].value).toBe("#"); expect(tokens[5][0].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); expect(tokens[5][1].value).toBe(" we recover just fine"); @@ -10236,9 +11131,9 @@ describe("Grammar Tests", function() { expect(tokens[0][15].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); }); - it("test/regexp/fregexp1.py", + it("test/regexp/python1.py", function() { - tokens = grammar.tokenizeLines("a = fr'[a-z]'\na = Fr'[a-z]'\na = rf'[a-z]'\na = rF'[a-z]'") + tokens = grammar.tokenizeLines("a = r'[a-z]'\na = R'[a-z]'") expect(tokens[0][0].value).toBe("a"); expect(tokens[0][0].scopes).toEqual(["source.python"]); expect(tokens[0][1].value).toBe(" "); @@ -10247,22 +11142,65 @@ describe("Grammar Tests", function() { expect(tokens[0][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); expect(tokens[0][3].value).toBe(" "); expect(tokens[0][3].scopes).toEqual(["source.python"]); - expect(tokens[0][4].value).toBe("fr"); - expect(tokens[0][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","storage.type.string.python"]); + expect(tokens[0][4].value).toBe("r"); + expect(tokens[0][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python","storage.type.string.python"]); expect(tokens[0][5].value).toBe("'"); - expect(tokens[0][5].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","punctuation.definition.string.begin.python"]); + expect(tokens[0][5].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.begin.python"]); expect(tokens[0][6].value).toBe("["); - expect(tokens[0][6].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.begin.regexp"]); + expect(tokens[0][6].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.begin.regexp"]); expect(tokens[0][7].value).toBe("a"); - expect(tokens[0][7].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","meta.character.set.regexp","constant.character.set.regexp"]); + expect(tokens[0][7].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.character.set.regexp","constant.character.set.regexp"]); expect(tokens[0][8].value).toBe("-"); - expect(tokens[0][8].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","meta.character.set.regexp","constant.character.set.regexp"]); + expect(tokens[0][8].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.character.set.regexp","constant.character.set.regexp"]); expect(tokens[0][9].value).toBe("z"); - expect(tokens[0][9].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","meta.character.set.regexp","constant.character.set.regexp"]); + expect(tokens[0][9].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.character.set.regexp","constant.character.set.regexp"]); expect(tokens[0][10].value).toBe("]"); - expect(tokens[0][10].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.end.regexp"]); + expect(tokens[0][10].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.end.regexp"]); expect(tokens[0][11].value).toBe("'"); - expect(tokens[0][11].scopes).toEqual(["source.python","string.regexp.quoted.single.python string.interpolated.python","punctuation.definition.string.end.python"]); + expect(tokens[0][11].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[1][0].value).toBe("a"); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe(" "); + expect(tokens[1][1].scopes).toEqual(["source.python"]); + expect(tokens[1][2].value).toBe("="); + expect(tokens[1][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[1][3].value).toBe(" "); + expect(tokens[1][3].scopes).toEqual(["source.python"]); + expect(tokens[1][4].value).toBe("R"); + expect(tokens[1][4].scopes).toEqual(["source.python","string.quoted.raw.single.python","storage.type.string.python"]); + expect(tokens[1][5].value).toBe("'"); + expect(tokens[1][5].scopes).toEqual(["source.python","string.quoted.raw.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[1][6].value).toBe("[a-z]"); + expect(tokens[1][6].scopes).toEqual(["source.python","string.quoted.raw.single.python"]); + expect(tokens[1][7].value).toBe("'"); + expect(tokens[1][7].scopes).toEqual(["source.python","string.quoted.raw.single.python","punctuation.definition.string.end.python"]); + }); + + it("test/regexp/python10.py", + function() { + tokens = grammar.tokenizeLines("a = r'(<\\' for\na = r\"(<\\\" for\na = r'[<\\' for\na = r\"[<\\\" for\na = r'(?=\\' for\na = r\"(?=\\\" for\na = r'(?P\\' for\na = r\"(?P\\\" for\na = r'(?"); + expect(tokens[6][7].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.named.regexp","entity.name.tag.named.group.regexp"]); + expect(tokens[6][8].value).toBe("\\'"); + expect(tokens[6][8].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.named.regexp","constant.character.escape.regexp"]); + expect(tokens[6][9].value).toBe(" for"); + expect(tokens[6][9].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.named.regexp"]); + expect(tokens[6][10].value).toBe(""); + expect(tokens[6][10].scopes).toEqual(["source.python","string.regexp.quoted.single.python","invalid.illegal.newline.python"]); + expect(tokens[7][0].value).toBe("a"); + expect(tokens[7][0].scopes).toEqual(["source.python"]); + expect(tokens[7][1].value).toBe(" "); + expect(tokens[7][1].scopes).toEqual(["source.python"]); + expect(tokens[7][2].value).toBe("="); + expect(tokens[7][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[7][3].value).toBe(" "); + expect(tokens[7][3].scopes).toEqual(["source.python"]); + expect(tokens[7][4].value).toBe("r"); + expect(tokens[7][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python","storage.type.string.python"]); + expect(tokens[7][5].value).toBe("\""); + expect(tokens[7][5].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[7][6].value).toBe("("); + expect(tokens[7][6].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.named.regexp","punctuation.parenthesis.named.begin.regexp support.other.parenthesis.regexp"]); + expect(tokens[7][7].value).toBe("?P"); + expect(tokens[7][7].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.named.regexp","entity.name.tag.named.group.regexp"]); + expect(tokens[7][8].value).toBe("\\\""); + expect(tokens[7][8].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.named.regexp","constant.character.escape.regexp"]); + expect(tokens[7][9].value).toBe(" for"); + expect(tokens[7][9].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.named.regexp"]); + expect(tokens[7][10].value).toBe(""); + expect(tokens[7][10].scopes).toEqual(["source.python","string.regexp.quoted.single.python","invalid.illegal.newline.python"]); + expect(tokens[8][0].value).toBe("a"); + expect(tokens[8][0].scopes).toEqual(["source.python"]); + expect(tokens[8][1].value).toBe(" "); + expect(tokens[8][1].scopes).toEqual(["source.python"]); + expect(tokens[8][2].value).toBe("="); + expect(tokens[8][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[8][3].value).toBe(" "); + expect(tokens[8][3].scopes).toEqual(["source.python"]); + expect(tokens[8][4].value).toBe("r"); + expect(tokens[8][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python","storage.type.string.python"]); + expect(tokens[8][5].value).toBe("'"); + expect(tokens[8][5].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[8][6].value).toBe("("); + expect(tokens[8][6].scopes).toEqual(["source.python","string.regexp.quoted.single.python","keyword.operator.lookbehind.negative.regexp","punctuation.parenthesis.lookbehind.begin.regexp"]); + expect(tokens[8][7].value).toBe("?\\' for\na = r\"(?P\\\" for\na = r'(?"); - expect(tokens[6][7].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.named.regexp","entity.name.tag.named.group.regexp"]); - expect(tokens[6][8].value).toBe("\\'"); - expect(tokens[6][8].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.named.regexp","constant.character.escape.regexp"]); - expect(tokens[6][9].value).toBe(" for"); - expect(tokens[6][9].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.named.regexp"]); - expect(tokens[6][10].value).toBe(""); - expect(tokens[6][10].scopes).toEqual(["source.python","string.regexp.quoted.single.python","invalid.illegal.newline.python"]); - expect(tokens[7][0].value).toBe("a"); - expect(tokens[7][0].scopes).toEqual(["source.python"]); - expect(tokens[7][1].value).toBe(" "); - expect(tokens[7][1].scopes).toEqual(["source.python"]); - expect(tokens[7][2].value).toBe("="); - expect(tokens[7][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[7][3].value).toBe(" "); - expect(tokens[7][3].scopes).toEqual(["source.python"]); - expect(tokens[7][4].value).toBe("r"); - expect(tokens[7][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python","storage.type.string.python"]); - expect(tokens[7][5].value).toBe("\""); - expect(tokens[7][5].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.begin.python"]); - expect(tokens[7][6].value).toBe("("); - expect(tokens[7][6].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.named.regexp","punctuation.parenthesis.named.begin.regexp support.other.parenthesis.regexp"]); - expect(tokens[7][7].value).toBe("?P"); - expect(tokens[7][7].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.named.regexp","entity.name.tag.named.group.regexp"]); - expect(tokens[7][8].value).toBe("\\\""); - expect(tokens[7][8].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.named.regexp","constant.character.escape.regexp"]); - expect(tokens[7][9].value).toBe(" for"); - expect(tokens[7][9].scopes).toEqual(["source.python","string.regexp.quoted.single.python","meta.named.regexp"]); - expect(tokens[7][10].value).toBe(""); - expect(tokens[7][10].scopes).toEqual(["source.python","string.regexp.quoted.single.python","invalid.illegal.newline.python"]); - expect(tokens[8][0].value).toBe("a"); - expect(tokens[8][0].scopes).toEqual(["source.python"]); - expect(tokens[8][1].value).toBe(" "); - expect(tokens[8][1].scopes).toEqual(["source.python"]); - expect(tokens[8][2].value).toBe("="); - expect(tokens[8][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[8][3].value).toBe(" "); - expect(tokens[8][3].scopes).toEqual(["source.python"]); - expect(tokens[8][4].value).toBe("r"); - expect(tokens[8][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python","storage.type.string.python"]); - expect(tokens[8][5].value).toBe("'"); - expect(tokens[8][5].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.begin.python"]); - expect(tokens[8][6].value).toBe("("); - expect(tokens[8][6].scopes).toEqual(["source.python","string.regexp.quoted.single.python","keyword.operator.lookbehind.negative.regexp","punctuation.parenthesis.lookbehind.begin.regexp"]); - expect(tokens[8][7].value).toBe("? # Start of group 'key'\n [\"\"\" + _LegalKeyChars + r\"\"\"]+? # Any word of at least one letter\n ) # End of group 'key'\n ( # Optional group: there may not be a value.\n \\s*=\\s* # Equal Sign\n (?P # Start of group 'val'\n \"(?:[^\\\\\"]|\\\\.)*\" # Any doublequoted string\n | # or\n \\w{3},\\s[\\w\\d\\s-]{9,11}\\s[\\d:]{8}\\sGMT # Special case for \"expires\" attr\n | # or\n [\"\"\" + _LegalValueChars + r\"\"\"]* # Any word or empty string\n ) # End of group 'val'\n )? # End of optional value group\n \\s* # Any number of spaces.\n (\\s+|;|$) # Ending either at space, semicolon, or EOS.\n \"\"\", re.ASCII) # May be removed if safe.") + expect(tokens[0][0].value).toBe("#"); + expect(tokens[0][0].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[0][1].value).toBe(" And now something fun!"); + expect(tokens[0][1].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[1][0].value).toBe(""); expect(tokens[1][0].scopes).toEqual(["source.python"]); - expect(tokens[1][1].value).toBe("("); - expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.parenthesis.begin.python"]); - expect(tokens[1][2].value).toBe("?"); - expect(tokens[1][2].scopes).toEqual(["source.python","invalid.illegal.operator.python"]); - expect(tokens[1][3].value).toBe("x"); - expect(tokens[1][3].scopes).toEqual(["source.python"]); - expect(tokens[1][4].value).toBe(")"); - expect(tokens[1][4].scopes).toEqual(["source.python","punctuation.parenthesis.end.python"]); - expect(tokens[2][0].value).toBe(" "); + expect(tokens[2][0].value).toBe("CookiePattern"); expect(tokens[2][0].scopes).toEqual(["source.python"]); - expect(tokens[2][1].value).toBe("foo"); + expect(tokens[2][1].value).toBe(" "); expect(tokens[2][1].scopes).toEqual(["source.python"]); - expect(tokens[3][0].value).toBe("'"); - expect(tokens[3][0].scopes).toEqual(["source.python","string.quoted.docstring.single.python","punctuation.definition.string.begin.python"]); - expect(tokens[3][1].value).toBe(""); - expect(tokens[3][1].scopes).toEqual(["source.python","string.quoted.docstring.single.python","invalid.illegal.newline.python"]); - }); - - it("test/regexp/python3.py", - function() { - tokens = grammar.tokenizeLines("a = r'''\n (?x)\n foo\n'''\na = br'''\n (?x)\n foo\n'''\na = rb'''\n (?x)\n foo\n'''\na = Br'''\n (?x)\n foo\n'''\na = rB'''\n (?x)\n foo\n'''") - expect(tokens[0][0].value).toBe("a"); - expect(tokens[0][0].scopes).toEqual(["source.python"]); - expect(tokens[0][1].value).toBe(" "); - expect(tokens[0][1].scopes).toEqual(["source.python"]); - expect(tokens[0][2].value).toBe("="); - expect(tokens[0][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[0][3].value).toBe(" "); - expect(tokens[0][3].scopes).toEqual(["source.python"]); - expect(tokens[0][4].value).toBe("r"); - expect(tokens[0][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[0][5].value).toBe("'''"); - expect(tokens[0][5].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); - expect(tokens[1][0].value).toBe(" "); - expect(tokens[1][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[1][1].value).toBe("(?x)"); - expect(tokens[1][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.modifier.flag.regexp"]); - expect(tokens[2][0].value).toBe(" foo"); - expect(tokens[2][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[3][0].value).toBe("'''"); - expect(tokens[3][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); - expect(tokens[4][0].value).toBe("a"); - expect(tokens[4][0].scopes).toEqual(["source.python"]); - expect(tokens[4][1].value).toBe(" "); - expect(tokens[4][1].scopes).toEqual(["source.python"]); - expect(tokens[4][2].value).toBe("="); - expect(tokens[4][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[4][3].value).toBe(" "); - expect(tokens[4][3].scopes).toEqual(["source.python"]); - expect(tokens[4][4].value).toBe("br"); - expect(tokens[4][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[4][5].value).toBe("'''"); - expect(tokens[4][5].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); + expect(tokens[2][2].value).toBe("="); + expect(tokens[2][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[2][3].value).toBe(" "); + expect(tokens[2][3].scopes).toEqual(["source.python"]); + expect(tokens[2][4].value).toBe("re"); + expect(tokens[2][4].scopes).toEqual(["source.python"]); + expect(tokens[2][5].value).toBe("."); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); + expect(tokens[2][6].value).toBe("compile"); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[2][7].value).toBe("("); + expect(tokens[2][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[2][8].value).toBe("r"); + expect(tokens[2][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","storage.type.string.python"]); + expect(tokens[2][9].value).toBe("\"\"\""); + expect(tokens[2][9].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); + expect(tokens[3][0].value).toBe(" "); + expect(tokens[3][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[3][1].value).toBe("(?x)"); + expect(tokens[3][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","storage.modifier.flag.regexp"]); + expect(tokens[3][2].value).toBe(" "); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[3][3].value).toBe("#"); + expect(tokens[3][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[3][4].value).toBe(" This is a verbose pattern"); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); + expect(tokens[4][0].value).toBe(" "); + expect(tokens[4][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[4][1].value).toBe("\\s"); + expect(tokens[4][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","support.other.escape.special.regexp"]); + expect(tokens[4][2].value).toBe("*"); + expect(tokens[4][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); + expect(tokens[4][3].value).toBe(" "); + expect(tokens[4][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[4][4].value).toBe("#"); + expect(tokens[4][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[4][5].value).toBe(" Optional whitespace at start of cookie"); + expect(tokens[4][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); expect(tokens[5][0].value).toBe(" "); - expect(tokens[5][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[5][1].value).toBe("(?x)"); - expect(tokens[5][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.modifier.flag.regexp"]); - expect(tokens[6][0].value).toBe(" foo"); - expect(tokens[6][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[7][0].value).toBe("'''"); - expect(tokens[7][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); - expect(tokens[8][0].value).toBe("a"); - expect(tokens[8][0].scopes).toEqual(["source.python"]); - expect(tokens[8][1].value).toBe(" "); - expect(tokens[8][1].scopes).toEqual(["source.python"]); - expect(tokens[8][2].value).toBe("="); - expect(tokens[8][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[8][3].value).toBe(" "); - expect(tokens[8][3].scopes).toEqual(["source.python"]); - expect(tokens[8][4].value).toBe("rb"); - expect(tokens[8][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[8][5].value).toBe("'''"); - expect(tokens[8][5].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); + expect(tokens[5][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[5][1].value).toBe("("); + expect(tokens[5][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","punctuation.parenthesis.named.begin.regexp support.other.parenthesis.regexp"]); + expect(tokens[5][2].value).toBe("?P"); + expect(tokens[5][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","entity.name.tag.named.group.regexp"]); + expect(tokens[5][3].value).toBe(" "); + expect(tokens[5][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); + expect(tokens[5][4].value).toBe("#"); + expect(tokens[5][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[5][5].value).toBe(" Start of group 'key'"); + expect(tokens[5][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python"]); + expect(tokens[6][0].value).toBe(" "); + expect(tokens[6][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); + expect(tokens[6][1].value).toBe("["); + expect(tokens[6][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.begin.regexp"]); + expect(tokens[6][2].value).toBe("\"\"\""); + expect(tokens[6][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); + expect(tokens[6][3].value).toBe(" "); + expect(tokens[6][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[6][4].value).toBe("+"); + expect(tokens[6][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.arithmetic.python"]); + expect(tokens[6][5].value).toBe(" "); + expect(tokens[6][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[6][6].value).toBe("_LegalKeyChars"); + expect(tokens[6][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[6][7].value).toBe(" "); + expect(tokens[6][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[6][8].value).toBe("+"); + expect(tokens[6][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.arithmetic.python"]); + expect(tokens[6][9].value).toBe(" "); + expect(tokens[6][9].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[6][10].value).toBe("r"); + expect(tokens[6][10].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","storage.type.string.python"]); + expect(tokens[6][11].value).toBe("\"\"\""); + expect(tokens[6][11].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); + expect(tokens[6][12].value).toBe("]"); + expect(tokens[6][12].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[6][13].value).toBe("+?"); + expect(tokens[6][13].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); + expect(tokens[6][14].value).toBe(" "); + expect(tokens[6][14].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[6][15].value).toBe("#"); + expect(tokens[6][15].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[6][16].value).toBe(" Any word of at least one letter"); + expect(tokens[6][16].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); + expect(tokens[7][0].value).toBe(" ) "); + expect(tokens[7][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[7][1].value).toBe("#"); + expect(tokens[7][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[7][2].value).toBe(" End of group 'key'"); + expect(tokens[7][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); + expect(tokens[8][0].value).toBe(" "); + expect(tokens[8][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[8][1].value).toBe("("); + expect(tokens[8][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.parenthesis.begin.regexp support.other.parenthesis.regexp"]); + expect(tokens[8][2].value).toBe(" "); + expect(tokens[8][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[8][3].value).toBe("#"); + expect(tokens[8][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[8][4].value).toBe(" Optional group: there may not be a value."); + expect(tokens[8][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); expect(tokens[9][0].value).toBe(" "); - expect(tokens[9][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[9][1].value).toBe("(?x)"); - expect(tokens[9][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.modifier.flag.regexp"]); - expect(tokens[10][0].value).toBe(" foo"); - expect(tokens[10][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[11][0].value).toBe("'''"); - expect(tokens[11][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); - expect(tokens[12][0].value).toBe("a"); - expect(tokens[12][0].scopes).toEqual(["source.python"]); - expect(tokens[12][1].value).toBe(" "); - expect(tokens[12][1].scopes).toEqual(["source.python"]); - expect(tokens[12][2].value).toBe("="); - expect(tokens[12][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[12][3].value).toBe(" "); - expect(tokens[12][3].scopes).toEqual(["source.python"]); - expect(tokens[12][4].value).toBe("Br"); - expect(tokens[12][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[12][5].value).toBe("'''"); - expect(tokens[12][5].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); + expect(tokens[9][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[9][1].value).toBe("\\s"); + expect(tokens[9][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","support.other.escape.special.regexp"]); + expect(tokens[9][2].value).toBe("*"); + expect(tokens[9][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); + expect(tokens[9][3].value).toBe("="); + expect(tokens[9][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[9][4].value).toBe("\\s"); + expect(tokens[9][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","support.other.escape.special.regexp"]); + expect(tokens[9][5].value).toBe("*"); + expect(tokens[9][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); + expect(tokens[9][6].value).toBe(" "); + expect(tokens[9][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[9][7].value).toBe("#"); + expect(tokens[9][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[9][8].value).toBe(" Equal Sign"); + expect(tokens[9][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); + expect(tokens[10][0].value).toBe(" "); + expect(tokens[10][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[10][1].value).toBe("("); + expect(tokens[10][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","punctuation.parenthesis.named.begin.regexp support.other.parenthesis.regexp"]); + expect(tokens[10][2].value).toBe("?P"); + expect(tokens[10][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","entity.name.tag.named.group.regexp"]); + expect(tokens[10][3].value).toBe(" "); + expect(tokens[10][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); + expect(tokens[10][4].value).toBe("#"); + expect(tokens[10][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[10][5].value).toBe(" Start of group 'val'"); + expect(tokens[10][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python"]); + expect(tokens[11][0].value).toBe(" \""); + expect(tokens[11][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); + expect(tokens[11][1].value).toBe("(?:"); + expect(tokens[11][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","punctuation.parenthesis.non-capturing.begin.regexp support.other.parenthesis.regexp"]); + expect(tokens[11][2].value).toBe("["); + expect(tokens[11][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.begin.regexp"]); + expect(tokens[11][3].value).toBe("^"); + expect(tokens[11][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","keyword.operator.negation.regexp"]); + expect(tokens[11][4].value).toBe("\\\\"); + expect(tokens[11][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.character.escape.regexp"]); + expect(tokens[11][5].value).toBe("\""); + expect(tokens[11][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.character.set.regexp"]); + expect(tokens[11][6].value).toBe("]"); + expect(tokens[11][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.end.regexp"]); + expect(tokens[11][7].value).toBe("|"); + expect(tokens[11][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","keyword.operator.disjunction.regexp"]); + expect(tokens[11][8].value).toBe("\\\\"); + expect(tokens[11][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","constant.character.escape.regexp"]); + expect(tokens[11][9].value).toBe("."); + expect(tokens[11][9].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","support.other.match.any.regexp"]); + expect(tokens[11][10].value).toBe(")"); + expect(tokens[11][10].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","punctuation.parenthesis.non-capturing.end.regexp support.other.parenthesis.regexp"]); + expect(tokens[11][11].value).toBe("*"); + expect(tokens[11][11].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","keyword.operator.quantifier.regexp"]); + expect(tokens[11][12].value).toBe("\" "); + expect(tokens[11][12].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); + expect(tokens[11][13].value).toBe("#"); + expect(tokens[11][13].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[11][14].value).toBe(" Any doublequoted string"); + expect(tokens[11][14].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python"]); + expect(tokens[12][0].value).toBe(" "); + expect(tokens[12][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); + expect(tokens[12][1].value).toBe("|"); + expect(tokens[12][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","keyword.operator.disjunction.regexp"]); + expect(tokens[12][2].value).toBe(" "); + expect(tokens[12][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); + expect(tokens[12][3].value).toBe("#"); + expect(tokens[12][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[12][4].value).toBe(" or"); + expect(tokens[12][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python"]); expect(tokens[13][0].value).toBe(" "); - expect(tokens[13][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[13][1].value).toBe("(?x)"); - expect(tokens[13][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.modifier.flag.regexp"]); - expect(tokens[14][0].value).toBe(" foo"); - expect(tokens[14][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[15][0].value).toBe("'''"); - expect(tokens[15][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); - expect(tokens[16][0].value).toBe("a"); - expect(tokens[16][0].scopes).toEqual(["source.python"]); - expect(tokens[16][1].value).toBe(" "); - expect(tokens[16][1].scopes).toEqual(["source.python"]); - expect(tokens[16][2].value).toBe("="); - expect(tokens[16][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[16][3].value).toBe(" "); - expect(tokens[16][3].scopes).toEqual(["source.python"]); - expect(tokens[16][4].value).toBe("rB"); - expect(tokens[16][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[16][5].value).toBe("'''"); - expect(tokens[16][5].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); - expect(tokens[17][0].value).toBe(" "); - expect(tokens[17][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[17][1].value).toBe("(?x)"); - expect(tokens[17][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.modifier.flag.regexp"]); - expect(tokens[18][0].value).toBe(" foo"); - expect(tokens[18][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[19][0].value).toBe("'''"); - expect(tokens[19][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); + expect(tokens[13][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); + expect(tokens[13][1].value).toBe("\\w"); + expect(tokens[13][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","support.other.escape.special.regexp"]); + expect(tokens[13][2].value).toBe("{3}"); + expect(tokens[13][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","keyword.operator.quantifier.regexp"]); + expect(tokens[13][3].value).toBe(","); + expect(tokens[13][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); + expect(tokens[13][4].value).toBe("\\s"); + expect(tokens[13][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","support.other.escape.special.regexp"]); + expect(tokens[13][5].value).toBe("["); + expect(tokens[13][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.begin.regexp"]); + expect(tokens[13][6].value).toBe("\\w"); + expect(tokens[13][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","support.other.escape.special.regexp"]); + expect(tokens[13][7].value).toBe("\\d"); + expect(tokens[13][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","support.other.escape.special.regexp"]); + expect(tokens[13][8].value).toBe("\\s"); + expect(tokens[13][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","support.other.escape.special.regexp"]); + expect(tokens[13][9].value).toBe("-"); + expect(tokens[13][9].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.character.set.regexp"]); + expect(tokens[13][10].value).toBe("]"); + expect(tokens[13][10].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.end.regexp"]); + expect(tokens[13][11].value).toBe("{9,11}"); + expect(tokens[13][11].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","keyword.operator.quantifier.regexp"]); + expect(tokens[13][12].value).toBe("\\s"); + expect(tokens[13][12].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","support.other.escape.special.regexp"]); + expect(tokens[13][13].value).toBe("["); + expect(tokens[13][13].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.begin.regexp"]); + expect(tokens[13][14].value).toBe("\\d"); + expect(tokens[13][14].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","support.other.escape.special.regexp"]); + expect(tokens[13][15].value).toBe(":"); + expect(tokens[13][15].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.character.set.regexp"]); + expect(tokens[13][16].value).toBe("]"); + expect(tokens[13][16].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.end.regexp"]); + expect(tokens[13][17].value).toBe("{8}"); + expect(tokens[13][17].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","keyword.operator.quantifier.regexp"]); + expect(tokens[13][18].value).toBe("\\s"); + expect(tokens[13][18].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","support.other.escape.special.regexp"]); + expect(tokens[13][19].value).toBe("GMT "); + expect(tokens[13][19].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); + expect(tokens[13][20].value).toBe("#"); + expect(tokens[13][20].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[13][21].value).toBe(" Special case for \"expires\" attr"); + expect(tokens[13][21].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python"]); + expect(tokens[14][0].value).toBe(" "); + expect(tokens[14][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); + expect(tokens[14][1].value).toBe("|"); + expect(tokens[14][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","keyword.operator.disjunction.regexp"]); + expect(tokens[14][2].value).toBe(" "); + expect(tokens[14][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); + expect(tokens[14][3].value).toBe("#"); + expect(tokens[14][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[14][4].value).toBe(" or"); + expect(tokens[14][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python"]); + expect(tokens[15][0].value).toBe(" "); + expect(tokens[15][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); + expect(tokens[15][1].value).toBe("["); + expect(tokens[15][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.begin.regexp"]); + expect(tokens[15][2].value).toBe("\"\"\""); + expect(tokens[15][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); + expect(tokens[15][3].value).toBe(" "); + expect(tokens[15][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[15][4].value).toBe("+"); + expect(tokens[15][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.arithmetic.python"]); + expect(tokens[15][5].value).toBe(" "); + expect(tokens[15][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[15][6].value).toBe("_LegalValueChars"); + expect(tokens[15][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[15][7].value).toBe(" "); + expect(tokens[15][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[15][8].value).toBe("+"); + expect(tokens[15][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.arithmetic.python"]); + expect(tokens[15][9].value).toBe(" "); + expect(tokens[15][9].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[15][10].value).toBe("r"); + expect(tokens[15][10].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","storage.type.string.python"]); + expect(tokens[15][11].value).toBe("\"\"\""); + expect(tokens[15][11].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); + expect(tokens[15][12].value).toBe("]"); + expect(tokens[15][12].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[15][13].value).toBe("*"); + expect(tokens[15][13].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); + expect(tokens[15][14].value).toBe(" "); + expect(tokens[15][14].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[15][15].value).toBe("#"); + expect(tokens[15][15].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[15][16].value).toBe(" Any word or empty string"); + expect(tokens[15][16].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); + expect(tokens[16][0].value).toBe(" ) "); + expect(tokens[16][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[16][1].value).toBe("#"); + expect(tokens[16][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[16][2].value).toBe(" End of group 'val'"); + expect(tokens[16][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); + expect(tokens[17][0].value).toBe(" )"); + expect(tokens[17][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[17][1].value).toBe("?"); + expect(tokens[17][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); + expect(tokens[17][2].value).toBe(" "); + expect(tokens[17][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[17][3].value).toBe("#"); + expect(tokens[17][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[17][4].value).toBe(" End of optional value group"); + expect(tokens[17][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); + expect(tokens[18][0].value).toBe(" "); + expect(tokens[18][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[18][1].value).toBe("\\s"); + expect(tokens[18][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","support.other.escape.special.regexp"]); + expect(tokens[18][2].value).toBe("*"); + expect(tokens[18][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); + expect(tokens[18][3].value).toBe(" "); + expect(tokens[18][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[18][4].value).toBe("#"); + expect(tokens[18][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[18][5].value).toBe(" Any number of spaces."); + expect(tokens[18][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); + expect(tokens[19][0].value).toBe(" "); + expect(tokens[19][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[19][1].value).toBe("("); + expect(tokens[19][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.parenthesis.begin.regexp support.other.parenthesis.regexp"]); + expect(tokens[19][2].value).toBe("\\s"); + expect(tokens[19][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","support.other.escape.special.regexp"]); + expect(tokens[19][3].value).toBe("+"); + expect(tokens[19][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); + expect(tokens[19][4].value).toBe("|"); + expect(tokens[19][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.disjunction.regexp"]); + expect(tokens[19][5].value).toBe(";"); + expect(tokens[19][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[19][6].value).toBe("|"); + expect(tokens[19][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.disjunction.regexp"]); + expect(tokens[19][7].value).toBe("$"); + expect(tokens[19][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","support.other.match.end.regexp"]); + expect(tokens[19][8].value).toBe(")"); + expect(tokens[19][8].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.parenthesis.end.regexp support.other.parenthesis.regexp"]); + expect(tokens[19][9].value).toBe(" "); + expect(tokens[19][9].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[19][10].value).toBe("#"); + expect(tokens[19][10].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[19][11].value).toBe(" Ending either at space, semicolon, or EOS."); + expect(tokens[19][11].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); + expect(tokens[20][0].value).toBe(" "); + expect(tokens[20][0].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); + expect(tokens[20][1].value).toBe("\"\"\""); + expect(tokens[20][1].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); + expect(tokens[20][2].value).toBe(","); + expect(tokens[20][2].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[20][3].value).toBe(" "); + expect(tokens[20][3].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[20][4].value).toBe("re"); + expect(tokens[20][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[20][5].value).toBe("."); + expect(tokens[20][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.member.access.python","punctuation.separator.period.python"]); + expect(tokens[20][6].value).toBe("ASCII"); + expect(tokens[20][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","meta.member.access.python","constant.other.caps.python"]); + expect(tokens[20][7].value).toBe(")"); + expect(tokens[20][7].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[20][8].value).toBe(" "); + expect(tokens[20][8].scopes).toEqual(["source.python"]); + expect(tokens[20][9].value).toBe("#"); + expect(tokens[20][9].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[20][10].value).toBe(" May be removed if safe."); + expect(tokens[20][10].scopes).toEqual(["source.python","comment.line.number-sign.python"]); }); - it("test/regexp/python4.py", + it("test/regexp/python9.py", function() { - tokens = grammar.tokenizeLines("a = r\"\"\"\n (?x)\n foo\n\"\"\"\na = br\"\"\"\n (?x)\n foo\n\"\"\"\na = rb\"\"\"\n (?x)\n foo\n\"\"\"\na = Br\"\"\"\n (?x)\n foo\n\"\"\"\na = rB\"\"\"\n (?x)\n foo\n\"\"\"") + tokens = grammar.tokenizeLines("a = r'foo[^]'\na = r'foo[]'") expect(tokens[0][0].value).toBe("a"); expect(tokens[0][0].scopes).toEqual(["source.python"]); expect(tokens[0][1].value).toBe(" "); @@ -11103,103 +12313,158 @@ describe("Grammar Tests", function() { expect(tokens[0][3].value).toBe(" "); expect(tokens[0][3].scopes).toEqual(["source.python"]); expect(tokens[0][4].value).toBe("r"); - expect(tokens[0][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[0][5].value).toBe("\"\"\""); - expect(tokens[0][5].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); - expect(tokens[1][0].value).toBe(" "); - expect(tokens[1][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[1][1].value).toBe("(?x)"); - expect(tokens[1][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.modifier.flag.regexp"]); - expect(tokens[2][0].value).toBe(" foo"); - expect(tokens[2][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[3][0].value).toBe("\"\"\""); - expect(tokens[3][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); - expect(tokens[4][0].value).toBe("a"); - expect(tokens[4][0].scopes).toEqual(["source.python"]); - expect(tokens[4][1].value).toBe(" "); - expect(tokens[4][1].scopes).toEqual(["source.python"]); - expect(tokens[4][2].value).toBe("="); - expect(tokens[4][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[4][3].value).toBe(" "); - expect(tokens[4][3].scopes).toEqual(["source.python"]); - expect(tokens[4][4].value).toBe("br"); - expect(tokens[4][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[4][5].value).toBe("\"\"\""); - expect(tokens[4][5].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); - expect(tokens[5][0].value).toBe(" "); - expect(tokens[5][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[5][1].value).toBe("(?x)"); - expect(tokens[5][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.modifier.flag.regexp"]); - expect(tokens[6][0].value).toBe(" foo"); - expect(tokens[6][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[7][0].value).toBe("\"\"\""); - expect(tokens[7][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); - expect(tokens[8][0].value).toBe("a"); - expect(tokens[8][0].scopes).toEqual(["source.python"]); - expect(tokens[8][1].value).toBe(" "); - expect(tokens[8][1].scopes).toEqual(["source.python"]); - expect(tokens[8][2].value).toBe("="); - expect(tokens[8][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[8][3].value).toBe(" "); - expect(tokens[8][3].scopes).toEqual(["source.python"]); - expect(tokens[8][4].value).toBe("rb"); - expect(tokens[8][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[8][5].value).toBe("\"\"\""); - expect(tokens[8][5].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); - expect(tokens[9][0].value).toBe(" "); - expect(tokens[9][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[9][1].value).toBe("(?x)"); - expect(tokens[9][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.modifier.flag.regexp"]); - expect(tokens[10][0].value).toBe(" foo"); - expect(tokens[10][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[11][0].value).toBe("\"\"\""); - expect(tokens[11][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); - expect(tokens[12][0].value).toBe("a"); - expect(tokens[12][0].scopes).toEqual(["source.python"]); - expect(tokens[12][1].value).toBe(" "); - expect(tokens[12][1].scopes).toEqual(["source.python"]); - expect(tokens[12][2].value).toBe("="); - expect(tokens[12][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[12][3].value).toBe(" "); - expect(tokens[12][3].scopes).toEqual(["source.python"]); - expect(tokens[12][4].value).toBe("Br"); - expect(tokens[12][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[12][5].value).toBe("\"\"\""); - expect(tokens[12][5].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); - expect(tokens[13][0].value).toBe(" "); - expect(tokens[13][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[13][1].value).toBe("(?x)"); - expect(tokens[13][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.modifier.flag.regexp"]); - expect(tokens[14][0].value).toBe(" foo"); - expect(tokens[14][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[15][0].value).toBe("\"\"\""); - expect(tokens[15][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); - expect(tokens[16][0].value).toBe("a"); - expect(tokens[16][0].scopes).toEqual(["source.python"]); - expect(tokens[16][1].value).toBe(" "); - expect(tokens[16][1].scopes).toEqual(["source.python"]); - expect(tokens[16][2].value).toBe("="); - expect(tokens[16][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[16][3].value).toBe(" "); - expect(tokens[16][3].scopes).toEqual(["source.python"]); - expect(tokens[16][4].value).toBe("rB"); - expect(tokens[16][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[16][5].value).toBe("\"\"\""); - expect(tokens[16][5].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); - expect(tokens[17][0].value).toBe(" "); - expect(tokens[17][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[17][1].value).toBe("(?x)"); - expect(tokens[17][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.modifier.flag.regexp"]); - expect(tokens[18][0].value).toBe(" foo"); - expect(tokens[18][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[19][0].value).toBe("\"\"\""); - expect(tokens[19][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); + expect(tokens[0][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python","storage.type.string.python"]); + expect(tokens[0][5].value).toBe("'"); + expect(tokens[0][5].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[0][6].value).toBe("foo"); + expect(tokens[0][6].scopes).toEqual(["source.python","string.regexp.quoted.single.python"]); + expect(tokens[0][7].value).toBe("[^]"); + expect(tokens[0][7].scopes).toEqual(["source.python","string.regexp.quoted.single.python"]); + expect(tokens[0][8].value).toBe("'"); + expect(tokens[0][8].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[1][0].value).toBe("a"); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe(" "); + expect(tokens[1][1].scopes).toEqual(["source.python"]); + expect(tokens[1][2].value).toBe("="); + expect(tokens[1][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[1][3].value).toBe(" "); + expect(tokens[1][3].scopes).toEqual(["source.python"]); + expect(tokens[1][4].value).toBe("r"); + expect(tokens[1][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python","storage.type.string.python"]); + expect(tokens[1][5].value).toBe("'"); + expect(tokens[1][5].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[1][6].value).toBe("foo"); + expect(tokens[1][6].scopes).toEqual(["source.python","string.regexp.quoted.single.python"]); + expect(tokens[1][7].value).toBe("[]"); + expect(tokens[1][7].scopes).toEqual(["source.python","string.regexp.quoted.single.python"]); + expect(tokens[1][8].value).toBe("'"); + expect(tokens[1][8].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.end.python"]); + }); + + it("test/semicolon/semi1.py", + function() { + tokens = grammar.tokenizeLines("a;\n;\na=1; b") + expect(tokens[0][0].value).toBe("a"); + expect(tokens[0][0].scopes).toEqual(["source.python"]); + expect(tokens[0][1].value).toBe(";"); + expect(tokens[0][1].scopes).toEqual(["source.python","invalid.deprecated.semicolon.python"]); + expect(tokens[1][0].value).toBe(";"); + expect(tokens[1][0].scopes).toEqual(["source.python","invalid.deprecated.semicolon.python"]); + expect(tokens[2][0].value).toBe("a"); + expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[2][1].value).toBe("="); + expect(tokens[2][1].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[2][2].value).toBe("1"); + expect(tokens[2][2].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[2][3].value).toBe("; "); + expect(tokens[2][3].scopes).toEqual(["source.python"]); + expect(tokens[2][4].value).toBe("b"); + expect(tokens[2][4].scopes).toEqual(["source.python"]); + }); + + it("test/statements/annotation1.py", + function() { + tokens = grammar.tokenizeLines("some_number: int # variable without initial value\nsome_list: List[int] = [] # variable with initial value") + expect(tokens[0][0].value).toBe("some_number"); + expect(tokens[0][0].scopes).toEqual(["source.python"]); + expect(tokens[0][1].value).toBe(":"); + expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[0][2].value).toBe(" "); + expect(tokens[0][2].scopes).toEqual(["source.python"]); + expect(tokens[0][3].value).toBe("int"); + expect(tokens[0][3].scopes).toEqual(["source.python","support.type.python"]); + expect(tokens[0][4].value).toBe(" "); + expect(tokens[0][4].scopes).toEqual(["source.python"]); + expect(tokens[0][5].value).toBe("#"); + expect(tokens[0][5].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[0][6].value).toBe(" variable without initial value"); + expect(tokens[0][6].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[1][0].value).toBe("some_list"); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe(":"); + expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[1][2].value).toBe(" "); + expect(tokens[1][2].scopes).toEqual(["source.python"]); + expect(tokens[1][3].value).toBe("List"); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.item-access.python","meta.indexed-name.python"]); + expect(tokens[1][4].value).toBe("["); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.item-access.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[1][5].value).toBe("int"); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.item-access.python","meta.item-access.arguments.python","support.type.python"]); + expect(tokens[1][6].value).toBe("]"); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.item-access.python","punctuation.definition.arguments.end.python"]); + expect(tokens[1][7].value).toBe(" "); + expect(tokens[1][7].scopes).toEqual(["source.python"]); + expect(tokens[1][8].value).toBe("="); + expect(tokens[1][8].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[1][9].value).toBe(" "); + expect(tokens[1][9].scopes).toEqual(["source.python"]); + expect(tokens[1][10].value).toBe("["); + expect(tokens[1][10].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); + expect(tokens[1][11].value).toBe("]"); + expect(tokens[1][11].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); + expect(tokens[1][12].value).toBe(" "); + expect(tokens[1][12].scopes).toEqual(["source.python"]); + expect(tokens[1][13].value).toBe("#"); + expect(tokens[1][13].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[1][14].value).toBe(" variable with initial value"); + expect(tokens[1][14].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + }); + + it("test/statements/for1.py", + function() { + tokens = grammar.tokenizeLines("for a, b, c in b:\n pass\nelse:\n 1/0") + expect(tokens[0][0].value).toBe("for"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("a"); + expect(tokens[0][2].scopes).toEqual(["source.python"]); + expect(tokens[0][3].value).toBe(","); + expect(tokens[0][3].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[0][4].value).toBe(" "); + expect(tokens[0][4].scopes).toEqual(["source.python"]); + expect(tokens[0][5].value).toBe("b"); + expect(tokens[0][5].scopes).toEqual(["source.python"]); + expect(tokens[0][6].value).toBe(","); + expect(tokens[0][6].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[0][7].value).toBe(" "); + expect(tokens[0][7].scopes).toEqual(["source.python"]); + expect(tokens[0][8].value).toBe("c"); + expect(tokens[0][8].scopes).toEqual(["source.python"]); + expect(tokens[0][9].value).toBe(" "); + expect(tokens[0][9].scopes).toEqual(["source.python"]); + expect(tokens[0][10].value).toBe("in"); + expect(tokens[0][10].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[0][11].value).toBe(" "); + expect(tokens[0][11].scopes).toEqual(["source.python"]); + expect(tokens[0][12].value).toBe("b"); + expect(tokens[0][12].scopes).toEqual(["source.python"]); + expect(tokens[0][13].value).toBe(":"); + expect(tokens[0][13].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[1][0].value).toBe(" "); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe("pass"); + expect(tokens[1][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[2][0].value).toBe("else"); + expect(tokens[2][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[2][1].value).toBe(":"); + expect(tokens[2][1].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[3][0].value).toBe(" "); + expect(tokens[3][0].scopes).toEqual(["source.python"]); + expect(tokens[3][1].value).toBe("1"); + expect(tokens[3][1].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[3][2].value).toBe("/"); + expect(tokens[3][2].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]); + expect(tokens[3][3].value).toBe("0"); + expect(tokens[3][3].scopes).toEqual(["source.python","constant.numeric.dec.python"]); }); - it("test/regexp/python5.py", + it("test/statements/for2.py", function() { - tokens = grammar.tokenizeLines("a = r'foo#not a comment'\na = r'''\n (?x) # multi-line regexp\n foo # comment\n'''\na = R'''\n (?x) # not a\n foo # comment\n'''") - expect(tokens[0][0].value).toBe("a"); + tokens = grammar.tokenizeLines("forvariable = None\nfor a, b, c, invariable in [2 in q, 2 in w]:\n pass") + expect(tokens[0][0].value).toBe("forvariable"); expect(tokens[0][0].scopes).toEqual(["source.python"]); expect(tokens[0][1].value).toBe(" "); expect(tokens[0][1].scopes).toEqual(["source.python"]); @@ -11207,1121 +12472,1904 @@ describe("Grammar Tests", function() { expect(tokens[0][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); expect(tokens[0][3].value).toBe(" "); expect(tokens[0][3].scopes).toEqual(["source.python"]); - expect(tokens[0][4].value).toBe("r"); - expect(tokens[0][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python","storage.type.string.python"]); - expect(tokens[0][5].value).toBe("'"); - expect(tokens[0][5].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.begin.python"]); - expect(tokens[0][6].value).toBe("foo#not a comment"); - expect(tokens[0][6].scopes).toEqual(["source.python","string.regexp.quoted.single.python"]); - expect(tokens[0][7].value).toBe("'"); - expect(tokens[0][7].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.end.python"]); - expect(tokens[1][0].value).toBe("a"); - expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("None"); + expect(tokens[0][4].scopes).toEqual(["source.python","constant.language.python"]); + expect(tokens[1][0].value).toBe("for"); + expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); expect(tokens[1][1].value).toBe(" "); expect(tokens[1][1].scopes).toEqual(["source.python"]); - expect(tokens[1][2].value).toBe("="); - expect(tokens[1][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[1][3].value).toBe(" "); - expect(tokens[1][3].scopes).toEqual(["source.python"]); - expect(tokens[1][4].value).toBe("r"); - expect(tokens[1][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[1][5].value).toBe("'''"); - expect(tokens[1][5].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); + expect(tokens[1][2].value).toBe("a"); + expect(tokens[1][2].scopes).toEqual(["source.python"]); + expect(tokens[1][3].value).toBe(","); + expect(tokens[1][3].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[1][4].value).toBe(" "); + expect(tokens[1][4].scopes).toEqual(["source.python"]); + expect(tokens[1][5].value).toBe("b"); + expect(tokens[1][5].scopes).toEqual(["source.python"]); + expect(tokens[1][6].value).toBe(","); + expect(tokens[1][6].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[1][7].value).toBe(" "); + expect(tokens[1][7].scopes).toEqual(["source.python"]); + expect(tokens[1][8].value).toBe("c"); + expect(tokens[1][8].scopes).toEqual(["source.python"]); + expect(tokens[1][9].value).toBe(","); + expect(tokens[1][9].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[1][10].value).toBe(" "); + expect(tokens[1][10].scopes).toEqual(["source.python"]); + expect(tokens[1][11].value).toBe("invariable"); + expect(tokens[1][11].scopes).toEqual(["source.python"]); + expect(tokens[1][12].value).toBe(" "); + expect(tokens[1][12].scopes).toEqual(["source.python"]); + expect(tokens[1][13].value).toBe("in"); + expect(tokens[1][13].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[1][14].value).toBe(" "); + expect(tokens[1][14].scopes).toEqual(["source.python"]); + expect(tokens[1][15].value).toBe("["); + expect(tokens[1][15].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); + expect(tokens[1][16].value).toBe("2"); + expect(tokens[1][16].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[1][17].value).toBe(" "); + expect(tokens[1][17].scopes).toEqual(["source.python"]); + expect(tokens[1][18].value).toBe("in"); + expect(tokens[1][18].scopes).toEqual(["source.python","keyword.operator.logical.python"]); + expect(tokens[1][19].value).toBe(" "); + expect(tokens[1][19].scopes).toEqual(["source.python"]); + expect(tokens[1][20].value).toBe("q"); + expect(tokens[1][20].scopes).toEqual(["source.python"]); + expect(tokens[1][21].value).toBe(","); + expect(tokens[1][21].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[1][22].value).toBe(" "); + expect(tokens[1][22].scopes).toEqual(["source.python"]); + expect(tokens[1][23].value).toBe("2"); + expect(tokens[1][23].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[1][24].value).toBe(" "); + expect(tokens[1][24].scopes).toEqual(["source.python"]); + expect(tokens[1][25].value).toBe("in"); + expect(tokens[1][25].scopes).toEqual(["source.python","keyword.operator.logical.python"]); + expect(tokens[1][26].value).toBe(" "); + expect(tokens[1][26].scopes).toEqual(["source.python"]); + expect(tokens[1][27].value).toBe("w"); + expect(tokens[1][27].scopes).toEqual(["source.python"]); + expect(tokens[1][28].value).toBe("]"); + expect(tokens[1][28].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); + expect(tokens[1][29].value).toBe(":"); + expect(tokens[1][29].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); expect(tokens[2][0].value).toBe(" "); - expect(tokens[2][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[2][1].value).toBe("(?x)"); - expect(tokens[2][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.modifier.flag.regexp"]); - expect(tokens[2][2].value).toBe(" "); - expect(tokens[2][2].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[2][3].value).toBe("#"); - expect(tokens[2][3].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[2][4].value).toBe(" multi-line regexp"); - expect(tokens[2][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); - expect(tokens[3][0].value).toBe(" foo "); - expect(tokens[3][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[3][1].value).toBe("#"); - expect(tokens[3][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[3][2].value).toBe(" comment"); - expect(tokens[3][2].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); - expect(tokens[4][0].value).toBe("'''"); - expect(tokens[4][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); - expect(tokens[5][0].value).toBe("a"); + expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[2][1].value).toBe("pass"); + expect(tokens[2][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + }); + + it("test/statements/for3.py", + function() { + tokens = grammar.tokenizeLines("for(a, b), c, invariable in[2 in q, 2 in w]:\n pass") + expect(tokens[0][0].value).toBe("for"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[0][1].value).toBe("("); + expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.parenthesis.begin.python"]); + expect(tokens[0][2].value).toBe("a"); + expect(tokens[0][2].scopes).toEqual(["source.python"]); + expect(tokens[0][3].value).toBe(","); + expect(tokens[0][3].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[0][4].value).toBe(" "); + expect(tokens[0][4].scopes).toEqual(["source.python"]); + expect(tokens[0][5].value).toBe("b"); + expect(tokens[0][5].scopes).toEqual(["source.python"]); + expect(tokens[0][6].value).toBe(")"); + expect(tokens[0][6].scopes).toEqual(["source.python","punctuation.parenthesis.end.python"]); + expect(tokens[0][7].value).toBe(","); + expect(tokens[0][7].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[0][8].value).toBe(" "); + expect(tokens[0][8].scopes).toEqual(["source.python"]); + expect(tokens[0][9].value).toBe("c"); + expect(tokens[0][9].scopes).toEqual(["source.python"]); + expect(tokens[0][10].value).toBe(","); + expect(tokens[0][10].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[0][11].value).toBe(" "); + expect(tokens[0][11].scopes).toEqual(["source.python"]); + expect(tokens[0][12].value).toBe("invariable"); + expect(tokens[0][12].scopes).toEqual(["source.python"]); + expect(tokens[0][13].value).toBe(" "); + expect(tokens[0][13].scopes).toEqual(["source.python"]); + expect(tokens[0][14].value).toBe("in"); + expect(tokens[0][14].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[0][15].value).toBe("["); + expect(tokens[0][15].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); + expect(tokens[0][16].value).toBe("2"); + expect(tokens[0][16].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[0][17].value).toBe(" "); + expect(tokens[0][17].scopes).toEqual(["source.python"]); + expect(tokens[0][18].value).toBe("in"); + expect(tokens[0][18].scopes).toEqual(["source.python","keyword.operator.logical.python"]); + expect(tokens[0][19].value).toBe(" "); + expect(tokens[0][19].scopes).toEqual(["source.python"]); + expect(tokens[0][20].value).toBe("q"); + expect(tokens[0][20].scopes).toEqual(["source.python"]); + expect(tokens[0][21].value).toBe(","); + expect(tokens[0][21].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[0][22].value).toBe(" "); + expect(tokens[0][22].scopes).toEqual(["source.python"]); + expect(tokens[0][23].value).toBe("2"); + expect(tokens[0][23].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[0][24].value).toBe(" "); + expect(tokens[0][24].scopes).toEqual(["source.python"]); + expect(tokens[0][25].value).toBe("in"); + expect(tokens[0][25].scopes).toEqual(["source.python","keyword.operator.logical.python"]); + expect(tokens[0][26].value).toBe(" "); + expect(tokens[0][26].scopes).toEqual(["source.python"]); + expect(tokens[0][27].value).toBe("w"); + expect(tokens[0][27].scopes).toEqual(["source.python"]); + expect(tokens[0][28].value).toBe("]"); + expect(tokens[0][28].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); + expect(tokens[0][29].value).toBe(":"); + expect(tokens[0][29].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[1][0].value).toBe(" "); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe("pass"); + expect(tokens[1][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + }); + + it("test/statements/from1.py", + function() { + tokens = grammar.tokenizeLines("from ... import foo as bar\nraise Exception('done') from exc\nyield from foo") + expect(tokens[0][0].value).toBe("from"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("..."); + expect(tokens[0][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("import"); + expect(tokens[0][4].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][5].value).toBe(" "); + expect(tokens[0][5].scopes).toEqual(["source.python"]); + expect(tokens[0][6].value).toBe("foo"); + expect(tokens[0][6].scopes).toEqual(["source.python"]); + expect(tokens[0][7].value).toBe(" "); + expect(tokens[0][7].scopes).toEqual(["source.python"]); + expect(tokens[0][8].value).toBe("as"); + expect(tokens[0][8].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][9].value).toBe(" "); + expect(tokens[0][9].scopes).toEqual(["source.python"]); + expect(tokens[0][10].value).toBe("bar"); + expect(tokens[0][10].scopes).toEqual(["source.python"]); + expect(tokens[1][0].value).toBe("raise"); + expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[1][1].value).toBe(" "); + expect(tokens[1][1].scopes).toEqual(["source.python"]); + expect(tokens[1][2].value).toBe("Exception"); + expect(tokens[1][2].scopes).toEqual(["source.python","meta.function-call.python","support.type.exception.python"]); + expect(tokens[1][3].value).toBe("("); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[1][4].value).toBe("'"); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[1][5].value).toBe("done"); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python"]); + expect(tokens[1][6].value).toBe("'"); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[1][7].value).toBe(")"); + expect(tokens[1][7].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[1][8].value).toBe(" "); + expect(tokens[1][8].scopes).toEqual(["source.python"]); + expect(tokens[1][9].value).toBe("from"); + expect(tokens[1][9].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[1][10].value).toBe(" "); + expect(tokens[1][10].scopes).toEqual(["source.python"]); + expect(tokens[1][11].value).toBe("exc"); + expect(tokens[1][11].scopes).toEqual(["source.python"]); + expect(tokens[2][0].value).toBe("yield from"); + expect(tokens[2][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[2][1].value).toBe(" "); + expect(tokens[2][1].scopes).toEqual(["source.python"]); + expect(tokens[2][2].value).toBe("foo"); + expect(tokens[2][2].scopes).toEqual(["source.python"]); + }); + + it("test/statements/global1.py", + function() { + tokens = grammar.tokenizeLines("global a, b, c") + expect(tokens[0][0].value).toBe("global"); + expect(tokens[0][0].scopes).toEqual(["source.python","storage.modifier.declaration.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("a"); + expect(tokens[0][2].scopes).toEqual(["source.python"]); + expect(tokens[0][3].value).toBe(","); + expect(tokens[0][3].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[0][4].value).toBe(" "); + expect(tokens[0][4].scopes).toEqual(["source.python"]); + expect(tokens[0][5].value).toBe("b"); + expect(tokens[0][5].scopes).toEqual(["source.python"]); + expect(tokens[0][6].value).toBe(","); + expect(tokens[0][6].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[0][7].value).toBe(" "); + expect(tokens[0][7].scopes).toEqual(["source.python"]); + expect(tokens[0][8].value).toBe("c"); + expect(tokens[0][8].scopes).toEqual(["source.python"]); + }); + + it("test/statements/if1.py", + function() { + tokens = grammar.tokenizeLines("if (a if b else c):\n 1\nelif b or c and d:\n 2\nelse:\n 3") + expect(tokens[0][0].value).toBe("if"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("("); + expect(tokens[0][2].scopes).toEqual(["source.python","punctuation.parenthesis.begin.python"]); + expect(tokens[0][3].value).toBe("a"); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe(" "); + expect(tokens[0][4].scopes).toEqual(["source.python"]); + expect(tokens[0][5].value).toBe("if"); + expect(tokens[0][5].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[0][6].value).toBe(" "); + expect(tokens[0][6].scopes).toEqual(["source.python"]); + expect(tokens[0][7].value).toBe("b"); + expect(tokens[0][7].scopes).toEqual(["source.python"]); + expect(tokens[0][8].value).toBe(" "); + expect(tokens[0][8].scopes).toEqual(["source.python"]); + expect(tokens[0][9].value).toBe("else"); + expect(tokens[0][9].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[0][10].value).toBe(" "); + expect(tokens[0][10].scopes).toEqual(["source.python"]); + expect(tokens[0][11].value).toBe("c"); + expect(tokens[0][11].scopes).toEqual(["source.python"]); + expect(tokens[0][12].value).toBe(")"); + expect(tokens[0][12].scopes).toEqual(["source.python","punctuation.parenthesis.end.python"]); + expect(tokens[0][13].value).toBe(":"); + expect(tokens[0][13].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[1][0].value).toBe(" "); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe("1"); + expect(tokens[1][1].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[2][0].value).toBe("elif"); + expect(tokens[2][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[2][1].value).toBe(" "); + expect(tokens[2][1].scopes).toEqual(["source.python"]); + expect(tokens[2][2].value).toBe("b"); + expect(tokens[2][2].scopes).toEqual(["source.python"]); + expect(tokens[2][3].value).toBe(" "); + expect(tokens[2][3].scopes).toEqual(["source.python"]); + expect(tokens[2][4].value).toBe("or"); + expect(tokens[2][4].scopes).toEqual(["source.python","keyword.operator.logical.python"]); + expect(tokens[2][5].value).toBe(" "); + expect(tokens[2][5].scopes).toEqual(["source.python"]); + expect(tokens[2][6].value).toBe("c"); + expect(tokens[2][6].scopes).toEqual(["source.python"]); + expect(tokens[2][7].value).toBe(" "); + expect(tokens[2][7].scopes).toEqual(["source.python"]); + expect(tokens[2][8].value).toBe("and"); + expect(tokens[2][8].scopes).toEqual(["source.python","keyword.operator.logical.python"]); + expect(tokens[2][9].value).toBe(" "); + expect(tokens[2][9].scopes).toEqual(["source.python"]); + expect(tokens[2][10].value).toBe("d"); + expect(tokens[2][10].scopes).toEqual(["source.python"]); + expect(tokens[2][11].value).toBe(":"); + expect(tokens[2][11].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[3][0].value).toBe(" "); + expect(tokens[3][0].scopes).toEqual(["source.python"]); + expect(tokens[3][1].value).toBe("2"); + expect(tokens[3][1].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[4][0].value).toBe("else"); + expect(tokens[4][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[4][1].value).toBe(":"); + expect(tokens[4][1].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[5][0].value).toBe(" "); expect(tokens[5][0].scopes).toEqual(["source.python"]); - expect(tokens[5][1].value).toBe(" "); - expect(tokens[5][1].scopes).toEqual(["source.python"]); - expect(tokens[5][2].value).toBe("="); - expect(tokens[5][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[5][3].value).toBe(" "); - expect(tokens[5][3].scopes).toEqual(["source.python"]); - expect(tokens[5][4].value).toBe("R"); - expect(tokens[5][4].scopes).toEqual(["source.python","string.quoted.raw.multi.python","storage.type.string.python"]); - expect(tokens[5][5].value).toBe("'''"); - expect(tokens[5][5].scopes).toEqual(["source.python","string.quoted.raw.multi.python","punctuation.definition.string.begin.python"]); - expect(tokens[6][0].value).toBe(" (?x) # not a"); - expect(tokens[6][0].scopes).toEqual(["source.python","string.quoted.raw.multi.python"]); - expect(tokens[7][0].value).toBe(" foo # comment"); - expect(tokens[7][0].scopes).toEqual(["source.python","string.quoted.raw.multi.python"]); - expect(tokens[8][0].value).toBe("'''"); - expect(tokens[8][0].scopes).toEqual(["source.python","string.quoted.raw.multi.python","punctuation.definition.string.end.python"]); + expect(tokens[5][1].value).toBe("3"); + expect(tokens[5][1].scopes).toEqual(["source.python","constant.numeric.dec.python"]); }); - it("test/regexp/python6.py", + it("test/statements/import1.py", function() { - tokens = grammar.tokenizeLines("a = r\"foo#not a comment\"\na = r\"\"\"\n (?x) # multi-line regexp\n foo # comment\n\"\"\"\na = R\"\"\"\n (?x) # not a\n foo # comment\n\"\"\"") - expect(tokens[0][0].value).toBe("a"); - expect(tokens[0][0].scopes).toEqual(["source.python"]); + tokens = grammar.tokenizeLines("from ...foo import bar as spam, baz\nimport time as ham, datetime") + expect(tokens[0][0].value).toBe("from"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]); expect(tokens[0][1].value).toBe(" "); expect(tokens[0][1].scopes).toEqual(["source.python"]); - expect(tokens[0][2].value).toBe("="); - expect(tokens[0][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][2].value).toBe("..."); + expect(tokens[0][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][3].value).toBe("foo"); expect(tokens[0][3].scopes).toEqual(["source.python"]); - expect(tokens[0][4].value).toBe("r"); - expect(tokens[0][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python","storage.type.string.python"]); - expect(tokens[0][5].value).toBe("\""); - expect(tokens[0][5].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.begin.python"]); - expect(tokens[0][6].value).toBe("foo#not a comment"); - expect(tokens[0][6].scopes).toEqual(["source.python","string.regexp.quoted.single.python"]); - expect(tokens[0][7].value).toBe("\""); - expect(tokens[0][7].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.end.python"]); - expect(tokens[1][0].value).toBe("a"); - expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe(" "); + expect(tokens[0][4].scopes).toEqual(["source.python"]); + expect(tokens[0][5].value).toBe("import"); + expect(tokens[0][5].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][6].value).toBe(" "); + expect(tokens[0][6].scopes).toEqual(["source.python"]); + expect(tokens[0][7].value).toBe("bar"); + expect(tokens[0][7].scopes).toEqual(["source.python"]); + expect(tokens[0][8].value).toBe(" "); + expect(tokens[0][8].scopes).toEqual(["source.python"]); + expect(tokens[0][9].value).toBe("as"); + expect(tokens[0][9].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][10].value).toBe(" "); + expect(tokens[0][10].scopes).toEqual(["source.python"]); + expect(tokens[0][11].value).toBe("spam"); + expect(tokens[0][11].scopes).toEqual(["source.python"]); + expect(tokens[0][12].value).toBe(","); + expect(tokens[0][12].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[0][13].value).toBe(" "); + expect(tokens[0][13].scopes).toEqual(["source.python"]); + expect(tokens[0][14].value).toBe("baz"); + expect(tokens[0][14].scopes).toEqual(["source.python"]); + expect(tokens[1][0].value).toBe("import"); + expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.import.python"]); expect(tokens[1][1].value).toBe(" "); expect(tokens[1][1].scopes).toEqual(["source.python"]); - expect(tokens[1][2].value).toBe("="); - expect(tokens[1][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[1][2].value).toBe("time"); + expect(tokens[1][2].scopes).toEqual(["source.python"]); expect(tokens[1][3].value).toBe(" "); expect(tokens[1][3].scopes).toEqual(["source.python"]); - expect(tokens[1][4].value).toBe("r"); - expect(tokens[1][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[1][5].value).toBe("\"\"\""); - expect(tokens[1][5].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); - expect(tokens[2][0].value).toBe(" "); - expect(tokens[2][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[2][1].value).toBe("(?x)"); - expect(tokens[2][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.modifier.flag.regexp"]); - expect(tokens[2][2].value).toBe(" "); - expect(tokens[2][2].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[2][3].value).toBe("#"); - expect(tokens[2][3].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[2][4].value).toBe(" multi-line regexp"); - expect(tokens[2][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); - expect(tokens[3][0].value).toBe(" foo "); - expect(tokens[3][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python"]); - expect(tokens[3][1].value).toBe("#"); - expect(tokens[3][1].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[3][2].value).toBe(" comment"); - expect(tokens[3][2].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); - expect(tokens[4][0].value).toBe("\"\"\""); - expect(tokens[4][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); - expect(tokens[5][0].value).toBe("a"); - expect(tokens[5][0].scopes).toEqual(["source.python"]); - expect(tokens[5][1].value).toBe(" "); - expect(tokens[5][1].scopes).toEqual(["source.python"]); - expect(tokens[5][2].value).toBe("="); - expect(tokens[5][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[5][3].value).toBe(" "); - expect(tokens[5][3].scopes).toEqual(["source.python"]); - expect(tokens[5][4].value).toBe("R"); - expect(tokens[5][4].scopes).toEqual(["source.python","string.quoted.raw.multi.python","storage.type.string.python"]); - expect(tokens[5][5].value).toBe("\"\"\""); - expect(tokens[5][5].scopes).toEqual(["source.python","string.quoted.raw.multi.python","punctuation.definition.string.begin.python"]); - expect(tokens[6][0].value).toBe(" (?x) # not a"); - expect(tokens[6][0].scopes).toEqual(["source.python","string.quoted.raw.multi.python"]); - expect(tokens[7][0].value).toBe(" foo # comment"); - expect(tokens[7][0].scopes).toEqual(["source.python","string.quoted.raw.multi.python"]); - expect(tokens[8][0].value).toBe("\"\"\""); - expect(tokens[8][0].scopes).toEqual(["source.python","string.quoted.raw.multi.python","punctuation.definition.string.end.python"]); + expect(tokens[1][4].value).toBe("as"); + expect(tokens[1][4].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[1][5].value).toBe(" "); + expect(tokens[1][5].scopes).toEqual(["source.python"]); + expect(tokens[1][6].value).toBe("ham"); + expect(tokens[1][6].scopes).toEqual(["source.python"]); + expect(tokens[1][7].value).toBe(","); + expect(tokens[1][7].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[1][8].value).toBe(" "); + expect(tokens[1][8].scopes).toEqual(["source.python"]); + expect(tokens[1][9].value).toBe("datetime"); + expect(tokens[1][9].scopes).toEqual(["source.python"]); }); - it("test/regexp/python7.py", + it("test/statements/import2.py", function() { - tokens = grammar.tokenizeLines("a = r'('\n1\n\na = r\"(?=\"\n1\n\na = r\"\"\"(?:\n\"\"\"\n1\n\na = r'''[\n'''\n1") - expect(tokens[0][0].value).toBe("a"); - expect(tokens[0][0].scopes).toEqual(["source.python"]); + tokens = grammar.tokenizeLines("from .... import a\nfrom ... import b\nfrom .. import c") + expect(tokens[0][0].value).toBe("from"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]); expect(tokens[0][1].value).toBe(" "); expect(tokens[0][1].scopes).toEqual(["source.python"]); - expect(tokens[0][2].value).toBe("="); - expect(tokens[0][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[0][2].value).toBe("...."); + expect(tokens[0][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); expect(tokens[0][3].value).toBe(" "); expect(tokens[0][3].scopes).toEqual(["source.python"]); - expect(tokens[0][4].value).toBe("r"); - expect(tokens[0][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python","storage.type.string.python"]); - expect(tokens[0][5].value).toBe("'"); - expect(tokens[0][5].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.begin.python"]); - expect(tokens[0][6].value).toBe("("); - expect(tokens[0][6].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.parenthesis.begin.regexp support.other.parenthesis.regexp"]); - expect(tokens[0][7].value).toBe("'"); - expect(tokens[0][7].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.end.python"]); - expect(tokens[1][0].value).toBe("1"); - expect(tokens[1][0].scopes).toEqual(["source.python","constant.numeric.dec.python"]); - expect(tokens[2][0].value).toBe(""); - expect(tokens[2][0].scopes).toEqual(["source.python"]); - expect(tokens[3][0].value).toBe("a"); - expect(tokens[3][0].scopes).toEqual(["source.python"]); - expect(tokens[3][1].value).toBe(" "); - expect(tokens[3][1].scopes).toEqual(["source.python"]); - expect(tokens[3][2].value).toBe("="); - expect(tokens[3][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[3][3].value).toBe(" "); - expect(tokens[3][3].scopes).toEqual(["source.python"]); - expect(tokens[3][4].value).toBe("r"); - expect(tokens[3][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python","storage.type.string.python"]); - expect(tokens[3][5].value).toBe("\""); - expect(tokens[3][5].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.begin.python"]); - expect(tokens[3][6].value).toBe("("); - expect(tokens[3][6].scopes).toEqual(["source.python","string.regexp.quoted.single.python","keyword.operator.lookahead.regexp","punctuation.parenthesis.lookahead.begin.regexp"]); - expect(tokens[3][7].value).toBe("?="); - expect(tokens[3][7].scopes).toEqual(["source.python","string.regexp.quoted.single.python","keyword.operator.lookahead.regexp"]); - expect(tokens[3][8].value).toBe("\""); - expect(tokens[3][8].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.end.python"]); - expect(tokens[4][0].value).toBe("1"); - expect(tokens[4][0].scopes).toEqual(["source.python","constant.numeric.dec.python"]); - expect(tokens[5][0].value).toBe(""); - expect(tokens[5][0].scopes).toEqual(["source.python"]); - expect(tokens[6][0].value).toBe("a"); - expect(tokens[6][0].scopes).toEqual(["source.python"]); - expect(tokens[6][1].value).toBe(" "); - expect(tokens[6][1].scopes).toEqual(["source.python"]); - expect(tokens[6][2].value).toBe("="); - expect(tokens[6][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[6][3].value).toBe(" "); - expect(tokens[6][3].scopes).toEqual(["source.python"]); - expect(tokens[6][4].value).toBe("r"); - expect(tokens[6][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[6][5].value).toBe("\"\"\""); - expect(tokens[6][5].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); - expect(tokens[6][6].value).toBe("(?:"); - expect(tokens[6][6].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.parenthesis.non-capturing.begin.regexp support.other.parenthesis.regexp"]); - expect(tokens[7][0].value).toBe("\"\"\""); - expect(tokens[7][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); - expect(tokens[8][0].value).toBe("1"); - expect(tokens[8][0].scopes).toEqual(["source.python","constant.numeric.dec.python"]); - expect(tokens[9][0].value).toBe(""); - expect(tokens[9][0].scopes).toEqual(["source.python"]); - expect(tokens[10][0].value).toBe("a"); - expect(tokens[10][0].scopes).toEqual(["source.python"]); - expect(tokens[10][1].value).toBe(" "); - expect(tokens[10][1].scopes).toEqual(["source.python"]); - expect(tokens[10][2].value).toBe("="); - expect(tokens[10][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[10][3].value).toBe(" "); - expect(tokens[10][3].scopes).toEqual(["source.python"]); - expect(tokens[10][4].value).toBe("r"); - expect(tokens[10][4].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[10][5].value).toBe("'''"); - expect(tokens[10][5].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); - expect(tokens[10][6].value).toBe("["); - expect(tokens[10][6].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.begin.regexp"]); - expect(tokens[11][0].value).toBe("'''"); - expect(tokens[11][0].scopes).toEqual(["source.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); - expect(tokens[12][0].value).toBe("1"); - expect(tokens[12][0].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[0][4].value).toBe("import"); + expect(tokens[0][4].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][5].value).toBe(" "); + expect(tokens[0][5].scopes).toEqual(["source.python"]); + expect(tokens[0][6].value).toBe("a"); + expect(tokens[0][6].scopes).toEqual(["source.python"]); + expect(tokens[1][0].value).toBe("from"); + expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[1][1].value).toBe(" "); + expect(tokens[1][1].scopes).toEqual(["source.python"]); + expect(tokens[1][2].value).toBe("..."); + expect(tokens[1][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[1][3].value).toBe(" "); + expect(tokens[1][3].scopes).toEqual(["source.python"]); + expect(tokens[1][4].value).toBe("import"); + expect(tokens[1][4].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[1][5].value).toBe(" "); + expect(tokens[1][5].scopes).toEqual(["source.python"]); + expect(tokens[1][6].value).toBe("b"); + expect(tokens[1][6].scopes).toEqual(["source.python"]); + expect(tokens[2][0].value).toBe("from"); + expect(tokens[2][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[2][1].value).toBe(" "); + expect(tokens[2][1].scopes).toEqual(["source.python"]); + expect(tokens[2][2].value).toBe(".."); + expect(tokens[2][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[2][3].value).toBe(" "); + expect(tokens[2][3].scopes).toEqual(["source.python"]); + expect(tokens[2][4].value).toBe("import"); + expect(tokens[2][4].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[2][5].value).toBe(" "); + expect(tokens[2][5].scopes).toEqual(["source.python"]); + expect(tokens[2][6].value).toBe("c"); + expect(tokens[2][6].scopes).toEqual(["source.python"]); }); - it("test/regexp/python8.py", + it("test/statements/import3.py", function() { - tokens = grammar.tokenizeLines("# And now something fun!\n\nCookiePattern = re.compile(r\"\"\"\n (?x) # This is a verbose pattern\n \\s* # Optional whitespace at start of cookie\n (?P # Start of group 'key'\n [\"\"\" + _LegalKeyChars + r\"\"\"]+? # Any word of at least one letter\n ) # End of group 'key'\n ( # Optional group: there may not be a value.\n \\s*=\\s* # Equal Sign\n (?P # Start of group 'val'\n \"(?:[^\\\\\"]|\\\\.)*\" # Any doublequoted string\n | # or\n \\w{3},\\s[\\w\\d\\s-]{9,11}\\s[\\d:]{8}\\sGMT # Special case for \"expires\" attr\n | # or\n [\"\"\" + _LegalValueChars + r\"\"\"]* # Any word or empty string\n ) # End of group 'val'\n )? # End of optional value group\n \\s* # Any number of spaces.\n (\\s+|;|$) # Ending either at space, semicolon, or EOS.\n \"\"\", re.ASCII) # May be removed if safe.") - expect(tokens[0][0].value).toBe("#"); - expect(tokens[0][0].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[0][1].value).toBe(" And now something fun!"); - expect(tokens[0][1].scopes).toEqual(["source.python","comment.line.number-sign.python"]); - expect(tokens[1][0].value).toBe(""); - expect(tokens[1][0].scopes).toEqual(["source.python"]); - expect(tokens[2][0].value).toBe("CookiePattern"); - expect(tokens[2][0].scopes).toEqual(["source.python"]); - expect(tokens[2][1].value).toBe(" "); - expect(tokens[2][1].scopes).toEqual(["source.python"]); - expect(tokens[2][2].value).toBe("="); - expect(tokens[2][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + tokens = grammar.tokenizeLines("from....import a\nfrom...import b\nfrom..import c\nfrom.import d") + expect(tokens[0][0].value).toBe("from"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][1].value).toBe("...."); + expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][2].value).toBe("import"); + expect(tokens[0][2].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("a"); + expect(tokens[0][4].scopes).toEqual(["source.python"]); + expect(tokens[1][0].value).toBe("from"); + expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[1][1].value).toBe("..."); + expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[1][2].value).toBe("import"); + expect(tokens[1][2].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[1][3].value).toBe(" "); + expect(tokens[1][3].scopes).toEqual(["source.python"]); + expect(tokens[1][4].value).toBe("b"); + expect(tokens[1][4].scopes).toEqual(["source.python"]); + expect(tokens[2][0].value).toBe("from"); + expect(tokens[2][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[2][1].value).toBe(".."); + expect(tokens[2][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[2][2].value).toBe("import"); + expect(tokens[2][2].scopes).toEqual(["source.python","keyword.control.import.python"]); expect(tokens[2][3].value).toBe(" "); expect(tokens[2][3].scopes).toEqual(["source.python"]); - expect(tokens[2][4].value).toBe("re"); + expect(tokens[2][4].value).toBe("c"); expect(tokens[2][4].scopes).toEqual(["source.python"]); - expect(tokens[2][5].value).toBe("."); - expect(tokens[2][5].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[2][6].value).toBe("compile"); - expect(tokens[2][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); - expect(tokens[2][7].value).toBe("("); - expect(tokens[2][7].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); - expect(tokens[2][8].value).toBe("r"); - expect(tokens[2][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[2][9].value).toBe("\"\"\""); - expect(tokens[2][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); - expect(tokens[3][0].value).toBe(" "); - expect(tokens[3][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[3][1].value).toBe("(?x)"); - expect(tokens[3][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","storage.modifier.flag.regexp"]); - expect(tokens[3][2].value).toBe(" "); - expect(tokens[3][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[3][3].value).toBe("#"); - expect(tokens[3][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[3][4].value).toBe(" This is a verbose pattern"); - expect(tokens[3][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); - expect(tokens[4][0].value).toBe(" "); - expect(tokens[4][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[4][1].value).toBe("\\s"); - expect(tokens[4][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","support.other.escape.special.regexp"]); - expect(tokens[4][2].value).toBe("*"); - expect(tokens[4][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); - expect(tokens[4][3].value).toBe(" "); - expect(tokens[4][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[4][4].value).toBe("#"); - expect(tokens[4][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[4][5].value).toBe(" Optional whitespace at start of cookie"); - expect(tokens[4][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); - expect(tokens[5][0].value).toBe(" "); - expect(tokens[5][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[5][1].value).toBe("("); - expect(tokens[5][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","punctuation.parenthesis.named.begin.regexp support.other.parenthesis.regexp"]); - expect(tokens[5][2].value).toBe("?P"); - expect(tokens[5][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","entity.name.tag.named.group.regexp"]); - expect(tokens[5][3].value).toBe(" "); - expect(tokens[5][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); - expect(tokens[5][4].value).toBe("#"); - expect(tokens[5][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[5][5].value).toBe(" Start of group 'key'"); - expect(tokens[5][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python"]); - expect(tokens[6][0].value).toBe(" "); - expect(tokens[6][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); - expect(tokens[6][1].value).toBe("["); - expect(tokens[6][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.begin.regexp"]); - expect(tokens[6][2].value).toBe("\"\"\""); - expect(tokens[6][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); - expect(tokens[6][3].value).toBe(" "); - expect(tokens[6][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); - expect(tokens[6][4].value).toBe("+"); - expect(tokens[6][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.arithmetic.python"]); - expect(tokens[6][5].value).toBe(" "); - expect(tokens[6][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); - expect(tokens[6][6].value).toBe("_LegalKeyChars"); - expect(tokens[6][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); - expect(tokens[6][7].value).toBe(" "); - expect(tokens[6][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); - expect(tokens[6][8].value).toBe("+"); - expect(tokens[6][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.arithmetic.python"]); - expect(tokens[6][9].value).toBe(" "); - expect(tokens[6][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); - expect(tokens[6][10].value).toBe("r"); - expect(tokens[6][10].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[6][11].value).toBe("\"\"\""); - expect(tokens[6][11].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); - expect(tokens[6][12].value).toBe("]"); - expect(tokens[6][12].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[6][13].value).toBe("+?"); - expect(tokens[6][13].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); - expect(tokens[6][14].value).toBe(" "); - expect(tokens[6][14].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[6][15].value).toBe("#"); - expect(tokens[6][15].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[6][16].value).toBe(" Any word of at least one letter"); - expect(tokens[6][16].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); - expect(tokens[7][0].value).toBe(" ) "); - expect(tokens[7][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[7][1].value).toBe("#"); - expect(tokens[7][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[7][2].value).toBe(" End of group 'key'"); - expect(tokens[7][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); - expect(tokens[8][0].value).toBe(" "); - expect(tokens[8][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[8][1].value).toBe("("); - expect(tokens[8][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.parenthesis.begin.regexp support.other.parenthesis.regexp"]); - expect(tokens[8][2].value).toBe(" "); - expect(tokens[8][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[8][3].value).toBe("#"); - expect(tokens[8][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[8][4].value).toBe(" Optional group: there may not be a value."); - expect(tokens[8][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); - expect(tokens[9][0].value).toBe(" "); - expect(tokens[9][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[9][1].value).toBe("\\s"); - expect(tokens[9][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","support.other.escape.special.regexp"]); - expect(tokens[9][2].value).toBe("*"); - expect(tokens[9][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); - expect(tokens[9][3].value).toBe("="); - expect(tokens[9][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[9][4].value).toBe("\\s"); - expect(tokens[9][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","support.other.escape.special.regexp"]); - expect(tokens[9][5].value).toBe("*"); - expect(tokens[9][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); - expect(tokens[9][6].value).toBe(" "); - expect(tokens[9][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[9][7].value).toBe("#"); - expect(tokens[9][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[9][8].value).toBe(" Equal Sign"); - expect(tokens[9][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); - expect(tokens[10][0].value).toBe(" "); - expect(tokens[10][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[10][1].value).toBe("("); - expect(tokens[10][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","punctuation.parenthesis.named.begin.regexp support.other.parenthesis.regexp"]); - expect(tokens[10][2].value).toBe("?P"); - expect(tokens[10][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","entity.name.tag.named.group.regexp"]); - expect(tokens[10][3].value).toBe(" "); - expect(tokens[10][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); - expect(tokens[10][4].value).toBe("#"); - expect(tokens[10][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[10][5].value).toBe(" Start of group 'val'"); - expect(tokens[10][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python"]); - expect(tokens[11][0].value).toBe(" \""); - expect(tokens[11][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); - expect(tokens[11][1].value).toBe("(?:"); - expect(tokens[11][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","punctuation.parenthesis.non-capturing.begin.regexp support.other.parenthesis.regexp"]); - expect(tokens[11][2].value).toBe("["); - expect(tokens[11][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.begin.regexp"]); - expect(tokens[11][3].value).toBe("^"); - expect(tokens[11][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","keyword.operator.negation.regexp"]); - expect(tokens[11][4].value).toBe("\\\\"); - expect(tokens[11][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.character.escape.regexp"]); - expect(tokens[11][5].value).toBe("\""); - expect(tokens[11][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.character.set.regexp"]); - expect(tokens[11][6].value).toBe("]"); - expect(tokens[11][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.end.regexp"]); - expect(tokens[11][7].value).toBe("|"); - expect(tokens[11][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","keyword.operator.disjunction.regexp"]); - expect(tokens[11][8].value).toBe("\\\\"); - expect(tokens[11][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","constant.character.escape.regexp"]); - expect(tokens[11][9].value).toBe("."); - expect(tokens[11][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","support.other.match.any.regexp"]); - expect(tokens[11][10].value).toBe(")"); - expect(tokens[11][10].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","punctuation.parenthesis.non-capturing.end.regexp support.other.parenthesis.regexp"]); - expect(tokens[11][11].value).toBe("*"); - expect(tokens[11][11].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","keyword.operator.quantifier.regexp"]); - expect(tokens[11][12].value).toBe("\" "); - expect(tokens[11][12].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); - expect(tokens[11][13].value).toBe("#"); - expect(tokens[11][13].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[11][14].value).toBe(" Any doublequoted string"); - expect(tokens[11][14].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python"]); - expect(tokens[12][0].value).toBe(" "); - expect(tokens[12][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); - expect(tokens[12][1].value).toBe("|"); - expect(tokens[12][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","keyword.operator.disjunction.regexp"]); - expect(tokens[12][2].value).toBe(" "); - expect(tokens[12][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); - expect(tokens[12][3].value).toBe("#"); - expect(tokens[12][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[12][4].value).toBe(" or"); - expect(tokens[12][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python"]); - expect(tokens[13][0].value).toBe(" "); - expect(tokens[13][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); - expect(tokens[13][1].value).toBe("\\w"); - expect(tokens[13][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","support.other.escape.special.regexp"]); - expect(tokens[13][2].value).toBe("{3}"); - expect(tokens[13][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","keyword.operator.quantifier.regexp"]); - expect(tokens[13][3].value).toBe(","); - expect(tokens[13][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); - expect(tokens[13][4].value).toBe("\\s"); - expect(tokens[13][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","support.other.escape.special.regexp"]); - expect(tokens[13][5].value).toBe("["); - expect(tokens[13][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.begin.regexp"]); - expect(tokens[13][6].value).toBe("\\w"); - expect(tokens[13][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","support.other.escape.special.regexp"]); - expect(tokens[13][7].value).toBe("\\d"); - expect(tokens[13][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","support.other.escape.special.regexp"]); - expect(tokens[13][8].value).toBe("\\s"); - expect(tokens[13][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","support.other.escape.special.regexp"]); - expect(tokens[13][9].value).toBe("-"); - expect(tokens[13][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.character.set.regexp"]); - expect(tokens[13][10].value).toBe("]"); - expect(tokens[13][10].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.end.regexp"]); - expect(tokens[13][11].value).toBe("{9,11}"); - expect(tokens[13][11].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","keyword.operator.quantifier.regexp"]); - expect(tokens[13][12].value).toBe("\\s"); - expect(tokens[13][12].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","support.other.escape.special.regexp"]); - expect(tokens[13][13].value).toBe("["); - expect(tokens[13][13].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.begin.regexp"]); - expect(tokens[13][14].value).toBe("\\d"); - expect(tokens[13][14].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","support.other.escape.special.regexp"]); - expect(tokens[13][15].value).toBe(":"); - expect(tokens[13][15].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.character.set.regexp"]); - expect(tokens[13][16].value).toBe("]"); - expect(tokens[13][16].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.end.regexp"]); - expect(tokens[13][17].value).toBe("{8}"); - expect(tokens[13][17].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","keyword.operator.quantifier.regexp"]); - expect(tokens[13][18].value).toBe("\\s"); - expect(tokens[13][18].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","support.other.escape.special.regexp"]); - expect(tokens[13][19].value).toBe("GMT "); - expect(tokens[13][19].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); - expect(tokens[13][20].value).toBe("#"); - expect(tokens[13][20].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[13][21].value).toBe(" Special case for \"expires\" attr"); - expect(tokens[13][21].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python"]); - expect(tokens[14][0].value).toBe(" "); - expect(tokens[14][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); - expect(tokens[14][1].value).toBe("|"); - expect(tokens[14][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","keyword.operator.disjunction.regexp"]); - expect(tokens[14][2].value).toBe(" "); - expect(tokens[14][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); - expect(tokens[14][3].value).toBe("#"); - expect(tokens[14][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[14][4].value).toBe(" or"); - expect(tokens[14][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","comment.line.number-sign.python"]); - expect(tokens[15][0].value).toBe(" "); - expect(tokens[15][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp"]); - expect(tokens[15][1].value).toBe("["); - expect(tokens[15][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","meta.named.regexp","meta.character.set.regexp","constant.other.set.regexp punctuation.character.set.begin.regexp"]); - expect(tokens[15][2].value).toBe("\"\"\""); - expect(tokens[15][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); - expect(tokens[15][3].value).toBe(" "); - expect(tokens[15][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); - expect(tokens[15][4].value).toBe("+"); - expect(tokens[15][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.arithmetic.python"]); - expect(tokens[15][5].value).toBe(" "); - expect(tokens[15][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); - expect(tokens[15][6].value).toBe("_LegalValueChars"); - expect(tokens[15][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); - expect(tokens[15][7].value).toBe(" "); - expect(tokens[15][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); - expect(tokens[15][8].value).toBe("+"); - expect(tokens[15][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.arithmetic.python"]); - expect(tokens[15][9].value).toBe(" "); - expect(tokens[15][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); - expect(tokens[15][10].value).toBe("r"); - expect(tokens[15][10].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","storage.type.string.python"]); - expect(tokens[15][11].value).toBe("\"\"\""); - expect(tokens[15][11].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.definition.string.begin.python"]); - expect(tokens[15][12].value).toBe("]"); - expect(tokens[15][12].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[15][13].value).toBe("*"); - expect(tokens[15][13].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); - expect(tokens[15][14].value).toBe(" "); - expect(tokens[15][14].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[15][15].value).toBe("#"); - expect(tokens[15][15].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[15][16].value).toBe(" Any word or empty string"); - expect(tokens[15][16].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); - expect(tokens[16][0].value).toBe(" ) "); - expect(tokens[16][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[16][1].value).toBe("#"); - expect(tokens[16][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[16][2].value).toBe(" End of group 'val'"); - expect(tokens[16][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); - expect(tokens[17][0].value).toBe(" )"); - expect(tokens[17][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[17][1].value).toBe("?"); - expect(tokens[17][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); - expect(tokens[17][2].value).toBe(" "); - expect(tokens[17][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[17][3].value).toBe("#"); - expect(tokens[17][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[17][4].value).toBe(" End of optional value group"); - expect(tokens[17][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); - expect(tokens[18][0].value).toBe(" "); - expect(tokens[18][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[18][1].value).toBe("\\s"); - expect(tokens[18][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","support.other.escape.special.regexp"]); - expect(tokens[18][2].value).toBe("*"); - expect(tokens[18][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); - expect(tokens[18][3].value).toBe(" "); - expect(tokens[18][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[18][4].value).toBe("#"); - expect(tokens[18][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[18][5].value).toBe(" Any number of spaces."); - expect(tokens[18][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); - expect(tokens[19][0].value).toBe(" "); - expect(tokens[19][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[19][1].value).toBe("("); - expect(tokens[19][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.parenthesis.begin.regexp support.other.parenthesis.regexp"]); - expect(tokens[19][2].value).toBe("\\s"); - expect(tokens[19][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","support.other.escape.special.regexp"]); - expect(tokens[19][3].value).toBe("+"); - expect(tokens[19][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.quantifier.regexp"]); - expect(tokens[19][4].value).toBe("|"); - expect(tokens[19][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.disjunction.regexp"]); - expect(tokens[19][5].value).toBe(";"); - expect(tokens[19][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[19][6].value).toBe("|"); - expect(tokens[19][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","keyword.operator.disjunction.regexp"]); - expect(tokens[19][7].value).toBe("$"); - expect(tokens[19][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","support.other.match.end.regexp"]); - expect(tokens[19][8].value).toBe(")"); - expect(tokens[19][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.parenthesis.end.regexp support.other.parenthesis.regexp"]); - expect(tokens[19][9].value).toBe(" "); - expect(tokens[19][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[19][10].value).toBe("#"); - expect(tokens[19][10].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[19][11].value).toBe(" Ending either at space, semicolon, or EOS."); - expect(tokens[19][11].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","comment.line.number-sign.python"]); - expect(tokens[20][0].value).toBe(" "); - expect(tokens[20][0].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python"]); - expect(tokens[20][1].value).toBe("\"\"\""); - expect(tokens[20][1].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.regexp.quoted.multi.python","punctuation.definition.string.end.python"]); - expect(tokens[20][2].value).toBe(","); - expect(tokens[20][2].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); - expect(tokens[20][3].value).toBe(" "); - expect(tokens[20][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); - expect(tokens[20][4].value).toBe("re"); - expect(tokens[20][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); - expect(tokens[20][5].value).toBe("."); - expect(tokens[20][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.period.python"]); - expect(tokens[20][6].value).toBe("ASCII"); - expect(tokens[20][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.other.caps.python"]); - expect(tokens[20][7].value).toBe(")"); - expect(tokens[20][7].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); - expect(tokens[20][8].value).toBe(" "); - expect(tokens[20][8].scopes).toEqual(["source.python"]); - expect(tokens[20][9].value).toBe("#"); - expect(tokens[20][9].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[20][10].value).toBe(" May be removed if safe."); - expect(tokens[20][10].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[3][0].value).toBe("from"); + expect(tokens[3][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[3][1].value).toBe("."); + expect(tokens[3][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[3][2].value).toBe("import"); + expect(tokens[3][2].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[3][3].value).toBe(" "); + expect(tokens[3][3].scopes).toEqual(["source.python"]); + expect(tokens[3][4].value).toBe("d"); + expect(tokens[3][4].scopes).toEqual(["source.python"]); + }); + + it("test/statements/import4.py", + function() { + tokens = grammar.tokenizeLines("from....foo import a\nfrom...foo import b\nfrom..foo import c\nfrom.foo import d") + expect(tokens[0][0].value).toBe("from"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][1].value).toBe("...."); + expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][2].value).toBe("foo"); + expect(tokens[0][2].scopes).toEqual(["source.python"]); + expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("import"); + expect(tokens[0][4].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][5].value).toBe(" "); + expect(tokens[0][5].scopes).toEqual(["source.python"]); + expect(tokens[0][6].value).toBe("a"); + expect(tokens[0][6].scopes).toEqual(["source.python"]); + expect(tokens[1][0].value).toBe("from"); + expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[1][1].value).toBe("..."); + expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[1][2].value).toBe("foo"); + expect(tokens[1][2].scopes).toEqual(["source.python"]); + expect(tokens[1][3].value).toBe(" "); + expect(tokens[1][3].scopes).toEqual(["source.python"]); + expect(tokens[1][4].value).toBe("import"); + expect(tokens[1][4].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[1][5].value).toBe(" "); + expect(tokens[1][5].scopes).toEqual(["source.python"]); + expect(tokens[1][6].value).toBe("b"); + expect(tokens[1][6].scopes).toEqual(["source.python"]); + expect(tokens[2][0].value).toBe("from"); + expect(tokens[2][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[2][1].value).toBe(".."); + expect(tokens[2][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[2][2].value).toBe("foo"); + expect(tokens[2][2].scopes).toEqual(["source.python"]); + expect(tokens[2][3].value).toBe(" "); + expect(tokens[2][3].scopes).toEqual(["source.python"]); + expect(tokens[2][4].value).toBe("import"); + expect(tokens[2][4].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[2][5].value).toBe(" "); + expect(tokens[2][5].scopes).toEqual(["source.python"]); + expect(tokens[2][6].value).toBe("c"); + expect(tokens[2][6].scopes).toEqual(["source.python"]); + expect(tokens[3][0].value).toBe("from"); + expect(tokens[3][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[3][1].value).toBe("."); + expect(tokens[3][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[3][2].value).toBe("foo"); + expect(tokens[3][2].scopes).toEqual(["source.python"]); + expect(tokens[3][3].value).toBe(" "); + expect(tokens[3][3].scopes).toEqual(["source.python"]); + expect(tokens[3][4].value).toBe("import"); + expect(tokens[3][4].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[3][5].value).toBe(" "); + expect(tokens[3][5].scopes).toEqual(["source.python"]); + expect(tokens[3][6].value).toBe("d"); + expect(tokens[3][6].scopes).toEqual(["source.python"]); }); - it("test/regexp/python9.py", + it("test/statements/import5.py", function() { - tokens = grammar.tokenizeLines("a = r'foo[^]'\na = r'foo[]'") - expect(tokens[0][0].value).toBe("a"); - expect(tokens[0][0].scopes).toEqual(["source.python"]); + tokens = grammar.tokenizeLines("from.foo import d\nfrom.import a\n\nfoo.import\n\nraise Exception from Foo\n\ndef bar():\n yield from baz") + expect(tokens[0][0].value).toBe("from"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][1].value).toBe("."); + expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][2].value).toBe("foo"); + expect(tokens[0][2].scopes).toEqual(["source.python"]); + expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("import"); + expect(tokens[0][4].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][5].value).toBe(" "); + expect(tokens[0][5].scopes).toEqual(["source.python"]); + expect(tokens[0][6].value).toBe("d"); + expect(tokens[0][6].scopes).toEqual(["source.python"]); + expect(tokens[1][0].value).toBe("from"); + expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[1][1].value).toBe("."); + expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[1][2].value).toBe("import"); + expect(tokens[1][2].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[1][3].value).toBe(" "); + expect(tokens[1][3].scopes).toEqual(["source.python"]); + expect(tokens[1][4].value).toBe("a"); + expect(tokens[1][4].scopes).toEqual(["source.python"]); + expect(tokens[2][0].value).toBe(""); + expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[3][0].value).toBe("foo"); + expect(tokens[3][0].scopes).toEqual(["source.python"]); + expect(tokens[3][1].value).toBe("."); + expect(tokens[3][1].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); + expect(tokens[3][2].value).toBe("import"); + expect(tokens[3][2].scopes).toEqual(["source.python","meta.member.access.python","keyword.control.import.python"]); + expect(tokens[4][0].value).toBe(""); + expect(tokens[4][0].scopes).toEqual(["source.python"]); + expect(tokens[5][0].value).toBe("raise"); + expect(tokens[5][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[5][1].value).toBe(" "); + expect(tokens[5][1].scopes).toEqual(["source.python"]); + expect(tokens[5][2].value).toBe("Exception"); + expect(tokens[5][2].scopes).toEqual(["source.python","support.type.exception.python"]); + expect(tokens[5][3].value).toBe(" "); + expect(tokens[5][3].scopes).toEqual(["source.python"]); + expect(tokens[5][4].value).toBe("from"); + expect(tokens[5][4].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[5][5].value).toBe(" "); + expect(tokens[5][5].scopes).toEqual(["source.python"]); + expect(tokens[5][6].value).toBe("Foo"); + expect(tokens[5][6].scopes).toEqual(["source.python"]); + expect(tokens[6][0].value).toBe(""); + expect(tokens[6][0].scopes).toEqual(["source.python"]); + expect(tokens[7][0].value).toBe("def"); + expect(tokens[7][0].scopes).toEqual(["source.python","meta.function.python","storage.type.function.python"]); + expect(tokens[7][1].value).toBe(" "); + expect(tokens[7][1].scopes).toEqual(["source.python","meta.function.python"]); + expect(tokens[7][2].value).toBe("bar"); + expect(tokens[7][2].scopes).toEqual(["source.python","meta.function.python","entity.name.function.python"]); + expect(tokens[7][3].value).toBe("("); + expect(tokens[7][3].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.definition.parameters.begin.python"]); + expect(tokens[7][4].value).toBe(")"); + expect(tokens[7][4].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.definition.parameters.end.python"]); + expect(tokens[7][5].value).toBe(":"); + expect(tokens[7][5].scopes).toEqual(["source.python","meta.function.python","punctuation.section.function.begin.python"]); + expect(tokens[8][0].value).toBe(" "); + expect(tokens[8][0].scopes).toEqual(["source.python"]); + expect(tokens[8][1].value).toBe("yield from"); + expect(tokens[8][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[8][2].value).toBe(" "); + expect(tokens[8][2].scopes).toEqual(["source.python"]); + expect(tokens[8][3].value).toBe("baz"); + expect(tokens[8][3].scopes).toEqual(["source.python"]); + }); + + it("test/statements/import6.py", + function() { + tokens = grammar.tokenizeLines("from __future__ import generator_stop") + expect(tokens[0][0].value).toBe("from"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]); expect(tokens[0][1].value).toBe(" "); expect(tokens[0][1].scopes).toEqual(["source.python"]); - expect(tokens[0][2].value).toBe("="); - expect(tokens[0][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[0][2].value).toBe("__future__"); + expect(tokens[0][2].scopes).toEqual(["source.python","support.variable.magic.python"]); expect(tokens[0][3].value).toBe(" "); expect(tokens[0][3].scopes).toEqual(["source.python"]); - expect(tokens[0][4].value).toBe("r"); - expect(tokens[0][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python","storage.type.string.python"]); - expect(tokens[0][5].value).toBe("'"); - expect(tokens[0][5].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.begin.python"]); - expect(tokens[0][6].value).toBe("foo"); - expect(tokens[0][6].scopes).toEqual(["source.python","string.regexp.quoted.single.python"]); - expect(tokens[0][7].value).toBe("[^]"); - expect(tokens[0][7].scopes).toEqual(["source.python","string.regexp.quoted.single.python"]); - expect(tokens[0][8].value).toBe("'"); - expect(tokens[0][8].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.end.python"]); - expect(tokens[1][0].value).toBe("a"); - expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("import"); + expect(tokens[0][4].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][5].value).toBe(" "); + expect(tokens[0][5].scopes).toEqual(["source.python"]); + expect(tokens[0][6].value).toBe("generator_stop"); + expect(tokens[0][6].scopes).toEqual(["source.python"]); + }); + + it("test/statements/import7.py", + function() { + tokens = grammar.tokenizeLines("from .importing import *\nfrom importing import *") + expect(tokens[0][0].value).toBe("from"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("."); + expect(tokens[0][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][3].value).toBe("importing"); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe(" "); + expect(tokens[0][4].scopes).toEqual(["source.python"]); + expect(tokens[0][5].value).toBe("import"); + expect(tokens[0][5].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][6].value).toBe(" "); + expect(tokens[0][6].scopes).toEqual(["source.python"]); + expect(tokens[0][7].value).toBe("*"); + expect(tokens[0][7].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]); + expect(tokens[1][0].value).toBe("from"); + expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.import.python"]); expect(tokens[1][1].value).toBe(" "); expect(tokens[1][1].scopes).toEqual(["source.python"]); - expect(tokens[1][2].value).toBe("="); - expect(tokens[1][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[1][2].value).toBe("importing"); + expect(tokens[1][2].scopes).toEqual(["source.python"]); expect(tokens[1][3].value).toBe(" "); expect(tokens[1][3].scopes).toEqual(["source.python"]); - expect(tokens[1][4].value).toBe("r"); - expect(tokens[1][4].scopes).toEqual(["source.python","string.regexp.quoted.single.python","storage.type.string.python"]); - expect(tokens[1][5].value).toBe("'"); - expect(tokens[1][5].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.begin.python"]); - expect(tokens[1][6].value).toBe("foo"); - expect(tokens[1][6].scopes).toEqual(["source.python","string.regexp.quoted.single.python"]); - expect(tokens[1][7].value).toBe("[]"); - expect(tokens[1][7].scopes).toEqual(["source.python","string.regexp.quoted.single.python"]); - expect(tokens[1][8].value).toBe("'"); - expect(tokens[1][8].scopes).toEqual(["source.python","string.regexp.quoted.single.python","punctuation.definition.string.end.python"]); - }); - - it("test/semicolon/semi1.py", - function() { - tokens = grammar.tokenizeLines("a;\n;\na=1; b") - expect(tokens[0][0].value).toBe("a"); - expect(tokens[0][0].scopes).toEqual(["source.python"]); - expect(tokens[0][1].value).toBe(";"); - expect(tokens[0][1].scopes).toEqual(["source.python","invalid.deprecated.semicolon.python"]); - expect(tokens[1][0].value).toBe(";"); - expect(tokens[1][0].scopes).toEqual(["source.python","invalid.deprecated.semicolon.python"]); - expect(tokens[2][0].value).toBe("a"); - expect(tokens[2][0].scopes).toEqual(["source.python"]); - expect(tokens[2][1].value).toBe("="); - expect(tokens[2][1].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[2][2].value).toBe("1"); - expect(tokens[2][2].scopes).toEqual(["source.python","constant.numeric.dec.python"]); - expect(tokens[2][3].value).toBe("; "); - expect(tokens[2][3].scopes).toEqual(["source.python"]); - expect(tokens[2][4].value).toBe("b"); - expect(tokens[2][4].scopes).toEqual(["source.python"]); + expect(tokens[1][4].value).toBe("import"); + expect(tokens[1][4].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[1][5].value).toBe(" "); + expect(tokens[1][5].scopes).toEqual(["source.python"]); + expect(tokens[1][6].value).toBe("*"); + expect(tokens[1][6].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]); }); - it("test/statements/annotation1.py", + it("test/statements/import8.py", function() { - tokens = grammar.tokenizeLines("some_number: int # variable without initial value\nsome_list: List[int] = [] # variable with initial value") - expect(tokens[0][0].value).toBe("some_number"); - expect(tokens[0][0].scopes).toEqual(["source.python"]); + tokens = grammar.tokenizeLines("try:\n import \\\n time as ham, \\\n datetime \\\n # XXX: comment at the end of import\nexcept Exception as exc:\n pass") + expect(tokens[0][0].value).toBe("try"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); expect(tokens[0][1].value).toBe(":"); expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); - expect(tokens[0][2].value).toBe(" "); - expect(tokens[0][2].scopes).toEqual(["source.python"]); - expect(tokens[0][3].value).toBe("int"); - expect(tokens[0][3].scopes).toEqual(["source.python","support.type.python"]); - expect(tokens[0][4].value).toBe(" "); - expect(tokens[0][4].scopes).toEqual(["source.python"]); - expect(tokens[0][5].value).toBe("#"); - expect(tokens[0][5].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[0][6].value).toBe(" variable without initial value"); - expect(tokens[0][6].scopes).toEqual(["source.python","comment.line.number-sign.python"]); - expect(tokens[1][0].value).toBe("some_list"); - expect(tokens[1][0].scopes).toEqual(["source.python"]); - expect(tokens[1][1].value).toBe(":"); - expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); - expect(tokens[1][2].value).toBe(" "); - expect(tokens[1][2].scopes).toEqual(["source.python"]); - expect(tokens[1][3].value).toBe("List"); - expect(tokens[1][3].scopes).toEqual(["source.python","meta.item-access.python"]); - expect(tokens[1][4].value).toBe("["); - expect(tokens[1][4].scopes).toEqual(["source.python","meta.item-access.python","punctuation.definition.arguments.begin.python"]); - expect(tokens[1][5].value).toBe("int"); - expect(tokens[1][5].scopes).toEqual(["source.python","meta.item-access.python","meta.item-access.arguments.python","support.type.python"]); - expect(tokens[1][6].value).toBe("]"); - expect(tokens[1][6].scopes).toEqual(["source.python","meta.item-access.python","punctuation.definition.arguments.end.python"]); - expect(tokens[1][7].value).toBe(" "); - expect(tokens[1][7].scopes).toEqual(["source.python"]); - expect(tokens[1][8].value).toBe("="); - expect(tokens[1][8].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); - expect(tokens[1][9].value).toBe(" "); - expect(tokens[1][9].scopes).toEqual(["source.python"]); - expect(tokens[1][10].value).toBe("["); - expect(tokens[1][10].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); - expect(tokens[1][11].value).toBe("]"); - expect(tokens[1][11].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); - expect(tokens[1][12].value).toBe(" "); - expect(tokens[1][12].scopes).toEqual(["source.python"]); - expect(tokens[1][13].value).toBe("#"); - expect(tokens[1][13].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[1][14].value).toBe(" variable with initial value"); - expect(tokens[1][14].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[1][0].value).toBe(" "); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe("import"); + expect(tokens[1][1].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[1][2].value).toBe(" "); + expect(tokens[1][2].scopes).toEqual(["source.python"]); + expect(tokens[1][3].value).toBe("\\"); + expect(tokens[1][3].scopes).toEqual(["source.python","punctuation.separator.continuation.line.python"]); + expect(tokens[1][4].value).toBe(""); + expect(tokens[1][4].scopes).toEqual(["source.python"]); + expect(tokens[2][0].value).toBe(" "); + expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[2][1].value).toBe("time"); + expect(tokens[2][1].scopes).toEqual(["source.python"]); + expect(tokens[2][2].value).toBe(" "); + expect(tokens[2][2].scopes).toEqual(["source.python"]); + expect(tokens[2][3].value).toBe("as"); + expect(tokens[2][3].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[2][4].value).toBe(" "); + expect(tokens[2][4].scopes).toEqual(["source.python"]); + expect(tokens[2][5].value).toBe("ham"); + expect(tokens[2][5].scopes).toEqual(["source.python"]); + expect(tokens[2][6].value).toBe(","); + expect(tokens[2][6].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[2][7].value).toBe(" "); + expect(tokens[2][7].scopes).toEqual(["source.python"]); + expect(tokens[2][8].value).toBe("\\"); + expect(tokens[2][8].scopes).toEqual(["source.python","punctuation.separator.continuation.line.python"]); + expect(tokens[2][9].value).toBe(""); + expect(tokens[2][9].scopes).toEqual(["source.python"]); + expect(tokens[3][0].value).toBe(" "); + expect(tokens[3][0].scopes).toEqual(["source.python"]); + expect(tokens[3][1].value).toBe("datetime"); + expect(tokens[3][1].scopes).toEqual(["source.python"]); + expect(tokens[3][2].value).toBe(" "); + expect(tokens[3][2].scopes).toEqual(["source.python"]); + expect(tokens[3][3].value).toBe("\\"); + expect(tokens[3][3].scopes).toEqual(["source.python","punctuation.separator.continuation.line.python"]); + expect(tokens[3][4].value).toBe(""); + expect(tokens[3][4].scopes).toEqual(["source.python"]); + expect(tokens[4][0].value).toBe(" "); + expect(tokens[4][0].scopes).toEqual(["source.python"]); + expect(tokens[4][1].value).toBe("#"); + expect(tokens[4][1].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[4][2].value).toBe(" "); + expect(tokens[4][2].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[4][3].value).toBe("XXX"); + expect(tokens[4][3].scopes).toEqual(["source.python","comment.line.number-sign.python","keyword.codetag.notation.python"]); + expect(tokens[4][4].value).toBe(": comment at the end of import"); + expect(tokens[4][4].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[5][0].value).toBe("except"); + expect(tokens[5][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[5][1].value).toBe(" "); + expect(tokens[5][1].scopes).toEqual(["source.python"]); + expect(tokens[5][2].value).toBe("Exception"); + expect(tokens[5][2].scopes).toEqual(["source.python","support.type.exception.python"]); + expect(tokens[5][3].value).toBe(" "); + expect(tokens[5][3].scopes).toEqual(["source.python"]); + expect(tokens[5][4].value).toBe("as"); + expect(tokens[5][4].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[5][5].value).toBe(" "); + expect(tokens[5][5].scopes).toEqual(["source.python"]); + expect(tokens[5][6].value).toBe("exc"); + expect(tokens[5][6].scopes).toEqual(["source.python"]); + expect(tokens[5][7].value).toBe(":"); + expect(tokens[5][7].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[6][0].value).toBe(" "); + expect(tokens[6][0].scopes).toEqual(["source.python"]); + expect(tokens[6][1].value).toBe("pass"); + expect(tokens[6][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); }); - it("test/statements/for1.py", + it("test/statements/import9.py", function() { - tokens = grammar.tokenizeLines("for a, b, c in b:\n pass\nelse:\n 1/0") - expect(tokens[0][0].value).toBe("for"); - expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + tokens = grammar.tokenizeLines("from . . . foo import \\\n (\n # XXX: legal comment inside import\n time as bar,\n # another comment\n baz,\n datetime as ham\n )\nraise Exception('!') from None") + expect(tokens[0][0].value).toBe("from"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]); expect(tokens[0][1].value).toBe(" "); expect(tokens[0][1].scopes).toEqual(["source.python"]); - expect(tokens[0][2].value).toBe("a"); - expect(tokens[0][2].scopes).toEqual(["source.python"]); - expect(tokens[0][3].value).toBe(","); - expect(tokens[0][3].scopes).toEqual(["source.python","punctuation.separator.element.python"]); - expect(tokens[0][4].value).toBe(" "); - expect(tokens[0][4].scopes).toEqual(["source.python"]); - expect(tokens[0][5].value).toBe("b"); + expect(tokens[0][2].value).toBe("."); + expect(tokens[0][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("."); + expect(tokens[0][4].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][5].value).toBe(" "); expect(tokens[0][5].scopes).toEqual(["source.python"]); - expect(tokens[0][6].value).toBe(","); - expect(tokens[0][6].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[0][6].value).toBe("."); + expect(tokens[0][6].scopes).toEqual(["source.python","punctuation.separator.period.python"]); expect(tokens[0][7].value).toBe(" "); expect(tokens[0][7].scopes).toEqual(["source.python"]); - expect(tokens[0][8].value).toBe("c"); + expect(tokens[0][8].value).toBe("foo"); expect(tokens[0][8].scopes).toEqual(["source.python"]); expect(tokens[0][9].value).toBe(" "); expect(tokens[0][9].scopes).toEqual(["source.python"]); - expect(tokens[0][10].value).toBe("in"); - expect(tokens[0][10].scopes).toEqual(["source.python","keyword.operator.logical.python"]); + expect(tokens[0][10].value).toBe("import"); + expect(tokens[0][10].scopes).toEqual(["source.python","keyword.control.import.python"]); expect(tokens[0][11].value).toBe(" "); expect(tokens[0][11].scopes).toEqual(["source.python"]); - expect(tokens[0][12].value).toBe("b"); - expect(tokens[0][12].scopes).toEqual(["source.python"]); - expect(tokens[0][13].value).toBe(":"); - expect(tokens[0][13].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[0][12].value).toBe("\\"); + expect(tokens[0][12].scopes).toEqual(["source.python","punctuation.separator.continuation.line.python"]); + expect(tokens[0][13].value).toBe(""); + expect(tokens[0][13].scopes).toEqual(["source.python"]); expect(tokens[1][0].value).toBe(" "); expect(tokens[1][0].scopes).toEqual(["source.python"]); - expect(tokens[1][1].value).toBe("pass"); - expect(tokens[1][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); - expect(tokens[2][0].value).toBe("else"); - expect(tokens[2][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); - expect(tokens[2][1].value).toBe(":"); - expect(tokens[2][1].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); - expect(tokens[3][0].value).toBe(" "); + expect(tokens[1][1].value).toBe("("); + expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.parenthesis.begin.python"]); + expect(tokens[2][0].value).toBe(" "); + expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[2][1].value).toBe("#"); + expect(tokens[2][1].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[2][2].value).toBe(" "); + expect(tokens[2][2].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[2][3].value).toBe("XXX"); + expect(tokens[2][3].scopes).toEqual(["source.python","comment.line.number-sign.python","keyword.codetag.notation.python"]); + expect(tokens[2][4].value).toBe(": legal comment inside import"); + expect(tokens[2][4].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[3][0].value).toBe(" "); expect(tokens[3][0].scopes).toEqual(["source.python"]); - expect(tokens[3][1].value).toBe("1"); - expect(tokens[3][1].scopes).toEqual(["source.python","constant.numeric.dec.python"]); - expect(tokens[3][2].value).toBe("/"); - expect(tokens[3][2].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]); - expect(tokens[3][3].value).toBe("0"); - expect(tokens[3][3].scopes).toEqual(["source.python","constant.numeric.dec.python"]); - }); - - it("test/statements/global1.py", - function() { - tokens = grammar.tokenizeLines("global a, b, c") - expect(tokens[0][0].value).toBe("global"); - expect(tokens[0][0].scopes).toEqual(["source.python","storage.modifier.declaration.python"]); - expect(tokens[0][1].value).toBe(" "); - expect(tokens[0][1].scopes).toEqual(["source.python"]); - expect(tokens[0][2].value).toBe("a"); - expect(tokens[0][2].scopes).toEqual(["source.python"]); - expect(tokens[0][3].value).toBe(","); - expect(tokens[0][3].scopes).toEqual(["source.python","punctuation.separator.element.python"]); - expect(tokens[0][4].value).toBe(" "); - expect(tokens[0][4].scopes).toEqual(["source.python"]); - expect(tokens[0][5].value).toBe("b"); - expect(tokens[0][5].scopes).toEqual(["source.python"]); - expect(tokens[0][6].value).toBe(","); - expect(tokens[0][6].scopes).toEqual(["source.python","punctuation.separator.element.python"]); - expect(tokens[0][7].value).toBe(" "); - expect(tokens[0][7].scopes).toEqual(["source.python"]); - expect(tokens[0][8].value).toBe("c"); - expect(tokens[0][8].scopes).toEqual(["source.python"]); + expect(tokens[3][1].value).toBe("time"); + expect(tokens[3][1].scopes).toEqual(["source.python"]); + expect(tokens[3][2].value).toBe(" "); + expect(tokens[3][2].scopes).toEqual(["source.python"]); + expect(tokens[3][3].value).toBe("as"); + expect(tokens[3][3].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[3][4].value).toBe(" "); + expect(tokens[3][4].scopes).toEqual(["source.python"]); + expect(tokens[3][5].value).toBe("bar"); + expect(tokens[3][5].scopes).toEqual(["source.python"]); + expect(tokens[3][6].value).toBe(","); + expect(tokens[3][6].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[4][0].value).toBe(" "); + expect(tokens[4][0].scopes).toEqual(["source.python"]); + expect(tokens[4][1].value).toBe("#"); + expect(tokens[4][1].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[4][2].value).toBe(" another comment"); + expect(tokens[4][2].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[5][0].value).toBe(" "); + expect(tokens[5][0].scopes).toEqual(["source.python"]); + expect(tokens[5][1].value).toBe("baz"); + expect(tokens[5][1].scopes).toEqual(["source.python"]); + expect(tokens[5][2].value).toBe(","); + expect(tokens[5][2].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[6][0].value).toBe(" "); + expect(tokens[6][0].scopes).toEqual(["source.python"]); + expect(tokens[6][1].value).toBe("datetime"); + expect(tokens[6][1].scopes).toEqual(["source.python"]); + expect(tokens[6][2].value).toBe(" "); + expect(tokens[6][2].scopes).toEqual(["source.python"]); + expect(tokens[6][3].value).toBe("as"); + expect(tokens[6][3].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[6][4].value).toBe(" "); + expect(tokens[6][4].scopes).toEqual(["source.python"]); + expect(tokens[6][5].value).toBe("ham"); + expect(tokens[6][5].scopes).toEqual(["source.python"]); + expect(tokens[7][0].value).toBe(" "); + expect(tokens[7][0].scopes).toEqual(["source.python"]); + expect(tokens[7][1].value).toBe(")"); + expect(tokens[7][1].scopes).toEqual(["source.python","punctuation.parenthesis.end.python"]); + expect(tokens[8][0].value).toBe("raise"); + expect(tokens[8][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[8][1].value).toBe(" "); + expect(tokens[8][1].scopes).toEqual(["source.python"]); + expect(tokens[8][2].value).toBe("Exception"); + expect(tokens[8][2].scopes).toEqual(["source.python","meta.function-call.python","support.type.exception.python"]); + expect(tokens[8][3].value).toBe("("); + expect(tokens[8][3].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[8][4].value).toBe("'"); + expect(tokens[8][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[8][5].value).toBe("!"); + expect(tokens[8][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python"]); + expect(tokens[8][6].value).toBe("'"); + expect(tokens[8][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[8][7].value).toBe(")"); + expect(tokens[8][7].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[8][8].value).toBe(" "); + expect(tokens[8][8].scopes).toEqual(["source.python"]); + expect(tokens[8][9].value).toBe("from"); + expect(tokens[8][9].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[8][10].value).toBe(" "); + expect(tokens[8][10].scopes).toEqual(["source.python"]); + expect(tokens[8][11].value).toBe("None"); + expect(tokens[8][11].scopes).toEqual(["source.python","constant.language.python"]); }); - it("test/statements/if1.py", + it("test/statements/match1.py", function() { - tokens = grammar.tokenizeLines("if (a if b else c):\n 1\nelif b or c and d:\n 2\nelse:\n 3") - expect(tokens[0][0].value).toBe("if"); - expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + tokens = grammar.tokenizeLines("def foo(status):\n match status:\n case 404:\n return \"Not found\"\n case 401 | 403:\n return \"Not allowed\"\n case _:\n return \"Something's wrong with the internet\"") + expect(tokens[0][0].value).toBe("def"); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.function.python","storage.type.function.python"]); expect(tokens[0][1].value).toBe(" "); - expect(tokens[0][1].scopes).toEqual(["source.python"]); - expect(tokens[0][2].value).toBe("("); - expect(tokens[0][2].scopes).toEqual(["source.python","punctuation.parenthesis.begin.python"]); - expect(tokens[0][3].value).toBe("a"); - expect(tokens[0][3].scopes).toEqual(["source.python"]); - expect(tokens[0][4].value).toBe(" "); - expect(tokens[0][4].scopes).toEqual(["source.python"]); - expect(tokens[0][5].value).toBe("if"); - expect(tokens[0][5].scopes).toEqual(["source.python","keyword.control.flow.python"]); - expect(tokens[0][6].value).toBe(" "); - expect(tokens[0][6].scopes).toEqual(["source.python"]); - expect(tokens[0][7].value).toBe("b"); - expect(tokens[0][7].scopes).toEqual(["source.python"]); - expect(tokens[0][8].value).toBe(" "); - expect(tokens[0][8].scopes).toEqual(["source.python"]); - expect(tokens[0][9].value).toBe("else"); - expect(tokens[0][9].scopes).toEqual(["source.python","keyword.control.flow.python"]); - expect(tokens[0][10].value).toBe(" "); - expect(tokens[0][10].scopes).toEqual(["source.python"]); - expect(tokens[0][11].value).toBe("c"); - expect(tokens[0][11].scopes).toEqual(["source.python"]); - expect(tokens[0][12].value).toBe(")"); - expect(tokens[0][12].scopes).toEqual(["source.python","punctuation.parenthesis.end.python"]); - expect(tokens[0][13].value).toBe(":"); - expect(tokens[0][13].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[0][1].scopes).toEqual(["source.python","meta.function.python"]); + expect(tokens[0][2].value).toBe("foo"); + expect(tokens[0][2].scopes).toEqual(["source.python","meta.function.python","entity.name.function.python"]); + expect(tokens[0][3].value).toBe("("); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.definition.parameters.begin.python"]); + expect(tokens[0][4].value).toBe("status"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","variable.parameter.function.language.python"]); + expect(tokens[0][5].value).toBe(")"); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.definition.parameters.end.python"]); + expect(tokens[0][6].value).toBe(":"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.function.python","punctuation.section.function.begin.python"]); expect(tokens[1][0].value).toBe(" "); expect(tokens[1][0].scopes).toEqual(["source.python"]); - expect(tokens[1][1].value).toBe("1"); - expect(tokens[1][1].scopes).toEqual(["source.python","constant.numeric.dec.python"]); - expect(tokens[2][0].value).toBe("elif"); - expect(tokens[2][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); - expect(tokens[2][1].value).toBe(" "); - expect(tokens[2][1].scopes).toEqual(["source.python"]); - expect(tokens[2][2].value).toBe("b"); + expect(tokens[1][1].value).toBe("match"); + expect(tokens[1][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[1][2].value).toBe(" "); + expect(tokens[1][2].scopes).toEqual(["source.python"]); + expect(tokens[1][3].value).toBe("status"); + expect(tokens[1][3].scopes).toEqual(["source.python"]); + expect(tokens[1][4].value).toBe(":"); + expect(tokens[1][4].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[2][0].value).toBe(" "); + expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[2][1].value).toBe("case"); + expect(tokens[2][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[2][2].value).toBe(" "); expect(tokens[2][2].scopes).toEqual(["source.python"]); - expect(tokens[2][3].value).toBe(" "); - expect(tokens[2][3].scopes).toEqual(["source.python"]); - expect(tokens[2][4].value).toBe("or"); - expect(tokens[2][4].scopes).toEqual(["source.python","keyword.operator.logical.python"]); - expect(tokens[2][5].value).toBe(" "); - expect(tokens[2][5].scopes).toEqual(["source.python"]); - expect(tokens[2][6].value).toBe("c"); - expect(tokens[2][6].scopes).toEqual(["source.python"]); - expect(tokens[2][7].value).toBe(" "); - expect(tokens[2][7].scopes).toEqual(["source.python"]); - expect(tokens[2][8].value).toBe("and"); - expect(tokens[2][8].scopes).toEqual(["source.python","keyword.operator.logical.python"]); - expect(tokens[2][9].value).toBe(" "); - expect(tokens[2][9].scopes).toEqual(["source.python"]); - expect(tokens[2][10].value).toBe("d"); - expect(tokens[2][10].scopes).toEqual(["source.python"]); - expect(tokens[2][11].value).toBe(":"); - expect(tokens[2][11].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); - expect(tokens[3][0].value).toBe(" "); + expect(tokens[2][3].value).toBe("404"); + expect(tokens[2][3].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[2][4].value).toBe(":"); + expect(tokens[2][4].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[3][0].value).toBe(" "); expect(tokens[3][0].scopes).toEqual(["source.python"]); - expect(tokens[3][1].value).toBe("2"); - expect(tokens[3][1].scopes).toEqual(["source.python","constant.numeric.dec.python"]); - expect(tokens[4][0].value).toBe("else"); - expect(tokens[4][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); - expect(tokens[4][1].value).toBe(":"); - expect(tokens[4][1].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); - expect(tokens[5][0].value).toBe(" "); + expect(tokens[3][1].value).toBe("return"); + expect(tokens[3][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[3][2].value).toBe(" "); + expect(tokens[3][2].scopes).toEqual(["source.python"]); + expect(tokens[3][3].value).toBe("\""); + expect(tokens[3][3].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[3][4].value).toBe("Not found"); + expect(tokens[3][4].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[3][5].value).toBe("\""); + expect(tokens[3][5].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[4][0].value).toBe(" "); + expect(tokens[4][0].scopes).toEqual(["source.python"]); + expect(tokens[4][1].value).toBe("case"); + expect(tokens[4][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[4][2].value).toBe(" "); + expect(tokens[4][2].scopes).toEqual(["source.python"]); + expect(tokens[4][3].value).toBe("401"); + expect(tokens[4][3].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[4][4].value).toBe(" "); + expect(tokens[4][4].scopes).toEqual(["source.python"]); + expect(tokens[4][5].value).toBe("|"); + expect(tokens[4][5].scopes).toEqual(["source.python","keyword.operator.bitwise.python"]); + expect(tokens[4][6].value).toBe(" "); + expect(tokens[4][6].scopes).toEqual(["source.python"]); + expect(tokens[4][7].value).toBe("403"); + expect(tokens[4][7].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[4][8].value).toBe(":"); + expect(tokens[4][8].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[5][0].value).toBe(" "); expect(tokens[5][0].scopes).toEqual(["source.python"]); - expect(tokens[5][1].value).toBe("3"); - expect(tokens[5][1].scopes).toEqual(["source.python","constant.numeric.dec.python"]); + expect(tokens[5][1].value).toBe("return"); + expect(tokens[5][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[5][2].value).toBe(" "); + expect(tokens[5][2].scopes).toEqual(["source.python"]); + expect(tokens[5][3].value).toBe("\""); + expect(tokens[5][3].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[5][4].value).toBe("Not allowed"); + expect(tokens[5][4].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[5][5].value).toBe("\""); + expect(tokens[5][5].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[6][0].value).toBe(" "); + expect(tokens[6][0].scopes).toEqual(["source.python"]); + expect(tokens[6][1].value).toBe("case"); + expect(tokens[6][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[6][2].value).toBe(" "); + expect(tokens[6][2].scopes).toEqual(["source.python"]); + expect(tokens[6][3].value).toBe("_"); + expect(tokens[6][3].scopes).toEqual(["source.python"]); + expect(tokens[6][4].value).toBe(":"); + expect(tokens[6][4].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[7][0].value).toBe(" "); + expect(tokens[7][0].scopes).toEqual(["source.python"]); + expect(tokens[7][1].value).toBe("return"); + expect(tokens[7][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[7][2].value).toBe(" "); + expect(tokens[7][2].scopes).toEqual(["source.python"]); + expect(tokens[7][3].value).toBe("\""); + expect(tokens[7][3].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[7][4].value).toBe("Something's wrong with the internet"); + expect(tokens[7][4].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[7][5].value).toBe("\""); + expect(tokens[7][5].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); }); - it("test/statements/import1.py", + it("test/statements/match2.py", function() { - tokens = grammar.tokenizeLines("from ...foo import bar as spam, baz\nimport time as ham, datetime") - expect(tokens[0][0].value).toBe("from"); - expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + tokens = grammar.tokenizeLines("match point:\n case Point(x=0, y=0):\n print(\"Origin is the point's location.\")\n case Point(x=0, y=y):\n print(f\"The point is on the y-axis.\")\n case Point(x=x, y=0):\n print(f\"The point is on the x-axis.\")\n case Point():\n print(\"The point is located somewhere else on the plane.\")\n case _:\n print(\"Not a point\")") + expect(tokens[0][0].value).toBe("match"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); expect(tokens[0][1].value).toBe(" "); expect(tokens[0][1].scopes).toEqual(["source.python"]); - expect(tokens[0][2].value).toBe("..."); - expect(tokens[0][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[0][3].value).toBe("foo"); - expect(tokens[0][3].scopes).toEqual(["source.python"]); - expect(tokens[0][4].value).toBe(" "); - expect(tokens[0][4].scopes).toEqual(["source.python"]); - expect(tokens[0][5].value).toBe("import"); - expect(tokens[0][5].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[0][6].value).toBe(" "); - expect(tokens[0][6].scopes).toEqual(["source.python"]); - expect(tokens[0][7].value).toBe("bar"); - expect(tokens[0][7].scopes).toEqual(["source.python"]); - expect(tokens[0][8].value).toBe(" "); - expect(tokens[0][8].scopes).toEqual(["source.python"]); - expect(tokens[0][9].value).toBe("as"); - expect(tokens[0][9].scopes).toEqual(["source.python","keyword.control.flow.python"]); - expect(tokens[0][10].value).toBe(" "); - expect(tokens[0][10].scopes).toEqual(["source.python"]); - expect(tokens[0][11].value).toBe("spam"); - expect(tokens[0][11].scopes).toEqual(["source.python"]); - expect(tokens[0][12].value).toBe(","); - expect(tokens[0][12].scopes).toEqual(["source.python","punctuation.separator.element.python"]); - expect(tokens[0][13].value).toBe(" "); - expect(tokens[0][13].scopes).toEqual(["source.python"]); - expect(tokens[0][14].value).toBe("baz"); - expect(tokens[0][14].scopes).toEqual(["source.python"]); - expect(tokens[1][0].value).toBe("import"); - expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[1][1].value).toBe(" "); - expect(tokens[1][1].scopes).toEqual(["source.python"]); - expect(tokens[1][2].value).toBe("time"); + expect(tokens[0][2].value).toBe("point"); + expect(tokens[0][2].scopes).toEqual(["source.python"]); + expect(tokens[0][3].value).toBe(":"); + expect(tokens[0][3].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[1][0].value).toBe(" "); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe("case"); + expect(tokens[1][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[1][2].value).toBe(" "); expect(tokens[1][2].scopes).toEqual(["source.python"]); - expect(tokens[1][3].value).toBe(" "); - expect(tokens[1][3].scopes).toEqual(["source.python"]); - expect(tokens[1][4].value).toBe("as"); - expect(tokens[1][4].scopes).toEqual(["source.python","keyword.control.flow.python"]); - expect(tokens[1][5].value).toBe(" "); - expect(tokens[1][5].scopes).toEqual(["source.python"]); - expect(tokens[1][6].value).toBe("ham"); - expect(tokens[1][6].scopes).toEqual(["source.python"]); - expect(tokens[1][7].value).toBe(","); - expect(tokens[1][7].scopes).toEqual(["source.python","punctuation.separator.element.python"]); - expect(tokens[1][8].value).toBe(" "); - expect(tokens[1][8].scopes).toEqual(["source.python"]); - expect(tokens[1][9].value).toBe("datetime"); - expect(tokens[1][9].scopes).toEqual(["source.python"]); + expect(tokens[1][3].value).toBe("Point"); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[1][4].value).toBe("("); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[1][5].value).toBe("x"); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[1][6].value).toBe("="); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[1][7].value).toBe("0"); + expect(tokens[1][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[1][8].value).toBe(","); + expect(tokens[1][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[1][9].value).toBe(" "); + expect(tokens[1][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[1][10].value).toBe("y"); + expect(tokens[1][10].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[1][11].value).toBe("="); + expect(tokens[1][11].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[1][12].value).toBe("0"); + expect(tokens[1][12].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[1][13].value).toBe(")"); + expect(tokens[1][13].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[1][14].value).toBe(":"); + expect(tokens[1][14].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[2][0].value).toBe(" "); + expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[2][1].value).toBe("print"); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[2][2].value).toBe("("); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[2][3].value).toBe("\""); + expect(tokens[2][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[2][4].value).toBe("Origin is the point's location."); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python"]); + expect(tokens[2][5].value).toBe("\""); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[2][6].value).toBe(")"); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[3][0].value).toBe(" "); + expect(tokens[3][0].scopes).toEqual(["source.python"]); + expect(tokens[3][1].value).toBe("case"); + expect(tokens[3][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[3][2].value).toBe(" "); + expect(tokens[3][2].scopes).toEqual(["source.python"]); + expect(tokens[3][3].value).toBe("Point"); + expect(tokens[3][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[3][4].value).toBe("("); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[3][5].value).toBe("x"); + expect(tokens[3][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[3][6].value).toBe("="); + expect(tokens[3][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[3][7].value).toBe("0"); + expect(tokens[3][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[3][8].value).toBe(","); + expect(tokens[3][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[3][9].value).toBe(" "); + expect(tokens[3][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[3][10].value).toBe("y"); + expect(tokens[3][10].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[3][11].value).toBe("="); + expect(tokens[3][11].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[3][12].value).toBe("y"); + expect(tokens[3][12].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[3][13].value).toBe(")"); + expect(tokens[3][13].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[3][14].value).toBe(":"); + expect(tokens[3][14].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[4][0].value).toBe(" "); + expect(tokens[4][0].scopes).toEqual(["source.python"]); + expect(tokens[4][1].value).toBe("print"); + expect(tokens[4][1].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[4][2].value).toBe("("); + expect(tokens[4][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[4][3].value).toBe("f"); + expect(tokens[4][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[4][4].value).toBe("\""); + expect(tokens[4][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[4][5].value).toBe("The point is on the y-axis."); + expect(tokens[4][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[4][6].value).toBe("\""); + expect(tokens[4][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[4][7].value).toBe(")"); + expect(tokens[4][7].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[5][0].value).toBe(" "); + expect(tokens[5][0].scopes).toEqual(["source.python"]); + expect(tokens[5][1].value).toBe("case"); + expect(tokens[5][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[5][2].value).toBe(" "); + expect(tokens[5][2].scopes).toEqual(["source.python"]); + expect(tokens[5][3].value).toBe("Point"); + expect(tokens[5][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[5][4].value).toBe("("); + expect(tokens[5][4].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[5][5].value).toBe("x"); + expect(tokens[5][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[5][6].value).toBe("="); + expect(tokens[5][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[5][7].value).toBe("x"); + expect(tokens[5][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[5][8].value).toBe(","); + expect(tokens[5][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[5][9].value).toBe(" "); + expect(tokens[5][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[5][10].value).toBe("y"); + expect(tokens[5][10].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[5][11].value).toBe("="); + expect(tokens[5][11].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[5][12].value).toBe("0"); + expect(tokens[5][12].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[5][13].value).toBe(")"); + expect(tokens[5][13].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[5][14].value).toBe(":"); + expect(tokens[5][14].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[6][0].value).toBe(" "); + expect(tokens[6][0].scopes).toEqual(["source.python"]); + expect(tokens[6][1].value).toBe("print"); + expect(tokens[6][1].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[6][2].value).toBe("("); + expect(tokens[6][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[6][3].value).toBe("f"); + expect(tokens[6][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[6][4].value).toBe("\""); + expect(tokens[6][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[6][5].value).toBe("The point is on the x-axis."); + expect(tokens[6][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[6][6].value).toBe("\""); + expect(tokens[6][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[6][7].value).toBe(")"); + expect(tokens[6][7].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[7][0].value).toBe(" "); + expect(tokens[7][0].scopes).toEqual(["source.python"]); + expect(tokens[7][1].value).toBe("case"); + expect(tokens[7][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[7][2].value).toBe(" "); + expect(tokens[7][2].scopes).toEqual(["source.python"]); + expect(tokens[7][3].value).toBe("Point"); + expect(tokens[7][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[7][4].value).toBe("("); + expect(tokens[7][4].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[7][5].value).toBe(")"); + expect(tokens[7][5].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[7][6].value).toBe(":"); + expect(tokens[7][6].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[8][0].value).toBe(" "); + expect(tokens[8][0].scopes).toEqual(["source.python"]); + expect(tokens[8][1].value).toBe("print"); + expect(tokens[8][1].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[8][2].value).toBe("("); + expect(tokens[8][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[8][3].value).toBe("\""); + expect(tokens[8][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[8][4].value).toBe("The point is located somewhere else on the plane."); + expect(tokens[8][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python"]); + expect(tokens[8][5].value).toBe("\""); + expect(tokens[8][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[8][6].value).toBe(")"); + expect(tokens[8][6].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[9][0].value).toBe(" "); + expect(tokens[9][0].scopes).toEqual(["source.python"]); + expect(tokens[9][1].value).toBe("case"); + expect(tokens[9][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[9][2].value).toBe(" "); + expect(tokens[9][2].scopes).toEqual(["source.python"]); + expect(tokens[9][3].value).toBe("_"); + expect(tokens[9][3].scopes).toEqual(["source.python"]); + expect(tokens[9][4].value).toBe(":"); + expect(tokens[9][4].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[10][0].value).toBe(" "); + expect(tokens[10][0].scopes).toEqual(["source.python"]); + expect(tokens[10][1].value).toBe("print"); + expect(tokens[10][1].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[10][2].value).toBe("("); + expect(tokens[10][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[10][3].value).toBe("\""); + expect(tokens[10][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[10][4].value).toBe("Not a point"); + expect(tokens[10][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python"]); + expect(tokens[10][5].value).toBe("\""); + expect(tokens[10][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[10][6].value).toBe(")"); + expect(tokens[10][6].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); }); - it("test/statements/import2.py", + it("test/statements/match3.py", function() { - tokens = grammar.tokenizeLines("from .... import a\nfrom ... import b\nfrom .. import c") - expect(tokens[0][0].value).toBe("from"); - expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]); + tokens = grammar.tokenizeLines("match points:\n case []:\n print(\"No points in the list.\")\n case [Point(0, 0)]:\n print(\"The origin is the only point in the list.\")\n case [Point(x, y)]:\n print(f\"A single point is in the list.\")\n case [Point(0, y1), Point(0, y2)]:\n print(f\"Two points on the Y axis are in the list.\")\n case _:\n print(\"Something else is found in the list.\")") + expect(tokens[0][0].value).toBe("match"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); expect(tokens[0][1].value).toBe(" "); expect(tokens[0][1].scopes).toEqual(["source.python"]); - expect(tokens[0][2].value).toBe("...."); - expect(tokens[0][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[0][3].value).toBe(" "); - expect(tokens[0][3].scopes).toEqual(["source.python"]); - expect(tokens[0][4].value).toBe("import"); - expect(tokens[0][4].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[0][5].value).toBe(" "); - expect(tokens[0][5].scopes).toEqual(["source.python"]); - expect(tokens[0][6].value).toBe("a"); - expect(tokens[0][6].scopes).toEqual(["source.python"]); - expect(tokens[1][0].value).toBe("from"); - expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[1][1].value).toBe(" "); - expect(tokens[1][1].scopes).toEqual(["source.python"]); - expect(tokens[1][2].value).toBe("..."); - expect(tokens[1][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[1][3].value).toBe(" "); - expect(tokens[1][3].scopes).toEqual(["source.python"]); - expect(tokens[1][4].value).toBe("import"); - expect(tokens[1][4].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[1][5].value).toBe(" "); - expect(tokens[1][5].scopes).toEqual(["source.python"]); - expect(tokens[1][6].value).toBe("b"); - expect(tokens[1][6].scopes).toEqual(["source.python"]); - expect(tokens[2][0].value).toBe("from"); - expect(tokens[2][0].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[2][1].value).toBe(" "); - expect(tokens[2][1].scopes).toEqual(["source.python"]); - expect(tokens[2][2].value).toBe(".."); - expect(tokens[2][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[2][3].value).toBe(" "); - expect(tokens[2][3].scopes).toEqual(["source.python"]); - expect(tokens[2][4].value).toBe("import"); - expect(tokens[2][4].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[2][5].value).toBe(" "); - expect(tokens[2][5].scopes).toEqual(["source.python"]); - expect(tokens[2][6].value).toBe("c"); - expect(tokens[2][6].scopes).toEqual(["source.python"]); - }); - - it("test/statements/import3.py", - function() { - tokens = grammar.tokenizeLines("from....import a\nfrom...import b\nfrom..import c\nfrom.import d") - expect(tokens[0][0].value).toBe("from"); - expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[0][1].value).toBe("...."); - expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[0][2].value).toBe("import"); - expect(tokens[0][2].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[0][3].value).toBe(" "); - expect(tokens[0][3].scopes).toEqual(["source.python"]); - expect(tokens[0][4].value).toBe("a"); - expect(tokens[0][4].scopes).toEqual(["source.python"]); - expect(tokens[1][0].value).toBe("from"); - expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[1][1].value).toBe("..."); - expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[1][2].value).toBe("import"); - expect(tokens[1][2].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[1][3].value).toBe(" "); - expect(tokens[1][3].scopes).toEqual(["source.python"]); - expect(tokens[1][4].value).toBe("b"); - expect(tokens[1][4].scopes).toEqual(["source.python"]); - expect(tokens[2][0].value).toBe("from"); - expect(tokens[2][0].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[2][1].value).toBe(".."); - expect(tokens[2][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[2][2].value).toBe("import"); - expect(tokens[2][2].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[2][3].value).toBe(" "); - expect(tokens[2][3].scopes).toEqual(["source.python"]); - expect(tokens[2][4].value).toBe("c"); - expect(tokens[2][4].scopes).toEqual(["source.python"]); - expect(tokens[3][0].value).toBe("from"); - expect(tokens[3][0].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[3][1].value).toBe("."); - expect(tokens[3][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[3][2].value).toBe("import"); - expect(tokens[3][2].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[3][3].value).toBe(" "); - expect(tokens[3][3].scopes).toEqual(["source.python"]); - expect(tokens[3][4].value).toBe("d"); - expect(tokens[3][4].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("points"); + expect(tokens[0][2].scopes).toEqual(["source.python"]); + expect(tokens[0][3].value).toBe(":"); + expect(tokens[0][3].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[1][0].value).toBe(" "); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe("case"); + expect(tokens[1][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[1][2].value).toBe(" "); + expect(tokens[1][2].scopes).toEqual(["source.python"]); + expect(tokens[1][3].value).toBe("["); + expect(tokens[1][3].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); + expect(tokens[1][4].value).toBe("]"); + expect(tokens[1][4].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); + expect(tokens[1][5].value).toBe(":"); + expect(tokens[1][5].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[2][0].value).toBe(" "); + expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[2][1].value).toBe("print"); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[2][2].value).toBe("("); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[2][3].value).toBe("\""); + expect(tokens[2][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[2][4].value).toBe("No points in the list."); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python"]); + expect(tokens[2][5].value).toBe("\""); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[2][6].value).toBe(")"); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[3][0].value).toBe(" "); + expect(tokens[3][0].scopes).toEqual(["source.python"]); + expect(tokens[3][1].value).toBe("case"); + expect(tokens[3][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[3][2].value).toBe(" "); + expect(tokens[3][2].scopes).toEqual(["source.python"]); + expect(tokens[3][3].value).toBe("["); + expect(tokens[3][3].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); + expect(tokens[3][4].value).toBe("Point"); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[3][5].value).toBe("("); + expect(tokens[3][5].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[3][6].value).toBe("0"); + expect(tokens[3][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[3][7].value).toBe(","); + expect(tokens[3][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[3][8].value).toBe(" "); + expect(tokens[3][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[3][9].value).toBe("0"); + expect(tokens[3][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[3][10].value).toBe(")"); + expect(tokens[3][10].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[3][11].value).toBe("]"); + expect(tokens[3][11].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); + expect(tokens[3][12].value).toBe(":"); + expect(tokens[3][12].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[4][0].value).toBe(" "); + expect(tokens[4][0].scopes).toEqual(["source.python"]); + expect(tokens[4][1].value).toBe("print"); + expect(tokens[4][1].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[4][2].value).toBe("("); + expect(tokens[4][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[4][3].value).toBe("\""); + expect(tokens[4][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[4][4].value).toBe("The origin is the only point in the list."); + expect(tokens[4][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python"]); + expect(tokens[4][5].value).toBe("\""); + expect(tokens[4][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[4][6].value).toBe(")"); + expect(tokens[4][6].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[5][0].value).toBe(" "); + expect(tokens[5][0].scopes).toEqual(["source.python"]); + expect(tokens[5][1].value).toBe("case"); + expect(tokens[5][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[5][2].value).toBe(" "); + expect(tokens[5][2].scopes).toEqual(["source.python"]); + expect(tokens[5][3].value).toBe("["); + expect(tokens[5][3].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); + expect(tokens[5][4].value).toBe("Point"); + expect(tokens[5][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[5][5].value).toBe("("); + expect(tokens[5][5].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[5][6].value).toBe("x"); + expect(tokens[5][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[5][7].value).toBe(","); + expect(tokens[5][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[5][8].value).toBe(" "); + expect(tokens[5][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[5][9].value).toBe("y"); + expect(tokens[5][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[5][10].value).toBe(")"); + expect(tokens[5][10].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[5][11].value).toBe("]"); + expect(tokens[5][11].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); + expect(tokens[5][12].value).toBe(":"); + expect(tokens[5][12].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[6][0].value).toBe(" "); + expect(tokens[6][0].scopes).toEqual(["source.python"]); + expect(tokens[6][1].value).toBe("print"); + expect(tokens[6][1].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[6][2].value).toBe("("); + expect(tokens[6][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[6][3].value).toBe("f"); + expect(tokens[6][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[6][4].value).toBe("\""); + expect(tokens[6][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[6][5].value).toBe("A single point is in the list."); + expect(tokens[6][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[6][6].value).toBe("\""); + expect(tokens[6][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[6][7].value).toBe(")"); + expect(tokens[6][7].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[7][0].value).toBe(" "); + expect(tokens[7][0].scopes).toEqual(["source.python"]); + expect(tokens[7][1].value).toBe("case"); + expect(tokens[7][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[7][2].value).toBe(" "); + expect(tokens[7][2].scopes).toEqual(["source.python"]); + expect(tokens[7][3].value).toBe("["); + expect(tokens[7][3].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); + expect(tokens[7][4].value).toBe("Point"); + expect(tokens[7][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[7][5].value).toBe("("); + expect(tokens[7][5].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[7][6].value).toBe("0"); + expect(tokens[7][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[7][7].value).toBe(","); + expect(tokens[7][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[7][8].value).toBe(" "); + expect(tokens[7][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[7][9].value).toBe("y1"); + expect(tokens[7][9].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[7][10].value).toBe(")"); + expect(tokens[7][10].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[7][11].value).toBe(","); + expect(tokens[7][11].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[7][12].value).toBe(" "); + expect(tokens[7][12].scopes).toEqual(["source.python"]); + expect(tokens[7][13].value).toBe("Point"); + expect(tokens[7][13].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[7][14].value).toBe("("); + expect(tokens[7][14].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[7][15].value).toBe("0"); + expect(tokens[7][15].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[7][16].value).toBe(","); + expect(tokens[7][16].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[7][17].value).toBe(" "); + expect(tokens[7][17].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[7][18].value).toBe("y2"); + expect(tokens[7][18].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[7][19].value).toBe(")"); + expect(tokens[7][19].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[7][20].value).toBe("]"); + expect(tokens[7][20].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); + expect(tokens[7][21].value).toBe(":"); + expect(tokens[7][21].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[8][0].value).toBe(" "); + expect(tokens[8][0].scopes).toEqual(["source.python"]); + expect(tokens[8][1].value).toBe("print"); + expect(tokens[8][1].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[8][2].value).toBe("("); + expect(tokens[8][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[8][3].value).toBe("f"); + expect(tokens[8][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[8][4].value).toBe("\""); + expect(tokens[8][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[8][5].value).toBe("Two points on the Y axis are in the list."); + expect(tokens[8][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[8][6].value).toBe("\""); + expect(tokens[8][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[8][7].value).toBe(")"); + expect(tokens[8][7].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[9][0].value).toBe(" "); + expect(tokens[9][0].scopes).toEqual(["source.python"]); + expect(tokens[9][1].value).toBe("case"); + expect(tokens[9][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[9][2].value).toBe(" "); + expect(tokens[9][2].scopes).toEqual(["source.python"]); + expect(tokens[9][3].value).toBe("_"); + expect(tokens[9][3].scopes).toEqual(["source.python"]); + expect(tokens[9][4].value).toBe(":"); + expect(tokens[9][4].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[10][0].value).toBe(" "); + expect(tokens[10][0].scopes).toEqual(["source.python"]); + expect(tokens[10][1].value).toBe("print"); + expect(tokens[10][1].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[10][2].value).toBe("("); + expect(tokens[10][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[10][3].value).toBe("\""); + expect(tokens[10][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[10][4].value).toBe("Something else is found in the list."); + expect(tokens[10][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python"]); + expect(tokens[10][5].value).toBe("\""); + expect(tokens[10][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[10][6].value).toBe(")"); + expect(tokens[10][6].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); }); - it("test/statements/import4.py", + it("test/statements/match4.py", function() { - tokens = grammar.tokenizeLines("from....foo import a\nfrom...foo import b\nfrom..foo import c\nfrom.foo import d") - expect(tokens[0][0].value).toBe("from"); - expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[0][1].value).toBe("...."); - expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[0][2].value).toBe("foo"); + tokens = grammar.tokenizeLines("match point:\n case Point(x, y) if x == y:\n print(f\"The point is located on the diagonal Y=X.\")\n case Point(x, y):\n print(f\"Point is not on the diagonal.\")") + expect(tokens[0][0].value).toBe("match"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("point"); expect(tokens[0][2].scopes).toEqual(["source.python"]); - expect(tokens[0][3].value).toBe(" "); - expect(tokens[0][3].scopes).toEqual(["source.python"]); - expect(tokens[0][4].value).toBe("import"); - expect(tokens[0][4].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[0][5].value).toBe(" "); - expect(tokens[0][5].scopes).toEqual(["source.python"]); - expect(tokens[0][6].value).toBe("a"); - expect(tokens[0][6].scopes).toEqual(["source.python"]); - expect(tokens[1][0].value).toBe("from"); - expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[1][1].value).toBe("..."); - expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[1][2].value).toBe("foo"); + expect(tokens[0][3].value).toBe(":"); + expect(tokens[0][3].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[1][0].value).toBe(" "); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe("case"); + expect(tokens[1][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[1][2].value).toBe(" "); expect(tokens[1][2].scopes).toEqual(["source.python"]); - expect(tokens[1][3].value).toBe(" "); - expect(tokens[1][3].scopes).toEqual(["source.python"]); - expect(tokens[1][4].value).toBe("import"); - expect(tokens[1][4].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[1][5].value).toBe(" "); - expect(tokens[1][5].scopes).toEqual(["source.python"]); - expect(tokens[1][6].value).toBe("b"); - expect(tokens[1][6].scopes).toEqual(["source.python"]); - expect(tokens[2][0].value).toBe("from"); - expect(tokens[2][0].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[2][1].value).toBe(".."); - expect(tokens[2][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[2][2].value).toBe("foo"); - expect(tokens[2][2].scopes).toEqual(["source.python"]); - expect(tokens[2][3].value).toBe(" "); - expect(tokens[2][3].scopes).toEqual(["source.python"]); - expect(tokens[2][4].value).toBe("import"); - expect(tokens[2][4].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[2][5].value).toBe(" "); - expect(tokens[2][5].scopes).toEqual(["source.python"]); - expect(tokens[2][6].value).toBe("c"); - expect(tokens[2][6].scopes).toEqual(["source.python"]); - expect(tokens[3][0].value).toBe("from"); - expect(tokens[3][0].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[3][1].value).toBe("."); - expect(tokens[3][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[3][2].value).toBe("foo"); + expect(tokens[1][3].value).toBe("Point"); + expect(tokens[1][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[1][4].value).toBe("("); + expect(tokens[1][4].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[1][5].value).toBe("x"); + expect(tokens[1][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[1][6].value).toBe(","); + expect(tokens[1][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[1][7].value).toBe(" "); + expect(tokens[1][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[1][8].value).toBe("y"); + expect(tokens[1][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[1][9].value).toBe(")"); + expect(tokens[1][9].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[1][10].value).toBe(" "); + expect(tokens[1][10].scopes).toEqual(["source.python"]); + expect(tokens[1][11].value).toBe("if"); + expect(tokens[1][11].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[1][12].value).toBe(" "); + expect(tokens[1][12].scopes).toEqual(["source.python"]); + expect(tokens[1][13].value).toBe("x"); + expect(tokens[1][13].scopes).toEqual(["source.python"]); + expect(tokens[1][14].value).toBe(" "); + expect(tokens[1][14].scopes).toEqual(["source.python"]); + expect(tokens[1][15].value).toBe("=="); + expect(tokens[1][15].scopes).toEqual(["source.python","keyword.operator.comparison.python"]); + expect(tokens[1][16].value).toBe(" "); + expect(tokens[1][16].scopes).toEqual(["source.python"]); + expect(tokens[1][17].value).toBe("y"); + expect(tokens[1][17].scopes).toEqual(["source.python"]); + expect(tokens[1][18].value).toBe(":"); + expect(tokens[1][18].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[2][0].value).toBe(" "); + expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[2][1].value).toBe("print"); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[2][2].value).toBe("("); + expect(tokens[2][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[2][3].value).toBe("f"); + expect(tokens[2][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[2][4].value).toBe("\""); + expect(tokens[2][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[2][5].value).toBe("The point is located on the diagonal Y=X."); + expect(tokens[2][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[2][6].value).toBe("\""); + expect(tokens[2][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[2][7].value).toBe(")"); + expect(tokens[2][7].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[3][0].value).toBe(" "); + expect(tokens[3][0].scopes).toEqual(["source.python"]); + expect(tokens[3][1].value).toBe("case"); + expect(tokens[3][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[3][2].value).toBe(" "); expect(tokens[3][2].scopes).toEqual(["source.python"]); - expect(tokens[3][3].value).toBe(" "); - expect(tokens[3][3].scopes).toEqual(["source.python"]); - expect(tokens[3][4].value).toBe("import"); - expect(tokens[3][4].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[3][5].value).toBe(" "); - expect(tokens[3][5].scopes).toEqual(["source.python"]); - expect(tokens[3][6].value).toBe("d"); - expect(tokens[3][6].scopes).toEqual(["source.python"]); + expect(tokens[3][3].value).toBe("Point"); + expect(tokens[3][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[3][4].value).toBe("("); + expect(tokens[3][4].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[3][5].value).toBe("x"); + expect(tokens[3][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[3][6].value).toBe(","); + expect(tokens[3][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","punctuation.separator.arguments.python"]); + expect(tokens[3][7].value).toBe(" "); + expect(tokens[3][7].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[3][8].value).toBe("y"); + expect(tokens[3][8].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[3][9].value).toBe(")"); + expect(tokens[3][9].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[3][10].value).toBe(":"); + expect(tokens[3][10].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[4][0].value).toBe(" "); + expect(tokens[4][0].scopes).toEqual(["source.python"]); + expect(tokens[4][1].value).toBe("print"); + expect(tokens[4][1].scopes).toEqual(["source.python","meta.function-call.python","support.function.builtin.python"]); + expect(tokens[4][2].value).toBe("("); + expect(tokens[4][2].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[4][3].value).toBe("f"); + expect(tokens[4][3].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[4][4].value).toBe("\""); + expect(tokens[4][4].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[4][5].value).toBe("Point is not on the diagonal."); + expect(tokens[4][5].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[4][6].value).toBe("\""); + expect(tokens[4][6].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[4][7].value).toBe(")"); + expect(tokens[4][7].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); }); - it("test/statements/import5.py", + it("test/statements/match5.py", function() { - tokens = grammar.tokenizeLines("from.foo import d\nfrom.import a\n\nfoo.import\n\nraise Exception from Foo\n\ndef bar():\n yield from baz") - expect(tokens[0][0].value).toBe("from"); - expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[0][1].value).toBe("."); - expect(tokens[0][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[0][2].value).toBe("foo"); + tokens = grammar.tokenizeLines("match command.split() if command else ['default']:\n ... # Other cases\n case [\"north\"] | [\"go\", \"north\"]:\n ... # handle case\n case [\"get\", obj] | [\"pick\", \"up\", *other] | [\"pick\", obj, \"up\"]:\n ... # handle case") + expect(tokens[0][0].value).toBe("match"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("command"); expect(tokens[0][2].scopes).toEqual(["source.python"]); - expect(tokens[0][3].value).toBe(" "); - expect(tokens[0][3].scopes).toEqual(["source.python"]); - expect(tokens[0][4].value).toBe("import"); - expect(tokens[0][4].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[0][5].value).toBe(" "); - expect(tokens[0][5].scopes).toEqual(["source.python"]); - expect(tokens[0][6].value).toBe("d"); - expect(tokens[0][6].scopes).toEqual(["source.python"]); - expect(tokens[1][0].value).toBe("from"); - expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[1][1].value).toBe("."); - expect(tokens[1][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[1][2].value).toBe("import"); - expect(tokens[1][2].scopes).toEqual(["source.python","keyword.control.import.python"]); - expect(tokens[1][3].value).toBe(" "); - expect(tokens[1][3].scopes).toEqual(["source.python"]); - expect(tokens[1][4].value).toBe("a"); - expect(tokens[1][4].scopes).toEqual(["source.python"]); - expect(tokens[2][0].value).toBe(""); + expect(tokens[0][3].value).toBe("."); + expect(tokens[0][3].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); + expect(tokens[0][4].value).toBe("split"); + expect(tokens[0][4].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[0][5].value).toBe("("); + expect(tokens[0][5].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[0][6].value).toBe(")"); + expect(tokens[0][6].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[0][7].value).toBe(" "); + expect(tokens[0][7].scopes).toEqual(["source.python"]); + expect(tokens[0][8].value).toBe("if"); + expect(tokens[0][8].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[0][9].value).toBe(" "); + expect(tokens[0][9].scopes).toEqual(["source.python"]); + expect(tokens[0][10].value).toBe("command"); + expect(tokens[0][10].scopes).toEqual(["source.python"]); + expect(tokens[0][11].value).toBe(" "); + expect(tokens[0][11].scopes).toEqual(["source.python"]); + expect(tokens[0][12].value).toBe("else"); + expect(tokens[0][12].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[0][13].value).toBe(" "); + expect(tokens[0][13].scopes).toEqual(["source.python"]); + expect(tokens[0][14].value).toBe("["); + expect(tokens[0][14].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); + expect(tokens[0][15].value).toBe("'"); + expect(tokens[0][15].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[0][16].value).toBe("default"); + expect(tokens[0][16].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[0][17].value).toBe("'"); + expect(tokens[0][17].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[0][18].value).toBe("]"); + expect(tokens[0][18].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); + expect(tokens[0][19].value).toBe(":"); + expect(tokens[0][19].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[1][0].value).toBe(" "); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe("..."); + expect(tokens[1][1].scopes).toEqual(["source.python","constant.other.ellipsis.python"]); + expect(tokens[1][2].value).toBe(" "); + expect(tokens[1][2].scopes).toEqual(["source.python"]); + expect(tokens[1][3].value).toBe("#"); + expect(tokens[1][3].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[1][4].value).toBe(" Other cases"); + expect(tokens[1][4].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[2][0].value).toBe(" "); expect(tokens[2][0].scopes).toEqual(["source.python"]); - expect(tokens[3][0].value).toBe("foo"); + expect(tokens[2][1].value).toBe("case"); + expect(tokens[2][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[2][2].value).toBe(" "); + expect(tokens[2][2].scopes).toEqual(["source.python"]); + expect(tokens[2][3].value).toBe("["); + expect(tokens[2][3].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); + expect(tokens[2][4].value).toBe("\""); + expect(tokens[2][4].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[2][5].value).toBe("north"); + expect(tokens[2][5].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[2][6].value).toBe("\""); + expect(tokens[2][6].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[2][7].value).toBe("]"); + expect(tokens[2][7].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); + expect(tokens[2][8].value).toBe(" "); + expect(tokens[2][8].scopes).toEqual(["source.python"]); + expect(tokens[2][9].value).toBe("|"); + expect(tokens[2][9].scopes).toEqual(["source.python","keyword.operator.bitwise.python"]); + expect(tokens[2][10].value).toBe(" "); + expect(tokens[2][10].scopes).toEqual(["source.python"]); + expect(tokens[2][11].value).toBe("["); + expect(tokens[2][11].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); + expect(tokens[2][12].value).toBe("\""); + expect(tokens[2][12].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[2][13].value).toBe("go"); + expect(tokens[2][13].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[2][14].value).toBe("\""); + expect(tokens[2][14].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[2][15].value).toBe(","); + expect(tokens[2][15].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[2][16].value).toBe(" "); + expect(tokens[2][16].scopes).toEqual(["source.python"]); + expect(tokens[2][17].value).toBe("\""); + expect(tokens[2][17].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[2][18].value).toBe("north"); + expect(tokens[2][18].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[2][19].value).toBe("\""); + expect(tokens[2][19].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[2][20].value).toBe("]"); + expect(tokens[2][20].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); + expect(tokens[2][21].value).toBe(":"); + expect(tokens[2][21].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[3][0].value).toBe(" "); expect(tokens[3][0].scopes).toEqual(["source.python"]); - expect(tokens[3][1].value).toBe("."); - expect(tokens[3][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]); - expect(tokens[3][2].value).toBe("import"); - expect(tokens[3][2].scopes).toEqual(["source.python","keyword.control.flow.python"]); - expect(tokens[4][0].value).toBe(""); + expect(tokens[3][1].value).toBe("..."); + expect(tokens[3][1].scopes).toEqual(["source.python","constant.other.ellipsis.python"]); + expect(tokens[3][2].value).toBe(" "); + expect(tokens[3][2].scopes).toEqual(["source.python"]); + expect(tokens[3][3].value).toBe("#"); + expect(tokens[3][3].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[3][4].value).toBe(" handle case"); + expect(tokens[3][4].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[4][0].value).toBe(" "); expect(tokens[4][0].scopes).toEqual(["source.python"]); - expect(tokens[5][0].value).toBe("raise"); - expect(tokens[5][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); - expect(tokens[5][1].value).toBe(" "); - expect(tokens[5][1].scopes).toEqual(["source.python"]); - expect(tokens[5][2].value).toBe("Exception"); - expect(tokens[5][2].scopes).toEqual(["source.python","support.type.exception.python"]); - expect(tokens[5][3].value).toBe(" "); - expect(tokens[5][3].scopes).toEqual(["source.python"]); - expect(tokens[5][4].value).toBe("from"); - expect(tokens[5][4].scopes).toEqual(["source.python","keyword.control.flow.python"]); - expect(tokens[5][5].value).toBe(" "); - expect(tokens[5][5].scopes).toEqual(["source.python"]); - expect(tokens[5][6].value).toBe("Foo"); - expect(tokens[5][6].scopes).toEqual(["source.python"]); - expect(tokens[6][0].value).toBe(""); - expect(tokens[6][0].scopes).toEqual(["source.python"]); - expect(tokens[7][0].value).toBe("def"); - expect(tokens[7][0].scopes).toEqual(["source.python","meta.function.python","storage.type.function.python"]); - expect(tokens[7][1].value).toBe(" "); - expect(tokens[7][1].scopes).toEqual(["source.python","meta.function.python"]); - expect(tokens[7][2].value).toBe("bar"); - expect(tokens[7][2].scopes).toEqual(["source.python","meta.function.python","entity.name.function.python"]); - expect(tokens[7][3].value).toBe("("); - expect(tokens[7][3].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.definition.parameters.begin.python"]); - expect(tokens[7][4].value).toBe(")"); - expect(tokens[7][4].scopes).toEqual(["source.python","meta.function.python","meta.function.parameters.python","punctuation.definition.parameters.end.python"]); - expect(tokens[7][5].value).toBe(":"); - expect(tokens[7][5].scopes).toEqual(["source.python","meta.function.python","punctuation.section.function.begin.python"]); - expect(tokens[8][0].value).toBe(" "); - expect(tokens[8][0].scopes).toEqual(["source.python"]); - expect(tokens[8][1].value).toBe("yield from"); - expect(tokens[8][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); - expect(tokens[8][2].value).toBe(" "); - expect(tokens[8][2].scopes).toEqual(["source.python"]); - expect(tokens[8][3].value).toBe("baz"); - expect(tokens[8][3].scopes).toEqual(["source.python"]); + expect(tokens[4][1].value).toBe("case"); + expect(tokens[4][1].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[4][2].value).toBe(" "); + expect(tokens[4][2].scopes).toEqual(["source.python"]); + expect(tokens[4][3].value).toBe("["); + expect(tokens[4][3].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); + expect(tokens[4][4].value).toBe("\""); + expect(tokens[4][4].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[4][5].value).toBe("get"); + expect(tokens[4][5].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[4][6].value).toBe("\""); + expect(tokens[4][6].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[4][7].value).toBe(","); + expect(tokens[4][7].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[4][8].value).toBe(" "); + expect(tokens[4][8].scopes).toEqual(["source.python"]); + expect(tokens[4][9].value).toBe("obj"); + expect(tokens[4][9].scopes).toEqual(["source.python"]); + expect(tokens[4][10].value).toBe("]"); + expect(tokens[4][10].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); + expect(tokens[4][11].value).toBe(" "); + expect(tokens[4][11].scopes).toEqual(["source.python"]); + expect(tokens[4][12].value).toBe("|"); + expect(tokens[4][12].scopes).toEqual(["source.python","keyword.operator.bitwise.python"]); + expect(tokens[4][13].value).toBe(" "); + expect(tokens[4][13].scopes).toEqual(["source.python"]); + expect(tokens[4][14].value).toBe("["); + expect(tokens[4][14].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); + expect(tokens[4][15].value).toBe("\""); + expect(tokens[4][15].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[4][16].value).toBe("pick"); + expect(tokens[4][16].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[4][17].value).toBe("\""); + expect(tokens[4][17].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[4][18].value).toBe(","); + expect(tokens[4][18].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[4][19].value).toBe(" "); + expect(tokens[4][19].scopes).toEqual(["source.python"]); + expect(tokens[4][20].value).toBe("\""); + expect(tokens[4][20].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[4][21].value).toBe("up"); + expect(tokens[4][21].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[4][22].value).toBe("\""); + expect(tokens[4][22].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[4][23].value).toBe(","); + expect(tokens[4][23].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[4][24].value).toBe(" "); + expect(tokens[4][24].scopes).toEqual(["source.python"]); + expect(tokens[4][25].value).toBe("*"); + expect(tokens[4][25].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]); + expect(tokens[4][26].value).toBe("other"); + expect(tokens[4][26].scopes).toEqual(["source.python"]); + expect(tokens[4][27].value).toBe("]"); + expect(tokens[4][27].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); + expect(tokens[4][28].value).toBe(" "); + expect(tokens[4][28].scopes).toEqual(["source.python"]); + expect(tokens[4][29].value).toBe("|"); + expect(tokens[4][29].scopes).toEqual(["source.python","keyword.operator.bitwise.python"]); + expect(tokens[4][30].value).toBe(" "); + expect(tokens[4][30].scopes).toEqual(["source.python"]); + expect(tokens[4][31].value).toBe("["); + expect(tokens[4][31].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); + expect(tokens[4][32].value).toBe("\""); + expect(tokens[4][32].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[4][33].value).toBe("pick"); + expect(tokens[4][33].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[4][34].value).toBe("\""); + expect(tokens[4][34].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[4][35].value).toBe(","); + expect(tokens[4][35].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[4][36].value).toBe(" "); + expect(tokens[4][36].scopes).toEqual(["source.python"]); + expect(tokens[4][37].value).toBe("obj"); + expect(tokens[4][37].scopes).toEqual(["source.python"]); + expect(tokens[4][38].value).toBe(","); + expect(tokens[4][38].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[4][39].value).toBe(" "); + expect(tokens[4][39].scopes).toEqual(["source.python"]); + expect(tokens[4][40].value).toBe("\""); + expect(tokens[4][40].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[4][41].value).toBe("up"); + expect(tokens[4][41].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[4][42].value).toBe("\""); + expect(tokens[4][42].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[4][43].value).toBe("]"); + expect(tokens[4][43].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); + expect(tokens[4][44].value).toBe(":"); + expect(tokens[4][44].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[5][0].value).toBe(" "); + expect(tokens[5][0].scopes).toEqual(["source.python"]); + expect(tokens[5][1].value).toBe("..."); + expect(tokens[5][1].scopes).toEqual(["source.python","constant.other.ellipsis.python"]); + expect(tokens[5][2].value).toBe(" "); + expect(tokens[5][2].scopes).toEqual(["source.python"]); + expect(tokens[5][3].value).toBe("#"); + expect(tokens[5][3].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[5][4].value).toBe(" handle case"); + expect(tokens[5][4].scopes).toEqual(["source.python","comment.line.number-sign.python"]); }); - it("test/statements/import6.py", + it("test/statements/match6.py", function() { - tokens = grammar.tokenizeLines("from __future__ import generator_stop") - expect(tokens[0][0].value).toBe("from"); + tokens = grammar.tokenizeLines("match (foo + bar):\n ... # cases\nmatch [foo, bar]:\n ... # cases\nmatch {foo, bar}:\n ... # cases") + expect(tokens[0][0].value).toBe("match"); expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); expect(tokens[0][1].value).toBe(" "); expect(tokens[0][1].scopes).toEqual(["source.python"]); - expect(tokens[0][2].value).toBe("__future__"); - expect(tokens[0][2].scopes).toEqual(["source.python","support.variable.magic.python"]); - expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][2].value).toBe("("); + expect(tokens[0][2].scopes).toEqual(["source.python","punctuation.parenthesis.begin.python"]); + expect(tokens[0][3].value).toBe("foo"); expect(tokens[0][3].scopes).toEqual(["source.python"]); - expect(tokens[0][4].value).toBe("import"); - expect(tokens[0][4].scopes).toEqual(["source.python","keyword.control.import.python"]); + expect(tokens[0][4].value).toBe(" "); + expect(tokens[0][4].scopes).toEqual(["source.python"]); + expect(tokens[0][5].value).toBe("+"); + expect(tokens[0][5].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]); + expect(tokens[0][6].value).toBe(" "); + expect(tokens[0][6].scopes).toEqual(["source.python"]); + expect(tokens[0][7].value).toBe("bar"); + expect(tokens[0][7].scopes).toEqual(["source.python"]); + expect(tokens[0][8].value).toBe(")"); + expect(tokens[0][8].scopes).toEqual(["source.python","punctuation.parenthesis.end.python"]); + expect(tokens[0][9].value).toBe(":"); + expect(tokens[0][9].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[1][0].value).toBe(" "); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe("..."); + expect(tokens[1][1].scopes).toEqual(["source.python","constant.other.ellipsis.python"]); + expect(tokens[1][2].value).toBe(" "); + expect(tokens[1][2].scopes).toEqual(["source.python"]); + expect(tokens[1][3].value).toBe("#"); + expect(tokens[1][3].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[1][4].value).toBe(" cases"); + expect(tokens[1][4].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[2][0].value).toBe("match"); + expect(tokens[2][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[2][1].value).toBe(" "); + expect(tokens[2][1].scopes).toEqual(["source.python"]); + expect(tokens[2][2].value).toBe("["); + expect(tokens[2][2].scopes).toEqual(["source.python","punctuation.definition.list.begin.python"]); + expect(tokens[2][3].value).toBe("foo"); + expect(tokens[2][3].scopes).toEqual(["source.python"]); + expect(tokens[2][4].value).toBe(","); + expect(tokens[2][4].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[2][5].value).toBe(" "); + expect(tokens[2][5].scopes).toEqual(["source.python"]); + expect(tokens[2][6].value).toBe("bar"); + expect(tokens[2][6].scopes).toEqual(["source.python"]); + expect(tokens[2][7].value).toBe("]"); + expect(tokens[2][7].scopes).toEqual(["source.python","punctuation.definition.list.end.python"]); + expect(tokens[2][8].value).toBe(":"); + expect(tokens[2][8].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[3][0].value).toBe(" "); + expect(tokens[3][0].scopes).toEqual(["source.python"]); + expect(tokens[3][1].value).toBe("..."); + expect(tokens[3][1].scopes).toEqual(["source.python","constant.other.ellipsis.python"]); + expect(tokens[3][2].value).toBe(" "); + expect(tokens[3][2].scopes).toEqual(["source.python"]); + expect(tokens[3][3].value).toBe("#"); + expect(tokens[3][3].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[3][4].value).toBe(" cases"); + expect(tokens[3][4].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[4][0].value).toBe("match"); + expect(tokens[4][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[4][1].value).toBe(" "); + expect(tokens[4][1].scopes).toEqual(["source.python"]); + expect(tokens[4][2].value).toBe("{"); + expect(tokens[4][2].scopes).toEqual(["source.python","punctuation.definition.dict.begin.python"]); + expect(tokens[4][3].value).toBe("foo"); + expect(tokens[4][3].scopes).toEqual(["source.python"]); + expect(tokens[4][4].value).toBe(","); + expect(tokens[4][4].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[4][5].value).toBe(" "); + expect(tokens[4][5].scopes).toEqual(["source.python"]); + expect(tokens[4][6].value).toBe("bar"); + expect(tokens[4][6].scopes).toEqual(["source.python"]); + expect(tokens[4][7].value).toBe("}"); + expect(tokens[4][7].scopes).toEqual(["source.python","punctuation.definition.dict.end.python"]); + expect(tokens[4][8].value).toBe(":"); + expect(tokens[4][8].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[5][0].value).toBe(" "); + expect(tokens[5][0].scopes).toEqual(["source.python"]); + expect(tokens[5][1].value).toBe("..."); + expect(tokens[5][1].scopes).toEqual(["source.python","constant.other.ellipsis.python"]); + expect(tokens[5][2].value).toBe(" "); + expect(tokens[5][2].scopes).toEqual(["source.python"]); + expect(tokens[5][3].value).toBe("#"); + expect(tokens[5][3].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[5][4].value).toBe(" cases"); + expect(tokens[5][4].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + }); + + it("test/statements/match7.py", + function() { + tokens = grammar.tokenizeLines("match 'prefix' + foo:\n ... # cases\nmatch \"prefix\" + foo:\n ... # cases\nmatch f'prefix{foo}':\n ... # cases\nmatch f\"prefix{foo}\":\n ... # cases\nmatch -foo:\n ... # cases\nmatch not foo:\n ... # cases") + expect(tokens[0][0].value).toBe("match"); + expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("'"); + expect(tokens[0][2].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[0][3].value).toBe("prefix"); + expect(tokens[0][3].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[0][4].value).toBe("'"); + expect(tokens[0][4].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); expect(tokens[0][5].value).toBe(" "); expect(tokens[0][5].scopes).toEqual(["source.python"]); - expect(tokens[0][6].value).toBe("generator_stop"); - expect(tokens[0][6].scopes).toEqual(["source.python"]); + expect(tokens[0][6].value).toBe("+"); + expect(tokens[0][6].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]); + expect(tokens[0][7].value).toBe(" "); + expect(tokens[0][7].scopes).toEqual(["source.python"]); + expect(tokens[0][8].value).toBe("foo"); + expect(tokens[0][8].scopes).toEqual(["source.python"]); + expect(tokens[0][9].value).toBe(":"); + expect(tokens[0][9].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[1][0].value).toBe(" "); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe("..."); + expect(tokens[1][1].scopes).toEqual(["source.python","constant.other.ellipsis.python"]); + expect(tokens[1][2].value).toBe(" "); + expect(tokens[1][2].scopes).toEqual(["source.python"]); + expect(tokens[1][3].value).toBe("#"); + expect(tokens[1][3].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[1][4].value).toBe(" cases"); + expect(tokens[1][4].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[2][0].value).toBe("match"); + expect(tokens[2][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[2][1].value).toBe(" "); + expect(tokens[2][1].scopes).toEqual(["source.python"]); + expect(tokens[2][2].value).toBe("\""); + expect(tokens[2][2].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[2][3].value).toBe("prefix"); + expect(tokens[2][3].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[2][4].value).toBe("\""); + expect(tokens[2][4].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[2][5].value).toBe(" "); + expect(tokens[2][5].scopes).toEqual(["source.python"]); + expect(tokens[2][6].value).toBe("+"); + expect(tokens[2][6].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]); + expect(tokens[2][7].value).toBe(" "); + expect(tokens[2][7].scopes).toEqual(["source.python"]); + expect(tokens[2][8].value).toBe("foo"); + expect(tokens[2][8].scopes).toEqual(["source.python"]); + expect(tokens[2][9].value).toBe(":"); + expect(tokens[2][9].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[3][0].value).toBe(" "); + expect(tokens[3][0].scopes).toEqual(["source.python"]); + expect(tokens[3][1].value).toBe("..."); + expect(tokens[3][1].scopes).toEqual(["source.python","constant.other.ellipsis.python"]); + expect(tokens[3][2].value).toBe(" "); + expect(tokens[3][2].scopes).toEqual(["source.python"]); + expect(tokens[3][3].value).toBe("#"); + expect(tokens[3][3].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[3][4].value).toBe(" cases"); + expect(tokens[3][4].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[4][0].value).toBe("match"); + expect(tokens[4][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[4][1].value).toBe(" "); + expect(tokens[4][1].scopes).toEqual(["source.python"]); + expect(tokens[4][2].value).toBe("f"); + expect(tokens[4][2].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[4][3].value).toBe("'"); + expect(tokens[4][3].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[4][4].value).toBe("prefix"); + expect(tokens[4][4].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[4][5].value).toBe("{"); + expect(tokens[4][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[4][6].value).toBe("foo"); + expect(tokens[4][6].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[4][7].value).toBe("}"); + expect(tokens[4][7].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[4][8].value).toBe("'"); + expect(tokens[4][8].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[4][9].value).toBe(":"); + expect(tokens[4][9].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[5][0].value).toBe(" "); + expect(tokens[5][0].scopes).toEqual(["source.python"]); + expect(tokens[5][1].value).toBe("..."); + expect(tokens[5][1].scopes).toEqual(["source.python","constant.other.ellipsis.python"]); + expect(tokens[5][2].value).toBe(" "); + expect(tokens[5][2].scopes).toEqual(["source.python"]); + expect(tokens[5][3].value).toBe("#"); + expect(tokens[5][3].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[5][4].value).toBe(" cases"); + expect(tokens[5][4].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[6][0].value).toBe("match"); + expect(tokens[6][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[6][1].value).toBe(" "); + expect(tokens[6][1].scopes).toEqual(["source.python"]); + expect(tokens[6][2].value).toBe("f"); + expect(tokens[6][2].scopes).toEqual(["source.python","meta.fstring.python","storage.type.string.python string.quoted.single.python string.interpolated.python"]); + expect(tokens[6][3].value).toBe("\""); + expect(tokens[6][3].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.begin.python"]); + expect(tokens[6][4].value).toBe("prefix"); + expect(tokens[6][4].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python"]); + expect(tokens[6][5].value).toBe("{"); + expect(tokens[6][5].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[6][6].value).toBe("foo"); + expect(tokens[6][6].scopes).toEqual(["source.python","meta.fstring.python"]); + expect(tokens[6][7].value).toBe("}"); + expect(tokens[6][7].scopes).toEqual(["source.python","meta.fstring.python","constant.character.format.placeholder.other.python"]); + expect(tokens[6][8].value).toBe("\""); + expect(tokens[6][8].scopes).toEqual(["source.python","meta.fstring.python","string.quoted.single.python string.interpolated.python punctuation.definition.string.end.python"]); + expect(tokens[6][9].value).toBe(":"); + expect(tokens[6][9].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[7][0].value).toBe(" "); + expect(tokens[7][0].scopes).toEqual(["source.python"]); + expect(tokens[7][1].value).toBe("..."); + expect(tokens[7][1].scopes).toEqual(["source.python","constant.other.ellipsis.python"]); + expect(tokens[7][2].value).toBe(" "); + expect(tokens[7][2].scopes).toEqual(["source.python"]); + expect(tokens[7][3].value).toBe("#"); + expect(tokens[7][3].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[7][4].value).toBe(" cases"); + expect(tokens[7][4].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[8][0].value).toBe("match"); + expect(tokens[8][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[8][1].value).toBe(" "); + expect(tokens[8][1].scopes).toEqual(["source.python"]); + expect(tokens[8][2].value).toBe("-"); + expect(tokens[8][2].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]); + expect(tokens[8][3].value).toBe("foo"); + expect(tokens[8][3].scopes).toEqual(["source.python"]); + expect(tokens[8][4].value).toBe(":"); + expect(tokens[8][4].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[9][0].value).toBe(" "); + expect(tokens[9][0].scopes).toEqual(["source.python"]); + expect(tokens[9][1].value).toBe("..."); + expect(tokens[9][1].scopes).toEqual(["source.python","constant.other.ellipsis.python"]); + expect(tokens[9][2].value).toBe(" "); + expect(tokens[9][2].scopes).toEqual(["source.python"]); + expect(tokens[9][3].value).toBe("#"); + expect(tokens[9][3].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[9][4].value).toBe(" cases"); + expect(tokens[9][4].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[10][0].value).toBe("match"); + expect(tokens[10][0].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[10][1].value).toBe(" "); + expect(tokens[10][1].scopes).toEqual(["source.python"]); + expect(tokens[10][2].value).toBe("not"); + expect(tokens[10][2].scopes).toEqual(["source.python","keyword.operator.logical.python"]); + expect(tokens[10][3].value).toBe(" "); + expect(tokens[10][3].scopes).toEqual(["source.python"]); + expect(tokens[10][4].value).toBe("foo"); + expect(tokens[10][4].scopes).toEqual(["source.python"]); + expect(tokens[10][5].value).toBe(":"); + expect(tokens[10][5].scopes).toEqual(["source.python","punctuation.separator.colon.python"]); + expect(tokens[11][0].value).toBe(" "); + expect(tokens[11][0].scopes).toEqual(["source.python"]); + expect(tokens[11][1].value).toBe("..."); + expect(tokens[11][1].scopes).toEqual(["source.python","constant.other.ellipsis.python"]); + expect(tokens[11][2].value).toBe(" "); + expect(tokens[11][2].scopes).toEqual(["source.python"]); + expect(tokens[11][3].value).toBe("#"); + expect(tokens[11][3].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[11][4].value).toBe(" cases"); + expect(tokens[11][4].scopes).toEqual(["source.python","comment.line.number-sign.python"]); }); it("test/statements/nonlocal1.py", @@ -12661,6 +14709,150 @@ describe("Grammar Tests", function() { expect(tokens[3][13].scopes).toEqual(["source.python","comment.line.number-sign.python"]); }); + it("test/strings/bug1.py", + function() { + tokens = grammar.tokenizeLines("# issue 150\nrecord = {\n \"a\": {k: str(v) for k, v in foo if \"\"}\n}") + expect(tokens[0][0].value).toBe("#"); + expect(tokens[0][0].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[0][1].value).toBe(" issue 150"); + expect(tokens[0][1].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[1][0].value).toBe("record"); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe(" "); + expect(tokens[1][1].scopes).toEqual(["source.python"]); + expect(tokens[1][2].value).toBe("="); + expect(tokens[1][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[1][3].value).toBe(" "); + expect(tokens[1][3].scopes).toEqual(["source.python"]); + expect(tokens[1][4].value).toBe("{"); + expect(tokens[1][4].scopes).toEqual(["source.python","punctuation.definition.dict.begin.python"]); + expect(tokens[2][0].value).toBe(" "); + expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[2][1].value).toBe("\""); + expect(tokens[2][1].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[2][2].value).toBe("a"); + expect(tokens[2][2].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[2][3].value).toBe("\""); + expect(tokens[2][3].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[2][4].value).toBe(":"); + expect(tokens[2][4].scopes).toEqual(["source.python","punctuation.separator.dict.python"]); + expect(tokens[2][5].value).toBe(" "); + expect(tokens[2][5].scopes).toEqual(["source.python"]); + expect(tokens[2][6].value).toBe("{"); + expect(tokens[2][6].scopes).toEqual(["source.python","punctuation.definition.dict.begin.python"]); + expect(tokens[2][7].value).toBe("k"); + expect(tokens[2][7].scopes).toEqual(["source.python"]); + expect(tokens[2][8].value).toBe(":"); + expect(tokens[2][8].scopes).toEqual(["source.python","punctuation.separator.dict.python"]); + expect(tokens[2][9].value).toBe(" "); + expect(tokens[2][9].scopes).toEqual(["source.python"]); + expect(tokens[2][10].value).toBe("str"); + expect(tokens[2][10].scopes).toEqual(["source.python","meta.function-call.python","support.type.python"]); + expect(tokens[2][11].value).toBe("("); + expect(tokens[2][11].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[2][12].value).toBe("v"); + expect(tokens[2][12].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]); + expect(tokens[2][13].value).toBe(")"); + expect(tokens[2][13].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[2][14].value).toBe(" "); + expect(tokens[2][14].scopes).toEqual(["source.python"]); + expect(tokens[2][15].value).toBe("for"); + expect(tokens[2][15].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[2][16].value).toBe(" "); + expect(tokens[2][16].scopes).toEqual(["source.python"]); + expect(tokens[2][17].value).toBe("k"); + expect(tokens[2][17].scopes).toEqual(["source.python"]); + expect(tokens[2][18].value).toBe(","); + expect(tokens[2][18].scopes).toEqual(["source.python","punctuation.separator.element.python"]); + expect(tokens[2][19].value).toBe(" "); + expect(tokens[2][19].scopes).toEqual(["source.python"]); + expect(tokens[2][20].value).toBe("v"); + expect(tokens[2][20].scopes).toEqual(["source.python"]); + expect(tokens[2][21].value).toBe(" "); + expect(tokens[2][21].scopes).toEqual(["source.python"]); + expect(tokens[2][22].value).toBe("in"); + expect(tokens[2][22].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[2][23].value).toBe(" "); + expect(tokens[2][23].scopes).toEqual(["source.python"]); + expect(tokens[2][24].value).toBe("foo"); + expect(tokens[2][24].scopes).toEqual(["source.python"]); + expect(tokens[2][25].value).toBe(" "); + expect(tokens[2][25].scopes).toEqual(["source.python"]); + expect(tokens[2][26].value).toBe("if"); + expect(tokens[2][26].scopes).toEqual(["source.python","keyword.control.flow.python"]); + expect(tokens[2][27].value).toBe(" "); + expect(tokens[2][27].scopes).toEqual(["source.python"]); + expect(tokens[2][28].value).toBe("\""); + expect(tokens[2][28].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[2][29].value).toBe("\""); + expect(tokens[2][29].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[2][30].value).toBe("}"); + expect(tokens[2][30].scopes).toEqual(["source.python","punctuation.definition.dict.end.python"]); + expect(tokens[3][0].value).toBe("}"); + expect(tokens[3][0].scopes).toEqual(["source.python","punctuation.definition.dict.end.python"]); + }); + + it("test/strings/bug2.py", + function() { + tokens = grammar.tokenizeLines("# issue 150\ncmd = \"git-clang-format --style=\\\"{{BasedOnStyle: Google, ColumnLimit: 100, IndentWidth: 2, \" \\\n \"AlignConsecutiveAssignments: true}}\\\" {COMMIT_SHA} -- ./**/*.proto > {OUTPUT}\".format(") + expect(tokens[0][0].value).toBe("#"); + expect(tokens[0][0].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[0][1].value).toBe(" issue 150"); + expect(tokens[0][1].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[1][0].value).toBe("cmd"); + expect(tokens[1][0].scopes).toEqual(["source.python"]); + expect(tokens[1][1].value).toBe(" "); + expect(tokens[1][1].scopes).toEqual(["source.python"]); + expect(tokens[1][2].value).toBe("="); + expect(tokens[1][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[1][3].value).toBe(" "); + expect(tokens[1][3].scopes).toEqual(["source.python"]); + expect(tokens[1][4].value).toBe("\""); + expect(tokens[1][4].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[1][5].value).toBe("git-clang-format --style="); + expect(tokens[1][5].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[1][6].value).toBe("\\\""); + expect(tokens[1][6].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.escape.python"]); + expect(tokens[1][7].value).toBe("{{"); + expect(tokens[1][7].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][8].value).toBe("BasedOnStyle: Google, ColumnLimit: 100, IndentWidth: 2, "); + expect(tokens[1][8].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[1][9].value).toBe("\""); + expect(tokens[1][9].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[1][10].value).toBe(" "); + expect(tokens[1][10].scopes).toEqual(["source.python"]); + expect(tokens[1][11].value).toBe("\\"); + expect(tokens[1][11].scopes).toEqual(["source.python","punctuation.separator.continuation.line.python"]); + expect(tokens[1][12].value).toBe(""); + expect(tokens[1][12].scopes).toEqual(["source.python"]); + expect(tokens[2][0].value).toBe(" "); + expect(tokens[2][0].scopes).toEqual(["source.python"]); + expect(tokens[2][1].value).toBe("\""); + expect(tokens[2][1].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[2][2].value).toBe("AlignConsecutiveAssignments: true"); + expect(tokens[2][2].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[2][3].value).toBe("}}"); + expect(tokens[2][3].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][4].value).toBe("\\\""); + expect(tokens[2][4].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.escape.python"]); + expect(tokens[2][5].value).toBe(" "); + expect(tokens[2][5].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[2][6].value).toBe("{COMMIT_SHA}"); + expect(tokens[2][6].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][7].value).toBe(" -- ./**/*.proto > "); + expect(tokens[2][7].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[2][8].value).toBe("{OUTPUT}"); + expect(tokens[2][8].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][9].value).toBe("\""); + expect(tokens[2][9].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[2][10].value).toBe("."); + expect(tokens[2][10].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); + expect(tokens[2][11].value).toBe("format"); + expect(tokens[2][11].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[2][12].value).toBe("("); + expect(tokens[2][12].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + }); + it("test/strings/bytes1.py", function() { tokens = grammar.tokenizeLines("a = b\"\"\"\nmultiline \"binary\" string \\\n\n \\xf1 \\u1234aaaa \\U1234aaaa\n\n \\N{BLACK SPADE SUIT}\n\"\"\"") @@ -12700,7 +14892,7 @@ describe("Grammar Tests", function() { function() { tokens = grammar.tokenizeLines("a[1] = b'''\nmultiline 'binary' string \\\n\n \\xf1 \\u1234aaaa \\U1234aaaa\n\n \\N{BLACK SPADE SUIT}\n'''") expect(tokens[0][0].value).toBe("a"); - expect(tokens[0][0].scopes).toEqual(["source.python","meta.item-access.python"]); + expect(tokens[0][0].scopes).toEqual(["source.python","meta.item-access.python","meta.indexed-name.python"]); expect(tokens[0][1].value).toBe("["); expect(tokens[0][1].scopes).toEqual(["source.python","meta.item-access.python","punctuation.definition.arguments.begin.python"]); expect(tokens[0][2].value).toBe("1"); @@ -12915,11 +15107,11 @@ describe("Grammar Tests", function() { expect(tokens[0][4].value).toBe("\""); expect(tokens[0][4].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); expect(tokens[0][5].value).toBe("{0[ ]"); - expect(tokens[0][5].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][5].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][6].value).toBe(":X>+10d"); - expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); + expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); expect(tokens[0][7].value).toBe("}"); - expect(tokens[0][7].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][7].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][8].value).toBe("\""); expect(tokens[0][8].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); expect(tokens[1][0].value).toBe("a"); @@ -12933,13 +15125,13 @@ describe("Grammar Tests", function() { expect(tokens[1][4].value).toBe("\""); expect(tokens[1][4].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); expect(tokens[1][5].value).toBe("{0[ ]"); - expect(tokens[1][5].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][5].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[1][6].value).toBe("!s"); - expect(tokens[1][6].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); + expect(tokens[1][6].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); expect(tokens[1][7].value).toBe(":X>+10d"); - expect(tokens[1][7].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); + expect(tokens[1][7].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); expect(tokens[1][8].value).toBe("}"); - expect(tokens[1][8].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][8].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[1][9].value).toBe("\""); expect(tokens[1][9].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); expect(tokens[2][0].value).toBe("a"); @@ -12953,21 +15145,19 @@ describe("Grammar Tests", function() { expect(tokens[2][4].value).toBe("\""); expect(tokens[2][4].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); expect(tokens[2][5].value).toBe("{0[ ]"); - expect(tokens[2][5].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][5].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[2][6].value).toBe(":"); - expect(tokens[2][6].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); - expect(tokens[2][7].value).toBe("Xd>+10d"); - expect(tokens[2][7].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); - expect(tokens[2][8].value).toBe("}"); - expect(tokens[2][8].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); - expect(tokens[2][9].value).toBe("\""); - expect(tokens[2][9].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); - expect(tokens[2][10].value).toBe(" "); - expect(tokens[2][10].scopes).toEqual(["source.python"]); - expect(tokens[2][11].value).toBe("#"); - expect(tokens[2][11].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); - expect(tokens[2][12].value).toBe("invalid"); - expect(tokens[2][12].scopes).toEqual(["source.python","comment.line.number-sign.python"]); + expect(tokens[2][6].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); + expect(tokens[2][7].value).toBe("Xd>+10d}"); + expect(tokens[2][7].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][8].value).toBe("\""); + expect(tokens[2][8].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[2][9].value).toBe(" "); + expect(tokens[2][9].scopes).toEqual(["source.python"]); + expect(tokens[2][10].value).toBe("#"); + expect(tokens[2][10].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]); + expect(tokens[2][11].value).toBe("invalid"); + expect(tokens[2][11].scopes).toEqual(["source.python","comment.line.number-sign.python"]); }); it("test/strings/format10.py", @@ -12986,25 +15176,25 @@ describe("Grammar Tests", function() { expect(tokens[0][5].value).toBe("blah {foo-bar "); expect(tokens[0][5].scopes).toEqual(["source.python","string.quoted.multi.python"]); expect(tokens[0][6].value).toBe("%d"); - expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.multi.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.multi.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[1][0].value).toBe(" blah "); expect(tokens[1][0].scopes).toEqual(["source.python","string.quoted.multi.python"]); expect(tokens[1][1].value).toBe("{foo-bar "); expect(tokens[1][1].scopes).toEqual(["source.python","string.quoted.multi.python"]); expect(tokens[1][2].value).toBe("%d"); - expect(tokens[1][2].scopes).toEqual(["source.python","string.quoted.multi.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][2].scopes).toEqual(["source.python","string.quoted.multi.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[1][3].value).toBe("}"); expect(tokens[1][3].scopes).toEqual(["source.python","string.quoted.multi.python"]); expect(tokens[2][0].value).toBe(" blah {foo-bar "); expect(tokens[2][0].scopes).toEqual(["source.python","string.quoted.multi.python"]); expect(tokens[2][1].value).toBe("%d"); - expect(tokens[2][1].scopes).toEqual(["source.python","string.quoted.multi.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][1].scopes).toEqual(["source.python","string.quoted.multi.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[2][2].value).toBe(" //insane {}}"); expect(tokens[2][2].scopes).toEqual(["source.python","string.quoted.multi.python"]); expect(tokens[3][0].value).toBe(" {}blah {foo-bar "); expect(tokens[3][0].scopes).toEqual(["source.python","string.quoted.multi.python"]); expect(tokens[3][1].value).toBe("%d"); - expect(tokens[3][1].scopes).toEqual(["source.python","string.quoted.multi.python","constant.character.format.placeholder.other.python"]); + expect(tokens[3][1].scopes).toEqual(["source.python","string.quoted.multi.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[3][2].value).toBe(" //insane {}}"); expect(tokens[3][2].scopes).toEqual(["source.python","string.quoted.multi.python"]); expect(tokens[3][3].value).toBe("'''"); @@ -13029,7 +15219,7 @@ describe("Grammar Tests", function() { expect(tokens[0][6].value).toBe("\\fr"); expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.raw.multi.python"]); expect(tokens[0][7].value).toBe("{still_ok}"); - expect(tokens[0][7].scopes).toEqual(["source.python","string.quoted.raw.multi.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][7].scopes).toEqual(["source.python","string.quoted.raw.multi.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][8].value).toBe("ac"); expect(tokens[0][8].scopes).toEqual(["source.python","string.quoted.raw.multi.python"]); expect(tokens[0][9].value).toBe("{m_{j \\rightarrow i}(\\mathrm{good})}"); @@ -13037,7 +15227,7 @@ describe("Grammar Tests", function() { expect(tokens[1][0].value).toBe(" {not_ok} "); expect(tokens[1][0].scopes).toEqual(["source.python","string.quoted.raw.multi.python"]); expect(tokens[1][1].value).toBe("%d"); - expect(tokens[1][1].scopes).toEqual(["source.python","string.quoted.raw.multi.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][1].scopes).toEqual(["source.python","string.quoted.raw.multi.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[2][0].value).toBe("'''"); expect(tokens[2][0].scopes).toEqual(["source.python","string.quoted.raw.multi.python","punctuation.definition.string.end.python"]); }); @@ -13062,11 +15252,11 @@ describe("Grammar Tests", function() { expect(tokens[0][7].value).toBe("{m_{j \\"); expect(tokens[0][7].scopes).toEqual(["source.python","string.quoted.raw.single.python"]); expect(tokens[0][8].value).toBe("%s"); - expect(tokens[0][8].scopes).toEqual(["source.python","string.quoted.raw.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][8].scopes).toEqual(["source.python","string.quoted.raw.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][9].value).toBe("rightarrow i}(\\mathrm{"); expect(tokens[0][9].scopes).toEqual(["source.python","string.quoted.raw.single.python"]); expect(tokens[0][10].value).toBe("%s"); - expect(tokens[0][10].scopes).toEqual(["source.python","string.quoted.raw.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][10].scopes).toEqual(["source.python","string.quoted.raw.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][11].value).toBe("good})}{\\su%m{m_{j \\rightarrow i}}}$"); expect(tokens[0][11].scopes).toEqual(["source.python","string.quoted.raw.single.python"]); expect(tokens[0][12].value).toBe("'"); @@ -13149,11 +15339,11 @@ describe("Grammar Tests", function() { expect(tokens[0][4].value).toBe("'''"); expect(tokens[0][4].scopes).toEqual(["source.python","string.quoted.multi.python","punctuation.definition.string.begin.python"]); expect(tokens[1][0].value).toBe("{{"); - expect(tokens[1][0].scopes).toEqual(["source.python","string.quoted.multi.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][0].scopes).toEqual(["source.python","string.quoted.multi.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[1][1].value).toBe(" before detection "); expect(tokens[1][1].scopes).toEqual(["source.python","string.quoted.multi.python"]); expect(tokens[1][2].value).toBe("}}"); - expect(tokens[1][2].scopes).toEqual(["source.python","string.quoted.multi.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][2].scopes).toEqual(["source.python","string.quoted.multi.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[2][0].value).toBe("{# jinja comment #}"); expect(tokens[2][0].scopes).toEqual(["source.python","string.quoted.multi.python"]); expect(tokens[3][0].value).toBe("{{ after detection }}"); @@ -13162,6 +15352,41 @@ describe("Grammar Tests", function() { expect(tokens[4][0].scopes).toEqual(["source.python","string.quoted.multi.python","punctuation.definition.string.end.python"]); }); + it("test/strings/format16.py", + function() { + tokens = grammar.tokenizeLines("a = b'%b' % b'foo'") + expect(tokens[0][0].value).toBe("a"); + expect(tokens[0][0].scopes).toEqual(["source.python"]); + expect(tokens[0][1].value).toBe(" "); + expect(tokens[0][1].scopes).toEqual(["source.python"]); + expect(tokens[0][2].value).toBe("="); + expect(tokens[0][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]); + expect(tokens[0][3].value).toBe(" "); + expect(tokens[0][3].scopes).toEqual(["source.python"]); + expect(tokens[0][4].value).toBe("b"); + expect(tokens[0][4].scopes).toEqual(["source.python","string.quoted.binary.single.python","storage.type.string.python"]); + expect(tokens[0][5].value).toBe("'"); + expect(tokens[0][5].scopes).toEqual(["source.python","string.quoted.binary.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[0][6].value).toBe("%b"); + expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.binary.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][7].value).toBe("'"); + expect(tokens[0][7].scopes).toEqual(["source.python","string.quoted.binary.single.python","punctuation.definition.string.end.python"]); + expect(tokens[0][8].value).toBe(" "); + expect(tokens[0][8].scopes).toEqual(["source.python"]); + expect(tokens[0][9].value).toBe("%"); + expect(tokens[0][9].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]); + expect(tokens[0][10].value).toBe(" "); + expect(tokens[0][10].scopes).toEqual(["source.python"]); + expect(tokens[0][11].value).toBe("b"); + expect(tokens[0][11].scopes).toEqual(["source.python","string.quoted.binary.single.python","storage.type.string.python"]); + expect(tokens[0][12].value).toBe("'"); + expect(tokens[0][12].scopes).toEqual(["source.python","string.quoted.binary.single.python","punctuation.definition.string.begin.python"]); + expect(tokens[0][13].value).toBe("foo"); + expect(tokens[0][13].scopes).toEqual(["source.python","string.quoted.binary.single.python"]); + expect(tokens[0][14].value).toBe("'"); + expect(tokens[0][14].scopes).toEqual(["source.python","string.quoted.binary.single.python","punctuation.definition.string.end.python"]); + }); + it("test/strings/format2.py", function() { tokens = grammar.tokenizeLines("a = \"normal {{ normal }} normal {10!r} normal {fo.__add__!s}\".format(fo=1)") @@ -13178,43 +15403,43 @@ describe("Grammar Tests", function() { expect(tokens[0][5].value).toBe("normal "); expect(tokens[0][5].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[0][6].value).toBe("{{"); - expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][7].value).toBe(" normal "); expect(tokens[0][7].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[0][8].value).toBe("}}"); - expect(tokens[0][8].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][8].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][9].value).toBe(" normal "); expect(tokens[0][9].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[0][10].value).toBe("{10"); - expect(tokens[0][10].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][10].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][11].value).toBe("!r"); - expect(tokens[0][11].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); + expect(tokens[0][11].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); expect(tokens[0][12].value).toBe("}"); - expect(tokens[0][12].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][12].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][13].value).toBe(" normal "); expect(tokens[0][13].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[0][14].value).toBe("{fo.__add__"); - expect(tokens[0][14].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][14].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][15].value).toBe("!s"); - expect(tokens[0][15].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); + expect(tokens[0][15].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); expect(tokens[0][16].value).toBe("}"); - expect(tokens[0][16].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][16].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][17].value).toBe("\""); expect(tokens[0][17].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); expect(tokens[0][18].value).toBe("."); - expect(tokens[0][18].scopes).toEqual(["source.python","punctuation.separator.period.python"]); + expect(tokens[0][18].scopes).toEqual(["source.python","meta.member.access.python","punctuation.separator.period.python"]); expect(tokens[0][19].value).toBe("format"); - expect(tokens[0][19].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]); + expect(tokens[0][19].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.generic.python"]); expect(tokens[0][20].value).toBe("("); - expect(tokens[0][20].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); + expect(tokens[0][20].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]); expect(tokens[0][21].value).toBe("fo"); - expect(tokens[0][21].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); + expect(tokens[0][21].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","variable.parameter.function-call.python"]); expect(tokens[0][22].value).toBe("="); - expect(tokens[0][22].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); + expect(tokens[0][22].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","keyword.operator.assignment.python"]); expect(tokens[0][23].value).toBe("1"); - expect(tokens[0][23].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); + expect(tokens[0][23].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","meta.function-call.arguments.python","constant.numeric.dec.python"]); expect(tokens[0][24].value).toBe(")"); - expect(tokens[0][24].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); + expect(tokens[0][24].scopes).toEqual(["source.python","meta.member.access.python","meta.function-call.python","punctuation.definition.arguments.end.python"]); }); it("test/strings/format3.py", @@ -13231,7 +15456,7 @@ describe("Grammar Tests", function() { expect(tokens[0][4].value).toBe("'"); expect(tokens[0][4].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); expect(tokens[0][5].value).toBe("%i"); - expect(tokens[0][5].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][5].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][6].value).toBe("'"); expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); expect(tokens[0][7].value).toBe(" "); @@ -13253,11 +15478,11 @@ describe("Grammar Tests", function() { expect(tokens[1][4].value).toBe("\""); expect(tokens[1][4].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); expect(tokens[1][5].value).toBe("%(language)s"); - expect(tokens[1][5].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][5].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[1][6].value).toBe(" has "); expect(tokens[1][6].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[1][7].value).toBe("%(number)03d"); - expect(tokens[1][7].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][7].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[1][8].value).toBe(" quote types."); expect(tokens[1][8].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[1][9].value).toBe("\""); @@ -13275,11 +15500,11 @@ describe("Grammar Tests", function() { expect(tokens[2][5].value).toBe("\""); expect(tokens[2][5].scopes).toEqual(["source.python","string.quoted.binary.single.python","punctuation.definition.string.begin.python"]); expect(tokens[2][6].value).toBe("%(language)s"); - expect(tokens[2][6].scopes).toEqual(["source.python","string.quoted.binary.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][6].scopes).toEqual(["source.python","string.quoted.binary.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[2][7].value).toBe(" has "); expect(tokens[2][7].scopes).toEqual(["source.python","string.quoted.binary.single.python"]); expect(tokens[2][8].value).toBe("%(number)03d"); - expect(tokens[2][8].scopes).toEqual(["source.python","string.quoted.binary.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][8].scopes).toEqual(["source.python","string.quoted.binary.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[2][9].value).toBe(" quote types."); expect(tokens[2][9].scopes).toEqual(["source.python","string.quoted.binary.single.python"]); expect(tokens[2][10].value).toBe("\""); @@ -13297,11 +15522,11 @@ describe("Grammar Tests", function() { expect(tokens[3][5].value).toBe("\""); expect(tokens[3][5].scopes).toEqual(["source.python","string.quoted.raw.single.python","punctuation.definition.string.begin.python"]); expect(tokens[3][6].value).toBe("%(language)s"); - expect(tokens[3][6].scopes).toEqual(["source.python","string.quoted.raw.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[3][6].scopes).toEqual(["source.python","string.quoted.raw.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[3][7].value).toBe(" has "); expect(tokens[3][7].scopes).toEqual(["source.python","string.quoted.raw.single.python"]); expect(tokens[3][8].value).toBe("%(number)03d"); - expect(tokens[3][8].scopes).toEqual(["source.python","string.quoted.raw.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[3][8].scopes).toEqual(["source.python","string.quoted.raw.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[3][9].value).toBe(" quote types."); expect(tokens[3][9].scopes).toEqual(["source.python","string.quoted.raw.single.python"]); expect(tokens[3][10].value).toBe("\""); @@ -13324,17 +15549,15 @@ describe("Grammar Tests", function() { expect(tokens[0][5].value).toBe("qqq"); expect(tokens[0][5].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[0][6].value).toBe("{"); - expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][7].value).toBe(":"); - expect(tokens[0][7].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); - expect(tokens[0][8].value).toBe("%Y-%m-%d %H:%M:%S"); - expect(tokens[0][8].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][9].value).toBe("}"); - expect(tokens[0][9].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][10].value).toBe("www"); - expect(tokens[0][10].scopes).toEqual(["source.python","string.quoted.single.python"]); - expect(tokens[0][11].value).toBe("'"); - expect(tokens[0][11].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[0][7].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); + expect(tokens[0][8].value).toBe("%Y-%m-%d %H:%M:%S}"); + expect(tokens[0][8].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][9].value).toBe("www"); + expect(tokens[0][9].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[0][10].value).toBe("'"); + expect(tokens[0][10].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); expect(tokens[1][0].value).toBe("a"); expect(tokens[1][0].scopes).toEqual(["source.python"]); expect(tokens[1][1].value).toBe(" "); @@ -13348,21 +15571,15 @@ describe("Grammar Tests", function() { expect(tokens[1][5].value).toBe("qqq"); expect(tokens[1][5].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[1][6].value).toBe("{0"); - expect(tokens[1][6].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][6].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[1][7].value).toBe(":"); - expect(tokens[1][7].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); - expect(tokens[1][8].value).toBe("{fill}"); - expect(tokens[1][8].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); - expect(tokens[1][9].value).toBe("{align}"); - expect(tokens[1][9].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); - expect(tokens[1][10].value).toBe("16"); - expect(tokens[1][10].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); - expect(tokens[1][11].value).toBe("}"); - expect(tokens[1][11].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); - expect(tokens[1][12].value).toBe("www"); - expect(tokens[1][12].scopes).toEqual(["source.python","string.quoted.single.python"]); - expect(tokens[1][13].value).toBe("'"); - expect(tokens[1][13].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[1][7].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); + expect(tokens[1][8].value).toBe("{fill}{align}16}"); + expect(tokens[1][8].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][9].value).toBe("www"); + expect(tokens[1][9].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[1][10].value).toBe("'"); + expect(tokens[1][10].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); }); it("test/strings/format5.py", @@ -13381,19 +15598,15 @@ describe("Grammar Tests", function() { expect(tokens[0][5].value).toBe("qqq"); expect(tokens[0][5].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[0][6].value).toBe("{0"); - expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][7].value).toBe(":"); - expect(tokens[0][7].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); - expect(tokens[0][8].value).toBe("{width}"); - expect(tokens[0][8].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][9].value).toBe("{base}"); - expect(tokens[0][9].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][10].value).toBe("}"); - expect(tokens[0][10].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); - expect(tokens[0][11].value).toBe("www"); - expect(tokens[0][11].scopes).toEqual(["source.python","string.quoted.single.python"]); - expect(tokens[0][12].value).toBe("'"); - expect(tokens[0][12].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[0][7].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); + expect(tokens[0][8].value).toBe("{width}{base}}"); + expect(tokens[0][8].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][9].value).toBe("www"); + expect(tokens[0][9].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[0][10].value).toBe("'"); + expect(tokens[0][10].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); expect(tokens[1][0].value).toBe("a"); expect(tokens[1][0].scopes).toEqual(["source.python"]); expect(tokens[1][1].value).toBe(" "); @@ -13407,17 +15620,15 @@ describe("Grammar Tests", function() { expect(tokens[1][5].value).toBe("qqq"); expect(tokens[1][5].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[1][6].value).toBe("{0"); - expect(tokens[1][6].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][6].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[1][7].value).toBe(":"); - expect(tokens[1][7].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); - expect(tokens[1][8].value).toBe("$20"); - expect(tokens[1][8].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); - expect(tokens[1][9].value).toBe("}"); - expect(tokens[1][9].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); - expect(tokens[1][10].value).toBe("www"); - expect(tokens[1][10].scopes).toEqual(["source.python","string.quoted.single.python"]); - expect(tokens[1][11].value).toBe("'"); - expect(tokens[1][11].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); + expect(tokens[1][7].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python","storage.type.format.python"]); + expect(tokens[1][8].value).toBe("$20}"); + expect(tokens[1][8].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][9].value).toBe("www"); + expect(tokens[1][9].scopes).toEqual(["source.python","string.quoted.single.python"]); + expect(tokens[1][10].value).toBe("'"); + expect(tokens[1][10].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); expect(tokens[2][0].value).toBe("a"); expect(tokens[2][0].scopes).toEqual(["source.python"]); expect(tokens[2][1].value).toBe(" "); @@ -13431,7 +15642,7 @@ describe("Grammar Tests", function() { expect(tokens[2][5].value).toBe("qqq"); expect(tokens[2][5].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[2][6].value).toBe("{0}"); - expect(tokens[2][6].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][6].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[2][7].value).toBe("www"); expect(tokens[2][7].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[2][8].value).toBe("'"); @@ -13494,7 +15705,7 @@ describe("Grammar Tests", function() { expect(tokens[2][11].value).toBe("h}"); expect(tokens[2][11].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[2][12].value).toBe("{base}"); - expect(tokens[2][12].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][12].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[2][13].value).toBe("}www"); expect(tokens[2][13].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[2][14].value).toBe("'"); @@ -13533,11 +15744,11 @@ describe("Grammar Tests", function() { expect(tokens[3][5].value).toBe("12"); expect(tokens[3][5].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[3][6].value).toBe("% o"); - expect(tokens[3][6].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[3][6].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[3][7].value).toBe("f "); expect(tokens[3][7].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[3][8].value).toBe("%s"); - expect(tokens[3][8].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[3][8].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[3][9].value).toBe("'"); expect(tokens[3][9].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); expect(tokens[3][10].value).toBe(" "); @@ -13599,7 +15810,7 @@ describe("Grammar Tests", function() { expect(tokens[0][5].value).toBe("blah {foo-bar "); expect(tokens[0][5].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[0][6].value).toBe("%d"); - expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[0][6].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[0][7].value).toBe("'"); expect(tokens[0][7].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]); expect(tokens[1][0].value).toBe("a"); @@ -13617,7 +15828,7 @@ describe("Grammar Tests", function() { expect(tokens[1][6].value).toBe("{foo-bar "); expect(tokens[1][6].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[1][7].value).toBe("%d"); - expect(tokens[1][7].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[1][7].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[1][8].value).toBe("}"); expect(tokens[1][8].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[1][9].value).toBe("'"); @@ -13637,7 +15848,7 @@ describe("Grammar Tests", function() { expect(tokens[2][6].value).toBe("{foo-bar "); expect(tokens[2][6].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[2][7].value).toBe("%d"); - expect(tokens[2][7].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[2][7].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[2][8].value).toBe(" //insane {}}"); expect(tokens[2][8].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[2][9].value).toBe("'"); @@ -13653,13 +15864,13 @@ describe("Grammar Tests", function() { expect(tokens[3][4].value).toBe("'"); expect(tokens[3][4].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]); expect(tokens[3][5].value).toBe("{}"); - expect(tokens[3][5].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[3][5].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]); expect(tokens[3][6].value).toBe("blah "); expect(tokens[3][6].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[3][7].value).toBe("{foo-bar "); expect(tokens[3][7].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[3][8].value).toBe("%d"); - expect(tokens[3][8].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.format.placeholder.other.python"]); + expect(tokens[3][8].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.percent.python","constant.character.format.placeholder.other.python"]); expect(tokens[3][9].value).toBe(" //insane {}}"); expect(tokens[3][9].scopes).toEqual(["source.python","string.quoted.single.python"]); expect(tokens[3][10].value).toBe("'"); @@ -14128,7 +16339,7 @@ describe("Grammar Tests", function() { expect(tokens[2][0].value).toBe(" "); expect(tokens[2][0].scopes).toEqual(["source.python","meta.function.decorator.python"]); expect(tokens[2][1].value).toBe("@"); - expect(tokens[2][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); + expect(tokens[2][1].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python","punctuation.definition.decorator.python"]); expect(tokens[2][2].value).toBe("æaœ"); expect(tokens[2][2].scopes).toEqual(["source.python","meta.function.decorator.python","entity.name.function.decorator.python"]); expect(tokens[3][0].value).toBe(" "); diff --git a/test/builtins/builtins1.py b/test/builtins/builtins1.py index 03c18cd6..36866c2a 100644 --- a/test/builtins/builtins1.py +++ b/test/builtins/builtins1.py @@ -5,7 +5,7 @@ NotImplemented True None False Ellipsis Warning Exception BaseException -sum oct abs type object print +sum oct abs type object print exec @@ -39,3 +39,5 @@ object : source.python, support.type.python : source.python print : source.python, support.function.builtin.python + : source.python +exec : source.python, support.function.builtin.python diff --git a/test/builtins/builtins3.py b/test/builtins/builtins3.py index 02ccb5af..f1f90d9c 100644 --- a/test/builtins/builtins3.py +++ b/test/builtins/builtins3.py @@ -40,6 +40,9 @@ some.__prepare__ some.__package__ some.__traceback__ +some.__closure__ +some.__globals__ +some.__match_args__ some.__notspecial__ @@ -60,127 +63,136 @@ ' : punctuation.definition.string.end.python, source.python, string.quoted.single.python ] : punctuation.definition.list.end.python, source.python some : source.python -. : punctuation.separator.period.python, source.python -__bases__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__bases__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__class__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__class__ : meta.member.access.python, source.python, support.variable.magic.python assert : keyword.control.flow.python, source.python : source.python __debug__ : source.python, support.variable.magic.python __builtins__ : source.python, support.variable.magic.python __builtins__ : source.python, support.variable.magic.python -. : punctuation.separator.period.python, source.python -len : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +len : meta.attribute.python, meta.member.access.python, source.python print : meta.function-call.python, source.python, support.function.builtin.python ( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python __builtins__ : meta.function-call.arguments.python, meta.function-call.python, source.python, support.variable.magic.python ) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python some : source.python -. : punctuation.separator.period.python, source.python -__dict__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__dict__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__doc__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__doc__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__file__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__file__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__members__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__members__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__metaclass__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__metaclass__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__methods__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__methods__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__module__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__module__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__mro__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__mro__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__name__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__name__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__slots__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__slots__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__subclasses__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__subclasses__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__version__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__version__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__weakref__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__weakref__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__qualname__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__qualname__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__code__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__code__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__wrapped__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__wrapped__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__signature__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__signature__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__defaults__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__defaults__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__func__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__func__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__self__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__self__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__kwdefaults__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__kwdefaults__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__matmul__ : source.python, support.function.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__matmul__ : meta.member.access.python, source.python, support.function.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__imatmul__ : source.python, support.function.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__imatmul__ : meta.member.access.python, source.python, support.function.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__rmatmul__ : source.python, support.function.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__rmatmul__ : meta.member.access.python, source.python, support.function.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__annotations__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__annotations__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__init_subclass__ : source.python, support.function.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__init_subclass__ : meta.member.access.python, source.python, support.function.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__set_name__ : source.python, support.function.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__set_name__ : meta.member.access.python, source.python, support.function.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__fspath__ : source.python, support.function.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__fspath__ : meta.member.access.python, source.python, support.function.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__classcell__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__classcell__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__bytes__ : source.python, support.function.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__bytes__ : meta.member.access.python, source.python, support.function.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__spec__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__spec__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__path__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__path__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__prepare__ : source.python, support.function.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__prepare__ : meta.member.access.python, source.python, support.function.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__package__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__package__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__traceback__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__traceback__ : meta.member.access.python, source.python, support.variable.magic.python some : source.python -. : punctuation.separator.period.python, source.python -__notspecial__ : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__closure__ : meta.member.access.python, source.python, support.variable.magic.python +some : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__globals__ : meta.member.access.python, source.python, support.variable.magic.python +some : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__match_args__ : meta.member.access.python, source.python, support.variable.magic.python +some : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__notspecial__ : meta.attribute.python, meta.member.access.python, source.python diff --git a/test/builtins/builtins4.py b/test/builtins/builtins4.py index b8f3401b..d126c0bf 100644 --- a/test/builtins/builtins4.py +++ b/test/builtins/builtins4.py @@ -7,21 +7,22 @@ + some : source.python -. : punctuation.separator.period.python, source.python -int : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +int : meta.attribute.python, meta.member.access.python, source.python some : source.python -. : punctuation.separator.period.python, source.python -sum : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +sum : meta.attribute.python, meta.member.access.python, source.python some : source.python -. : punctuation.separator.period.python, source.python -super : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +super : meta.attribute.python, meta.member.access.python, source.python some : source.python -. : punctuation.separator.period.python, source.python -unicode : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +unicode : meta.attribute.python, meta.member.access.python, source.python some : source.python -. : punctuation.separator.period.python, source.python -foo : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +foo : meta.attribute.python, meta.member.access.python, source.python some : source.python -. : punctuation.separator.period.python, source.python -Exception : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +Exception : meta.attribute.python, meta.member.access.python, source.python diff --git a/test/builtins/builtins5.py b/test/builtins/builtins5.py index 674df37f..af3db3e5 100644 --- a/test/builtins/builtins5.py +++ b/test/builtins/builtins5.py @@ -7,20 +7,21 @@ + some : source.python -. : punctuation.separator.period.python, source.python - : source.python -True : keyword.illegal.name.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python + : meta.member.access.python, source.python +True : keyword.illegal.name.python, meta.member.access.python, source.python some : source.python -. : punctuation.separator.period.python, source.python - : source.python -\ : punctuation.separator.continuation.line.python, source.python - : source.python - : source.python -True : keyword.illegal.name.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python + : meta.member.access.python, source.python +\ : meta.member.access.python, punctuation.separator.continuation.line.python, source.python + : meta.member.access.python, source.python + : meta.member.access.python, source.python +True : keyword.illegal.name.python, meta.member.access.python, source.python True : constant.language.python, source.python some : source.python -. : punctuation.separator.period.python, source.python - : source.python - : source.python -True : keyword.illegal.name.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python + : meta.member.access.python, source.python + : meta.member.access.python, source.python +True : keyword.illegal.name.python, meta.member.access.python, source.python diff --git a/test/builtins/builtins6.py b/test/builtins/builtins6.py new file mode 100644 index 00000000..c110fa4a --- /dev/null +++ b/test/builtins/builtins6.py @@ -0,0 +1,13 @@ +exec() +exec(code_obj) + + + + +exec : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +exec : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +code_obj : meta.function-call.arguments.python, meta.function-call.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/builtins/builtins7.py b/test/builtins/builtins7.py new file mode 100644 index 00000000..6d23b2b7 --- /dev/null +++ b/test/builtins/builtins7.py @@ -0,0 +1,16 @@ +breakpoint() +aiter() +anext() + + + + +breakpoint : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +aiter : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +anext : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/calls/call1.py b/test/calls/call1.py index aab3f9f7..86f32acb 100644 --- a/test/calls/call1.py +++ b/test/calls/call1.py @@ -2,6 +2,7 @@ + some_call : meta.function-call.generic.python, meta.function-call.python, source.python ( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python A : meta.function-call.arguments.python, meta.function-call.python, source.python @@ -10,7 +11,7 @@ b : meta.function-call.arguments.python, meta.function-call.python, source.python , : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python : meta.function-call.arguments.python, meta.function-call.python, source.python -c : meta.function-call.arguments.python, meta.function-call.python, meta.item-access.python, source.python +c : meta.function-call.arguments.python, meta.function-call.python, meta.indexed-name.python, meta.item-access.python, source.python [ : meta.function-call.arguments.python, meta.function-call.python, meta.item-access.python, punctuation.definition.arguments.begin.python, source.python 1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, meta.item-access.arguments.python, meta.item-access.python, source.python ] : meta.function-call.arguments.python, meta.function-call.python, meta.item-access.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/calls/call10.py b/test/calls/call10.py new file mode 100644 index 00000000..98b52f2d --- /dev/null +++ b/test/calls/call10.py @@ -0,0 +1,32 @@ +x = foo(True, + 3 * 4, + *a, + **bar) + + + + + +x : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +foo : meta.function-call.generic.python, meta.function-call.python, source.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +True : constant.language.python, meta.function-call.arguments.python, meta.function-call.python, source.python +, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +3 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +* : keyword.operator.arithmetic.python, meta.function-call.arguments.python, meta.function-call.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +4 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python +, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +* : keyword.operator.unpacking.arguments.python, meta.function-call.arguments.python, meta.function-call.python, source.python +a : meta.function-call.arguments.python, meta.function-call.python, source.python +, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +** : keyword.operator.unpacking.arguments.python, meta.function-call.arguments.python, meta.function-call.python, source.python +bar : meta.function-call.arguments.python, meta.function-call.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/calls/call11.py b/test/calls/call11.py new file mode 100644 index 00000000..3695fc57 --- /dev/null +++ b/test/calls/call11.py @@ -0,0 +1,44 @@ +id = Field[uuid.UUID] ( + uuid.UUID, + inheritable=False, + simpledelta=False, + allow_ddl_set=True, +) + + + + + +id : source.python, support.function.builtin.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +Field : meta.indexed-name.python, meta.item-access.python, source.python +[ : meta.item-access.python, punctuation.definition.arguments.begin.python, source.python +uuid : meta.item-access.arguments.python, meta.item-access.python, source.python +. : meta.item-access.arguments.python, meta.item-access.python, meta.member.access.python, punctuation.separator.period.python, source.python +UUID : constant.other.caps.python, meta.item-access.arguments.python, meta.item-access.python, meta.member.access.python, source.python +] : meta.item-access.python, punctuation.definition.arguments.end.python, source.python + : source.python +( : punctuation.definition.arguments.begin.python, source.python + : meta.function-call.arguments.python, source.python +uuid : meta.function-call.arguments.python, source.python +. : meta.function-call.arguments.python, meta.member.access.python, punctuation.separator.period.python, source.python +UUID : constant.other.caps.python, meta.function-call.arguments.python, meta.member.access.python, source.python +, : meta.function-call.arguments.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, source.python +inheritable : meta.function-call.arguments.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, source.python +False : constant.language.python, meta.function-call.arguments.python, source.python +, : meta.function-call.arguments.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, source.python +simpledelta : meta.function-call.arguments.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, source.python +False : constant.language.python, meta.function-call.arguments.python, source.python +, : meta.function-call.arguments.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, source.python +allow_ddl_set : meta.function-call.arguments.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, source.python +True : constant.language.python, meta.function-call.arguments.python, source.python +, : meta.function-call.arguments.python, punctuation.separator.arguments.python, source.python +) : punctuation.definition.arguments.end.python, source.python diff --git a/test/calls/call3.py b/test/calls/call3.py index 3e5bca3d..3eb5ff59 100644 --- a/test/calls/call3.py +++ b/test/calls/call3.py @@ -4,17 +4,18 @@ + foo : source.python -. : punctuation.separator.period.python, source.python -class : keyword.control.flow.python, meta.function-call.python, source.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -a : meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +class : keyword.control.flow.python, meta.function-call.python, meta.member.access.python, source.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +a : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python foo : source.python -. : punctuation.separator.period.python, source.python -and : keyword.control.flow.python, meta.function-call.python, source.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +and : keyword.control.flow.python, meta.function-call.python, meta.member.access.python, source.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python foo : source.python -. : punctuation.separator.period.python, source.python -if : keyword.control.flow.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +if : keyword.control.flow.python, meta.member.access.python, source.python diff --git a/test/calls/call4.py b/test/calls/call4.py index a2976601..6da33186 100644 --- a/test/calls/call4.py +++ b/test/calls/call4.py @@ -4,9 +4,10 @@ + foo : source.python -. : punctuation.separator.period.python, source.python -1 : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +1 : meta.member.access.python, source.python foo : meta.function-call.generic.python, meta.function-call.python, source.python ( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python bar : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python @@ -19,13 +20,13 @@ sam : meta.function-call.arguments.python, meta.function-call.python, source.python ) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python foo : source.python -. : punctuation.separator.period.python, source.python -None : keyword.illegal.name.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +None : keyword.illegal.name.python, meta.member.access.python, source.python : source.python and : keyword.operator.logical.python, source.python : source.python foo : source.python -. : punctuation.separator.period.python, source.python -None : keyword.illegal.name.python, source.python -. : punctuation.separator.period.python, source.python -baz : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +None : keyword.illegal.name.python, meta.member.access.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +baz : meta.attribute.python, meta.member.access.python, source.python diff --git a/test/calls/call5.py b/test/calls/call5.py index f18470c4..4ea20afa 100644 --- a/test/calls/call5.py +++ b/test/calls/call5.py @@ -5,11 +5,11 @@ f : meta.function-call.generic.python, meta.function-call.python, source.python ( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -* : keyword.operator.unpacking.arguments.python, meta.function-call.python, source.python +* : keyword.operator.unpacking.arguments.python, meta.function-call.arguments.python, meta.function-call.python, source.python a : meta.function-call.arguments.python, meta.function-call.python, source.python ) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python f : meta.function-call.generic.python, meta.function-call.python, source.python ( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -** : keyword.operator.unpacking.arguments.python, meta.function-call.python, source.python +** : keyword.operator.unpacking.arguments.python, meta.function-call.arguments.python, meta.function-call.python, source.python a : meta.function-call.arguments.python, meta.function-call.python, source.python ) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/calls/call6.py b/test/calls/call6.py index 8cdcd6d4..afc87850 100644 --- a/test/calls/call6.py +++ b/test/calls/call6.py @@ -5,8 +5,8 @@ f : meta.function-call.generic.python, meta.function-call.python, source.python ( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python - : meta.function-call.python, source.python -* : keyword.operator.unpacking.arguments.python, meta.function-call.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +* : keyword.operator.unpacking.arguments.python, meta.function-call.arguments.python, meta.function-call.python, source.python a : meta.function-call.arguments.python, meta.function-call.python, source.python : meta.function-call.arguments.python, meta.function-call.python, source.python , : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python @@ -17,8 +17,8 @@ ) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python f : meta.function-call.generic.python, meta.function-call.python, source.python ( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python - : meta.function-call.python, source.python -** : keyword.operator.unpacking.arguments.python, meta.function-call.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +** : keyword.operator.unpacking.arguments.python, meta.function-call.arguments.python, meta.function-call.python, source.python a : meta.function-call.arguments.python, meta.function-call.python, source.python : meta.function-call.arguments.python, meta.function-call.python, source.python , : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python diff --git a/test/calls/call7.py b/test/calls/call7.py index b0b00f05..97cf7ee9 100644 --- a/test/calls/call7.py +++ b/test/calls/call7.py @@ -7,43 +7,44 @@ + foo : source.python -. : punctuation.separator.period.python, source.python -__class__ : meta.function-call.python, source.python, support.variable.magic.python - : meta.function-call.python, source.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -foo : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python -= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python -bar : meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__class__ : meta.function-call.python, meta.member.access.python, source.python, support.variable.magic.python + : meta.function-call.python, meta.member.access.python, source.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +foo : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +bar : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python foo : source.python -. : punctuation.separator.period.python, source.python -__class__ : meta.function-call.python, source.python, support.variable.magic.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -foo : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python -= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python -bar : meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__class__ : meta.function-call.python, meta.member.access.python, source.python, support.variable.magic.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +foo : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +bar : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python foo : source.python -. : punctuation.separator.period.python, source.python -__add__ : meta.function-call.python, source.python, support.function.magic.python - : meta.function-call.python, source.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -foo : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python -= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python -bar : meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__add__ : meta.function-call.python, meta.member.access.python, source.python, support.function.magic.python + : meta.function-call.python, meta.member.access.python, source.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +foo : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +bar : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python foo : source.python -. : punctuation.separator.period.python, source.python -__add__ : meta.function-call.python, source.python, support.function.magic.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -foo : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python -= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python -bar : meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__add__ : meta.function-call.python, meta.member.access.python, source.python, support.function.magic.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +foo : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +bar : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python : source.python foo : source.python -. : punctuation.separator.period.python, source.python -__class__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__class__ : meta.member.access.python, source.python, support.variable.magic.python : source.python 1 : constant.numeric.dec.python, source.python diff --git a/test/calls/call8.py b/test/calls/call8.py index 471a64d3..0b78f3d3 100644 --- a/test/calls/call8.py +++ b/test/calls/call8.py @@ -5,41 +5,42 @@ + foo : source.python -. : punctuation.separator.period.python, source.python - : source.python -__class__ : meta.function-call.python, source.python, support.variable.magic.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -foo : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python -= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python -bar : meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python + : meta.member.access.python, source.python +__class__ : meta.function-call.python, meta.member.access.python, source.python, support.variable.magic.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +foo : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +bar : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python foo : source.python -. : punctuation.separator.period.python, source.python - : source.python -__class__ : meta.function-call.python, source.python, support.variable.magic.python - : meta.function-call.python, source.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -foo : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python -= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python -bar : meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python + : meta.member.access.python, source.python +__class__ : meta.function-call.python, meta.member.access.python, source.python, support.variable.magic.python + : meta.function-call.python, meta.member.access.python, source.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +foo : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +bar : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python foo : source.python -. : punctuation.separator.period.python, source.python - : source.python -__add__ : meta.function-call.python, source.python, support.function.magic.python - : meta.function-call.python, source.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -foo : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python -= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python -bar : meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python + : meta.member.access.python, source.python +__add__ : meta.function-call.python, meta.member.access.python, source.python, support.function.magic.python + : meta.function-call.python, meta.member.access.python, source.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +foo : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +bar : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python foo : source.python -. : punctuation.separator.period.python, source.python - : source.python -__add__ : meta.function-call.python, source.python, support.function.magic.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -foo : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python -= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python -bar : meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python + : meta.member.access.python, source.python +__add__ : meta.function-call.python, meta.member.access.python, source.python, support.function.magic.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +foo : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +bar : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/calls/print1.py b/test/calls/print1.py index c5f3e7f7..9339060e 100644 --- a/test/calls/print1.py +++ b/test/calls/print1.py @@ -11,6 +11,7 @@ + print : source.python, support.function.builtin.python : source.python " : punctuation.definition.string.begin.python, source.python, string.quoted.single.python @@ -55,8 +56,8 @@ : source.python >> : keyword.operator.bitwise.python, source.python sys : source.python -. : punctuation.separator.period.python, source.python -stderr : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +stderr : meta.attribute.python, meta.member.access.python, source.python , : punctuation.separator.element.python, source.python : source.python " : punctuation.definition.string.begin.python, source.python, string.quoted.single.python @@ -72,8 +73,8 @@ file : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python = : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python sys : meta.function-call.arguments.python, meta.function-call.python, source.python -. : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.period.python, source.python -stderr : meta.function-call.arguments.python, meta.function-call.python, source.python +. : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.separator.period.python, source.python +stderr : meta.attribute.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python ) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python print : meta.function-call.python, source.python, support.function.builtin.python : meta.function-call.python, source.python diff --git a/test/classes/class11.py b/test/classes/class11.py index bad00706..4cb0b927 100644 --- a/test/classes/class11.py +++ b/test/classes/class11.py @@ -10,6 +10,7 @@ def __init__(self, a, b=1): + class : meta.class.python, source.python, storage.type.class.python : meta.class.python, source.python F : entity.name.type.class.python, meta.class.python, source.python @@ -32,16 +33,16 @@ def : meta.function.python, source.python, storage.type.function.pytho : : meta.function.python, punctuation.section.function.begin.python, source.python : source.python self : source.python, variable.language.special.self.python -. : punctuation.separator.period.python, source.python -a : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +a : meta.attribute.python, meta.member.access.python, source.python : source.python = : keyword.operator.assignment.python, source.python : source.python a : source.python : source.python self : source.python, variable.language.special.self.python -. : punctuation.separator.period.python, source.python -b : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +b : meta.attribute.python, meta.member.access.python, source.python : source.python = : keyword.operator.assignment.python, source.python : source.python @@ -57,18 +58,18 @@ def : meta.function.python, source.python, storage.type.function.pytho ) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python : source.python a : source.python -. : punctuation.separator.period.python, source.python -self : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +self : meta.attribute.python, meta.member.access.python, source.python : source.python = : keyword.operator.assignment.python, source.python : source.python 1 : constant.numeric.dec.python, source.python : source.python a : source.python -. : punctuation.separator.period.python, source.python -self : source.python -. : punctuation.separator.period.python, source.python -bar : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +self : meta.attribute.python, meta.member.access.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +bar : meta.attribute.python, meta.member.access.python, source.python : source.python = : keyword.operator.assignment.python, source.python : source.python diff --git a/test/classes/class12.py b/test/classes/class12.py index e8b69161..838a1bb2 100644 --- a/test/classes/class12.py +++ b/test/classes/class12.py @@ -12,12 +12,13 @@ def meth(cls, a, b=1): + class : meta.class.python, source.python, storage.type.class.python : meta.class.python, source.python F : entity.name.type.class.python, meta.class.python, source.python : : meta.class.python, punctuation.section.class.begin.python, source.python : meta.function.decorator.python, source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python classmethod : meta.function.decorator.python, source.python, support.type.python : meta.function.python, source.python def : meta.function.python, source.python, storage.type.function.python @@ -37,16 +38,16 @@ def : meta.function.python, source.python, storage.type.function.pytho : : meta.function.python, punctuation.section.function.begin.python, source.python : source.python cls : source.python, variable.language.special.cls.python -. : punctuation.separator.period.python, source.python -a : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +a : meta.attribute.python, meta.member.access.python, source.python : source.python = : keyword.operator.assignment.python, source.python : source.python a : source.python : source.python cls : source.python, variable.language.special.cls.python -. : punctuation.separator.period.python, source.python -b : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +b : meta.attribute.python, meta.member.access.python, source.python : source.python = : keyword.operator.assignment.python, source.python : source.python @@ -68,18 +69,18 @@ def : meta.function.python, source.python, storage.type.function.pytho 1 : constant.numeric.dec.python, source.python : source.python a : source.python -. : punctuation.separator.period.python, source.python -cls : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +cls : meta.attribute.python, meta.member.access.python, source.python : source.python = : keyword.operator.assignment.python, source.python : source.python 1 : constant.numeric.dec.python, source.python : source.python a : source.python -. : punctuation.separator.period.python, source.python -cls : source.python -. : punctuation.separator.period.python, source.python -__name__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +cls : meta.attribute.python, meta.member.access.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__name__ : meta.member.access.python, source.python, support.variable.magic.python : source.python cls : meta.item-access.python, source.python, variable.language.special.cls.python [ : meta.item-access.python, punctuation.definition.arguments.begin.python, source.python diff --git a/test/classes/class14.py b/test/classes/class14.py index 706969f9..45455895 100644 --- a/test/classes/class14.py +++ b/test/classes/class14.py @@ -3,26 +3,27 @@ class F(f.Exception, f.type, Exception, Exception.a, b=Exception): + class : meta.class.python, source.python, storage.type.class.python : meta.class.python, source.python F : entity.name.type.class.python, meta.class.python, source.python ( : meta.class.inheritance.python, meta.class.python, punctuation.definition.inheritance.begin.python, source.python f : entity.other.inherited-class.python, meta.class.inheritance.python, meta.class.python, source.python -. : meta.class.inheritance.python, meta.class.python, punctuation.separator.period.python, source.python -Exception : entity.other.inherited-class.python, meta.class.inheritance.python, meta.class.python, source.python +. : meta.class.inheritance.python, meta.class.python, meta.member.access.python, punctuation.separator.period.python, source.python +Exception : entity.other.inherited-class.python, meta.class.inheritance.python, meta.class.python, meta.member.access.python, source.python , : meta.class.inheritance.python, meta.class.python, punctuation.separator.inheritance.python, source.python : meta.class.inheritance.python, meta.class.python, source.python f : entity.other.inherited-class.python, meta.class.inheritance.python, meta.class.python, source.python -. : meta.class.inheritance.python, meta.class.python, punctuation.separator.period.python, source.python -type : entity.other.inherited-class.python, meta.class.inheritance.python, meta.class.python, source.python +. : meta.class.inheritance.python, meta.class.python, meta.member.access.python, punctuation.separator.period.python, source.python +type : entity.other.inherited-class.python, meta.class.inheritance.python, meta.class.python, meta.member.access.python, source.python , : meta.class.inheritance.python, meta.class.python, punctuation.separator.inheritance.python, source.python : meta.class.inheritance.python, meta.class.python, source.python Exception : meta.class.inheritance.python, meta.class.python, source.python, support.type.exception.python , : meta.class.inheritance.python, meta.class.python, punctuation.separator.inheritance.python, source.python : meta.class.inheritance.python, meta.class.python, source.python Exception : meta.class.inheritance.python, meta.class.python, source.python, support.type.exception.python -. : meta.class.inheritance.python, meta.class.python, punctuation.separator.period.python, source.python -a : entity.other.inherited-class.python, meta.class.inheritance.python, meta.class.python, source.python +. : meta.class.inheritance.python, meta.class.python, meta.member.access.python, punctuation.separator.period.python, source.python +a : entity.other.inherited-class.python, meta.class.inheritance.python, meta.class.python, meta.member.access.python, source.python , : meta.class.inheritance.python, meta.class.python, punctuation.separator.inheritance.python, source.python : meta.class.inheritance.python, meta.class.python, source.python b : entity.other.inherited-class.python, meta.class.inheritance.python, meta.class.python, source.python, variable.parameter.class.python diff --git a/test/classes/class2.py b/test/classes/class2.py index 536f9258..1f15e252 100644 --- a/test/classes/class2.py +++ b/test/classes/class2.py @@ -5,7 +5,8 @@ class Spam(Foo.Bar, Bar.name={'very': 'odd'}): -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python + +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python dec : entity.name.function.decorator.python, meta.function.decorator.python, source.python # : comment.line.number-sign.python, punctuation.definition.comment.python, source.python Bar.name=... is not legal, but the test is for highlighter not breaking badly : comment.line.number-sign.python, source.python @@ -14,13 +15,13 @@ class : meta.class.python, source.python, storage.type.class.python Spam : entity.name.type.class.python, meta.class.python, source.python ( : meta.class.inheritance.python, meta.class.python, punctuation.definition.inheritance.begin.python, source.python Foo : entity.other.inherited-class.python, meta.class.inheritance.python, meta.class.python, source.python -. : meta.class.inheritance.python, meta.class.python, punctuation.separator.period.python, source.python -Bar : entity.other.inherited-class.python, meta.class.inheritance.python, meta.class.python, source.python +. : meta.class.inheritance.python, meta.class.python, meta.member.access.python, punctuation.separator.period.python, source.python +Bar : entity.other.inherited-class.python, meta.class.inheritance.python, meta.class.python, meta.member.access.python, source.python , : meta.class.inheritance.python, meta.class.python, punctuation.separator.inheritance.python, source.python : meta.class.inheritance.python, meta.class.python, source.python Bar : entity.other.inherited-class.python, meta.class.inheritance.python, meta.class.python, source.python -. : meta.class.inheritance.python, meta.class.python, punctuation.separator.period.python, source.python -name : entity.other.inherited-class.python, meta.class.inheritance.python, meta.class.python, source.python +. : meta.class.inheritance.python, meta.class.python, meta.member.access.python, punctuation.separator.period.python, source.python +name : entity.other.inherited-class.python, meta.class.inheritance.python, meta.class.python, meta.member.access.python, source.python = : keyword.operator.assignment.python, meta.class.inheritance.python, meta.class.python, source.python { : meta.class.inheritance.python, meta.class.python, punctuation.definition.dict.begin.python, source.python ' : meta.class.inheritance.python, meta.class.python, punctuation.definition.string.begin.python, source.python, string.quoted.single.python diff --git a/test/classes/class9.py b/test/classes/class9.py index bbf24feb..a4ea943f 100644 --- a/test/classes/class9.py +++ b/test/classes/class9.py @@ -1,5 +1,6 @@ class Foo: __slots__ = () + __match_args__ = ('key', 'name') @@ -13,4 +14,19 @@ class : meta.class.python, source.python, storage.type.class.python = : keyword.operator.assignment.python, source.python : source.python ( : punctuation.parenthesis.begin.python, source.python +) : punctuation.parenthesis.end.python, source.python + : source.python +__match_args__ : source.python, support.variable.magic.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +( : punctuation.parenthesis.begin.python, source.python +' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +key : source.python, string.quoted.single.python +' : punctuation.definition.string.end.python, source.python, string.quoted.single.python +, : punctuation.separator.element.python, source.python + : source.python +' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +name : source.python, string.quoted.single.python +' : punctuation.definition.string.end.python, source.python, string.quoted.single.python ) : punctuation.parenthesis.end.python, source.python diff --git a/test/classes/super1.py b/test/classes/super1.py index 1840ed9b..709205c4 100644 --- a/test/classes/super1.py +++ b/test/classes/super1.py @@ -30,39 +30,39 @@ def : meta.function.python, source.python, storage.type.function.pytho super : meta.function-call.python, source.python, support.type.python ( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python ) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python -. : punctuation.separator.period.python, source.python -__init__ : meta.function-call.python, source.python, support.function.magic.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -foo : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python -= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python -1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__init__ : meta.function-call.python, meta.member.access.python, source.python, support.function.magic.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +foo : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python : source.python super : meta.function-call.python, source.python, support.type.python ( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python ) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python -. : punctuation.separator.period.python, source.python - : source.python -__init__ : meta.function-call.python, source.python, support.function.magic.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -foo : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python -= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python -1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python + : meta.member.access.python, source.python +__init__ : meta.function-call.python, meta.member.access.python, source.python, support.function.magic.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +foo : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python : source.python super : meta.function-call.python, source.python, support.type.python ( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python ) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python -. : punctuation.separator.period.python, source.python - : source.python -\ : punctuation.separator.continuation.line.python, source.python - : source.python -__init__ : meta.function-call.python, source.python, support.function.magic.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -foo : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python -= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python -1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python + : meta.member.access.python, source.python +\ : meta.member.access.python, punctuation.separator.continuation.line.python, source.python + : meta.member.access.python, source.python +__init__ : meta.function-call.python, meta.member.access.python, source.python, support.function.magic.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +foo : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python : source.python __init__ : meta.function-call.python, source.python, support.function.magic.python ( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python @@ -73,13 +73,13 @@ def : meta.function.python, source.python, storage.type.function.pytho : source.python : source.python foo : source.python -. : punctuation.separator.period.python, source.python -__init__ : meta.function-call.python, source.python, support.function.magic.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -bar : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python -= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python -1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__init__ : meta.function-call.python, meta.member.access.python, source.python, support.function.magic.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +bar : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python : source.python __init__ : meta.function-call.python, source.python, support.function.magic.python ( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python diff --git a/test/docstrings/continuation2.py b/test/docstrings/continuation2.py index 6219f6fb..b9580e19 100644 --- a/test/docstrings/continuation2.py +++ b/test/docstrings/continuation2.py @@ -1,5 +1,6 @@ ' ' +# comment @@ -7,3 +8,5 @@ : invalid.illegal.newline.python, source.python, string.quoted.docstring.single.python ' : punctuation.definition.string.begin.python, source.python, string.quoted.docstring.single.python : invalid.illegal.newline.python, source.python, string.quoted.docstring.single.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + comment : comment.line.number-sign.python, source.python diff --git a/test/docstrings/continuation5.py b/test/docstrings/continuation5.py new file mode 100644 index 00000000..2e1f96ce --- /dev/null +++ b/test/docstrings/continuation5.py @@ -0,0 +1,47 @@ +'implicit ' "concatenation" + +'''implicit +''' 'concatenation' + +'''implicit +''' """ +concatenation +""" + +'implicit' ''' +concatenation +''' + + + +' : punctuation.definition.string.begin.python, source.python, string.quoted.docstring.single.python +implicit : source.python, string.quoted.docstring.single.python +' : punctuation.definition.string.end.python, source.python, string.quoted.docstring.single.python + : source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.docstring.single.python +concatenation : source.python, string.quoted.docstring.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.docstring.single.python + : source.python +''' : punctuation.definition.string.begin.python, source.python, string.quoted.docstring.multi.python +implicit : source.python, string.quoted.docstring.multi.python +''' : punctuation.definition.string.end.python, source.python, string.quoted.docstring.multi.python + : source.python +' : punctuation.definition.string.begin.python, source.python, string.quoted.docstring.single.python +concatenation : source.python, string.quoted.docstring.single.python +' : punctuation.definition.string.end.python, source.python, string.quoted.docstring.single.python + : source.python +''' : punctuation.definition.string.begin.python, source.python, string.quoted.docstring.multi.python +implicit : source.python, string.quoted.docstring.multi.python +''' : punctuation.definition.string.end.python, source.python, string.quoted.docstring.multi.python + : source.python +""" : punctuation.definition.string.begin.python, source.python, string.quoted.docstring.multi.python +concatenation : source.python, string.quoted.docstring.multi.python +""" : punctuation.definition.string.end.python, source.python, string.quoted.docstring.multi.python + : source.python +' : punctuation.definition.string.begin.python, source.python, string.quoted.docstring.single.python +implicit : source.python, string.quoted.docstring.single.python +' : punctuation.definition.string.end.python, source.python, string.quoted.docstring.single.python + : source.python +''' : punctuation.definition.string.begin.python, source.python, string.quoted.docstring.multi.python +concatenation : source.python, string.quoted.docstring.multi.python +''' : punctuation.definition.string.end.python, source.python, string.quoted.docstring.multi.python diff --git a/test/docstrings/regr1.py b/test/docstrings/regr1.py index 7d3d5dcc..8b5a65e9 100644 --- a/test/docstrings/regr1.py +++ b/test/docstrings/regr1.py @@ -8,7 +8,7 @@ def foo(): # : comment.line.number-sign.python, punctuation.definition.comment.python, source.python : : comment.line.number-sign.python, source.python : meta.function.decorator.python, source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python asd : entity.name.function.decorator.python, meta.function.decorator.python, source.python : meta.function.python, source.python def : meta.function.python, source.python, storage.type.function.python diff --git a/test/expressions/const1.py b/test/expressions/const1.py index e59a19be..5288d71a 100644 --- a/test/expressions/const1.py +++ b/test/expressions/const1.py @@ -3,6 +3,7 @@ + QQQQ : constant.other.caps.python, source.python : source.python QQQQ_123 : constant.other.caps.python, source.python @@ -12,27 +13,27 @@ PROTOCOL_v2 : constant.other.caps.python, source.python : source.python QQQ : constant.other.caps.python, source.python -. : punctuation.separator.period.python, source.python -bar : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +bar : meta.attribute.python, meta.member.access.python, source.python : source.python baz : source.python -. : punctuation.separator.period.python, source.python -AA_a : constant.other.caps.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +AA_a : constant.other.caps.python, meta.member.access.python, source.python : source.python _AAA : constant.other.caps.python, source.python : source.python foo : source.python -. : punctuation.separator.period.python, source.python -_AAA : constant.other.caps.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +_AAA : constant.other.caps.python, meta.member.access.python, source.python QQQq : source.python : source.python QQQq123 : source.python : source.python self : source.python, variable.language.special.self.python -. : punctuation.separator.period.python, source.python -FOOO : meta.function-call.generic.python, meta.function-call.python, source.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +FOOO : meta.function-call.generic.python, meta.function-call.python, meta.member.access.python, source.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python : source.python _ : source.python : source.python diff --git a/test/expressions/expr10.py b/test/expressions/expr10.py index 501fb475..df5f1165 100644 --- a/test/expressions/expr10.py +++ b/test/expressions/expr10.py @@ -5,6 +5,7 @@ + a : source.python : source.python = : keyword.operator.assignment.python, source.python @@ -32,5 +33,5 @@ ... : constant.other.ellipsis.python, source.python ) : punctuation.parenthesis.end.python, source.python ... : constant.other.ellipsis.python, source.python -. : punctuation.separator.period.python, source.python -__class__ : source.python, support.variable.magic.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +__class__ : meta.member.access.python, source.python, support.variable.magic.python diff --git a/test/expressions/expr11.py b/test/expressions/expr11.py index 142ff621..de8e348c 100644 --- a/test/expressions/expr11.py +++ b/test/expressions/expr11.py @@ -2,15 +2,16 @@ + a : source.python : source.python = : keyword.operator.assignment.python, source.python : source.python self : source.python, variable.language.special.self.python -. : punctuation.separator.period.python, source.python -some_list : meta.item-access.python, source.python -[ : meta.item-access.python, punctuation.definition.arguments.begin.python, source.python -1 : constant.numeric.dec.python, meta.item-access.arguments.python, meta.item-access.python, source.python -: : meta.item-access.arguments.python, meta.item-access.python, punctuation.separator.slice.python, source.python -2 : constant.numeric.dec.python, meta.item-access.arguments.python, meta.item-access.python, source.python -] : meta.item-access.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +some_list : meta.indexed-name.python, meta.item-access.python, meta.member.access.python, source.python +[ : meta.item-access.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +1 : constant.numeric.dec.python, meta.item-access.arguments.python, meta.item-access.python, meta.member.access.python, source.python +: : meta.item-access.arguments.python, meta.item-access.python, meta.member.access.python, punctuation.separator.slice.python, source.python +2 : constant.numeric.dec.python, meta.item-access.arguments.python, meta.item-access.python, meta.member.access.python, source.python +] : meta.item-access.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/expressions/expr15.py b/test/expressions/expr15.py index 2815cdae..4038218a 100644 --- a/test/expressions/expr15.py +++ b/test/expressions/expr15.py @@ -2,6 +2,7 @@ + foofrom : source.python -. : punctuation.separator.period.python, source.python -something : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +something : meta.attribute.python, meta.member.access.python, source.python diff --git a/test/expressions/expr18.py b/test/expressions/expr18.py index 8326520f..6e9413bf 100644 --- a/test/expressions/expr18.py +++ b/test/expressions/expr18.py @@ -3,9 +3,10 @@ + a : source.python -. : punctuation.separator.period.python, source.python -Exception : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +Exception : meta.attribute.python, meta.member.access.python, source.python Exception : source.python, support.type.exception.python -. : punctuation.separator.period.python, source.python -a : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +a : meta.attribute.python, meta.member.access.python, source.python diff --git a/test/expressions/expr19.py b/test/expressions/expr19.py index 45dd0e8e..4a4a3a5b 100644 --- a/test/expressions/expr19.py +++ b/test/expressions/expr19.py @@ -11,40 +11,41 @@ + a : source.python -. : punctuation.separator.period.python, source.python - : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python + : meta.member.access.python, source.python # : comment.line.number-sign.python, punctuation.definition.comment.python, source.python foo : comment.line.number-sign.python, source.python a : source.python -. : punctuation.separator.period.python, source.python - : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python + : meta.member.access.python, source.python # : comment.line.number-sign.python, punctuation.definition.comment.python, source.python foo : comment.line.number-sign.python, source.python a : source.python -. : punctuation.separator.period.python, source.python - : source.python -\ : punctuation.separator.continuation.line.python, source.python - : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python + : meta.member.access.python, source.python +\ : meta.member.access.python, punctuation.separator.continuation.line.python, source.python + : meta.member.access.python, source.python # : comment.line.number-sign.python, punctuation.definition.comment.python, source.python foo : comment.line.number-sign.python, source.python a : source.python -. : punctuation.separator.period.python, source.python - : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python + : meta.member.access.python, source.python ' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python bar : source.python, string.quoted.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.single.python a : source.python -. : punctuation.separator.period.python, source.python - : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python + : meta.member.access.python, source.python ' : punctuation.definition.string.begin.python, source.python, string.quoted.docstring.single.python bar : source.python, string.quoted.docstring.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.docstring.single.python a : source.python -. : punctuation.separator.period.python, source.python - : source.python -\ : punctuation.separator.continuation.line.python, source.python - : source.python -' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python -bar : source.python, string.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.quoted.single.python +. : meta.member.access.python, punctuation.separator.period.python, source.python + : meta.member.access.python, source.python +\ : meta.member.access.python, punctuation.separator.continuation.line.python, source.python + : meta.member.access.python, source.python +' : meta.member.access.python, punctuation.definition.string.begin.python, source.python, string.quoted.single.python +bar : meta.member.access.python, source.python, string.quoted.single.python +' : meta.member.access.python, punctuation.definition.string.end.python, source.python, string.quoted.single.python diff --git a/test/expressions/expr21.py b/test/expressions/expr21.py new file mode 100644 index 00000000..59556710 --- /dev/null +++ b/test/expressions/expr21.py @@ -0,0 +1,39 @@ +while chunk := file.read(8192): + process(chunk) + y0 = (y1 := f(x)) + + + +while : keyword.control.flow.python, source.python + : source.python +chunk : source.python + : source.python +:= : keyword.operator.assignment.python, source.python + : source.python +file : source.python, variable.legacy.builtin.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +read : meta.function-call.generic.python, meta.function-call.python, meta.member.access.python, source.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +8192 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +process : meta.function-call.generic.python, meta.function-call.python, source.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +chunk : meta.function-call.arguments.python, meta.function-call.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python + : source.python +y0 : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +( : punctuation.parenthesis.begin.python, source.python +y1 : source.python + : source.python +:= : keyword.operator.assignment.python, source.python + : source.python +f : meta.function-call.generic.python, meta.function-call.python, source.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +x : meta.function-call.arguments.python, meta.function-call.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +) : punctuation.parenthesis.end.python, source.python diff --git a/test/expressions/expr22.py b/test/expressions/expr22.py new file mode 100644 index 00000000..7c03f542 --- /dev/null +++ b/test/expressions/expr22.py @@ -0,0 +1,33 @@ +match = 13 +case = 12 +if case == 4: + return match * 5 + + + +match : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +13 : constant.numeric.dec.python, source.python +case : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +12 : constant.numeric.dec.python, source.python +if : keyword.control.flow.python, source.python + : source.python +case : source.python + : source.python +== : keyword.operator.comparison.python, source.python + : source.python +4 : constant.numeric.dec.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +return : keyword.control.flow.python, source.python + : source.python +match : source.python + : source.python +* : keyword.operator.arithmetic.python, source.python + : source.python +5 : constant.numeric.dec.python, source.python diff --git a/test/expressions/expr4.py b/test/expressions/expr4.py index 6795c76d..ac5e5ddc 100644 --- a/test/expressions/expr4.py +++ b/test/expressions/expr4.py @@ -13,7 +13,7 @@ : source.python i : source.python : source.python -in : keyword.operator.logical.python, source.python +in : keyword.control.flow.python, source.python : source.python range : meta.function-call.python, source.python, support.function.builtin.python ( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python diff --git a/test/expressions/expr5.py b/test/expressions/expr5.py index 0e19a719..9c734c46 100644 --- a/test/expressions/expr5.py +++ b/test/expressions/expr5.py @@ -33,7 +33,7 @@ : : punctuation.separator.dict.python, source.python : source.python { : punctuation.definition.dict.begin.python, source.python -import : keyword.control.flow.python, source.python +import : keyword.control.import.python, source.python : : punctuation.separator.dict.python, source.python : source.python a : source.python diff --git a/test/expressions/expr7.py b/test/expressions/expr7.py index 936af9e8..8bfa1704 100644 --- a/test/expressions/expr7.py +++ b/test/expressions/expr7.py @@ -2,18 +2,19 @@ + a : source.python -. : punctuation.separator.period.python, source.python -True : keyword.illegal.name.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +True : keyword.illegal.name.python, meta.member.access.python, source.python : source.python = : keyword.operator.assignment.python, source.python : source.python b : source.python -. : punctuation.separator.period.python, source.python -False : keyword.illegal.name.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +False : keyword.illegal.name.python, meta.member.access.python, source.python : source.python = : keyword.operator.assignment.python, source.python : source.python d : source.python -. : punctuation.separator.period.python, source.python -None : keyword.illegal.name.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +None : keyword.illegal.name.python, meta.member.access.python, source.python diff --git a/test/expressions/keywords.py b/test/expressions/keywords.py index 82ae6521..7c14d5c2 100644 --- a/test/expressions/keywords.py +++ b/test/expressions/keywords.py @@ -1,12 +1,14 @@ -as async await continue del assert break finally for +as async await continue del assert break finally from elif else if import except pass raise return try while with nonlocal global class def +for -as : keyword.control.flow.python, source.python + +as : keyword.control.import.python, source.python : source.python async : keyword.control.flow.python, source.python : source.python @@ -21,9 +23,7 @@ break : keyword.control.flow.python, source.python : source.python finally : keyword.control.flow.python, source.python - : source.python -for : keyword.control.flow.python, source.python -from : keyword.control.flow.python, source.python +from : keyword.control.import.python, source.python : source.python elif : keyword.control.flow.python, source.python : source.python @@ -52,3 +52,5 @@ : source.python class : source.python, storage.type.class.python def : source.python, storage.type.function.python + : source.python +for : keyword.control.flow.python, source.python diff --git a/test/expressions/special2.py b/test/expressions/special2.py new file mode 100644 index 00000000..727d664f --- /dev/null +++ b/test/expressions/special2.py @@ -0,0 +1,16 @@ +__post_init__ +def __class_getitem__(): pass +__mro_entries__ + + + +__post_init__ : source.python, support.variable.magic.python +def : meta.function.python, source.python, storage.type.function.python + : meta.function.python, source.python +__class_getitem__ : meta.function.python, source.python, support.function.magic.python +( : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.begin.python, source.python +) : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.end.python, source.python +: : meta.function.python, punctuation.section.function.begin.python, source.python + : source.python +pass : keyword.control.flow.python, source.python +__mro_entries__ : source.python, support.variable.magic.python diff --git a/test/fstrings/comment4.py b/test/fstrings/comment4.py index f070cdd0..66943523 100644 --- a/test/fstrings/comment4.py +++ b/test/fstrings/comment4.py @@ -4,36 +4,36 @@ self : source.python, variable.language.special.self.python -. : punctuation.separator.period.python, source.python -assertEqual : meta.function-call.generic.python, meta.function-call.python, source.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -f : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.single.python -' : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.quoted.single.python -{ : constant.character.format.placeholder.other.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python -10 : constant.numeric.dec.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python -: : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, storage.type.format.python -# : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, storage.type.format.python -{ : constant.character.format.placeholder.other.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python -3 : constant.numeric.dec.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python - : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python -!= : keyword.operator.comparison.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python - : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python -{ : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.dict.begin.python, source.python -4 : constant.numeric.dec.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python -: : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.dict.python, source.python -5 : constant.numeric.dec.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python -} : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.dict.end.python, source.python - : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python -and : keyword.operator.logical.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python - : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python -width : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python -} : constant.character.format.placeholder.other.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python -x : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, storage.type.format.python -} : constant.character.format.placeholder.other.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python -' : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.single.python -, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python - : meta.function-call.arguments.python, meta.function-call.python, source.python -' : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.quoted.single.python - 0xa : meta.function-call.arguments.python, meta.function-call.python, source.python, string.quoted.single.python -' : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.quoted.single.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +assertEqual : meta.function-call.generic.python, meta.function-call.python, meta.member.access.python, source.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +f : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.single.python +' : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.quoted.single.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +10 : constant.numeric.dec.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +: : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, storage.type.format.python +# : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, storage.type.format.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +3 : constant.numeric.dec.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python + : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +!= : keyword.operator.comparison.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python + : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +{ : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.dict.begin.python, source.python +4 : constant.numeric.dec.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +: : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.separator.dict.python, source.python +5 : constant.numeric.dec.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +} : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.dict.end.python, source.python + : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +and : keyword.operator.logical.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python + : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +width : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +x : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, storage.type.format.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +' : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.single.python +, : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +' : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.string.begin.python, source.python, string.quoted.single.python + 0xa : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.quoted.single.python +' : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.string.end.python, source.python, string.quoted.single.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/fstrings/empty2.py b/test/fstrings/empty2.py index 77dc9087..9a007e14 100644 --- a/test/fstrings/empty2.py +++ b/test/fstrings/empty2.py @@ -7,20 +7,22 @@ -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -" : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -{ : constant.character.format.placeholder.other.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -} : constant.character.format.placeholder.other.python, source.python, string.interpolated.python, string.regexp.quoted.single.python - : source.python, string.interpolated.python, string.regexp.quoted.single.python -{ : constant.character.format.placeholder.other.python, source.python, string.interpolated.python, string.regexp.quoted.single.python - : invalid.illegal.brace.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -} : constant.character.format.placeholder.other.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -" : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.multi.python -""" : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.multi.python -{ : constant.character.format.placeholder.other.python, source.python, string.interpolated.python, string.regexp.quoted.multi.python -} : constant.character.format.placeholder.other.python, source.python, string.interpolated.python, string.regexp.quoted.multi.python -{ : constant.character.format.placeholder.other.python, source.python, string.interpolated.python, string.regexp.quoted.multi.python - : invalid.illegal.brace.python, source.python, string.interpolated.python, string.regexp.quoted.multi.python -} : constant.character.format.placeholder.other.python, source.python, string.interpolated.python, string.regexp.quoted.multi.python -""" : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.multi.python +rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +" : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python + : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python + : invalid.illegal.brace.python, meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +" : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python +rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.multi.python +""" : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.multi.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python + : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.multi.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python + : invalid.illegal.brace.python, meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python + : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.multi.python +""" : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.multi.python diff --git a/test/fstrings/fraw1.py b/test/fstrings/fraw1.py new file mode 100644 index 00000000..31e2196e --- /dev/null +++ b/test/fstrings/fraw1.py @@ -0,0 +1,40 @@ +a = fr'[a-z]' +a = Fr'[a-z]' +a = rf'[a-z]' +a = rF'[a-z]' + + + + +a : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +fr : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +[a-z] : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python +a : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +Fr : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +[a-z] : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python +a : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +[a-z] : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python +a : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +rF : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +[a-z] : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python diff --git a/test/fstrings/fraw2.py b/test/fstrings/fraw2.py new file mode 100644 index 00000000..df0a2fed --- /dev/null +++ b/test/fstrings/fraw2.py @@ -0,0 +1,36 @@ +rf'fo{{2}}' +rf"fo{{2}}" +rf'''fo{{2}}''' +rf"""fo{{2}}""" + + + + +rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +fo : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +{{ : constant.character.escape.python, meta.fstring.python, source.python +2 : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +}} : constant.character.escape.python, meta.fstring.python, source.python +' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python +rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +" : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +fo : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +{{ : constant.character.escape.python, meta.fstring.python, source.python +2 : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +}} : constant.character.escape.python, meta.fstring.python, source.python +" : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python +rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.multi.python +''' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.multi.python +fo : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.multi.python +{{ : constant.character.escape.python, meta.fstring.python, source.python +2 : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.multi.python +}} : constant.character.escape.python, meta.fstring.python, source.python +''' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.multi.python +rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.multi.python +""" : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.multi.python +fo : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.multi.python +{{ : constant.character.escape.python, meta.fstring.python, source.python +2 : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.multi.python +}} : constant.character.escape.python, meta.fstring.python, source.python +""" : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.multi.python diff --git a/test/fstrings/fraw3.py b/test/fstrings/fraw3.py new file mode 100644 index 00000000..da1a6aff --- /dev/null +++ b/test/fstrings/fraw3.py @@ -0,0 +1,36 @@ +rf'fo{2}' +rf"fo{2}" +rf'''fo{2}''' +rf"""fo{2}""" + + + + +rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +fo : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +2 : constant.numeric.dec.python, meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python +rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +" : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +fo : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +2 : constant.numeric.dec.python, meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +" : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python +rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.multi.python +''' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.multi.python +fo : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.multi.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +2 : constant.numeric.dec.python, meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +''' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.multi.python +rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.multi.python +""" : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.multi.python +fo : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.multi.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +2 : constant.numeric.dec.python, meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +""" : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.multi.python diff --git a/test/fstrings/fraw4.py b/test/fstrings/fraw4.py new file mode 100644 index 00000000..2bf2d465 --- /dev/null +++ b/test/fstrings/fraw4.py @@ -0,0 +1,45 @@ +a = rf'fo{{{2}}}' +a = rf'fo{{{bar}}}' +a = rf'fo{{2}}' + + + + + +a : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +fo : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +{{ : constant.character.escape.python, meta.fstring.python, source.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +2 : constant.numeric.dec.python, meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +}} : constant.character.escape.python, meta.fstring.python, source.python +' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python +a : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +fo : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +{{ : constant.character.escape.python, meta.fstring.python, source.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +bar : meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +}} : constant.character.escape.python, meta.fstring.python, source.python +' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python +a : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +fo : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +{{ : constant.character.escape.python, meta.fstring.python, source.python +2 : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +}} : constant.character.escape.python, meta.fstring.python, source.python +' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python diff --git a/test/fstrings/nested1.py b/test/fstrings/nested1.py index d7d1c8bf..91f15907 100644 --- a/test/fstrings/nested1.py +++ b/test/fstrings/nested1.py @@ -26,7 +26,7 @@ : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.interpolated.python, string.quoted.multi.python { : constant.character.format.placeholder.other.python, meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python -bar : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.item-access.python, source.python +bar : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.indexed-name.python, meta.item-access.python, source.python [ : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.item-access.python, punctuation.definition.arguments.begin.python, source.python " : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.item-access.arguments.python, meta.item-access.python, punctuation.definition.string.begin.python, source.python, string.quoted.single.python q : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, meta.item-access.arguments.python, meta.item-access.python, source.python, string.quoted.single.python diff --git a/test/fstrings/nested3.py b/test/fstrings/nested3.py index 607c38ca..64589b18 100644 --- a/test/fstrings/nested3.py +++ b/test/fstrings/nested3.py @@ -1,6 +1,6 @@ f"result: {value:{60}.{16!s:2}{'qwerty' [2]}}" - +# comment @@ -30,3 +30,5 @@ }} : source.python " : punctuation.definition.string.begin.python, source.python, string.quoted.single.python : invalid.illegal.newline.python, source.python, string.quoted.single.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + comment : comment.line.number-sign.python, source.python diff --git a/test/fstrings/prefixes2.py b/test/fstrings/prefixes2.py index 861d2b66..78ee4246 100644 --- a/test/fstrings/prefixes2.py +++ b/test/fstrings/prefixes2.py @@ -22,16 +22,20 @@ obj : meta.fstring.python, source.python } : constant.character.format.placeholder.other.python, meta.fstring.python, source.python ' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.single.python -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -some : source.python, string.interpolated.python, string.regexp.quoted.single.python -{obj} : source.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -rF : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -some : source.python, string.interpolated.python, string.regexp.quoted.single.python -{obj} : source.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python +rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +some : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +obj : meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python +rF : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +some : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +obj : meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python Rf : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python ' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python some : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python diff --git a/test/fstrings/prefixes3.py b/test/fstrings/prefixes3.py index 200fa896..46d12ffb 100644 --- a/test/fstrings/prefixes3.py +++ b/test/fstrings/prefixes3.py @@ -6,16 +6,20 @@ -fr : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -some : source.python, string.interpolated.python, string.regexp.quoted.single.python -{obj} : source.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -Fr : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -some : source.python, string.interpolated.python, string.regexp.quoted.single.python -{obj} : source.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python +fr : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +some : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +obj : meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python +Fr : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python +' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python +some : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +obj : meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.raw.single.python fR : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.raw.single.python ' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python some : meta.fstring.python, source.python, string.interpolated.python, string.quoted.raw.single.python diff --git a/test/fstrings/simple10.py b/test/fstrings/simple10.py new file mode 100644 index 00000000..ae793021 --- /dev/null +++ b/test/fstrings/simple10.py @@ -0,0 +1,18 @@ +f'values: {a=} {b=!r}' + + + + +f : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.single.python +' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.quoted.single.python +values: : meta.fstring.python, source.python, string.interpolated.python, string.quoted.single.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +a : meta.fstring.python, source.python += : meta.fstring.python, source.python, storage.type.format.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python + : meta.fstring.python, source.python, string.interpolated.python, string.quoted.single.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +b : meta.fstring.python, source.python +=!r : meta.fstring.python, source.python, storage.type.format.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.single.python diff --git a/test/fstrings/simple2.py b/test/fstrings/simple2.py index 48ce0dcd..e4e1ff37 100644 --- a/test/fstrings/simple2.py +++ b/test/fstrings/simple2.py @@ -2,6 +2,7 @@ + a : source.python : source.python = : keyword.operator.assignment.python, source.python @@ -22,8 +23,8 @@ normal : meta.fstring.python, source.python, string.interpolated.python, string.quoted.single.python { : constant.character.format.placeholder.other.python, meta.fstring.python, source.python fo : meta.fstring.python, source.python -. : meta.fstring.python, punctuation.separator.period.python, source.python -__add__ : meta.fstring.python, source.python, support.function.magic.python +. : meta.fstring.python, meta.member.access.python, punctuation.separator.period.python, source.python +__add__ : meta.fstring.python, meta.member.access.python, source.python, support.function.magic.python !s : meta.fstring.python, source.python, storage.type.format.python } : constant.character.format.placeholder.other.python, meta.fstring.python, source.python " : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.single.python diff --git a/test/functions/async1.py b/test/functions/async1.py index cb6fd70e..0218fafd 100644 --- a/test/functions/async1.py +++ b/test/functions/async1.py @@ -7,7 +7,7 @@ async def foo(): -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python foo : entity.name.function.decorator.python, meta.function.decorator.python, source.python async : meta.function.python, source.python, storage.type.function.async.python : meta.function.python, source.python @@ -36,7 +36,7 @@ def : meta.function.python, source.python, storage.type.function.pytho : source.python c : source.python : source.python -in : keyword.operator.logical.python, source.python +in : keyword.control.flow.python, source.python : source.python b : source.python : : punctuation.separator.colon.python, source.python diff --git a/test/functions/decl15.py b/test/functions/decl15.py new file mode 100644 index 00000000..7f5c4ecc --- /dev/null +++ b/test/functions/decl15.py @@ -0,0 +1,34 @@ +def showcase(a, b, /, c, d, *, e, f): + return + + + + +def : meta.function.python, source.python, storage.type.function.python + : meta.function.python, source.python +showcase : entity.name.function.python, meta.function.python, source.python +( : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.begin.python, source.python +a : meta.function.parameters.python, meta.function.python, source.python, variable.parameter.function.language.python +, : meta.function.parameters.python, meta.function.python, punctuation.separator.parameters.python, source.python + : meta.function.parameters.python, meta.function.python, source.python +b : meta.function.parameters.python, meta.function.python, source.python, variable.parameter.function.language.python +, : meta.function.parameters.python, meta.function.python, punctuation.separator.parameters.python, source.python + : meta.function.parameters.python, meta.function.python, source.python +/ : keyword.operator.positional.parameter.python, meta.function.parameters.python, meta.function.python, source.python +, : meta.function.parameters.python, meta.function.python, source.python +c : meta.function.parameters.python, meta.function.python, source.python, variable.parameter.function.language.python +, : meta.function.parameters.python, meta.function.python, punctuation.separator.parameters.python, source.python + : meta.function.parameters.python, meta.function.python, source.python +d : meta.function.parameters.python, meta.function.python, source.python, variable.parameter.function.language.python +, : meta.function.parameters.python, meta.function.python, punctuation.separator.parameters.python, source.python + : meta.function.parameters.python, meta.function.python, source.python +* : keyword.operator.unpacking.parameter.python, meta.function.parameters.python, meta.function.python, source.python +, : meta.function.parameters.python, meta.function.python, source.python +e : meta.function.parameters.python, meta.function.python, source.python, variable.parameter.function.language.python +, : meta.function.parameters.python, meta.function.python, punctuation.separator.parameters.python, source.python + : meta.function.parameters.python, meta.function.python, source.python +f : meta.function.parameters.python, meta.function.python, source.python, variable.parameter.function.language.python +) : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.end.python, source.python +: : meta.function.python, punctuation.section.function.begin.python, source.python + : source.python +return : keyword.control.flow.python, source.python diff --git a/test/functions/decl2.py b/test/functions/decl2.py index 7da74fcb..f858ea26 100644 --- a/test/functions/decl2.py +++ b/test/functions/decl2.py @@ -2,6 +2,8 @@ def result_annot(lambda, lambda=) -> qqq[None]: pass + + def : meta.function.python, source.python, storage.type.function.python : meta.function.python, source.python result_annot : entity.name.function.python, meta.function.python, source.python @@ -14,7 +16,7 @@ def : meta.function.python, source.python, storage.type.function.pytho : meta.function.python, source.python -> : meta.function.python, punctuation.separator.annotation.result.python, source.python : meta.function.python, source.python -qqq : meta.function.python, meta.item-access.python, source.python +qqq : meta.function.python, meta.indexed-name.python, meta.item-access.python, source.python [ : meta.function.python, meta.item-access.python, punctuation.definition.arguments.begin.python, source.python None : constant.language.python, meta.function.python, meta.item-access.arguments.python, meta.item-access.python, source.python ] : meta.function.python, meta.item-access.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/functions/decl4.py b/test/functions/decl4.py index f3b40fe5..5a452ea4 100644 --- a/test/functions/decl4.py +++ b/test/functions/decl4.py @@ -38,7 +38,7 @@ def : meta.function.python, source.python, storage.type.function.pytho : meta.function.parameters.python, meta.function.python, source.python val : meta.function.parameters.python, meta.function.python, source.python : meta.function.parameters.python, meta.function.python, source.python -in : keyword.operator.logical.python, meta.function.parameters.python, meta.function.python, source.python +in : keyword.control.flow.python, meta.function.parameters.python, meta.function.python, source.python : meta.function.parameters.python, meta.function.python, source.python ( : meta.function.parameters.python, meta.function.python, punctuation.parenthesis.begin.python, source.python x : meta.function.parameters.python, meta.function.python, source.python diff --git a/test/functions/decorators1.py b/test/functions/decorators1.py index 6fc61aea..bf03fad0 100644 --- a/test/functions/decorators1.py +++ b/test/functions/decorators1.py @@ -8,25 +8,25 @@ def decorated(a): pass -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python some_decorator : entity.name.function.decorator.python, meta.function.decorator.python, source.python : meta.function.decorator.python, source.python # : comment.line.number-sign.python, punctuation.definition.comment.python, source.python with comment : comment.line.number-sign.python, source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python some : entity.name.function.decorator.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python class : keyword.control.flow.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python decorator : entity.name.function.decorator.python, meta.function.decorator.python, source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python some_decorator : entity.name.function.decorator.python, meta.function.decorator.python, source.python ( : meta.function.decorator.python, punctuation.definition.arguments.begin.python, source.python 1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function.decorator.python, source.python ) : meta.function.decorator.python, punctuation.definition.arguments.end.python, source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python some : entity.name.function.decorator.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python decorator : entity.name.function.decorator.python, meta.function.decorator.python, source.python : meta.function.decorator.python, source.python ( : meta.function.decorator.python, punctuation.definition.arguments.begin.python, source.python @@ -35,7 +35,7 @@ class : keyword.control.flow.python, meta.function.decorator.python, sou : meta.function-call.arguments.python, meta.function.decorator.python, source.python 3 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function.decorator.python, source.python ) : meta.function.decorator.python, punctuation.definition.arguments.end.python, source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python some_decorator : entity.name.function.decorator.python, meta.function.decorator.python, source.python ( : meta.function.decorator.python, punctuation.definition.arguments.begin.python, source.python a : meta.function-call.arguments.python, meta.function.decorator.python, source.python, variable.parameter.function-call.python @@ -58,7 +58,7 @@ class : keyword.control.flow.python, meta.function.decorator.python, sou ** : keyword.operator.unpacking.arguments.python, meta.function-call.arguments.python, meta.function.decorator.python, source.python kwargs : meta.function-call.arguments.python, meta.function.decorator.python, source.python ) : meta.function.decorator.python, punctuation.definition.arguments.end.python, source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python classmethod : meta.function.decorator.python, source.python, support.type.python def : meta.function.python, source.python, storage.type.function.python : meta.function.python, source.python diff --git a/test/functions/decorators2.py b/test/functions/decorators2.py index af5d7170..0b129649 100644 --- a/test/functions/decorators2.py +++ b/test/functions/decorators2.py @@ -3,19 +3,19 @@ def foo(): pass -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python : meta.function.decorator.python, source.python f : entity.name.function.decorator.python, meta.function.decorator.python, source.python : meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python : meta.function.decorator.python, source.python bar : entity.name.function.decorator.python, meta.function.decorator.python, source.python : meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python : meta.function.decorator.python, source.python a : entity.name.function.decorator.python, meta.function.decorator.python, source.python : meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python : meta.function.decorator.python, source.python b : entity.name.function.decorator.python, meta.function.decorator.python, source.python def : meta.function.python, source.python, storage.type.function.python diff --git a/test/functions/decorators3.py b/test/functions/decorators3.py index 0cfe7a4f..24e7a58f 100644 --- a/test/functions/decorators3.py +++ b/test/functions/decorators3.py @@ -3,11 +3,11 @@ def foo(): pass -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python : meta.function.decorator.python, source.python f : entity.name.function.decorator.python, meta.function.decorator.python, source.python : meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python : meta.function.decorator.python, source.python bar : entity.name.function.decorator.python, meta.function.decorator.python, source.python : meta.function.decorator.python, source.python diff --git a/test/functions/decorators4.py b/test/functions/decorators4.py index f2aab448..ba7df7bd 100644 --- a/test/functions/decorators4.py +++ b/test/functions/decorators4.py @@ -3,15 +3,15 @@ def foo(): pass -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python a : entity.name.function.decorator.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python b : entity.name.function.decorator.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python c : entity.name.function.decorator.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python None : keyword.illegal.name.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python z : entity.name.function.decorator.python, meta.function.decorator.python, source.python def : meta.function.python, source.python, storage.type.function.python : meta.function.python, source.python diff --git a/test/functions/decorators5.py b/test/functions/decorators5.py index 412747ae..436d1a4b 100644 --- a/test/functions/decorators5.py +++ b/test/functions/decorators5.py @@ -7,24 +7,24 @@ def foo(): pass -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python a : entity.name.function.decorator.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python : meta.function.decorator.python, source.python \ : meta.function.decorator.python, punctuation.separator.continuation.line.python, source.python : meta.function.decorator.python, source.python : meta.function.decorator.python, source.python b : entity.name.function.decorator.python, meta.function.decorator.python, source.python : meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python : meta.function.decorator.python, source.python \ : meta.function.decorator.python, punctuation.separator.continuation.line.python, source.python : meta.function.decorator.python, source.python : meta.function.decorator.python, source.python c : entity.name.function.decorator.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python None : keyword.illegal.name.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python z : entity.name.function.decorator.python, meta.function.decorator.python, source.python : meta.function.decorator.python, source.python \ : meta.function.decorator.python, punctuation.separator.continuation.line.python, source.python @@ -36,9 +36,9 @@ def foo(): pass = : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function.decorator.python, source.python 1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function.decorator.python, source.python ) : meta.function.decorator.python, punctuation.definition.arguments.end.python, source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python foo : entity.name.function.decorator.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python ok : entity.name.function.decorator.python, meta.function.decorator.python, source.python def : meta.function.python, source.python, storage.type.function.python : meta.function.python, source.python diff --git a/test/functions/decorators6.py b/test/functions/decorators6.py index 53264a2e..5c9b4289 100644 --- a/test/functions/decorators6.py +++ b/test/functions/decorators6.py @@ -6,21 +6,23 @@ def foo(): pass -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python + + +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python a : entity.name.function.decorator.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python : meta.function.decorator.python, source.python b : entity.name.function.decorator.python, meta.function.decorator.python, source.python : meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python : meta.function.decorator.python, source.python \ : meta.function.decorator.python, punctuation.separator.continuation.line.python, source.python : meta.function.decorator.python, source.python : meta.function.decorator.python, source.python c : entity.name.function.decorator.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python None : keyword.illegal.name.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python z : entity.name.function.decorator.python, meta.function.decorator.python, source.python ( : meta.function.decorator.python, punctuation.definition.arguments.begin.python, source.python foo : meta.function-call.arguments.python, meta.function.decorator.python, source.python, variable.parameter.function-call.python @@ -29,22 +31,22 @@ def foo(): pass ) : meta.function.decorator.python, punctuation.definition.arguments.end.python, source.python . \ : invalid.illegal.decorator.python, meta.function.decorator.python, source.python : source.python -baz : meta.item-access.python, source.python +baz : meta.indexed-name.python, meta.item-access.python, source.python [ : meta.item-access.python, punctuation.definition.arguments.begin.python, source.python 1 : constant.numeric.dec.python, meta.item-access.arguments.python, meta.item-access.python, source.python : : meta.item-access.arguments.python, meta.item-access.python, punctuation.separator.slice.python, source.python 2 : constant.numeric.dec.python, meta.item-access.arguments.python, meta.item-access.python, source.python ] : meta.item-access.python, punctuation.definition.arguments.end.python, source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python foo : entity.name.function.decorator.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python class : keyword.control.flow.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python bar : entity.name.function.decorator.python, meta.function.decorator.python, source.python [] : invalid.illegal.decorator.python, meta.function.decorator.python, source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python foo : entity.name.function.decorator.python, meta.function.decorator.python, source.python -. : entity.name.function.decorator.python, meta.function.decorator.python, source.python +. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python ok : entity.name.function.decorator.python, meta.function.decorator.python, source.python : invalid.illegal.decorator.python, meta.function.decorator.python, source.python ''' : invalid.illegal.decorator.python, meta.function.decorator.python, source.python diff --git a/test/functions/decorators7.py b/test/functions/decorators7.py index 19d3f3bd..c604f818 100644 --- a/test/functions/decorators7.py +++ b/test/functions/decorators7.py @@ -16,23 +16,23 @@ def baz(): pass this is testing trailing whitespace after the decorator : comment.line.number-sign.python, source.python # : comment.line.number-sign.python, punctuation.definition.comment.python, source.python DO NOT DELETE TRAILING WHITESTAPCE IN THIS FILE : comment.line.number-sign.python, source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python foo : entity.name.function.decorator.python, meta.function.decorator.python, source.python : meta.function.decorator.python, source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python foo : entity.name.function.decorator.python, meta.function.decorator.python, source.python ( : meta.function.decorator.python, punctuation.definition.arguments.begin.python, source.python ) : meta.function.decorator.python, punctuation.definition.arguments.end.python, source.python : source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python bar : entity.name.function.decorator.python, meta.function.decorator.python, source.python : meta.function.decorator.python, source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python bar : entity.name.function.decorator.python, meta.function.decorator.python, source.python ( : meta.function.decorator.python, punctuation.definition.arguments.begin.python, source.python ) : meta.function.decorator.python, punctuation.definition.arguments.end.python, source.python : source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python bar : entity.name.function.decorator.python, meta.function.decorator.python, source.python ( : meta.function.decorator.python, punctuation.definition.arguments.begin.python, source.python ) : meta.function.decorator.python, punctuation.definition.arguments.end.python, source.python @@ -40,7 +40,7 @@ def baz(): pass : source.python # : comment.line.number-sign.python, punctuation.definition.comment.python, source.python legal : comment.line.number-sign.python, source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python bar : entity.name.function.decorator.python, meta.function.decorator.python, source.python ( : meta.function.decorator.python, punctuation.definition.arguments.begin.python, source.python ) : meta.function.decorator.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/functions/decorators8.py b/test/functions/decorators8.py index f3898789..aeb2454e 100644 --- a/test/functions/decorators8.py +++ b/test/functions/decorators8.py @@ -3,7 +3,7 @@ def foo(): pass -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python deco : entity.name.function.decorator.python, meta.function.decorator.python, source.python ( : meta.function.decorator.python, punctuation.definition.arguments.begin.python, source.python ) : meta.function.decorator.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/functions/lambda10.py b/test/functions/lambda10.py new file mode 100644 index 00000000..c033ac71 --- /dev/null +++ b/test/functions/lambda10.py @@ -0,0 +1,35 @@ +showcase = lambda a, /, b, *, c: (a + b + c) + + + + +showcase : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +lambda : meta.lambda-function.python, source.python, storage.type.function.lambda.python + : meta.function.lambda.parameters.python, meta.lambda-function.python, source.python +a : meta.function.lambda.parameters.python, meta.lambda-function.python, source.python, variable.parameter.function.language.python +, : meta.function.lambda.parameters.python, meta.lambda-function.python, punctuation.separator.parameters.python, source.python + : meta.function.lambda.parameters.python, meta.lambda-function.python, source.python +/ : keyword.operator.positional.parameter.python, meta.function.lambda.parameters.python, meta.lambda-function.python, source.python +, : meta.function.lambda.parameters.python, meta.lambda-function.python, source.python +b : meta.function.lambda.parameters.python, meta.lambda-function.python, source.python, variable.parameter.function.language.python +, : meta.function.lambda.parameters.python, meta.lambda-function.python, punctuation.separator.parameters.python, source.python + : meta.function.lambda.parameters.python, meta.lambda-function.python, source.python +* : keyword.operator.unpacking.parameter.python, meta.function.lambda.parameters.python, meta.lambda-function.python, source.python +, : meta.function.lambda.parameters.python, meta.lambda-function.python, source.python +c : meta.function.lambda.parameters.python, meta.lambda-function.python, source.python, variable.parameter.function.language.python +: : meta.lambda-function.python, punctuation.section.function.lambda.begin.python, source.python + : source.python +( : punctuation.parenthesis.begin.python, source.python +a : source.python + : source.python ++ : keyword.operator.arithmetic.python, source.python + : source.python +b : source.python + : source.python ++ : keyword.operator.arithmetic.python, source.python + : source.python +c : source.python +) : punctuation.parenthesis.end.python, source.python diff --git a/test/illegals/backticks3.py b/test/illegals/backticks3.py index b4ae29c9..d99080e8 100644 --- a/test/illegals/backticks3.py +++ b/test/illegals/backticks3.py @@ -1,4 +1,5 @@ a = lambda `123` +# comment @@ -12,3 +13,5 @@ 123 : constant.numeric.dec.python, invalid.deprecated.backtick.python, meta.function.lambda.parameters.python, meta.lambda-function.python, source.python ` : invalid.deprecated.backtick.python, meta.function.lambda.parameters.python, meta.lambda-function.python, source.python : meta.lambda-function.python, source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + comment : comment.line.number-sign.python, source.python diff --git a/test/illegals/illegal1.py b/test/illegals/illegal1.py index 6010bc4f..5ee9654d 100644 --- a/test/illegals/illegal1.py +++ b/test/illegals/illegal1.py @@ -9,6 +9,7 @@ def f(): pass + -> : invalid.illegal.annotation.python, source.python def : meta.function.python, source.python, storage.type.function.python : meta.function.python, source.python @@ -28,13 +29,13 @@ def : meta.function.python, source.python, storage.type.function.pytho .class : source.python, string.quoted.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.single.python ) : punctuation.parenthesis.end.python, source.python -. : punctuation.separator.period.python, source.python -fuuuu : meta.function-call.generic.python, meta.function-call.python, source.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -baz : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python -= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python -1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +fuuuu : meta.function-call.generic.python, meta.function-call.python, meta.member.access.python, source.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +baz : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python # : comment.line.number-sign.python, punctuation.definition.comment.python, source.python we recover just fine : comment.line.number-sign.python, source.python b : source.python diff --git a/test/regexp/fregexp1.py b/test/regexp/fregexp1.py deleted file mode 100644 index 9e77d66b..00000000 --- a/test/regexp/fregexp1.py +++ /dev/null @@ -1,56 +0,0 @@ -a = fr'[a-z]' -a = Fr'[a-z]' -a = rf'[a-z]' -a = rF'[a-z]' - - - - -a : source.python - : source.python -= : keyword.operator.assignment.python, source.python - : source.python -fr : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -[ : constant.other.set.regexp, meta.character.set.regexp, punctuation.character.set.begin.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -a : constant.character.set.regexp, meta.character.set.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -- : constant.character.set.regexp, meta.character.set.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -z : constant.character.set.regexp, meta.character.set.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -] : constant.other.set.regexp, meta.character.set.regexp, punctuation.character.set.end.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -a : source.python - : source.python -= : keyword.operator.assignment.python, source.python - : source.python -Fr : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -[ : constant.other.set.regexp, meta.character.set.regexp, punctuation.character.set.begin.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -a : constant.character.set.regexp, meta.character.set.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -- : constant.character.set.regexp, meta.character.set.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -z : constant.character.set.regexp, meta.character.set.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -] : constant.other.set.regexp, meta.character.set.regexp, punctuation.character.set.end.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -a : source.python - : source.python -= : keyword.operator.assignment.python, source.python - : source.python -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -[ : constant.other.set.regexp, meta.character.set.regexp, punctuation.character.set.begin.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -a : constant.character.set.regexp, meta.character.set.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -- : constant.character.set.regexp, meta.character.set.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -z : constant.character.set.regexp, meta.character.set.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -] : constant.other.set.regexp, meta.character.set.regexp, punctuation.character.set.end.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -a : source.python - : source.python -= : keyword.operator.assignment.python, source.python - : source.python -rF : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -[ : constant.other.set.regexp, meta.character.set.regexp, punctuation.character.set.begin.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -a : constant.character.set.regexp, meta.character.set.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -- : constant.character.set.regexp, meta.character.set.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -z : constant.character.set.regexp, meta.character.set.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -] : constant.other.set.regexp, meta.character.set.regexp, punctuation.character.set.end.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python diff --git a/test/regexp/fregexp2.py b/test/regexp/fregexp2.py deleted file mode 100644 index 72eccc28..00000000 --- a/test/regexp/fregexp2.py +++ /dev/null @@ -1,28 +0,0 @@ -rf'fo{{2}}' -rf"fo{{2}}" -rf'''fo{{2}}''' -rf"""fo{{2}}""" - - - - -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -fo : source.python, string.interpolated.python, string.regexp.quoted.single.python -{{2}} : keyword.operator.quantifier.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -" : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -fo : source.python, string.interpolated.python, string.regexp.quoted.single.python -{{2}} : keyword.operator.quantifier.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -" : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.multi.python -''' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.multi.python -fo : source.python, string.interpolated.python, string.regexp.quoted.multi.python -{{2}} : keyword.operator.quantifier.regexp, source.python, string.interpolated.python, string.regexp.quoted.multi.python -''' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.multi.python -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.multi.python -""" : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.multi.python -fo : source.python, string.interpolated.python, string.regexp.quoted.multi.python -{{2}} : keyword.operator.quantifier.regexp, source.python, string.interpolated.python, string.regexp.quoted.multi.python -""" : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.multi.python diff --git a/test/regexp/fregexp3.py b/test/regexp/fregexp3.py deleted file mode 100644 index ede8a6c3..00000000 --- a/test/regexp/fregexp3.py +++ /dev/null @@ -1,28 +0,0 @@ -rf'fo{2}' -rf"fo{2}" -rf'''fo{2}''' -rf"""fo{2}""" - - - - -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -fo : source.python, string.interpolated.python, string.regexp.quoted.single.python -{2} : source.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -" : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -fo : source.python, string.interpolated.python, string.regexp.quoted.single.python -{2} : source.python, string.interpolated.python, string.regexp.quoted.single.python -" : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.multi.python -''' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.multi.python -fo : source.python, string.interpolated.python, string.regexp.quoted.multi.python -{2} : source.python, string.interpolated.python, string.regexp.quoted.multi.python -''' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.multi.python -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.multi.python -""" : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.multi.python -fo : source.python, string.interpolated.python, string.regexp.quoted.multi.python -{2} : source.python, string.interpolated.python, string.regexp.quoted.multi.python -""" : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.multi.python diff --git a/test/regexp/fregexp4.py b/test/regexp/fregexp4.py deleted file mode 100644 index 5b707ad3..00000000 --- a/test/regexp/fregexp4.py +++ /dev/null @@ -1,36 +0,0 @@ -a = rf'fo{{2}}' -a = r'fo{{2}}' -a = r'fo{2}' - - - - - -a : source.python - : source.python -= : keyword.operator.assignment.python, source.python - : source.python -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -fo : source.python, string.interpolated.python, string.regexp.quoted.single.python -{{2}} : keyword.operator.quantifier.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -a : source.python - : source.python -= : keyword.operator.assignment.python, source.python - : source.python -r : source.python, storage.type.string.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.regexp.quoted.single.python -fo{ : source.python, string.regexp.quoted.single.python -{2} : keyword.operator.quantifier.regexp, source.python, string.regexp.quoted.single.python -} : source.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.regexp.quoted.single.python -a : source.python - : source.python -= : keyword.operator.assignment.python, source.python - : source.python -r : source.python, storage.type.string.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.regexp.quoted.single.python -fo : source.python, string.regexp.quoted.single.python -{2} : keyword.operator.quantifier.regexp, source.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.regexp.quoted.single.python diff --git a/test/regexp/fregexp5.py b/test/regexp/fregexp5.py deleted file mode 100644 index 0d339e27..00000000 --- a/test/regexp/fregexp5.py +++ /dev/null @@ -1,26 +0,0 @@ -a = rf'{{foo}}' -a = r'\{foo\}' - - - - -a : source.python - : source.python -= : keyword.operator.assignment.python, source.python - : source.python -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -{{ : constant.character.escape.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -foo : source.python, string.interpolated.python, string.regexp.quoted.single.python -}} : constant.character.escape.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -a : source.python - : source.python -= : keyword.operator.assignment.python, source.python - : source.python -r : source.python, storage.type.string.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.regexp.quoted.single.python -\{ : constant.character.escape.regexp, source.python, string.regexp.quoted.single.python -foo : source.python, string.regexp.quoted.single.python -\} : constant.character.escape.regexp, source.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.regexp.quoted.single.python diff --git a/test/regexp/fregexp6.py b/test/regexp/fregexp6.py deleted file mode 100644 index a51311d0..00000000 --- a/test/regexp/fregexp6.py +++ /dev/null @@ -1,39 +0,0 @@ -a = rf'fo{{{2}}}' -a = rf'fo{{{bar}}}' -a = rf'fo{{2}}' - - - - - -a : source.python - : source.python -= : keyword.operator.assignment.python, source.python - : source.python -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -fo : source.python, string.interpolated.python, string.regexp.quoted.single.python -{{ : constant.character.escape.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -{2} : source.python, string.interpolated.python, string.regexp.quoted.single.python -}} : constant.character.escape.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -a : source.python - : source.python -= : keyword.operator.assignment.python, source.python - : source.python -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -fo : source.python, string.interpolated.python, string.regexp.quoted.single.python -{{ : constant.character.escape.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -{bar} : source.python, string.interpolated.python, string.regexp.quoted.single.python -}} : constant.character.escape.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -a : source.python - : source.python -= : keyword.operator.assignment.python, source.python - : source.python -rf : source.python, storage.type.string.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.regexp.quoted.single.python -fo : source.python, string.interpolated.python, string.regexp.quoted.single.python -{{2}} : keyword.operator.quantifier.regexp, source.python, string.interpolated.python, string.regexp.quoted.single.python -' : punctuation.definition.string.end.python, source.python, string.interpolated.python, string.regexp.quoted.single.python diff --git a/test/regexp/python2.py b/test/regexp/python2.py index bda2bb0b..1738c203 100644 --- a/test/regexp/python2.py +++ b/test/regexp/python2.py @@ -2,6 +2,7 @@ (?x) foo ' +# comment @@ -21,3 +22,5 @@ foo : source.python ' : punctuation.definition.string.begin.python, source.python, string.quoted.docstring.single.python : invalid.illegal.newline.python, source.python, string.quoted.docstring.single.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + comment : comment.line.number-sign.python, source.python diff --git a/test/regexp/python8.py b/test/regexp/python8.py index f0babc73..ba72a7be 100644 --- a/test/regexp/python8.py +++ b/test/regexp/python8.py @@ -22,6 +22,7 @@ + # : comment.line.number-sign.python, punctuation.definition.comment.python, source.python And now something fun! : comment.line.number-sign.python, source.python : source.python @@ -30,166 +31,166 @@ = : keyword.operator.assignment.python, source.python : source.python re : source.python -. : punctuation.separator.period.python, source.python -compile : meta.function-call.generic.python, meta.function-call.python, source.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -r : meta.function-call.arguments.python, meta.function-call.python, source.python, storage.type.string.python, string.regexp.quoted.multi.python -""" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -(?x) : meta.function-call.arguments.python, meta.function-call.python, source.python, storage.modifier.flag.regexp, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - This is a verbose pattern : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -\s : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp -* : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - Optional whitespace at start of cookie : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -( : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.parenthesis.named.begin.regexp, source.python, string.regexp.quoted.multi.python, support.other.parenthesis.regexp -?P : entity.name.tag.named.group.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - Start of group 'key' : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -[ : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.character.set.begin.regexp, source.python, string.regexp.quoted.multi.python -""" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python -+ : keyword.operator.arithmetic.python, meta.function-call.arguments.python, meta.function-call.python, source.python - : meta.function-call.arguments.python, meta.function-call.python, source.python -_LegalKeyChars : meta.function-call.arguments.python, meta.function-call.python, source.python - : meta.function-call.arguments.python, meta.function-call.python, source.python -+ : keyword.operator.arithmetic.python, meta.function-call.arguments.python, meta.function-call.python, source.python - : meta.function-call.arguments.python, meta.function-call.python, source.python -r : meta.function-call.arguments.python, meta.function-call.python, source.python, storage.type.string.python, string.regexp.quoted.multi.python -""" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.regexp.quoted.multi.python -] : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -+? : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - Any word of at least one letter : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - ) : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - End of group 'key' : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -( : meta.function-call.arguments.python, meta.function-call.python, punctuation.parenthesis.begin.regexp, source.python, string.regexp.quoted.multi.python, support.other.parenthesis.regexp - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - Optional group: there may not be a value. : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -\s : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp -* : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -= : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -\s : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp -* : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - Equal Sign : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -( : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.parenthesis.named.begin.regexp, source.python, string.regexp.quoted.multi.python, support.other.parenthesis.regexp -?P : entity.name.tag.named.group.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - Start of group 'val' : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python - " : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -(?: : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.parenthesis.non-capturing.begin.regexp, source.python, string.regexp.quoted.multi.python, support.other.parenthesis.regexp -[ : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.character.set.begin.regexp, source.python, string.regexp.quoted.multi.python -^ : keyword.operator.negation.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -\\ : constant.character.escape.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -" : constant.character.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -] : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.character.set.end.regexp, source.python, string.regexp.quoted.multi.python -| : keyword.operator.disjunction.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -\\ : constant.character.escape.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -. : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.match.any.regexp -) : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.parenthesis.non-capturing.end.regexp, source.python, string.regexp.quoted.multi.python, support.other.parenthesis.regexp -* : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -" : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - Any doublequoted string : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -| : keyword.operator.disjunction.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - or : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -\w : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp -{3} : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -, : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -\s : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp -[ : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.character.set.begin.regexp, source.python, string.regexp.quoted.multi.python -\w : meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp -\d : meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp -\s : meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp -- : constant.character.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -] : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.character.set.end.regexp, source.python, string.regexp.quoted.multi.python -{9,11} : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -\s : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp -[ : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.character.set.begin.regexp, source.python, string.regexp.quoted.multi.python -\d : meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp -: : constant.character.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -] : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.character.set.end.regexp, source.python, string.regexp.quoted.multi.python -{8} : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -\s : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp -GMT : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - Special case for "expires" attr : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -| : keyword.operator.disjunction.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - or : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python -[ : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.named.regexp, punctuation.character.set.begin.regexp, source.python, string.regexp.quoted.multi.python -""" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python -+ : keyword.operator.arithmetic.python, meta.function-call.arguments.python, meta.function-call.python, source.python - : meta.function-call.arguments.python, meta.function-call.python, source.python -_LegalValueChars : meta.function-call.arguments.python, meta.function-call.python, source.python - : meta.function-call.arguments.python, meta.function-call.python, source.python -+ : keyword.operator.arithmetic.python, meta.function-call.arguments.python, meta.function-call.python, source.python - : meta.function-call.arguments.python, meta.function-call.python, source.python -r : meta.function-call.arguments.python, meta.function-call.python, source.python, storage.type.string.python, string.regexp.quoted.multi.python -""" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.regexp.quoted.multi.python -] : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -* : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - Any word or empty string : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - ) : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - End of group 'val' : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - ) : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -? : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - End of optional value group : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -\s : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp -* : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - Any number of spaces. : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -( : meta.function-call.arguments.python, meta.function-call.python, punctuation.parenthesis.begin.regexp, source.python, string.regexp.quoted.multi.python, support.other.parenthesis.regexp -\s : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp -+ : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -| : keyword.operator.disjunction.regexp, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -; : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -| : keyword.operator.disjunction.regexp, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -$ : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python, support.other.match.end.regexp -) : meta.function-call.arguments.python, meta.function-call.python, punctuation.parenthesis.end.regexp, source.python, string.regexp.quoted.multi.python, support.other.parenthesis.regexp - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python - Ending either at space, semicolon, or EOS. : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python - : meta.function-call.arguments.python, meta.function-call.python, source.python, string.regexp.quoted.multi.python -""" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.regexp.quoted.multi.python -, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python - : meta.function-call.arguments.python, meta.function-call.python, source.python -re : meta.function-call.arguments.python, meta.function-call.python, source.python -. : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.period.python, source.python -ASCII : constant.other.caps.python, meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +compile : meta.function-call.generic.python, meta.function-call.python, meta.member.access.python, source.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +r : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, storage.type.string.python, string.regexp.quoted.multi.python +""" : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.string.begin.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +(?x) : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, storage.modifier.flag.regexp, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + This is a verbose pattern : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +\s : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp +* : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + Optional whitespace at start of cookie : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +( : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.parenthesis.named.begin.regexp, source.python, string.regexp.quoted.multi.python, support.other.parenthesis.regexp +?P : entity.name.tag.named.group.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + Start of group 'key' : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +[ : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.character.set.begin.regexp, source.python, string.regexp.quoted.multi.python +""" : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.string.end.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python ++ : keyword.operator.arithmetic.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +_LegalKeyChars : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python ++ : keyword.operator.arithmetic.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +r : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, storage.type.string.python, string.regexp.quoted.multi.python +""" : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.string.begin.python, source.python, string.regexp.quoted.multi.python +] : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python ++? : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + Any word of at least one letter : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + ) : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + End of group 'key' : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +( : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.parenthesis.begin.regexp, source.python, string.regexp.quoted.multi.python, support.other.parenthesis.regexp + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + Optional group: there may not be a value. : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +\s : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp +* : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python += : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +\s : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp +* : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + Equal Sign : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +( : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.parenthesis.named.begin.regexp, source.python, string.regexp.quoted.multi.python, support.other.parenthesis.regexp +?P : entity.name.tag.named.group.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + Start of group 'val' : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python + " : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +(?: : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.parenthesis.non-capturing.begin.regexp, source.python, string.regexp.quoted.multi.python, support.other.parenthesis.regexp +[ : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.character.set.begin.regexp, source.python, string.regexp.quoted.multi.python +^ : keyword.operator.negation.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +\\ : constant.character.escape.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +" : constant.character.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +] : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.character.set.end.regexp, source.python, string.regexp.quoted.multi.python +| : keyword.operator.disjunction.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +\\ : constant.character.escape.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +. : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.match.any.regexp +) : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.parenthesis.non-capturing.end.regexp, source.python, string.regexp.quoted.multi.python, support.other.parenthesis.regexp +* : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +" : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + Any doublequoted string : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +| : keyword.operator.disjunction.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + or : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +\w : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp +{3} : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +, : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +\s : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp +[ : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.character.set.begin.regexp, source.python, string.regexp.quoted.multi.python +\w : meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp +\d : meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp +\s : meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp +- : constant.character.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +] : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.character.set.end.regexp, source.python, string.regexp.quoted.multi.python +{9,11} : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +\s : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp +[ : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.character.set.begin.regexp, source.python, string.regexp.quoted.multi.python +\d : meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp +: : constant.character.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +] : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.character.set.end.regexp, source.python, string.regexp.quoted.multi.python +{8} : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +\s : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp +GMT : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + Special case for "expires" attr : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +| : keyword.operator.disjunction.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + or : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, source.python, string.regexp.quoted.multi.python +[ : constant.other.set.regexp, meta.character.set.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, meta.named.regexp, punctuation.character.set.begin.regexp, source.python, string.regexp.quoted.multi.python +""" : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.string.end.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python ++ : keyword.operator.arithmetic.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +_LegalValueChars : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python ++ : keyword.operator.arithmetic.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +r : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, storage.type.string.python, string.regexp.quoted.multi.python +""" : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.string.begin.python, source.python, string.regexp.quoted.multi.python +] : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +* : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + Any word or empty string : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + ) : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + End of group 'val' : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + ) : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +? : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + End of optional value group : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +\s : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp +* : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + Any number of spaces. : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +( : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.parenthesis.begin.regexp, source.python, string.regexp.quoted.multi.python, support.other.parenthesis.regexp +\s : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python, support.other.escape.special.regexp ++ : keyword.operator.quantifier.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +| : keyword.operator.disjunction.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +; : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +| : keyword.operator.disjunction.regexp, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +$ : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python, support.other.match.end.regexp +) : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.parenthesis.end.regexp, source.python, string.regexp.quoted.multi.python, support.other.parenthesis.regexp + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +# : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.comment.python, source.python, string.regexp.quoted.multi.python + Ending either at space, semicolon, or EOS. : comment.line.number-sign.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, string.regexp.quoted.multi.python +""" : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.definition.string.end.python, source.python, string.regexp.quoted.multi.python +, : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +re : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +. : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, punctuation.separator.period.python, source.python +ASCII : constant.other.caps.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python : source.python # : comment.line.number-sign.python, punctuation.definition.comment.python, source.python May be removed if safe. : comment.line.number-sign.python, source.python diff --git a/test/statements/annotation1.py b/test/statements/annotation1.py index a72bafc6..332cd26a 100644 --- a/test/statements/annotation1.py +++ b/test/statements/annotation1.py @@ -3,6 +3,7 @@ + some_number : source.python : : punctuation.separator.colon.python, source.python : source.python @@ -13,7 +14,7 @@ some_list : source.python : : punctuation.separator.colon.python, source.python : source.python -List : meta.item-access.python, source.python +List : meta.indexed-name.python, meta.item-access.python, source.python [ : meta.item-access.python, punctuation.definition.arguments.begin.python, source.python int : meta.item-access.arguments.python, meta.item-access.python, source.python, support.type.python ] : meta.item-access.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/statements/for1.py b/test/statements/for1.py index 3300f8cb..b379ef19 100644 --- a/test/statements/for1.py +++ b/test/statements/for1.py @@ -15,7 +15,7 @@ : source.python c : source.python : source.python -in : keyword.operator.logical.python, source.python +in : keyword.control.flow.python, source.python : source.python b : source.python : : punctuation.separator.colon.python, source.python diff --git a/test/statements/for2.py b/test/statements/for2.py new file mode 100644 index 00000000..8468e08e --- /dev/null +++ b/test/statements/for2.py @@ -0,0 +1,44 @@ +forvariable = None +for a, b, c, invariable in [2 in q, 2 in w]: + pass + + + + +forvariable : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +None : constant.language.python, source.python +for : keyword.control.flow.python, source.python + : source.python +a : source.python +, : punctuation.separator.element.python, source.python + : source.python +b : source.python +, : punctuation.separator.element.python, source.python + : source.python +c : source.python +, : punctuation.separator.element.python, source.python + : source.python +invariable : source.python + : source.python +in : keyword.control.flow.python, source.python + : source.python +[ : punctuation.definition.list.begin.python, source.python +2 : constant.numeric.dec.python, source.python + : source.python +in : keyword.operator.logical.python, source.python + : source.python +q : source.python +, : punctuation.separator.element.python, source.python + : source.python +2 : constant.numeric.dec.python, source.python + : source.python +in : keyword.operator.logical.python, source.python + : source.python +w : source.python +] : punctuation.definition.list.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +pass : keyword.control.flow.python, source.python diff --git a/test/statements/for3.py b/test/statements/for3.py new file mode 100644 index 00000000..5ebfc592 --- /dev/null +++ b/test/statements/for3.py @@ -0,0 +1,38 @@ +for(a, b), c, invariable in[2 in q, 2 in w]: + pass + + + + +for : keyword.control.flow.python, source.python +( : punctuation.parenthesis.begin.python, source.python +a : source.python +, : punctuation.separator.element.python, source.python + : source.python +b : source.python +) : punctuation.parenthesis.end.python, source.python +, : punctuation.separator.element.python, source.python + : source.python +c : source.python +, : punctuation.separator.element.python, source.python + : source.python +invariable : source.python + : source.python +in : keyword.control.flow.python, source.python +[ : punctuation.definition.list.begin.python, source.python +2 : constant.numeric.dec.python, source.python + : source.python +in : keyword.operator.logical.python, source.python + : source.python +q : source.python +, : punctuation.separator.element.python, source.python + : source.python +2 : constant.numeric.dec.python, source.python + : source.python +in : keyword.operator.logical.python, source.python + : source.python +w : source.python +] : punctuation.definition.list.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +pass : keyword.control.flow.python, source.python diff --git a/test/statements/from1.py b/test/statements/from1.py new file mode 100644 index 00000000..99d3a670 --- /dev/null +++ b/test/statements/from1.py @@ -0,0 +1,33 @@ +from ... import foo as bar +raise Exception('done') from exc +yield from foo + + + + +from : keyword.control.import.python, source.python + : source.python +... : punctuation.separator.period.python, source.python + : source.python +import : keyword.control.import.python, source.python + : source.python +foo : source.python + : source.python +as : keyword.control.import.python, source.python + : source.python +bar : source.python +raise : keyword.control.flow.python, source.python + : source.python +Exception : meta.function-call.python, source.python, support.type.exception.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +' : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.quoted.single.python +done : meta.function-call.arguments.python, meta.function-call.python, source.python, string.quoted.single.python +' : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.quoted.single.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python + : source.python +from : keyword.control.flow.python, source.python + : source.python +exc : source.python +yield from : keyword.control.flow.python, source.python + : source.python +foo : source.python diff --git a/test/statements/import1.py b/test/statements/import1.py index f41b72c5..6faca8b3 100644 --- a/test/statements/import1.py +++ b/test/statements/import1.py @@ -12,7 +12,7 @@ : source.python bar : source.python : source.python -as : keyword.control.flow.python, source.python +as : keyword.control.import.python, source.python : source.python spam : source.python , : punctuation.separator.element.python, source.python @@ -22,7 +22,7 @@ : source.python time : source.python : source.python -as : keyword.control.flow.python, source.python +as : keyword.control.import.python, source.python : source.python ham : source.python , : punctuation.separator.element.python, source.python diff --git a/test/statements/import5.py b/test/statements/import5.py index 2df920d6..6050a777 100644 --- a/test/statements/import5.py +++ b/test/statements/import5.py @@ -10,6 +10,7 @@ def bar(): + from : keyword.control.import.python, source.python . : punctuation.separator.period.python, source.python foo : source.python @@ -24,8 +25,8 @@ def bar(): a : source.python : source.python foo : source.python -. : punctuation.separator.period.python, source.python -import : keyword.control.flow.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +import : keyword.control.import.python, meta.member.access.python, source.python : source.python raise : keyword.control.flow.python, source.python : source.python diff --git a/test/statements/import6.py b/test/statements/import6.py index 18bacd0e..a39a790e 100644 --- a/test/statements/import6.py +++ b/test/statements/import6.py @@ -2,7 +2,7 @@ -from : keyword.control.flow.python, source.python +from : keyword.control.import.python, source.python : source.python __future__ : source.python, support.variable.magic.python : source.python diff --git a/test/statements/import7.py b/test/statements/import7.py new file mode 100644 index 00000000..7951802b --- /dev/null +++ b/test/statements/import7.py @@ -0,0 +1,20 @@ +from .importing import * +from importing import * + + + +from : keyword.control.import.python, source.python + : source.python +. : punctuation.separator.period.python, source.python +importing : source.python + : source.python +import : keyword.control.import.python, source.python + : source.python +* : keyword.operator.arithmetic.python, source.python +from : keyword.control.import.python, source.python + : source.python +importing : source.python + : source.python +import : keyword.control.import.python, source.python + : source.python +* : keyword.operator.arithmetic.python, source.python diff --git a/test/statements/import8.py b/test/statements/import8.py new file mode 100644 index 00000000..1d49bbd1 --- /dev/null +++ b/test/statements/import8.py @@ -0,0 +1,48 @@ +try: + import \ + time as ham, \ + datetime \ + # XXX: comment at the end of import +except Exception as exc: + pass + + + + +try : keyword.control.flow.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +import : keyword.control.import.python, source.python + : source.python +\ : punctuation.separator.continuation.line.python, source.python + : source.python + : source.python +time : source.python + : source.python +as : keyword.control.import.python, source.python + : source.python +ham : source.python +, : punctuation.separator.element.python, source.python + : source.python +\ : punctuation.separator.continuation.line.python, source.python + : source.python + : source.python +datetime : source.python + : source.python +\ : punctuation.separator.continuation.line.python, source.python + : source.python + : source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + : comment.line.number-sign.python, source.python +XXX : comment.line.number-sign.python, keyword.codetag.notation.python, source.python +: comment at the end of import : comment.line.number-sign.python, source.python +except : keyword.control.flow.python, source.python + : source.python +Exception : source.python, support.type.exception.python + : source.python +as : keyword.control.flow.python, source.python + : source.python +exc : source.python +: : punctuation.separator.colon.python, source.python + : source.python +pass : keyword.control.flow.python, source.python diff --git a/test/statements/import9.py b/test/statements/import9.py new file mode 100644 index 00000000..2fa6bfac --- /dev/null +++ b/test/statements/import9.py @@ -0,0 +1,67 @@ +from . . . foo import \ + ( + # XXX: legal comment inside import + time as bar, + # another comment + baz, + datetime as ham + ) +raise Exception('!') from None + + + + +from : keyword.control.import.python, source.python + : source.python +. : punctuation.separator.period.python, source.python + : source.python +. : punctuation.separator.period.python, source.python + : source.python +. : punctuation.separator.period.python, source.python + : source.python +foo : source.python + : source.python +import : keyword.control.import.python, source.python + : source.python +\ : punctuation.separator.continuation.line.python, source.python + : source.python + : source.python +( : punctuation.parenthesis.begin.python, source.python + : source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + : comment.line.number-sign.python, source.python +XXX : comment.line.number-sign.python, keyword.codetag.notation.python, source.python +: legal comment inside import : comment.line.number-sign.python, source.python + : source.python +time : source.python + : source.python +as : keyword.control.import.python, source.python + : source.python +bar : source.python +, : punctuation.separator.element.python, source.python + : source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + another comment : comment.line.number-sign.python, source.python + : source.python +baz : source.python +, : punctuation.separator.element.python, source.python + : source.python +datetime : source.python + : source.python +as : keyword.control.import.python, source.python + : source.python +ham : source.python + : source.python +) : punctuation.parenthesis.end.python, source.python +raise : keyword.control.flow.python, source.python + : source.python +Exception : meta.function-call.python, source.python, support.type.exception.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +' : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.quoted.single.python +! : meta.function-call.arguments.python, meta.function-call.python, source.python, string.quoted.single.python +' : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.quoted.single.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python + : source.python +from : keyword.control.flow.python, source.python + : source.python +None : constant.language.python, source.python diff --git a/test/statements/match1.py b/test/statements/match1.py new file mode 100644 index 00000000..f393066a --- /dev/null +++ b/test/statements/match1.py @@ -0,0 +1,61 @@ +def foo(status): + match status: + case 404: + return "Not found" + case 401 | 403: + return "Not allowed" + case _: + return "Something's wrong with the internet" + + + + +def : meta.function.python, source.python, storage.type.function.python + : meta.function.python, source.python +foo : entity.name.function.python, meta.function.python, source.python +( : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.begin.python, source.python +status : meta.function.parameters.python, meta.function.python, source.python, variable.parameter.function.language.python +) : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.end.python, source.python +: : meta.function.python, punctuation.section.function.begin.python, source.python + : source.python +match : keyword.control.flow.python, source.python + : source.python +status : source.python +: : punctuation.separator.colon.python, source.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +404 : constant.numeric.dec.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +return : keyword.control.flow.python, source.python + : source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +Not found : source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +401 : constant.numeric.dec.python, source.python + : source.python +| : keyword.operator.bitwise.python, source.python + : source.python +403 : constant.numeric.dec.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +return : keyword.control.flow.python, source.python + : source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +Not allowed : source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +_ : source.python +: : punctuation.separator.colon.python, source.python + : source.python +return : keyword.control.flow.python, source.python + : source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +Something's wrong with the internet : source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python diff --git a/test/statements/match2.py b/test/statements/match2.py new file mode 100644 index 00000000..a88ba055 --- /dev/null +++ b/test/statements/match2.py @@ -0,0 +1,112 @@ +match point: + case Point(x=0, y=0): + print("Origin is the point's location.") + case Point(x=0, y=y): + print(f"The point is on the y-axis.") + case Point(x=x, y=0): + print(f"The point is on the x-axis.") + case Point(): + print("The point is located somewhere else on the plane.") + case _: + print("Not a point") + + + +match : keyword.control.flow.python, source.python + : source.python +point : source.python +: : punctuation.separator.colon.python, source.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +Point : meta.function-call.generic.python, meta.function-call.python, source.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +x : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python +0 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python +, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +y : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python +0 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +print : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.quoted.single.python +Origin is the point's location. : meta.function-call.arguments.python, meta.function-call.python, source.python, string.quoted.single.python +" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.quoted.single.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +Point : meta.function-call.generic.python, meta.function-call.python, source.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +x : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python +0 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python +, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +y : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python +y : meta.function-call.arguments.python, meta.function-call.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +print : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +f : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.single.python +" : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.quoted.single.python +The point is on the y-axis. : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.interpolated.python, string.quoted.single.python +" : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.single.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +Point : meta.function-call.generic.python, meta.function-call.python, source.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +x : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python +x : meta.function-call.arguments.python, meta.function-call.python, source.python +, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +y : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python +0 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +print : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +f : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.single.python +" : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.quoted.single.python +The point is on the x-axis. : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.interpolated.python, string.quoted.single.python +" : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.single.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +Point : meta.function-call.generic.python, meta.function-call.python, source.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +print : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.quoted.single.python +The point is located somewhere else on the plane. : meta.function-call.arguments.python, meta.function-call.python, source.python, string.quoted.single.python +" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.quoted.single.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +_ : source.python +: : punctuation.separator.colon.python, source.python + : source.python +print : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.quoted.single.python +Not a point : meta.function-call.arguments.python, meta.function-call.python, source.python, string.quoted.single.python +" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.quoted.single.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/statements/match3.py b/test/statements/match3.py new file mode 100644 index 00000000..ac8e176c --- /dev/null +++ b/test/statements/match3.py @@ -0,0 +1,114 @@ +match points: + case []: + print("No points in the list.") + case [Point(0, 0)]: + print("The origin is the only point in the list.") + case [Point(x, y)]: + print(f"A single point is in the list.") + case [Point(0, y1), Point(0, y2)]: + print(f"Two points on the Y axis are in the list.") + case _: + print("Something else is found in the list.") + + + +match : keyword.control.flow.python, source.python + : source.python +points : source.python +: : punctuation.separator.colon.python, source.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +[ : punctuation.definition.list.begin.python, source.python +] : punctuation.definition.list.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +print : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.quoted.single.python +No points in the list. : meta.function-call.arguments.python, meta.function-call.python, source.python, string.quoted.single.python +" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.quoted.single.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +[ : punctuation.definition.list.begin.python, source.python +Point : meta.function-call.generic.python, meta.function-call.python, source.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +0 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python +, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +0 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +] : punctuation.definition.list.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +print : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.quoted.single.python +The origin is the only point in the list. : meta.function-call.arguments.python, meta.function-call.python, source.python, string.quoted.single.python +" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.quoted.single.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +[ : punctuation.definition.list.begin.python, source.python +Point : meta.function-call.generic.python, meta.function-call.python, source.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +x : meta.function-call.arguments.python, meta.function-call.python, source.python +, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +y : meta.function-call.arguments.python, meta.function-call.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +] : punctuation.definition.list.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +print : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +f : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.single.python +" : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.quoted.single.python +A single point is in the list. : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.interpolated.python, string.quoted.single.python +" : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.single.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +[ : punctuation.definition.list.begin.python, source.python +Point : meta.function-call.generic.python, meta.function-call.python, source.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +0 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python +, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +y1 : meta.function-call.arguments.python, meta.function-call.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +, : punctuation.separator.element.python, source.python + : source.python +Point : meta.function-call.generic.python, meta.function-call.python, source.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +0 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python +, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +y2 : meta.function-call.arguments.python, meta.function-call.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +] : punctuation.definition.list.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +print : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +f : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.single.python +" : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.quoted.single.python +Two points on the Y axis are in the list. : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.interpolated.python, string.quoted.single.python +" : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.single.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +_ : source.python +: : punctuation.separator.colon.python, source.python + : source.python +print : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.quoted.single.python +Something else is found in the list. : meta.function-call.arguments.python, meta.function-call.python, source.python, string.quoted.single.python +" : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.quoted.single.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/statements/match4.py b/test/statements/match4.py new file mode 100644 index 00000000..fc4857f5 --- /dev/null +++ b/test/statements/match4.py @@ -0,0 +1,59 @@ +match point: + case Point(x, y) if x == y: + print(f"The point is located on the diagonal Y=X.") + case Point(x, y): + print(f"Point is not on the diagonal.") + + + + +match : keyword.control.flow.python, source.python + : source.python +point : source.python +: : punctuation.separator.colon.python, source.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +Point : meta.function-call.generic.python, meta.function-call.python, source.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +x : meta.function-call.arguments.python, meta.function-call.python, source.python +, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +y : meta.function-call.arguments.python, meta.function-call.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python + : source.python +if : keyword.control.flow.python, source.python + : source.python +x : source.python + : source.python +== : keyword.operator.comparison.python, source.python + : source.python +y : source.python +: : punctuation.separator.colon.python, source.python + : source.python +print : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +f : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.single.python +" : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.quoted.single.python +The point is located on the diagonal Y=X. : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.interpolated.python, string.quoted.single.python +" : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.single.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +Point : meta.function-call.generic.python, meta.function-call.python, source.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +x : meta.function-call.arguments.python, meta.function-call.python, source.python +, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python + : meta.function-call.arguments.python, meta.function-call.python, source.python +y : meta.function-call.arguments.python, meta.function-call.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +print : meta.function-call.python, source.python, support.function.builtin.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +f : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.single.python +" : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.quoted.single.python +Point is not on the diagonal. : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, source.python, string.interpolated.python, string.quoted.single.python +" : meta.fstring.python, meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.single.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/statements/match5.py b/test/statements/match5.py new file mode 100644 index 00000000..905ef8ba --- /dev/null +++ b/test/statements/match5.py @@ -0,0 +1,112 @@ +match command.split() if command else ['default']: + ... # Other cases + case ["north"] | ["go", "north"]: + ... # handle case + case ["get", obj] | ["pick", "up", *other] | ["pick", obj, "up"]: + ... # handle case + + + + +match : keyword.control.flow.python, source.python + : source.python +command : source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +split : meta.function-call.generic.python, meta.function-call.python, meta.member.access.python, source.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python + : source.python +if : keyword.control.flow.python, source.python + : source.python +command : source.python + : source.python +else : keyword.control.flow.python, source.python + : source.python +[ : punctuation.definition.list.begin.python, source.python +' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +default : source.python, string.quoted.single.python +' : punctuation.definition.string.end.python, source.python, string.quoted.single.python +] : punctuation.definition.list.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +... : constant.other.ellipsis.python, source.python + : source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + Other cases : comment.line.number-sign.python, source.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +[ : punctuation.definition.list.begin.python, source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +north : source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python +] : punctuation.definition.list.end.python, source.python + : source.python +| : keyword.operator.bitwise.python, source.python + : source.python +[ : punctuation.definition.list.begin.python, source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +go : source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python +, : punctuation.separator.element.python, source.python + : source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +north : source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python +] : punctuation.definition.list.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +... : constant.other.ellipsis.python, source.python + : source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + handle case : comment.line.number-sign.python, source.python + : source.python +case : keyword.control.flow.python, source.python + : source.python +[ : punctuation.definition.list.begin.python, source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +get : source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python +, : punctuation.separator.element.python, source.python + : source.python +obj : source.python +] : punctuation.definition.list.end.python, source.python + : source.python +| : keyword.operator.bitwise.python, source.python + : source.python +[ : punctuation.definition.list.begin.python, source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +pick : source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python +, : punctuation.separator.element.python, source.python + : source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +up : source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python +, : punctuation.separator.element.python, source.python + : source.python +* : keyword.operator.arithmetic.python, source.python +other : source.python +] : punctuation.definition.list.end.python, source.python + : source.python +| : keyword.operator.bitwise.python, source.python + : source.python +[ : punctuation.definition.list.begin.python, source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +pick : source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python +, : punctuation.separator.element.python, source.python + : source.python +obj : source.python +, : punctuation.separator.element.python, source.python + : source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +up : source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python +] : punctuation.definition.list.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +... : constant.other.ellipsis.python, source.python + : source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + handle case : comment.line.number-sign.python, source.python diff --git a/test/statements/match6.py b/test/statements/match6.py new file mode 100644 index 00000000..b74491f7 --- /dev/null +++ b/test/statements/match6.py @@ -0,0 +1,53 @@ +match (foo + bar): + ... # cases +match [foo, bar]: + ... # cases +match {foo, bar}: + ... # cases + + + + +match : keyword.control.flow.python, source.python + : source.python +( : punctuation.parenthesis.begin.python, source.python +foo : source.python + : source.python ++ : keyword.operator.arithmetic.python, source.python + : source.python +bar : source.python +) : punctuation.parenthesis.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +... : constant.other.ellipsis.python, source.python + : source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + cases : comment.line.number-sign.python, source.python +match : keyword.control.flow.python, source.python + : source.python +[ : punctuation.definition.list.begin.python, source.python +foo : source.python +, : punctuation.separator.element.python, source.python + : source.python +bar : source.python +] : punctuation.definition.list.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +... : constant.other.ellipsis.python, source.python + : source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + cases : comment.line.number-sign.python, source.python +match : keyword.control.flow.python, source.python + : source.python +{ : punctuation.definition.dict.begin.python, source.python +foo : source.python +, : punctuation.separator.element.python, source.python + : source.python +bar : source.python +} : punctuation.definition.dict.end.python, source.python +: : punctuation.separator.colon.python, source.python + : source.python +... : constant.other.ellipsis.python, source.python + : source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + cases : comment.line.number-sign.python, source.python \ No newline at end of file diff --git a/test/statements/match7.py b/test/statements/match7.py new file mode 100644 index 00000000..878fa813 --- /dev/null +++ b/test/statements/match7.py @@ -0,0 +1,97 @@ +match 'prefix' + foo: + ... # cases +match "prefix" + foo: + ... # cases +match f'prefix{foo}': + ... # cases +match f"prefix{foo}": + ... # cases +match -foo: + ... # cases +match not foo: + ... # cases + + + + +match : keyword.control.flow.python, source.python + : source.python +' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +prefix : source.python, string.quoted.single.python +' : punctuation.definition.string.end.python, source.python, string.quoted.single.python + : source.python ++ : keyword.operator.arithmetic.python, source.python + : source.python +foo : source.python +: : punctuation.separator.colon.python, source.python + : source.python +... : constant.other.ellipsis.python, source.python + : source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + cases : comment.line.number-sign.python, source.python +match : keyword.control.flow.python, source.python + : source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +prefix : source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python + : source.python ++ : keyword.operator.arithmetic.python, source.python + : source.python +foo : source.python +: : punctuation.separator.colon.python, source.python + : source.python +... : constant.other.ellipsis.python, source.python + : source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + cases : comment.line.number-sign.python, source.python +match : keyword.control.flow.python, source.python + : source.python +f : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.single.python +' : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.quoted.single.python +prefix : meta.fstring.python, source.python, string.interpolated.python, string.quoted.single.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +foo : meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +' : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.single.python +: : punctuation.separator.colon.python, source.python + : source.python +... : constant.other.ellipsis.python, source.python + : source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + cases : comment.line.number-sign.python, source.python +match : keyword.control.flow.python, source.python + : source.python +f : meta.fstring.python, source.python, storage.type.string.python, string.interpolated.python, string.quoted.single.python +" : meta.fstring.python, punctuation.definition.string.begin.python, source.python, string.interpolated.python, string.quoted.single.python +prefix : meta.fstring.python, source.python, string.interpolated.python, string.quoted.single.python +{ : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +foo : meta.fstring.python, source.python +} : constant.character.format.placeholder.other.python, meta.fstring.python, source.python +" : meta.fstring.python, punctuation.definition.string.end.python, source.python, string.interpolated.python, string.quoted.single.python +: : punctuation.separator.colon.python, source.python + : source.python +... : constant.other.ellipsis.python, source.python + : source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + cases : comment.line.number-sign.python, source.python +match : keyword.control.flow.python, source.python + : source.python +- : keyword.operator.arithmetic.python, source.python +foo : source.python +: : punctuation.separator.colon.python, source.python + : source.python +... : constant.other.ellipsis.python, source.python + : source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + cases : comment.line.number-sign.python, source.python +match : keyword.control.flow.python, source.python + : source.python +not : keyword.operator.logical.python, source.python + : source.python +foo : source.python +: : punctuation.separator.colon.python, source.python + : source.python +... : constant.other.ellipsis.python, source.python + : source.python +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + cases : comment.line.number-sign.python, source.python \ No newline at end of file diff --git a/test/strings/bug1.py b/test/strings/bug1.py new file mode 100644 index 00000000..eeb0f950 --- /dev/null +++ b/test/strings/bug1.py @@ -0,0 +1,47 @@ +# issue 150 +record = { + "a": {k: str(v) for k, v in foo if ""} +} + + + + +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + issue 150 : comment.line.number-sign.python, source.python +record : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +{ : punctuation.definition.dict.begin.python, source.python + : source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +a : source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python +: : punctuation.separator.dict.python, source.python + : source.python +{ : punctuation.definition.dict.begin.python, source.python +k : source.python +: : punctuation.separator.dict.python, source.python + : source.python +str : meta.function-call.python, source.python, support.type.python +( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python +v : meta.function-call.arguments.python, meta.function-call.python, source.python +) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python + : source.python +for : keyword.control.flow.python, source.python + : source.python +k : source.python +, : punctuation.separator.element.python, source.python + : source.python +v : source.python + : source.python +in : keyword.control.flow.python, source.python + : source.python +foo : source.python + : source.python +if : keyword.control.flow.python, source.python + : source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python +} : punctuation.definition.dict.end.python, source.python +} : punctuation.definition.dict.end.python, source.python diff --git a/test/strings/bug2.py b/test/strings/bug2.py new file mode 100644 index 00000000..3f4622e8 --- /dev/null +++ b/test/strings/bug2.py @@ -0,0 +1,35 @@ +# issue 150 +cmd = "git-clang-format --style=\"{{BasedOnStyle: Google, ColumnLimit: 100, IndentWidth: 2, " \ + "AlignConsecutiveAssignments: true}}\" {COMMIT_SHA} -- ./**/*.proto > {OUTPUT}".format( + + + + +# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python + issue 150 : comment.line.number-sign.python, source.python +cmd : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +git-clang-format --style= : source.python, string.quoted.single.python +\" : constant.character.escape.python, source.python, string.quoted.single.python +{{ : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python +BasedOnStyle: Google, ColumnLimit: 100, IndentWidth: 2, : source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python + : source.python +\ : punctuation.separator.continuation.line.python, source.python + : source.python + : source.python +" : punctuation.definition.string.begin.python, source.python, string.quoted.single.python +AlignConsecutiveAssignments: true : source.python, string.quoted.single.python +}} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python +\" : constant.character.escape.python, source.python, string.quoted.single.python + : source.python, string.quoted.single.python +{COMMIT_SHA} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python + -- ./**/*.proto > : source.python, string.quoted.single.python +{OUTPUT} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python +" : punctuation.definition.string.end.python, source.python, string.quoted.single.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +format : meta.function-call.generic.python, meta.function-call.python, meta.member.access.python, source.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python diff --git a/test/strings/bytes2.py b/test/strings/bytes2.py index 22df557e..7aefd973 100644 --- a/test/strings/bytes2.py +++ b/test/strings/bytes2.py @@ -8,7 +8,8 @@ -a : meta.item-access.python, source.python + +a : meta.indexed-name.python, meta.item-access.python, source.python [ : meta.item-access.python, punctuation.definition.arguments.begin.python, source.python 1 : constant.numeric.dec.python, meta.item-access.arguments.python, meta.item-access.python, source.python ] : meta.item-access.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/strings/format1.py b/test/strings/format1.py index b9b8e6e0..55327cae 100644 --- a/test/strings/format1.py +++ b/test/strings/format1.py @@ -9,29 +9,28 @@ = : keyword.operator.assignment.python, source.python : source.python " : punctuation.definition.string.begin.python, source.python, string.quoted.single.python -{0[ ] : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -:X>+10d : constant.character.format.placeholder.other.python, source.python, storage.type.format.python, string.quoted.single.python -} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +{0[ ] : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python +:X>+10d : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, storage.type.format.python, string.quoted.single.python +} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python " : punctuation.definition.string.end.python, source.python, string.quoted.single.python a : source.python : source.python = : keyword.operator.assignment.python, source.python : source.python " : punctuation.definition.string.begin.python, source.python, string.quoted.single.python -{0[ ] : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -!s : constant.character.format.placeholder.other.python, source.python, storage.type.format.python, string.quoted.single.python -:X>+10d : constant.character.format.placeholder.other.python, source.python, storage.type.format.python, string.quoted.single.python -} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +{0[ ] : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python +!s : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, storage.type.format.python, string.quoted.single.python +:X>+10d : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, storage.type.format.python, string.quoted.single.python +} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python " : punctuation.definition.string.end.python, source.python, string.quoted.single.python a : source.python : source.python = : keyword.operator.assignment.python, source.python : source.python " : punctuation.definition.string.begin.python, source.python, string.quoted.single.python -{0[ ] : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -: : constant.character.format.placeholder.other.python, source.python, storage.type.format.python, string.quoted.single.python -Xd>+10d : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +{0[ ] : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python +: : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, storage.type.format.python, string.quoted.single.python +Xd>+10d} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python " : punctuation.definition.string.end.python, source.python, string.quoted.single.python : source.python # : comment.line.number-sign.python, punctuation.definition.comment.python, source.python diff --git a/test/strings/format10.py b/test/strings/format10.py index 01f848f6..3cd456f7 100644 --- a/test/strings/format10.py +++ b/test/strings/format10.py @@ -11,15 +11,15 @@ : source.python ''' : punctuation.definition.string.begin.python, source.python, string.quoted.multi.python blah {foo-bar : source.python, string.quoted.multi.python -%d : constant.character.format.placeholder.other.python, source.python, string.quoted.multi.python +%d : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.multi.python blah : source.python, string.quoted.multi.python {foo-bar : source.python, string.quoted.multi.python -%d : constant.character.format.placeholder.other.python, source.python, string.quoted.multi.python +%d : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.multi.python } : source.python, string.quoted.multi.python blah {foo-bar : source.python, string.quoted.multi.python -%d : constant.character.format.placeholder.other.python, source.python, string.quoted.multi.python +%d : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.multi.python //insane {}} : source.python, string.quoted.multi.python {}blah {foo-bar : source.python, string.quoted.multi.python -%d : constant.character.format.placeholder.other.python, source.python, string.quoted.multi.python +%d : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.multi.python //insane {}} : source.python, string.quoted.multi.python ''' : punctuation.definition.string.end.python, source.python, string.quoted.multi.python diff --git a/test/strings/format11.py b/test/strings/format11.py index c16d3fbf..358bb9f7 100644 --- a/test/strings/format11.py +++ b/test/strings/format11.py @@ -11,9 +11,9 @@ R : source.python, storage.type.string.python, string.quoted.raw.multi.python ''' : punctuation.definition.string.begin.python, source.python, string.quoted.raw.multi.python \fr : source.python, string.quoted.raw.multi.python -{still_ok} : constant.character.format.placeholder.other.python, source.python, string.quoted.raw.multi.python +{still_ok} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.raw.multi.python ac : source.python, string.quoted.raw.multi.python {m_{j \rightarrow i}(\mathrm{good})} : source.python, string.quoted.raw.multi.python {not_ok} : source.python, string.quoted.raw.multi.python -%d : constant.character.format.placeholder.other.python, source.python, string.quoted.raw.multi.python +%d : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.raw.multi.python ''' : punctuation.definition.string.end.python, source.python, string.quoted.raw.multi.python diff --git a/test/strings/format12.py b/test/strings/format12.py index 6b9fd6fc..e370a39d 100644 --- a/test/strings/format12.py +++ b/test/strings/format12.py @@ -10,8 +10,8 @@ ' : punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python $\frac : source.python, string.quoted.raw.single.python {m_{j \ : source.python, string.quoted.raw.single.python -%s : constant.character.format.placeholder.other.python, source.python, string.quoted.raw.single.python +%s : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.raw.single.python rightarrow i}(\mathrm{ : source.python, string.quoted.raw.single.python -%s : constant.character.format.placeholder.other.python, source.python, string.quoted.raw.single.python +%s : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.raw.single.python good})}{\su%m{m_{j \rightarrow i}}}$ : source.python, string.quoted.raw.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.raw.single.python diff --git a/test/strings/format15.py b/test/strings/format15.py index b1f7ddfe..68743f4d 100644 --- a/test/strings/format15.py +++ b/test/strings/format15.py @@ -11,9 +11,9 @@ = : keyword.operator.assignment.python, source.python : source.python ''' : punctuation.definition.string.begin.python, source.python, string.quoted.multi.python -{{ : constant.character.format.placeholder.other.python, source.python, string.quoted.multi.python +{{ : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.multi.python before detection : source.python, string.quoted.multi.python -}} : constant.character.format.placeholder.other.python, source.python, string.quoted.multi.python +}} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.multi.python {# jinja comment #} : source.python, string.quoted.multi.python {{ after detection }} : source.python, string.quoted.multi.python ''' : punctuation.definition.string.end.python, source.python, string.quoted.multi.python diff --git a/test/strings/format16.py b/test/strings/format16.py new file mode 100644 index 00000000..9b81ed31 --- /dev/null +++ b/test/strings/format16.py @@ -0,0 +1,19 @@ +a = b'%b' % b'foo' + + + +a : source.python + : source.python += : keyword.operator.assignment.python, source.python + : source.python +b : source.python, storage.type.string.python, string.quoted.binary.single.python +' : punctuation.definition.string.begin.python, source.python, string.quoted.binary.single.python +%b : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.binary.single.python +' : punctuation.definition.string.end.python, source.python, string.quoted.binary.single.python + : source.python +% : keyword.operator.arithmetic.python, source.python + : source.python +b : source.python, storage.type.string.python, string.quoted.binary.single.python +' : punctuation.definition.string.begin.python, source.python, string.quoted.binary.single.python +foo : source.python, string.quoted.binary.single.python +' : punctuation.definition.string.end.python, source.python, string.quoted.binary.single.python diff --git a/test/strings/format2.py b/test/strings/format2.py index 41c1baed..d6079535 100644 --- a/test/strings/format2.py +++ b/test/strings/format2.py @@ -2,28 +2,29 @@ + a : source.python : source.python = : keyword.operator.assignment.python, source.python : source.python " : punctuation.definition.string.begin.python, source.python, string.quoted.single.python normal : source.python, string.quoted.single.python -{{ : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +{{ : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python normal : source.python, string.quoted.single.python -}} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +}} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python normal : source.python, string.quoted.single.python -{10 : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -!r : constant.character.format.placeholder.other.python, source.python, storage.type.format.python, string.quoted.single.python -} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +{10 : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python +!r : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, storage.type.format.python, string.quoted.single.python +} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python normal : source.python, string.quoted.single.python -{fo.__add__ : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -!s : constant.character.format.placeholder.other.python, source.python, storage.type.format.python, string.quoted.single.python -} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +{fo.__add__ : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python +!s : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, storage.type.format.python, string.quoted.single.python +} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python " : punctuation.definition.string.end.python, source.python, string.quoted.single.python -. : punctuation.separator.period.python, source.python -format : meta.function-call.generic.python, meta.function-call.python, source.python -( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python -fo : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python -= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python -1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python -) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python +. : meta.member.access.python, punctuation.separator.period.python, source.python +format : meta.function-call.generic.python, meta.function-call.python, meta.member.access.python, source.python +( : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.begin.python, source.python +fo : meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python, variable.parameter.function-call.python += : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, meta.member.access.python, source.python +) : meta.function-call.python, meta.member.access.python, punctuation.definition.arguments.end.python, source.python diff --git a/test/strings/format3.py b/test/strings/format3.py index b699bdff..2a63d31a 100644 --- a/test/strings/format3.py +++ b/test/strings/format3.py @@ -10,7 +10,7 @@ = : keyword.operator.assignment.python, source.python : source.python ' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python -%i : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +%i : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.single.python : source.python % : keyword.operator.arithmetic.python, source.python @@ -21,9 +21,9 @@ = : keyword.operator.assignment.python, source.python : source.python " : punctuation.definition.string.begin.python, source.python, string.quoted.single.python -%(language)s : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +%(language)s : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.single.python has : source.python, string.quoted.single.python -%(number)03d : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +%(number)03d : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.single.python quote types. : source.python, string.quoted.single.python " : punctuation.definition.string.end.python, source.python, string.quoted.single.python a : source.python @@ -32,9 +32,9 @@ : source.python b : source.python, storage.type.string.python, string.quoted.binary.single.python " : punctuation.definition.string.begin.python, source.python, string.quoted.binary.single.python -%(language)s : constant.character.format.placeholder.other.python, source.python, string.quoted.binary.single.python +%(language)s : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.binary.single.python has : source.python, string.quoted.binary.single.python -%(number)03d : constant.character.format.placeholder.other.python, source.python, string.quoted.binary.single.python +%(number)03d : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.binary.single.python quote types. : source.python, string.quoted.binary.single.python " : punctuation.definition.string.end.python, source.python, string.quoted.binary.single.python a : source.python @@ -43,8 +43,8 @@ : source.python R : source.python, storage.type.string.python, string.quoted.raw.single.python " : punctuation.definition.string.begin.python, source.python, string.quoted.raw.single.python -%(language)s : constant.character.format.placeholder.other.python, source.python, string.quoted.raw.single.python +%(language)s : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.raw.single.python has : source.python, string.quoted.raw.single.python -%(number)03d : constant.character.format.placeholder.other.python, source.python, string.quoted.raw.single.python +%(number)03d : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.raw.single.python quote types. : source.python, string.quoted.raw.single.python " : punctuation.definition.string.end.python, source.python, string.quoted.raw.single.python diff --git a/test/strings/format4.py b/test/strings/format4.py index e135cf03..4f21cd9c 100644 --- a/test/strings/format4.py +++ b/test/strings/format4.py @@ -10,10 +10,9 @@ : source.python ' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python qqq : source.python, string.quoted.single.python -{ : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -: : constant.character.format.placeholder.other.python, source.python, storage.type.format.python, string.quoted.single.python -%Y-%m-%d %H:%M:%S : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +{ : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python +: : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, storage.type.format.python, string.quoted.single.python +%Y-%m-%d %H:%M:%S} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python www : source.python, string.quoted.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.single.python a : source.python @@ -22,11 +21,8 @@ : source.python ' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python qqq : source.python, string.quoted.single.python -{0 : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -: : constant.character.format.placeholder.other.python, source.python, storage.type.format.python, string.quoted.single.python -{fill} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -{align} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -16 : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +{0 : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python +: : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, storage.type.format.python, string.quoted.single.python +{fill}{align}16} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python www : source.python, string.quoted.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.single.python diff --git a/test/strings/format5.py b/test/strings/format5.py index 0c3f6bb4..230253a3 100644 --- a/test/strings/format5.py +++ b/test/strings/format5.py @@ -11,11 +11,9 @@ : source.python ' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python qqq : source.python, string.quoted.single.python -{0 : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -: : constant.character.format.placeholder.other.python, source.python, storage.type.format.python, string.quoted.single.python -{width} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -{base} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +{0 : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python +: : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, storage.type.format.python, string.quoted.single.python +{width}{base}} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python www : source.python, string.quoted.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.single.python a : source.python @@ -24,10 +22,9 @@ : source.python ' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python qqq : source.python, string.quoted.single.python -{0 : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -: : constant.character.format.placeholder.other.python, source.python, storage.type.format.python, string.quoted.single.python -$20 : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python -} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +{0 : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python +: : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, storage.type.format.python, string.quoted.single.python +$20} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python www : source.python, string.quoted.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.single.python a : source.python @@ -36,6 +33,6 @@ : source.python ' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python qqq : source.python, string.quoted.single.python -{0} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +{0} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python www : source.python, string.quoted.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.single.python diff --git a/test/strings/format6.py b/test/strings/format6.py index cf0ea3c7..aff1a320 100644 --- a/test/strings/format6.py +++ b/test/strings/format6.py @@ -31,6 +31,6 @@ : source.python ' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python h} : source.python, string.quoted.single.python -{base} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +{base} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python }www : source.python, string.quoted.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.single.python diff --git a/test/strings/format7.py b/test/strings/format7.py index e80e3d27..cafb5dcd 100644 --- a/test/strings/format7.py +++ b/test/strings/format7.py @@ -19,9 +19,9 @@ : source.python ' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python 12 : source.python, string.quoted.single.python -% o : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +% o : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.single.python f : source.python, string.quoted.single.python -%s : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +%s : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.single.python : source.python % : keyword.operator.arithmetic.python, source.python diff --git a/test/strings/format9.py b/test/strings/format9.py index 26e5d643..1b493484 100644 --- a/test/strings/format9.py +++ b/test/strings/format9.py @@ -11,7 +11,7 @@ : source.python ' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python blah {foo-bar : source.python, string.quoted.single.python -%d : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +%d : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.single.python a : source.python : source.python @@ -20,7 +20,7 @@ ' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python blah : source.python, string.quoted.single.python {foo-bar : source.python, string.quoted.single.python -%d : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +%d : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.single.python } : source.python, string.quoted.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.single.python a : source.python @@ -30,7 +30,7 @@ ' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python blah : source.python, string.quoted.single.python {foo-bar : source.python, string.quoted.single.python -%d : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +%d : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.single.python //insane {}} : source.python, string.quoted.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.single.python a : source.python @@ -38,9 +38,9 @@ = : keyword.operator.assignment.python, source.python : source.python ' : punctuation.definition.string.begin.python, source.python, string.quoted.single.python -{} : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +{} : constant.character.format.placeholder.other.python, meta.format.brace.python, source.python, string.quoted.single.python blah : source.python, string.quoted.single.python {foo-bar : source.python, string.quoted.single.python -%d : constant.character.format.placeholder.other.python, source.python, string.quoted.single.python +%d : constant.character.format.placeholder.other.python, meta.format.percent.python, source.python, string.quoted.single.python //insane {}} : source.python, string.quoted.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.single.python diff --git a/test/unicode/unicode1.py b/test/unicode/unicode1.py index 9d853df6..795a2645 100644 --- a/test/unicode/unicode1.py +++ b/test/unicode/unicode1.py @@ -24,7 +24,7 @@ class : meta.class.python, source.python, storage.type.class.python Ń : source.python, string.quoted.docstring.single.python ' : punctuation.definition.string.end.python, source.python, string.quoted.docstring.single.python : meta.function.decorator.python, source.python -@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python +@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python æaœ : entity.name.function.decorator.python, meta.function.decorator.python, source.python : meta.function.python, source.python def : meta.function.python, source.python, storage.type.function.python