Skip to content

Commit c4d768a

Browse files
committed
Fix regex for 'def' and 'async def'
1 parent fdb7ca7 commit c4d768a

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

grammars/MagicPython.cson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ repository:
10581058
begin: '''
10591059
(?x)
10601060
\\s*
1061-
(?:(async) \\s+)? (def)\\s+
1061+
(?:\\b(async) \\s+)? \\b(def)\\s+
10621062
(?=
10631063
[[:alpha:]_][[:word:]]* \\s* \\(
10641064
)

grammars/MagicPython.tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1706,7 +1706,7 @@ it's not tokenized as ellipsis.
17061706
<key>begin</key>
17071707
<string>(?x)
17081708
\s*
1709-
(?:(async) \s+)? (def)\s+
1709+
(?:\b(async) \s+)? \b(def)\s+
17101710
(?=
17111711
[[:alpha:]_][[:word:]]* \s* \(
17121712
)

grammars/src/MagicPython.syntax.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ repository:
730730
begin: |
731731
(?x)
732732
\s*
733-
(?:(async) \s+)? (def)\s+
733+
(?:\b(async) \s+)? \b(def)\s+
734734
(?=
735735
[[:alpha:]_][[:word:]]* \s* \(
736736
)

test/functions/async3.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
casync def foo(): pass
2+
3+
4+
5+
casync : source.python
6+
: meta.function.python, source.python
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+
) : meta.function.parameters.python, meta.function.python, punctuation.definition.parameters.end.python, source.python
12+
: : meta.function.python, punctuation.section.function.begin.python, source.python
13+
: source.python
14+
pass : keyword.control.flow.python, source.python

test/functions/decl9.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cdef foo(): pass
2+
3+
4+
5+
cdef : source.python
6+
foo : meta.function-call.generic.python, meta.function-call.python, source.python
7+
( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python
8+
) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python
9+
: : source.python
10+
pass : keyword.control.flow.python, source.python

0 commit comments

Comments
 (0)