Skip to content

Commit 64fd8f8

Browse files
committed
[python] update grammar
1 parent 82b7f24 commit 64fd8f8

3 files changed

Lines changed: 167 additions & 46 deletions

File tree

extensions/python/syntaxes/MagicPython.tmLanguage.json

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
55
"Once accepted there, we are happy to receive an update request."
66
],
7-
"version": "https://github.com/MagicStack/MagicPython/commit/976e59dcb78cb577e79c8f2117216c06718337e0",
7+
"version": "https://github.com/MagicStack/MagicPython/commit/b453f26ed856c9b16a053517c41207e3a72cc7d5",
88
"name": "MagicPython",
99
"scopeName": "source.python",
1010
"fileTypes": [
@@ -260,14 +260,6 @@
260260
}
261261
}
262262
},
263-
"codetags": {
264-
"match": "(?:\\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\\b)",
265-
"captures": {
266-
"1": {
267-
"name": "keyword.codetag.notation.python"
268-
}
269-
}
270-
},
271263
"statement-keyword": {
272264
"patterns": [
273265
{
@@ -392,8 +384,13 @@
392384
]
393385
},
394386
"member-access": {
395-
"begin": "\\.\\s*(?!\\.)",
387+
"begin": "(\\.)\\s*(?!\\.)",
396388
"end": "(?x)\n # stop when you've just read non-whitespace followed by non-word\n # i.e. when finished reading an identifier or function call\n (?<=\\S)(?=\\W) |\n # stop when seeing the start of something that's not a word,\n # i.e. when seeing a non-identifier\n (^|(?<=\\s))(?=[^\\\\\\w\\s]) |\n $\n",
389+
"beginCaptures": {
390+
"1": {
391+
"name": "punctuation.separator.period.python"
392+
}
393+
},
397394
"patterns": [
398395
{
399396
"include": "#function-call"
@@ -918,29 +915,6 @@
918915
}
919916
]
920917
},
921-
"fstring-formatting-braces": {
922-
"patterns": [
923-
{
924-
"comment": "empty braces are illegal",
925-
"match": "({)(\\s*?)(})",
926-
"captures": {
927-
"1": {
928-
"name": "constant.character.format.placeholder.other.python"
929-
},
930-
"2": {
931-
"name": "invalid.illegal.brace.python"
932-
},
933-
"3": {
934-
"name": "constant.character.format.placeholder.other.python"
935-
}
936-
}
937-
},
938-
{
939-
"name": "constant.character.escape.python",
940-
"match": "({{|}})"
941-
}
942-
]
943-
},
944918
"fstring-formatting-singe-brace": {
945919
"name": "invalid.illegal.brace.python",
946920
"match": "(}(?!}))"
@@ -949,11 +923,14 @@
949923
"comment": "Import statements\n",
950924
"patterns": [
951925
{
952-
"match": "(?x)\n \\s* \\b(from)\\b (\\s*\\.+\\s*) (import)?\n",
926+
"match": "(?x)\n \\s* \\b(from)\\b \\s*(\\.+)\\s* (import)?\n",
953927
"captures": {
954928
"1": {
955929
"name": "keyword.control.import.python"
956930
},
931+
"2": {
932+
"name": "punctuation.separator.period.python"
933+
},
957934
"3": {
958935
"name": "keyword.control.import.python"
959936
}
@@ -1077,8 +1054,13 @@
10771054
}
10781055
},
10791056
"member-access-class": {
1080-
"begin": "\\.\\s*(?!\\.)",
1057+
"begin": "(\\.)\\s*(?!\\.)",
10811058
"end": "(?<=\\S)(?=\\W)|$",
1059+
"beginCaptures": {
1060+
"1": {
1061+
"name": "punctuation.separator.period.python"
1062+
}
1063+
},
10821064
"patterns": [
10831065
{
10841066
"include": "#call-wrapper-inheritance"
@@ -1671,7 +1653,7 @@
16711653
},
16721654
"magic-variable-names": {
16731655
"comment": "magic variables which a class/module may have.",
1674-
"match": "(?x)\n \\b(\n __(?:\n all | bases | builtins | class | code | debug | defaults | dict\n | doc | file | func | kwdefaults | members\n | metaclass | methods | module | mro | name\n | qualname | self | signature | slots | subclasses\n | version | weakref | wrapped | annotations | classcell\n | spec | path | package | future\n )__\n )\\b\n",
1656+
"match": "(?x)\n \\b(\n __(?:\n all | bases | builtins | class | code | debug | defaults | dict\n | doc | file | func | kwdefaults | members\n | metaclass | methods | module | mro | name\n | qualname | self | signature | slots | subclasses\n | version | weakref | wrapped | annotations | classcell\n | spec | path | package | future | traceback\n )__\n )\\b\n",
16751657
"captures": {
16761658
"1": {
16771659
"name": "support.variable.magic.python"
@@ -1769,6 +1751,29 @@
17691751
}
17701752
]
17711753
},
1754+
"fstring-formatting-braces": {
1755+
"patterns": [
1756+
{
1757+
"comment": "empty braces are illegal",
1758+
"match": "({)(\\s*?)(})",
1759+
"captures": {
1760+
"1": {
1761+
"name": "constant.character.format.placeholder.other.python"
1762+
},
1763+
"2": {
1764+
"name": "invalid.illegal.brace.python"
1765+
},
1766+
"3": {
1767+
"name": "constant.character.format.placeholder.other.python"
1768+
}
1769+
}
1770+
},
1771+
{
1772+
"name": "constant.character.escape.python",
1773+
"match": "({{|}})"
1774+
}
1775+
]
1776+
},
17721777
"regexp-base-common": {
17731778
"patterns": [
17741779
{
@@ -1891,6 +1896,14 @@
18911896
}
18921897
]
18931898
},
1899+
"codetags": {
1900+
"match": "(?:\\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\\b)",
1901+
"captures": {
1902+
"1": {
1903+
"name": "keyword.codetag.notation.python"
1904+
}
1905+
}
1906+
},
18941907
"comments-base": {
18951908
"name": "comment.line.number-sign.python",
18961909
"begin": "(\\#)",

extensions/python/syntaxes/MagicRegExp.tmLanguage.json

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
55
"Once accepted there, we are happy to receive an update request."
66
],
7-
"version": "https://github.com/MagicStack/MagicPython/commit/df5bb18c64252f2e7b1aa87e2ed124666d314f1d",
7+
"version": "https://github.com/MagicStack/MagicPython/commit/361a4964a559481330764a447e7bab88d4f1b01b",
88
"name": "MagicRegExp",
99
"scopeName": "source.regexp.python",
1010
"fileTypes": [
@@ -43,6 +43,29 @@
4343
}
4444
]
4545
},
46+
"fstring-formatting-braces": {
47+
"patterns": [
48+
{
49+
"comment": "empty braces are illegal",
50+
"match": "({)(\\s*?)(})",
51+
"captures": {
52+
"1": {
53+
"name": "constant.character.format.placeholder.other.python"
54+
},
55+
"2": {
56+
"name": "invalid.illegal.brace.python"
57+
},
58+
"3": {
59+
"name": "constant.character.format.placeholder.other.python"
60+
}
61+
}
62+
},
63+
{
64+
"name": "constant.character.escape.python",
65+
"match": "({{|}})"
66+
}
67+
]
68+
},
4669
"regexp-base-common": {
4770
"patterns": [
4871
{
@@ -165,6 +188,14 @@
165188
}
166189
]
167190
},
191+
"codetags": {
192+
"match": "(?:\\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\\b)",
193+
"captures": {
194+
"1": {
195+
"name": "keyword.codetag.notation.python"
196+
}
197+
}
198+
},
168199
"regexp-expression": {
169200
"patterns": [
170201
{

extensions/python/test/colorize-results/test_py.json

Lines changed: 86 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,29 @@
407407
}
408408
},
409409
{
410-
"c": "banana.size",
410+
"c": "banana",
411+
"t": "source.python",
412+
"r": {
413+
"dark_plus": "default: #D4D4D4",
414+
"light_plus": "default: #000000",
415+
"dark_vs": "default: #D4D4D4",
416+
"light_vs": "default: #000000",
417+
"hc_black": "default: #FFFFFF"
418+
}
419+
},
420+
{
421+
"c": ".",
422+
"t": "source.python punctuation.separator.period.python",
423+
"r": {
424+
"dark_plus": "default: #D4D4D4",
425+
"light_plus": "default: #000000",
426+
"dark_vs": "default: #D4D4D4",
427+
"light_vs": "default: #000000",
428+
"hc_black": "default: #FFFFFF"
429+
}
430+
},
431+
{
432+
"c": "size",
411433
"t": "source.python",
412434
"r": {
413435
"dark_plus": "default: #D4D4D4",
@@ -2189,7 +2211,7 @@
21892211
}
21902212
},
21912213
{
2192-
"c": " g.",
2214+
"c": " g",
21932215
"t": "source.python",
21942216
"r": {
21952217
"dark_plus": "default: #D4D4D4",
@@ -2199,6 +2221,17 @@
21992221
"hc_black": "default: #FFFFFF"
22002222
}
22012223
},
2224+
{
2225+
"c": ".",
2226+
"t": "source.python punctuation.separator.period.python",
2227+
"r": {
2228+
"dark_plus": "default: #D4D4D4",
2229+
"light_plus": "default: #000000",
2230+
"dark_vs": "default: #D4D4D4",
2231+
"light_vs": "default: #000000",
2232+
"hc_black": "default: #FFFFFF"
2233+
}
2234+
},
22022235
{
22032236
"c": "next",
22042237
"t": "source.python meta.function-call.python meta.function-call.generic.python",
@@ -4499,7 +4532,18 @@
44994532
}
45004533
},
45014534
{
4502-
"c": ".fn ",
4535+
"c": ".",
4536+
"t": "source.python punctuation.separator.period.python",
4537+
"r": {
4538+
"dark_plus": "default: #D4D4D4",
4539+
"light_plus": "default: #000000",
4540+
"dark_vs": "default: #D4D4D4",
4541+
"light_vs": "default: #000000",
4542+
"hc_black": "default: #FFFFFF"
4543+
}
4544+
},
4545+
{
4546+
"c": "fn ",
45034547
"t": "source.python",
45044548
"r": {
45054549
"dark_plus": "default: #D4D4D4",
@@ -4554,7 +4598,18 @@
45544598
}
45554599
},
45564600
{
4557-
"c": ".memo ",
4601+
"c": ".",
4602+
"t": "source.python punctuation.separator.period.python",
4603+
"r": {
4604+
"dark_plus": "default: #D4D4D4",
4605+
"light_plus": "default: #000000",
4606+
"dark_vs": "default: #D4D4D4",
4607+
"light_vs": "default: #000000",
4608+
"hc_black": "default: #FFFFFF"
4609+
}
4610+
},
4611+
{
4612+
"c": "memo ",
45584613
"t": "source.python",
45594614
"r": {
45604615
"dark_plus": "default: #D4D4D4",
@@ -4829,7 +4884,18 @@
48294884
}
48304885
},
48314886
{
4832-
"c": ".memo",
4887+
"c": ".",
4888+
"t": "source.python punctuation.separator.period.python",
4889+
"r": {
4890+
"dark_plus": "default: #D4D4D4",
4891+
"light_plus": "default: #000000",
4892+
"dark_vs": "default: #D4D4D4",
4893+
"light_vs": "default: #000000",
4894+
"hc_black": "default: #FFFFFF"
4895+
}
4896+
},
4897+
{
4898+
"c": "memo",
48334899
"t": "source.python",
48344900
"r": {
48354901
"dark_plus": "default: #D4D4D4",
@@ -4874,7 +4940,7 @@
48744940
},
48754941
{
48764942
"c": ".",
4877-
"t": "source.python",
4943+
"t": "source.python punctuation.separator.period.python",
48784944
"r": {
48794945
"dark_plus": "default: #D4D4D4",
48804946
"light_plus": "default: #000000",
@@ -4973,7 +5039,7 @@
49735039
},
49745040
{
49755041
"c": ".",
4976-
"t": "source.python",
5042+
"t": "source.python punctuation.separator.period.python",
49775043
"r": {
49785044
"dark_plus": "default: #D4D4D4",
49795045
"light_plus": "default: #000000",
@@ -5083,7 +5149,7 @@
50835149
},
50845150
{
50855151
"c": ".",
5086-
"t": "source.python",
5152+
"t": "source.python punctuation.separator.period.python",
50875153
"r": {
50885154
"dark_plus": "default: #D4D4D4",
50895155
"light_plus": "default: #000000",
@@ -5159,7 +5225,7 @@
51595225
}
51605226
},
51615227
{
5162-
"c": " re.",
5228+
"c": " re",
51635229
"t": "source.python",
51645230
"r": {
51655231
"dark_plus": "default: #D4D4D4",
@@ -5169,6 +5235,17 @@
51695235
"hc_black": "default: #FFFFFF"
51705236
}
51715237
},
5238+
{
5239+
"c": ".",
5240+
"t": "source.python punctuation.separator.period.python",
5241+
"r": {
5242+
"dark_plus": "default: #D4D4D4",
5243+
"light_plus": "default: #000000",
5244+
"dark_vs": "default: #D4D4D4",
5245+
"light_vs": "default: #000000",
5246+
"hc_black": "default: #FFFFFF"
5247+
}
5248+
},
51725249
{
51735250
"c": "search",
51745251
"t": "source.python meta.function-call.python meta.function-call.generic.python",

0 commit comments

Comments
 (0)