File tree Expand file tree Collapse file tree 8 files changed +86
-52
lines changed Expand file tree Collapse file tree 8 files changed +86
-52
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ repository:
2727 statement :
2828 patterns : [
2929 {
30- include : " #from- import"
30+ include : " #import"
3131 }
3232 {
3333 include : " #class-declaration"
@@ -259,7 +259,7 @@ repository:
259259 (?x)
260260 \\ b(?<!\\ .)(
261261 as | async | continue | del | assert | break | finally | for
262- | from | elif | else | if | import | except | pass | raise
262+ | from | elif | else | if | except | pass | raise
263263 | return | try | while | with
264264 )\\ b
265265
@@ -926,20 +926,29 @@ repository:
926926 ]
927927 }
928928 ]
929- " from- import" :
929+ import :
930930 comment : '''
931- The main purpose of this rule is to consume '...', so that
932- it's not tokenized as ellipsis.
931+ Import statements
933932
934933 '''
935- match : '''
936- (?x)
937- \\ s* \\ b(from)\\ b (\\ s*\\ .+\\ s*)
938-
939- '''
940- captures :
941- " 1" :
942- name : " keyword.control.flow.python"
934+ patterns : [
935+ {
936+ match : '''
937+ (?x)
938+ \\ s* \\ b(from)\\ b (\\ s*\\ .+\\ s*) (import)?
939+
940+ '''
941+ captures :
942+ " 1" :
943+ name : " keyword.control.import.python"
944+ " 3" :
945+ name : " keyword.control.import.python"
946+ }
947+ {
948+ name : " keyword.control.import.python"
949+ match : " \\ b(?<!\\ .)import\\ b"
950+ }
951+ ]
943952 " class-declaration" :
944953 patterns : [
945954 {
Original file line number Diff line number Diff line change 4444 <array >
4545 <dict >
4646 <key >include </key >
47- <string >#from- import </string >
47+ <string >#import </string >
4848 </dict >
4949 <dict >
5050 <key >include </key >
420420 <string >(?x)
421421 \b(?< !\.)(
422422 as | async | continue | del | assert | break | finally | for
423- | from | elif | else | if | import | except | pass | raise
423+ | from | elif | else | if | except | pass | raise
424424 | return | try | while | with
425425 )\b
426426 </string >
14801480 </dict >
14811481 </array >
14821482 </dict >
1483- <key >from- import </key >
1483+ <key >import </key >
14841484 <dict >
14851485 <key >comment </key >
1486- <string >The main purpose of this rule is to consume '...', so that
1487- it's not tokenized as ellipsis.
1486+ <string >Import statements
14881487 </string >
1489- <key >match </key >
1490- <string >(?x)
1491- \s* \b(from)\b (\s*\.+\s*)
1488+ <key >patterns </key >
1489+ <array >
1490+ <dict >
1491+ <key >match </key >
1492+ <string >(?x)
1493+ \s* \b(from)\b (\s*\.+\s*) (import)?
14921494 </string >
1493- <key >captures </key >
1494- <dict >
1495- <key >1 </key >
1495+ <key >captures </key >
1496+ <dict >
1497+ <key >1 </key >
1498+ <dict >
1499+ <key >name </key >
1500+ <string >keyword.control.import.python </string >
1501+ </dict >
1502+ <key >3 </key >
1503+ <dict >
1504+ <key >name </key >
1505+ <string >keyword.control.import.python </string >
1506+ </dict >
1507+ </dict >
1508+ </dict >
14961509 <dict >
14971510 <key >name </key >
1498- <string >keyword.control.flow.python </string >
1511+ <string >keyword.control.import.python </string >
1512+ <key >match </key >
1513+ <string >\b(?< !\.)import\b </string >
14991514 </dict >
1500- </dict >
1515+ </array >
15011516 </dict >
15021517 <key >class-declaration </key >
15031518 <dict >
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ repository:
7272
7373 statement :
7474 patterns :
75- - include : ' #from- import'
75+ - include : ' #import'
7676 - include : ' #class-declaration'
7777 - include : ' #function-declaration'
7878 - include : ' #statement-keyword'
@@ -219,7 +219,7 @@ repository:
219219 (?x)
220220 \b(?<!\.)(
221221 as | async | continue | del | assert | break | finally | for
222- | from | elif | else | if | import | except | pass | raise
222+ | from | elif | else | if | except | pass | raise
223223 | return | try | while | with
224224 )\b
225225 - name : storage.modifier.declaration.python
@@ -650,15 +650,18 @@ repository:
650650 - match : |
651651 (?x) \{ [^'"}\n]*? \} (?=.*?\})
652652
653- from- import :
653+ import :
654654 comment : |
655- The main purpose of this rule is to consume '...', so that
656- it's not tokenized as ellipsis.
657- match : |
658- (?x)
659- \s* \b(from)\b (\s*\.+\s*)
660- captures :
661- ' 1 ' : {name: keyword.control.flow.python}
655+ Import statements
656+ patterns :
657+ - match : |
658+ (?x)
659+ \s* \b(from)\b (\s*\.+\s*) (import)?
660+ captures:
661+ '1': {name: keyword.control.import.python}
662+ '3': {name: keyword.control.import.python}
663+ - name : keyword.control.import.python
664+ match : \b(?<!\.)import\b
662665
663666 class-declaration :
664667 patterns :
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ invalid.illegal.operator.python
4040invalid.illegal.prefix.python
4141keyword.codetag.notation.python
4242keyword.control.flow.python
43+ keyword.control.import.python
4344keyword.illegal.name.python
4445keyword.operator.arithmetic.python
4546keyword.operator.assignment.python
Original file line number Diff line number Diff line change 3131 : source .python
3232if : keyword .control .flow .python , source .python
3333 : source .python
34- import : keyword .control .flow .python , source .python
34+ import : keyword .control .import .python , source .python
3535 : source .python
3636except : keyword .control .flow .python , source .python
3737 : source .python
Original file line number Diff line number Diff line change 33
44
55
6- from : keyword .control .flow .python , source .python
6+ from : keyword .control .import .python , source .python
77 ... : source .python
88foo : source .python
99 : source .python
10- import : keyword .control .flow .python , source .python
10+ import : keyword .control .import .python , source .python
1111 : source .python
1212bar : source .python
1313 : source .python
1616spam : source .python
1717, : source .python
1818baz : source .python
19- import : keyword .control .flow .python , source .python
19+ import : keyword .control .import .python , source .python
2020 : source .python
2121time : source .python
2222 : source .python
Original file line number Diff line number Diff line change 44
55
66
7- from : keyword .control .flow .python , source .python
7+ from : keyword .control .import .python , source .python
88 .... : source .python
9- import : keyword .control .flow .python , source .python
9+ import : keyword .control .import .python , source .python
1010 : source .python
1111a : source .python
12- from : keyword .control .flow .python , source .python
12+ from : keyword .control .import .python , source .python
1313 ... : source .python
14- import : keyword .control .flow .python , source .python
14+ import : keyword .control .import .python , source .python
1515 : source .python
1616b : source .python
17- from : keyword .control .flow .python , source .python
17+ from : keyword .control .import .python , source .python
1818 .. : source .python
19- import : keyword .control .flow .python , source .python
19+ import : keyword .control .import .python , source .python
2020 : source .python
2121c : source .python
Original file line number Diff line number Diff line change 11from ....import a
22from ...import b
33from ..import c
4+ from .import d
45
56
67
7- from : keyword .control .flow .python , source .python
8+ from : keyword .control .import .python , source .python
89.... : source .python
9- import : keyword .control .flow .python , source .python
10+ import : keyword .control .import .python , source .python
1011 : source .python
1112a : source .python
12- from : keyword .control .flow .python , source .python
13+ from : keyword .control .import .python , source .python
1314... : source .python
14- import : keyword .control .flow .python , source .python
15+ import : keyword .control .import .python , source .python
1516 : source .python
1617b : source .python
17- from : keyword .control .flow .python , source .python
18+ from : keyword .control .import .python , source .python
1819.. : source .python
19- import : keyword .control .flow .python , source .python
20+ import : keyword .control .import .python , source .python
2021 : source .python
2122c : source .python
23+ from : keyword .control .import .python , source .python
24+ . : source .python
25+ import : keyword .control .import .python , source .python
26+ : source .python
27+ d : source .python
You can’t perform that action at this time.
0 commit comments