Skip to content

Commit 643a5be

Browse files
author
MattDMo
committed
Better spacing for larger regexes
1 parent b38db21 commit 643a5be

File tree

1 file changed

+83
-8
lines changed

1 file changed

+83
-8
lines changed

PythonImproved-Unicode.YAML-tmLanguage

Lines changed: 83 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,12 @@ patterns:
226226
let 'async def' be matched *first*.
227227
228228
name: keyword.control.flow.python
229-
match: (?x)\b(async|await|break|continue|elif|else|except|finally|for|if|pass|raise|return|try|while|with|(yield(?:\s+from)?))\b
229+
match: |
230+
(?x) \b(
231+
async | await | break | continue | elif | else | except | finally | for |
232+
if | pass | raise | return | try | while | with |
233+
(yield(?:\s+from)?)
234+
)\b
230235
231236
- name: meta.function.inline.python
232237
begin: (lambda)(?=\s+|:)
@@ -501,7 +506,20 @@ repository:
501506
builtin_functions:
502507
patterns:
503508
- name: meta.function-call.python
504-
begin: (?<!\.)(__import__|abs|all|any|ascii|basestring|bin|bool|bytearray|bytes|callable|chr|classmethod|cmp|compile|complex|delattr|dict|dir|divmod|enumerate|eval|exec|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\s*(?=(\())
509+
begin: |
510+
(?x)
511+
(?<!\.)(
512+
__import__ | abs | all | any | ascii | basestring | bin | bool | bytearray |
513+
bytes | callable | chr | classmethod | cmp | compile | complex | delattr |
514+
dict | dir | divmod | enumerate | eval | exec | execfile | file | filter |
515+
float | format | frozenset | getattr | globals | hasattr | hash | help |
516+
hex | id | input | int | isinstance | issubclass | iter | len | list |
517+
locals | long | map | max | memoryview | min | next | object | oct | open |
518+
ord | pow | print | property | range | raw_input | reduce | reload | repr |
519+
reversed | round | set | setattr | slice | sorted | staticmethod | str |
520+
sum | super | tuple | type | unichr | unicode | vars | xrange | zip)
521+
\s*
522+
(?=(\())
505523
beginCaptures:
506524
'1': {name: support.function.builtin.python}
507525
'2': {name: punctuation.definition.arguments.begin.python}
@@ -524,7 +542,15 @@ repository:
524542

525543
builtin_types:
526544
name: support.type.python
527-
match: (?<!\.)\b(ascii|basestring|bin|bool|buffer|bytearray|bytes|classmethod|complex|dict|file|float|frozenset|hex|int|list|long|object|oct|property|reversed|set|slice|staticmethod|str|super|tuple|type|unicode|xrange)\b
545+
match: |
546+
(?x)
547+
(?<!\.)
548+
\b(
549+
ascii | basestring | bin | bool | buffer | bytearray | bytes | classmethod |
550+
complex | dict | file | float | frozenset | hex | int | list | long |
551+
object | oct | property | reversed | set | slice | staticmethod | str |
552+
super | tuple | type | unicode | xrange)
553+
\b
528554
529555
character-class:
530556
patterns:
@@ -578,7 +604,12 @@ repository:
578604
- include: '#string_quoted_single'
579605

580606
dotted_name:
581-
begin: (?=(?:\.(?!\s+import)\s*)?[\p{Alpha}_][\p{Alnum}_]*(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*)
607+
begin: |
608+
(?x)(?=
609+
(?:\.(?!\s+import)\s*)?
610+
[\p{Alpha}_][\p{Alnum}_]*
611+
(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*
612+
)
582613
end: (?![\p{Alnum}_\.\s])|(?=(?<!\.)\s+[^.])|$
583614
# contentName: meta.dotted-name.python
584615
patterns:
@@ -616,8 +647,29 @@ repository:
616647

617648
errors_warnings_exceptions:
618649
name: support.type.exception.python
619-
match: (?x)\b((Arithmetic|Assertion|Attribute|Buffer|BlockingIO|BrokenPipe|ChildProcess|(Connection(Aborted|Refused|Reset)?)|EOF|Environment|FileExists|FileNotFound|FloatingPoint|IO|Import|Indentation|Index|Interrupted|IsADirectory|NotADirectory|Permission|ProcessLookup|Timeout|Key|Lookup|Memory|Name|NotImplemented|OS|Overflow|Reference|Runtime|Recursion|Standard|Syntax|System|Tab|Type|UnboundLocal|Unicode(Encode|Decode|Translate)?|Value|VMS|Windows|ZeroDivision|([\.\p{Alpha}_][\p{Alnum}_]*))?Error|((Pending)?Deprecation|Runtime|Syntax|User|Future|Import|Unicode|Bytes|Resource)?Warning|SystemExit|Stop(Async)?Iteration|NotImplemented|KeyboardInterrupt|GeneratorExit|([\.\p{Alpha}_][\p{Alnum}_]*)?Exception)\b
620-
650+
match: |
651+
(?x)
652+
\b(
653+
(
654+
Arithmetic | Assertion | Attribute | Buffer | BlockingIO | BrokenPipe |
655+
ChildProcess |
656+
(Connection(Aborted | Refused | Reset)?) |
657+
EOF | Environment | FileExists | FileNotFound | FloatingPoint | IO |
658+
Import | Indentation | Index | Interrupted | IsADirectory | NotADirectory |
659+
Permission | ProcessLookup | Timeout | Key | Lookup | Memory | Name |
660+
NotImplemented | OS | Overflow | Reference | Runtime | Recursion | Standard |
661+
Syntax | System | Tab | Type | UnboundLocal |
662+
Unicode(Encode | Decode | Translate)? | Value | VMS | Windows | ZeroDivision |
663+
([\.\p{Alpha}_][\p{Alnum}_]*))
664+
? Error
665+
| (
666+
(Pending)?Deprecation | Bytes | Future | Import | Resource | Runtime |
667+
Syntax | Unicode | User)
668+
?Warning
669+
|
670+
SystemExit | Stop(Async)?Iteration | NotImplemented | KeyboardInterrupt |
671+
GeneratorExit | ([\.\p{Alpha}_][\p{Alnum}_]*)?Exception)
672+
\b
621673
escaped_char:
622674
match: (\\x[\h]{2})|(\\[0-7]{3})|(\\\n)|(\\\\)|(\\\")|(\\')|(\\a)|(\\b)|(\\f)|(\\n)|(\\r)|(\\t)|(\\v)
623675
captures:
@@ -660,7 +712,13 @@ repository:
660712

661713
illegal_names:
662714
name: invalid.illegal.name.python
663-
match: \b(and|as|assert|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b
715+
match: |
716+
(?x)
717+
\b (
718+
and | as | assert | await | break | class | continue | def | del | elif | else |
719+
except | exec | finally | for | from | global | if | import | in | is | lambda |
720+
nonlocal | not | or | pass | print | raise | return | try | while | with | yield)
721+
\b
664722
665723
keyword_arguments:
666724
begin: \b([\p{Alpha}_][\p{Alnum}_]*)\s*(=)(?!=)
@@ -685,7 +743,24 @@ repository:
685743
magic_function_names:
686744
comment: these methods have magic interpretation by python and are generally called
687745
indirectly through syntactic constructs
688-
match: (\.)?\b(__(?:abs|add|and|bool|call|ceil|cmp|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|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)__)\b
746+
match: |
747+
(?x)
748+
(\.)?
749+
\b (
750+
__(?:abs | add | and | bool | call | ceil | cmp | complex | contains | copy |
751+
deepcopy | del | delattr | delete | delitem | delslice | dir | div | divmod |
752+
enter | eq | exit | float | floor | floordiv | format | ge | get | getattr |
753+
getattribute | getinitargs | getitem | getnewargs | getslice | getstate |
754+
gt | hash | hex | iadd | iand | idiv | ifloordiv | ilshift | imod | imul |
755+
index | init | instancecheck | int | invert | ior | ipow | irshift | isub |
756+
iter | itruediv | ixor | le | len | long | lshift | lt | missing | mod |
757+
mul | ne | neg | new | nonzero | oct | or | pos | pow | radd | rand | rdiv |
758+
rdivmod | reduce | reduce_ex | repr | reversed | rfloordiv | rlshift | rmod |
759+
rmul | ror | round | rpow | rrshift | rshift | rsub | rtruediv | rxor | set |
760+
setattr | setitem | setslice | setstate | sizeof | str | sub | subclasscheck |
761+
truediv | trunc | unicode | xor)
762+
__)
763+
\b
689764
captures:
690765
'2': {name: support.function.magic.python}
691766

0 commit comments

Comments
 (0)