Skip to content

Commit 2c9dcb6

Browse files
committed
Add ellipsis
1 parent 7bbbc08 commit 2c9dcb6

File tree

7 files changed

+114
-3
lines changed

7 files changed

+114
-3
lines changed

grammars/MagicPython.cson

+18
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ patterns: [
2424
repository:
2525
statement:
2626
patterns: [
27+
{
28+
include: "#from-import"
29+
}
2730
{
2831
include: "#class-declaration"
2932
}
@@ -302,6 +305,9 @@ repository:
302305
{
303306
include: "#illegal-names"
304307
}
308+
{
309+
include: "#ellipsis"
310+
}
305311
]
306312
"special-names":
307313
name: "constant.other.caps.python"
@@ -806,6 +812,15 @@ repository:
806812
]
807813
}
808814
]
815+
"from-import":
816+
match: '''
817+
(?x)
818+
^\\s* (from) (\\s+\\.*\\s*)
819+
820+
'''
821+
captures:
822+
"1":
823+
name: "keyword.control.flow.python"
809824
"class-declaration":
810825
patterns: [
811826
{
@@ -1513,6 +1528,9 @@ repository:
15131528
include: "#special-names"
15141529
}
15151530
]
1531+
ellipsis:
1532+
name: "constant.other.ellipsis.python"
1533+
match: "\\.\\.\\."
15161534
backticks:
15171535
name: "invalid.deprecated.backtick.python"
15181536
begin: "\\`"

grammars/MagicPython.syntax.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ repository:
6666

6767
statement:
6868
patterns:
69+
- include: '#from-import'
6970
- include: '#class-declaration'
7071
- include: '#function-declaration'
7172
- include: '#statement-keyword'
@@ -214,6 +215,7 @@ repository:
214215
- include: '#special-names'
215216
- include: '#illegal-operator'
216217
- include: '#illegal-names'
218+
- include: '#ellipsis'
217219

218220
special-names:
219221
name: constant.other.caps.python
@@ -565,6 +567,13 @@ repository:
565567
- match: |
566568
(?x) \{ [^'"}\n]*? \} (?=.*?\})
567569
570+
from-import:
571+
match: |
572+
(?x)
573+
^\s* (from) (\s+\.*\s*)
574+
captures:
575+
'1': {name: keyword.control.flow.python}
576+
568577
class-declaration:
569578
patterns:
570579
- name: meta.class.python
@@ -1025,6 +1034,10 @@ repository:
10251034
- include: '#illegal-object-name'
10261035
- include: '#special-names'
10271036

1037+
ellipsis:
1038+
name: constant.other.ellipsis.python
1039+
match: \.\.\.
1040+
10281041
backticks:
10291042
name: invalid.deprecated.backtick.python
10301043
begin: \`

grammars/MagicPython.tmLanguage

+30
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
<dict>
3939
<key>patterns</key>
4040
<array>
41+
<dict>
42+
<key>include</key>
43+
<string>#from-import</string>
44+
</dict>
4145
<dict>
4246
<key>include</key>
4347
<string>#class-declaration</string>
@@ -475,6 +479,10 @@
475479
<key>include</key>
476480
<string>#illegal-names</string>
477481
</dict>
482+
<dict>
483+
<key>include</key>
484+
<string>#ellipsis</string>
485+
</dict>
478486
</array>
479487
</dict>
480488
<key>special-names</key>
@@ -1306,6 +1314,21 @@
13061314
</dict>
13071315
</array>
13081316
</dict>
1317+
<key>from-import</key>
1318+
<dict>
1319+
<key>match</key>
1320+
<string>(?x)
1321+
^\s* (from) (\s+\.*\s*)
1322+
</string>
1323+
<key>captures</key>
1324+
<dict>
1325+
<key>1</key>
1326+
<dict>
1327+
<key>name</key>
1328+
<string>keyword.control.flow.python</string>
1329+
</dict>
1330+
</dict>
1331+
</dict>
13091332
<key>class-declaration</key>
13101333
<dict>
13111334
<key>patterns</key>
@@ -2401,6 +2424,13 @@ indirectly through syntactic constructs
24012424
</dict>
24022425
</array>
24032426
</dict>
2427+
<key>ellipsis</key>
2428+
<dict>
2429+
<key>name</key>
2430+
<string>constant.other.ellipsis.python</string>
2431+
<key>match</key>
2432+
<string>\.\.\.</string>
2433+
</dict>
24042434
<key>backticks</key>
24052435
<dict>
24062436
<key>name</key>

misc/scopes

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ constant.numeric.hex.python
1313
constant.numeric.oct.python
1414
constant.numeric.python
1515
constant.other.caps.python
16+
constant.other.ellipsis.python
1617
constant.other.set.regexp
1718
entity.name.function.decorator.python
1819
entity.name.function.python

test/expressions/expr10.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
a = ...
2+
a(..., c=...)
3+
a = ((...), ...)
4+
....__class__
5+
6+
7+
8+
a : source.python
9+
= : keyword.operator.assignment.python, source.python
10+
: source.python
11+
... : constant.other.ellipsis.python, source.python
12+
a : meta.function-call.python, source.python
13+
( : meta.function-call.arguments.python, meta.function-call.python, punctuation.definition.arguments.begin.python, source.python
14+
... : constant.other.ellipsis.python, meta.function-call.arguments.python, meta.function-call.python, source.python
15+
, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python
16+
: meta.function-call.arguments.python, meta.function-call.python, source.python
17+
c : meta.function-call.arguments.python, meta.function-call.python, source.python, variable.parameter.function-call.python
18+
= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function-call.python, source.python
19+
... : constant.other.ellipsis.python, meta.function-call.arguments.python, meta.function-call.python, source.python
20+
) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python
21+
a : source.python
22+
= : keyword.operator.assignment.python, source.python
23+
: source.python
24+
( : punctuation.parenthesis.begin.python, source.python
25+
( : punctuation.parenthesis.begin.python, source.python
26+
... : constant.other.ellipsis.python, source.python
27+
) : punctuation.parenthesis.end.python, source.python
28+
, : source.python
29+
... : constant.other.ellipsis.python, source.python
30+
) : punctuation.parenthesis.end.python, source.python
31+
... : constant.other.ellipsis.python, source.python
32+
. : source.python
33+
__class__ : source.python, support.variable.magic.python

test/statements/import1.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55

66
from : keyword.control.flow.python, source.python
7-
.. : source.python
8-
. : source.python
7+
... : source.python
98
foo : source.python
10-
: source.python
119
import : keyword.control.flow.python, source.python
1210
bar : source.python
1311
as : keyword.control.flow.python, source.python

test/statements/import2.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from .... import a
2+
from ... import b
3+
from .. import c
4+
5+
6+
7+
from : keyword.control.flow.python, source.python
8+
.... : source.python
9+
import : keyword.control.flow.python, source.python
10+
a : source.python
11+
from : keyword.control.flow.python, source.python
12+
... : source.python
13+
import : keyword.control.flow.python, source.python
14+
b : source.python
15+
from : keyword.control.flow.python, source.python
16+
.. : source.python
17+
import : keyword.control.flow.python, source.python
18+
c : source.python

0 commit comments

Comments
 (0)