pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/MagicStack/MagicPython/commit/a8407a07004e679f7e49d55a18078a2ca8de7b40

s" /> Recognize '*' in function declarations · MagicStack/MagicPython@a8407a0 · GitHub
Skip to content

Commit a8407a0

Browse files
committed
Recognize '*' in function declarations
1 parent a304f63 commit a8407a0

File tree

8 files changed

+117
-8
lines changed

8 files changed

+117
-8
lines changed

grammars/MagicPython.cson

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,8 @@ repository:
987987
contentName: "meta.function.lambda.parameters.python"
988988
patterns: [
989989
{
990-
match: "\\*"
990+
name: "keyword.operator.unpacking.parameter.python"
991+
match: "(\\*\\*|\\*)"
991992
}
992993
{
993994
include: "#lambda-incomplete"
@@ -1108,7 +1109,8 @@ repository:
11081109
name: "punctuation.definition.parameters.end.python"
11091110
patterns: [
11101111
{
1111-
match: "\\*"
1112+
name: "keyword.operator.unpacking.parameter.python"
1113+
match: "(\\*\\*|\\*)"
11121114
}
11131115
{
11141116
include: "#lambda-incomplete"

grammars/MagicPython.syntax.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,8 @@ repository:
689689

690690
contentName: meta.function.lambda.parameters.python
691691
patterns:
692-
- match: \*
692+
- name: keyword.operator.unpacking.parameter.python
693+
match: (\*\*|\*)
693694
- include: '#lambda-incomplete'
694695
- include: '#illegal-names'
695696
- match: ([[:alpha:]_]\w*)\s*(?:(,)|(?=:|$))
@@ -764,7 +765,8 @@ repository:
764765
'1': {name: punctuation.definition.parameters.end.python}
765766

766767
patterns:
767-
- match: \*
768+
- name: keyword.operator.unpacking.parameter.python
769+
match: (\*\*|\*)
768770
- include: '#lambda-incomplete'
769771
- include: '#illegal-names'
770772
- include: '#parameter-special'

grammars/MagicPython.tmLanguage

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,8 +1590,10 @@ it's not tokenized as ellipsis.
15901590
<key>patterns</key>
15911591
<array>
15921592
<dict>
1593+
<key>name</key>
1594+
<string>keyword.operator.unpacking.parameter.python</string>
15931595
<key>match</key>
1594-
<string>\*</string>
1596+
<string>(\*\*|\*)</string>
15951597
</dict>
15961598
<dict>
15971599
<key>include</key>
@@ -1791,8 +1793,10 @@ it&apos;s not tokenized as ellipsis.
17911793
<key>patterns</key>
17921794
<array>
17931795
<dict>
1796+
<key>name</key>
1797+
<string>keyword.operator.unpacking.parameter.python</string>
17941798
<key>match</key>
1795-
<string>\*</string>
1799+
<string>(\*\*|\*)</string>
17961800
</dict>
17971801
<dict>
17981802
<key>include</key>

misc/scopes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ keyword.operator.negation.regexp
5656
keyword.operator.python
5757
keyword.operator.quantifier.regexp
5858
keyword.operator.unpacking.arguments.python
59+
keyword.operator.unpacking.parameter.python
5960
meta.backreference.named.regexp
6061
meta.backreference.regexp
6162
meta.character.set.regexp

test/functions/decl1.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ def : meta.function.python, source.python, storage.type.function.pytho
3434
# : comment.line.number-sign.python, meta.function.parameters.python, meta.function.python, punctuation.definition.comment.python, source.python
3535
or False, whatever : comment.line.number-sign.python, meta.function.parameters.python, meta.function.python, source.python
3636
: meta.function.parameters.python, meta.function.python, source.python
37-
* : meta.function.parameters.python, meta.function.python, source.python
38-
* : meta.function.parameters.python, meta.function.python, source.python
37+
** : keyword.operator.unpacking.parameter.python, meta.function.parameters.python, meta.function.python, source.python
3938
kwargs : meta.function.parameters.python, meta.function.python, source.python, variable.parameter.function.language.python
4039
) : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.end.python, source.python
4140
: : meta.function.python, punctuation.section.function.begin.python, source.python

test/functions/decl7.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
def foo(*, a): pass
2+
def foo(*a): pass
3+
def foo(**a): pass
4+
5+
6+
7+
def : meta.function.python, source.python, storage.type.function.python
8+
: meta.function.python, source.python
9+
foo : entity.name.function.python, meta.function.python, source.python
10+
( : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.begin.python, source.python
11+
* : keyword.operator.unpacking.parameter.python, meta.function.parameters.python, meta.function.python, source.python
12+
, : meta.function.parameters.python, meta.function.python, source.python
13+
a : meta.function.parameters.python, meta.function.python, source.python, variable.parameter.function.language.python
14+
) : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.end.python, source.python
15+
: : meta.function.python, punctuation.section.function.begin.python, source.python
16+
: source.python
17+
pass : keyword.control.flow.python, source.python
18+
def : meta.function.python, source.python, storage.type.function.python
19+
: meta.function.python, source.python
20+
foo : entity.name.function.python, meta.function.python, source.python
21+
( : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.begin.python, source.python
22+
* : keyword.operator.unpacking.parameter.python, meta.function.parameters.python, meta.function.python, source.python
23+
a : meta.function.parameters.python, meta.function.python, source.python, variable.parameter.function.language.python
24+
) : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.end.python, source.python
25+
: : meta.function.python, punctuation.section.function.begin.python, source.python
26+
: source.python
27+
pass : keyword.control.flow.python, source.python
28+
def : meta.function.python, source.python, storage.type.function.python
29+
: meta.function.python, source.python
30+
foo : entity.name.function.python, meta.function.python, source.python
31+
( : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.begin.python, source.python
32+
** : keyword.operator.unpacking.parameter.python, meta.function.parameters.python, meta.function.python, source.python
33+
a : meta.function.parameters.python, meta.function.python, source.python, variable.parameter.function.language.python
34+
) : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.end.python, source.python
35+
: : meta.function.python, punctuation.section.function.begin.python, source.python
36+
: source.python
37+
pass : keyword.control.flow.python, source.python

test/functions/decl8.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
def foo(a=1**1, *b:3*2=1*2, **a=1*2**3): pass
2+
3+
4+
5+
def : meta.function.python, source.python, storage.type.function.python
6+
: meta.function.python, source.python
7+
foo : entity.name.function.python, meta.function.python, source.python
8+
( : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.begin.python, source.python
9+
a : meta.function.parameters.python, meta.function.python, source.python, variable.parameter.function.language.python
10+
= : keyword.operator.python, meta.function.parameters.python, meta.function.python, source.python
11+
1 : constant.numeric.dec.python, meta.function.parameters.python, meta.function.python, source.python
12+
** : keyword.operator.arithmetic.python, meta.function.parameters.python, meta.function.python, source.python
13+
1 : constant.numeric.dec.python, meta.function.parameters.python, meta.function.python, source.python
14+
, : meta.function.parameters.python, meta.function.python, punctuation.separator.parameters.python, source.python
15+
: meta.function.parameters.python, meta.function.python, source.python
16+
* : keyword.operator.unpacking.parameter.python, meta.function.parameters.python, meta.function.python, source.python
17+
b : meta.function.parameters.python, meta.function.python, source.python, variable.parameter.function.language.python
18+
: : meta.function.parameters.python, meta.function.python, punctuation.separator.annotation.python, source.python
19+
3 : constant.numeric.dec.python, meta.function.parameters.python, meta.function.python, source.python
20+
* : keyword.operator.arithmetic.python, meta.function.parameters.python, meta.function.python, source.python
21+
2 : constant.numeric.dec.python, meta.function.parameters.python, meta.function.python, source.python
22+
= : keyword.operator.assignment.python, meta.function.parameters.python, meta.function.python, source.python
23+
1 : constant.numeric.dec.python, meta.function.parameters.python, meta.function.python, source.python
24+
* : keyword.operator.arithmetic.python, meta.function.parameters.python, meta.function.python, source.python
25+
2 : constant.numeric.dec.python, meta.function.parameters.python, meta.function.python, source.python
26+
, : meta.function.parameters.python, meta.function.python, punctuation.separator.parameters.python, source.python
27+
: meta.function.parameters.python, meta.function.python, source.python
28+
** : keyword.operator.unpacking.parameter.python, meta.function.parameters.python, meta.function.python, source.python
29+
a : meta.function.parameters.python, meta.function.python, source.python, variable.parameter.function.language.python
30+
= : keyword.operator.python, meta.function.parameters.python, meta.function.python, source.python
31+
1 : constant.numeric.dec.python, meta.function.parameters.python, meta.function.python, source.python
32+
* : keyword.operator.arithmetic.python, meta.function.parameters.python, meta.function.python, source.python
33+
2 : constant.numeric.dec.python, meta.function.parameters.python, meta.function.python, source.python
34+
** : keyword.operator.arithmetic.python, meta.function.parameters.python, meta.function.python, source.python
35+
3 : constant.numeric.dec.python, meta.function.parameters.python, meta.function.python, source.python
36+
) : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.end.python, source.python
37+
: : meta.function.python, punctuation.section.function.begin.python, source.python
38+
: source.python
39+
pass : keyword.control.flow.python, source.python

test/functions/lambda9.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
lambda *, b: b
2+
lambda *b: b
3+
lambda **b: b
4+
5+
6+
7+
lambda : meta.lambda-function.python, source.python, storage.type.function.lambda.python
8+
: meta.function.lambda.parameters.python, meta.lambda-function.python, source.python
9+
* : keyword.operator.unpacking.parameter.python, meta.function.lambda.parameters.python, meta.lambda-function.python, source.python
10+
, : meta.function.lambda.parameters.python, meta.lambda-function.python, source.python
11+
b : meta.function.lambda.parameters.python, meta.lambda-function.python, source.python, variable.parameter.function.language.python
12+
: : meta.lambda-function.python, punctuation.section.function.lambda.begin.python, source.python
13+
b : source.python
14+
lambda : meta.lambda-function.python, source.python, storage.type.function.lambda.python
15+
: meta.function.lambda.parameters.python, meta.lambda-function.python, source.python
16+
* : keyword.operator.unpacking.parameter.python, meta.function.lambda.parameters.python, meta.lambda-function.python, source.python
17+
b : meta.function.lambda.parameters.python, meta.lambda-function.python, source.python, variable.parameter.function.language.python
18+
: : meta.lambda-function.python, punctuation.section.function.lambda.begin.python, source.python
19+
b : source.python
20+
lambda : meta.lambda-function.python, source.python, storage.type.function.lambda.python
21+
: meta.function.lambda.parameters.python, meta.lambda-function.python, source.python
22+
** : keyword.operator.unpacking.parameter.python, meta.function.lambda.parameters.python, meta.lambda-function.python, source.python
23+
b : meta.function.lambda.parameters.python, meta.lambda-function.python, source.python, variable.parameter.function.language.python
24+
: : meta.lambda-function.python, punctuation.section.function.lambda.begin.python, source.python
25+
b : source.python

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy