Skip to content

Update the syntax to Python 3.10 #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 49 additions & 32 deletions grammars/MagicPython.cson
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,18 @@ repository:
name: "storage.type.class.python"
match: "\\b(?<!\\.)(class)\\b"
}
{
match: '''
(?x)
^\\s*(
case | match
)(?=\\s*([-+\\w\\d(\\[{'":#]|$))\\b

'''
captures:
"1":
name: "keyword.control.flow.python"
}
]
"expression-bare":
comment: "valid Python expressions w/o comments and line continuation"
Expand Down Expand Up @@ -1826,14 +1838,14 @@ repository:
match: '''
(?x)
(?<!\\.) \\b(
__import__ | abs | all | any | ascii | bin | breakpoint | callable
| chr | compile | copyright | credits | delattr | dir | divmod
| enumerate | eval | exec | exit | filter | format | getattr
| globals | hasattr | hash | help | hex | id | input
| isinstance | issubclass | iter | len | license | locals | map
| max | memoryview | min | next | oct | open | ord | pow | print
| quit | range | reload | repr | reversed | round
| setattr | sorted | sum | vars | zip
__import__ | abs | aiter | all | any | anext | ascii | bin
| breakpoint | callable | chr | compile | copyright | credits
| delattr | dir | divmod | enumerate | eval | exec | exit
| filter | format | getattr | globals | hasattr | hash | help
| hex | id | input | isinstance | issubclass | iter | len
| license | locals | map | max | memoryview | min | next
| oct | open | ord | pow | print | quit | range | reload | repr
| reversed | round | setattr | sorted | sum | vars | zip
)\\b

'''
Expand Down Expand Up @@ -1876,24 +1888,29 @@ repository:
(?x)
\\b(
__(?:
abs | add | aenter | aexit | aiter | and | anext | await
| bool | call | ceil | cmp | coerce | complex | contains
| copy | deepcopy | del | delattr | delete | delitem
| delslice | dir | div | divmod | enter | eq | exit | float
| floor | floordiv | format | ge | get | getattr
| getattribute | getinitargs | getitem | getnewargs
| getslice | getstate | gt | hash | hex | iadd | iand | idiv
| ifloordiv | ilshift | imod | imul | index | init
| instancecheck | int | invert | ior | ipow | irshift | isub
| iter | itruediv | ixor | le | len | long | lshift | lt
| missing | mod | mul | ne | neg | new | next | nonzero | oct | or
| pos | pow | radd | rand | rdiv | rdivmod | reduce
| reduce_ex | repr | reversed | rfloordiv | rlshift | rmod
| rmul | ror | round | rpow | rrshift | rshift | rsub
| rtruediv | rxor | set | setattr | setitem | setslice
| setstate | sizeof | str | sub | subclasscheck | truediv
| trunc | unicode | xor | matmul | rmatmul | imatmul
| init_subclass | set_name | fspath | bytes | prepare
abs | add | aenter | aexit | aiter | and | anext
| await | bool | call | ceil | class_getitem
| cmp | coerce | complex | contains | copy
| deepcopy | del | delattr | delete | delitem
| delslice | dir | div | divmod | enter | eq
| exit | float | floor | floordiv | format | ge
| get | getattr | getattribute | getinitargs
| getitem | getnewargs | getslice | getstate | gt
| hash | hex | iadd | iand | idiv | ifloordiv |
| ilshift | imod | imul | index | init
| instancecheck | int | invert | ior | ipow
| irshift | isub | iter | itruediv | ixor | le
| len | long | lshift | lt | missing | mod | mul
| ne | neg | new | next | nonzero | oct | or | pos
| pow | radd | rand | rdiv | rdivmod | reduce
| reduce_ex | repr | reversed | rfloordiv |
| rlshift | rmod | rmul | ror | round | rpow
| rrshift | rshift | rsub | rtruediv | rxor | set
| setattr | setitem | set_name | setslice
| setstate | sizeof | str | sub | subclasscheck
| truediv | trunc | unicode | xor | matmul
| rmatmul | imatmul | init_subclass | set_name
| fspath | bytes | prepare | length_hint
)__
)\\b

Expand All @@ -1907,12 +1924,12 @@ repository:
(?x)
\\b(
__(?:
all | bases | builtins | class | class_getitem | code | debug
| defaults | dict | doc | file | func | kwdefaults | members
| metaclass | methods | module | mro | mro_entries | name
| qualname | post_init | self | signature | slots | subclasses
| version | weakref | wrapped | annotations | classcell
| spec | path | package | future | traceback
all | annotations | bases | builtins | class
| closure | code | debug | defaults | dict | doc | file | func
| globals | kwdefaults | match_args | members | metaclass | methods
| module | mro | mro_entries | name | qualname | post_init | self
| signature | slots | subclasses | version | weakref | wrapped
| classcell | spec | path | package | future | traceback
)__
)\\b

Expand Down
85 changes: 53 additions & 32 deletions grammars/MagicPython.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,22 @@ it's probably control flow like:
<key>match</key>
<string>\b(?&lt;!\.)(class)\b</string>
</dict>
<dict>
<key>match</key>
<string>(?x)
^\s*(
case | match
)(?=\s*([-+\w\d(\[{'":#]|$))\b
</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.control.flow.python</string>
</dict>
</dict>
</dict>
</array>
</dict>
<key>expression-bare</key>
Expand Down Expand Up @@ -2852,14 +2868,14 @@ correctly identify the "in" as a control flow keyword.
<key>match</key>
<string>(?x)
(?&lt;!\.) \b(
__import__ | abs | all | any | ascii | bin | breakpoint | callable
| chr | compile | copyright | credits | delattr | dir | divmod
| enumerate | eval | exec | exit | filter | format | getattr
| globals | hasattr | hash | help | hex | id | input
| isinstance | issubclass | iter | len | license | locals | map
| max | memoryview | min | next | oct | open | ord | pow | print
| quit | range | reload | repr | reversed | round
| setattr | sorted | sum | vars | zip
__import__ | abs | aiter | all | any | anext | ascii | bin
| breakpoint | callable | chr | compile | copyright | credits
| delattr | dir | divmod | enumerate | eval | exec | exit
| filter | format | getattr | globals | hasattr | hash | help
| hex | id | input | isinstance | issubclass | iter | len
| license | locals | map | max | memoryview | min | next
| oct | open | ord | pow | print | quit | range | reload | repr
| reversed | round | setattr | sorted | sum | vars | zip
)\b
</string>
</dict>
Expand Down Expand Up @@ -2904,24 +2920,29 @@ indirectly through syntactic constructs
<string>(?x)
\b(
__(?:
abs | add | aenter | aexit | aiter | and | anext | await
| bool | call | ceil | cmp | coerce | complex | contains
| copy | deepcopy | del | delattr | delete | delitem
| delslice | dir | div | divmod | enter | eq | exit | float
| floor | floordiv | format | ge | get | getattr
| getattribute | getinitargs | getitem | getnewargs
| getslice | getstate | gt | hash | hex | iadd | iand | idiv
| ifloordiv | ilshift | imod | imul | index | init
| instancecheck | int | invert | ior | ipow | irshift | isub
| iter | itruediv | ixor | le | len | long | lshift | lt
| missing | mod | mul | ne | neg | new | next | nonzero | oct | or
| pos | pow | radd | rand | rdiv | rdivmod | reduce
| reduce_ex | repr | reversed | rfloordiv | rlshift | rmod
| rmul | ror | round | rpow | rrshift | rshift | rsub
| rtruediv | rxor | set | setattr | setitem | setslice
| setstate | sizeof | str | sub | subclasscheck | truediv
| trunc | unicode | xor | matmul | rmatmul | imatmul
| init_subclass | set_name | fspath | bytes | prepare
abs | add | aenter | aexit | aiter | and | anext
| await | bool | call | ceil | class_getitem
| cmp | coerce | complex | contains | copy
| deepcopy | del | delattr | delete | delitem
| delslice | dir | div | divmod | enter | eq
| exit | float | floor | floordiv | format | ge
| get | getattr | getattribute | getinitargs
| getitem | getnewargs | getslice | getstate | gt
| hash | hex | iadd | iand | idiv | ifloordiv |
| ilshift | imod | imul | index | init
| instancecheck | int | invert | ior | ipow
| irshift | isub | iter | itruediv | ixor | le
| len | long | lshift | lt | missing | mod | mul
| ne | neg | new | next | nonzero | oct | or | pos
| pow | radd | rand | rdiv | rdivmod | reduce
| reduce_ex | repr | reversed | rfloordiv |
| rlshift | rmod | rmul | ror | round | rpow
| rrshift | rshift | rsub | rtruediv | rxor | set
| setattr | setitem | set_name | setslice
| setstate | sizeof | str | sub | subclasscheck
| truediv | trunc | unicode | xor | matmul
| rmatmul | imatmul | init_subclass | set_name
| fspath | bytes | prepare | length_hint
)__
)\b
</string>
Expand All @@ -2942,12 +2963,12 @@ indirectly through syntactic constructs
<string>(?x)
\b(
__(?:
all | bases | builtins | class | class_getitem | code | debug
| defaults | dict | doc | file | func | kwdefaults | members
| metaclass | methods | module | mro | mro_entries | name
| qualname | post_init | self | signature | slots | subclasses
| version | weakref | wrapped | annotations | classcell
| spec | path | package | future | traceback
all | annotations | bases | builtins | class
| closure | code | debug | defaults | dict | doc | file | func
| globals | kwdefaults | match_args | members | metaclass | methods
| module | mro | mro_entries | name | qualname | post_init | self
| signature | slots | subclasses | version | weakref | wrapped
| classcell | spec | path | package | future | traceback
)__
)\b
</string>
Expand Down
76 changes: 44 additions & 32 deletions grammars/src/MagicPython.syntax.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,13 @@ repository:
)\b
- name: storage.type.class.python
match: \b(?<!\.)(class)\b
- match: |
(?x)
^\s*(
case | match
)(?=\s*([-+\w\d(\[{'":#]|$))\b
captures:
'1': {name: keyword.control.flow.python}

expression-bare:
comment: valid Python expressions w/o comments and line continuation
Expand Down Expand Up @@ -1284,14 +1291,14 @@ repository:
match: |
(?x)
(?<!\.) \b(
__import__ | abs | all | any | ascii | bin | breakpoint | callable
| chr | compile | copyright | credits | delattr | dir | divmod
| enumerate | eval | exec | exit | filter | format | getattr
| globals | hasattr | hash | help | hex | id | input
| isinstance | issubclass | iter | len | license | locals | map
| max | memoryview | min | next | oct | open | ord | pow | print
| quit | range | reload | repr | reversed | round
| setattr | sorted | sum | vars | zip
__import__ | abs | aiter | all | any | anext | ascii | bin
| breakpoint | callable | chr | compile | copyright | credits
| delattr | dir | divmod | enumerate | eval | exec | exit
| filter | format | getattr | globals | hasattr | hash | help
| hex | id | input | isinstance | issubclass | iter | len
| license | locals | map | max | memoryview | min | next
| oct | open | ord | pow | print | quit | range | reload | repr
| reversed | round | setattr | sorted | sum | vars | zip
)\b

- name: variable.legacy.builtin.python
Expand Down Expand Up @@ -1325,24 +1332,29 @@ repository:
(?x)
\b(
__(?:
abs | add | aenter | aexit | aiter | and | anext | await
| bool | call | ceil | cmp | coerce | complex | contains
| copy | deepcopy | del | delattr | delete | delitem
| delslice | dir | div | divmod | enter | eq | exit | float
| floor | floordiv | format | ge | get | getattr
| getattribute | getinitargs | getitem | getnewargs
| getslice | getstate | gt | hash | hex | iadd | iand | idiv
| ifloordiv | ilshift | imod | imul | index | init
| instancecheck | int | invert | ior | ipow | irshift | isub
| iter | itruediv | ixor | le | len | long | lshift | lt
| missing | mod | mul | ne | neg | new | next | nonzero | oct | or
| pos | pow | radd | rand | rdiv | rdivmod | reduce
| reduce_ex | repr | reversed | rfloordiv | rlshift | rmod
| rmul | ror | round | rpow | rrshift | rshift | rsub
| rtruediv | rxor | set | setattr | setitem | setslice
| setstate | sizeof | str | sub | subclasscheck | truediv
| trunc | unicode | xor | matmul | rmatmul | imatmul
| init_subclass | set_name | fspath | bytes | prepare
abs | add | aenter | aexit | aiter | and | anext
| await | bool | call | ceil | class_getitem
| cmp | coerce | complex | contains | copy
| deepcopy | del | delattr | delete | delitem
| delslice | dir | div | divmod | enter | eq
| exit | float | floor | floordiv | format | ge
| get | getattr | getattribute | getinitargs
| getitem | getnewargs | getslice | getstate | gt
| hash | hex | iadd | iand | idiv | ifloordiv |
| ilshift | imod | imul | index | init
| instancecheck | int | invert | ior | ipow
| irshift | isub | iter | itruediv | ixor | le
| len | long | lshift | lt | missing | mod | mul
| ne | neg | new | next | nonzero | oct | or | pos
| pow | radd | rand | rdiv | rdivmod | reduce
| reduce_ex | repr | reversed | rfloordiv |
| rlshift | rmod | rmul | ror | round | rpow
| rrshift | rshift | rsub | rtruediv | rxor | set
| setattr | setitem | set_name | setslice
| setstate | sizeof | str | sub | subclasscheck
| truediv | trunc | unicode | xor | matmul
| rmatmul | imatmul | init_subclass | set_name
| fspath | bytes | prepare | length_hint
)__
)\b
captures:
Expand All @@ -1354,12 +1366,12 @@ repository:
(?x)
\b(
__(?:
all | bases | builtins | class | class_getitem | code | debug
| defaults | dict | doc | file | func | kwdefaults | members
| metaclass | methods | module | mro | mro_entries | name
| qualname | post_init | self | signature | slots | subclasses
| version | weakref | wrapped | annotations | classcell
| spec | path | package | future | traceback
all | annotations | bases | builtins | class
| closure | code | debug | defaults | dict | doc | file | func
| globals | kwdefaults | match_args | members | metaclass | methods
| module | mro | mro_entries | name | qualname | post_init | self
| signature | slots | subclasses | version | weakref | wrapped
| classcell | spec | path | package | future | traceback
)__
)\b
captures:
Expand Down
Loading