Skip to content

Commit 493c95c

Browse files
author
MattDMo
committed
Use PCRE unicode character classes, fix comment.line.note highlighting
1 parent e5333f4 commit 493c95c

File tree

1 file changed

+49
-49
lines changed

1 file changed

+49
-49
lines changed

PythonImproved.YAML-tmLanguage

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ patterns:
2424

2525
- comment: Match identifiers in ALL_CAPS as constants, except when followed by `.`, `(`, `'`, or `"`.
2626
name: constant.other.allcaps.python
27-
match: \b([\p{Upper}_][\p{Upper}\p{Digit}_]*)\b(?![\.\(\'\"])
27+
match: \b([[:upper:]_][[:upper:][:digit:]_]*)\b(?![\.\(\'\"])
2828

2929
- name: constant.numeric.integer.long.hexadecimal.python
3030
match: \b(?i:(0x\h+)L)
@@ -46,15 +46,15 @@ patterns:
4646

4747
- comment: Not quite perfect...
4848
name: constant.numeric.complex.python
49-
match: \b(?i:(((\d+(\.(?=[^\p{Alpha}_])\d*)?|(?<=[^\p{Alnum}_])\.\d+)(e[\-\+]?\d+)?))J)
49+
match: \b(?i:(((\d+(\.(?=[^[:alpha:]_])\d*)?|(?<=[^[:alnum:]_])\.\d+)(e[\-\+]?\d+)?))J)
5050

5151
- comment: Ummm... why do we have three of these? This is one...
5252
name: constant.numeric.float.python
53-
match: \b(?i:(\d+\.\d*(e[\-\+]?\d+)?))(?=[^\p{Alpha}_])
53+
match: \b(?i:(\d+\.\d*(e[\-\+]?\d+)?))(?=[^[:alpha:]_])
5454

5555
- comment: This is two...
5656
name: constant.numeric.float.python
57-
match: (?<=[^\p{Alnum}_])(?i:(\.\d+(e[\-\+]?\d+)?))
57+
match: (?<=[^[:alnum:]_])(?i:(\.\d+(e[\-\+]?\d+)?))
5858

5959
- comment: And this is three...
6060
name: constant.numeric.float.python
@@ -103,7 +103,7 @@ patterns:
103103

104104
- name: meta.class.old-style.python
105105
contentName: entity.name.type.class.python
106-
begin: \s*(class)\s+(?=[\p{Alpha}_][\p{Alnum}_]*\s*\:)
106+
begin: \s*(class)\s+(?=[[:alpha:]_][[:alnum:]_]*\s*\:)
107107
beginCaptures:
108108
'1': {name: storage.type.class.python}
109109
end: \s*(:)
@@ -113,7 +113,7 @@ patterns:
113113
- include: '#entity_name_class'
114114

115115
- name: meta.class.python
116-
begin: \s*(class)\s+(?=[\p{Alpha}_][\p{Alnum}_]*\s*\()
116+
begin: \s*(class)\s+(?=[[:alpha:]_][[:alnum:]_]*\s*\()
117117
beginCaptures:
118118
'1': {name: storage.type.class.python}
119119
end: (\))\s*(?:(\:)|(.*$\n?))
@@ -123,8 +123,8 @@ patterns:
123123
'3': {name: invalid.illegal.missing-section-begin.python}
124124
patterns:
125125
- contentName: entity.name.type.class.python
126-
begin: (?=[\p{Alpha}_][\p{Alnum}_]*)
127-
end: (?![\p{Alnum}_])
126+
begin: (?=[[:alpha:]_][[:alnum:]_]*)
127+
end: (?![[:alnum:]_])
128128
patterns:
129129
- include: '#entity_name_class'
130130
- contentName: meta.class.inheritance.python
@@ -142,7 +142,7 @@ patterns:
142142
- include: $self
143143

144144
- name: meta.class.python
145-
begin: \s*(class)\s+(?=[\p{Alpha}_][\p{Alnum}_]*)
145+
begin: \s*(class)\s+(?=[[:alpha:]_][[:alnum:]_]*)
146146
beginCaptures:
147147
'1': {name: storage.type.class.python}
148148
end: (\()|\s*($\n?|#.*$\n?)
@@ -151,22 +151,22 @@ patterns:
151151
'2': {name: invalid.illegal.missing-inheritance.python}
152152
patterns:
153153
- contentName: entity.name.type.class.python
154-
begin: (?=[\p{Alpha}_][\p{Alnum}_]*)
155-
end: (?![\p{Alnum}_])
154+
begin: (?=[[:alpha:]_][[:alnum:]_]*)
155+
end: (?![[:alnum:]_])
156156
patterns:
157157
- include: '#entity_name_function'
158158

159159
- name: meta.function.python
160-
begin: \s*((?:async\s+)?def)\s+(?=[\p{Alpha}_][\p{Alnum}_]*\s*\()
160+
begin: \s*((?:async\s+)?def)\s+(?=[[:alpha:]_][[:alnum:]_]*\s*\()
161161
beginCaptures:
162162
'1': {name: storage.type.function.python}
163163
end: (\:)
164164
endCaptures:
165165
'1': {name: punctuation.section.function.begin.python}
166166
patterns:
167167
- contentName: entity.name.function.python
168-
begin: (?=[\p{Alpha}_][\p{Alnum}_]*)
169-
end: (?![\p{Alnum}_])
168+
begin: (?=[[:alpha:]_][[:alnum:]_]*)
169+
end: (?![[:alnum:]_])
170170
patterns:
171171
- include: '#entity_name_function'
172172
- contentName: meta.function.parameters.python
@@ -178,7 +178,7 @@ patterns:
178178
- include: '#annotated_arguments'
179179
- include: '#keyword_arguments'
180180
- include: '#comments'
181-
- match: \b(?:(self|cls)|([\p{Alpha}_][\p{Alnum}_]*))\s*(?:(,)|(?=[\n\)]))
181+
- match: \b(?:(self|cls)|([[:alpha:]_][[:alnum:]_]*))\s*(?:(,)|(?=[\n\)]))
182182
captures:
183183
'1': {name: variable.parameter.function.language.python}
184184
'2': {name: variable.parameter.function.python}
@@ -192,7 +192,7 @@ patterns:
192192
- include: $self
193193

194194
- name: meta.function.python
195-
begin: \s*((?:async\s+)?def)\s+(?=[\p{Alpha}_][\p{Alnum}_]*)
195+
begin: \s*((?:async\s+)?def)\s+(?=[[:alpha:]_][[:alnum:]_]*)
196196
beginCaptures:
197197
'1': {name: storage.type.function.python}
198198
end: (\()|\s*($\n?|#.*$\n?)
@@ -201,8 +201,8 @@ patterns:
201201
'2': {name: invalid.illegal.missing-parameters.python}
202202
patterns:
203203
- contentName: entity.name.function.python
204-
begin: (?=[\p{Alpha}_][\p{Alnum}_]*)
205-
end: (?![\p{Alnum}_])
204+
begin: (?=[[:alpha:]_][[:alnum:]_]*)
205+
end: (?![[:alnum:]_])
206206
patterns:
207207
- include: '#entity_name_function'
208208

@@ -236,20 +236,20 @@ patterns:
236236
end: (?=\:)
237237
patterns:
238238
- include: '#keyword_arguments'
239-
- match: \b([\p{Alpha}_][\p{Alnum}_]*)\s*(?:(,)|(?=[\n\)\:]))
239+
- match: \b([[:alpha:]_][[:alnum:]_]*)\s*(?:(,)|(?=[\n\)\:]))
240240
captures:
241241
'1': {name: variable.parameter.function.python}
242242
'2': {name: punctuation.separator.parameters.python}
243243

244244
- comment: a decorator may be a function call which returns a decorator.
245245
name: meta.function.decorator.python
246-
begin: ^\s*(?=@\s*[\p{Alpha}_][\p{Alnum}_]*(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*\s*\()
246+
begin: ^\s*(?=@\s*[[:alpha:]_][[:alnum:]_]*(?:\s*\.\s*[[:alpha:]_][[:alnum:]_]*)*\s*\()
247247
end: (?<=\))
248248
endCaptures:
249249
'1': {name: punctuation.definition.arguments.end.python}
250250
patterns:
251251
- contentName: entity.name.function.decorator.python
252-
begin: (?=(@)\s*[\p{Alpha}_][\p{Alnum}_]*(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*\s*\()
252+
begin: (?=(@)\s*[[:alpha:]_][[:alnum:]_]*(?:\s*\.\s*[[:alpha:]_][[:alnum:]_]*)*\s*\()
253253
beginCaptures:
254254
'1': {name: punctuation.definition.decorator.python}
255255
end: (?=\s*\()
@@ -268,10 +268,10 @@ patterns:
268268

269269
- name: meta.function.decorator.python
270270
contentName: entity.name.function.decorator.python
271-
begin: ^\s*(?=@\s*[\p{Alpha}_][\p{Alnum}_]*(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*)
271+
begin: ^\s*(?=@\s*[[:alpha:]_][[:alnum:]_]*(?:\s*\.\s*[[:alpha:]_][[:alnum:]_]*)*)
272272
end: (?=\s|$\n?|#)
273273
patterns:
274-
- begin: (?=(@)\s*[\p{Alpha}_][\p{Alnum}_]*(\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*)
274+
- begin: (?=(@)\s*[[:alpha:]_][[:alnum:]_]*(\s*\.\s*[[:alpha:]_][[:alnum:]_]*)*)
275275
beginCaptures:
276276
'1': {name: punctuation.definition.decorator.python}
277277
end: (?=\s|$\n?|#)
@@ -332,15 +332,15 @@ patterns:
332332
- include: '#generic_object_names'
333333

334334
- name: meta.function-call.python
335-
begin: (?:\.)?([\p{Alpha}_][\p{Alnum}_]*)\s*(?=(\())
335+
begin: (?:\.)?([[:alpha:]_][[:alnum:]_]*)\s*(?=(\())
336336
beginCaptures:
337337
'1': {name: meta.function-call.generic.python}
338338
'2': {name: punctuation.definition.arguments.begin.python}
339339
end: (\))
340340
endCaptures:
341341
'1': {name: punctuation.definition.arguments.end.python}
342342
patterns:
343-
- begin: (?=[\p{Alpha}_][\p{Alnum}_]*(?:\.[\p{Alpha}_][\p{Alnum}_]*)*\s*\()
343+
- begin: (?=[[:alpha:]_][[:alnum:]_]*(?:\.[[:alpha:]_][[:alnum:]_]*)*\s*\()
344344
end: (?=\s*\()
345345
patterns:
346346
- include: '#dotted_name'
@@ -364,12 +364,12 @@ patterns:
364364
match: (?<!\.)\b(print)(?=\s|$)
365365

366366
- name: meta.item-access.python
367-
begin: (?=[\p{Alpha}_][\p{Alnum}_]*(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*\s*\[)
367+
begin: (?=[[:alpha:]_][[:alnum:]_]*(?:\s*\.\s*[[:alpha:]_][[:alnum:]_]*)*\s*\[)
368368
end: (\])
369369
endCaptures:
370370
'1': {name: punctuation.definition.arguments.end.python}
371371
patterns:
372-
- begin: (?=[\p{Alpha}_][\p{Alnum}_]*(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*\s*\[)
372+
- begin: (?=[[:alpha:]_][[:alnum:]_]*(?:\s*\.\s*[[:alpha:]_][[:alnum:]_]*)*\s*\[)
373373
end: (?=\s*\[)
374374
patterns:
375375
- include: '#dotted_name'
@@ -468,7 +468,7 @@ patterns:
468468

469469
repository:
470470
annotated_arguments:
471-
begin: \b([\p{Alpha}_][\p{Alnum}_]*)\s*(:)|(?=\()
471+
begin: \b([[:alpha:]_][[:alnum:]_]*)\s*(:)|(?=\()
472472
beginCaptures:
473473
'1': {name: variable.parameter.function.python}
474474
'2': {name: punctuation.separator.annotation.python}
@@ -489,7 +489,7 @@ repository:
489489
endCaptures:
490490
'1': {name: punctuation.definition.parameters-group.end.python}
491491
patterns:
492-
- begin: \b([\p{Alpha}_][\p{Alnum}_]*)\s*(:)
492+
- begin: \b([[:alpha:]_][[:alnum:]_]*)\s*(:)
493493
beginCaptures:
494494
'1': {name: variable.parameter.function.python}
495495
'2': {name: punctuation.separator.annotation.python}
@@ -498,7 +498,7 @@ repository:
498498
'1': {name: punctuation.separator.parameters.python}
499499
patterns:
500500
- include: $self
501-
- begin: \b([\p{Alpha}_][\p{Alnum}_]*)
501+
- begin: \b([[:alpha:]_][[:alnum:]_]*)
502502
beginCaptures:
503503
'1': {name: variable.parameter.function.python}
504504
end: \s*(?:(,)|(?=$\n?|\)))
@@ -531,7 +531,7 @@ repository:
531531
endCaptures:
532532
'1': {name: punctuation.definition.arguments.end.python}
533533
patterns:
534-
- begin: (?=[\p{Alpha}_][\p{Alnum}_]*(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*\s*\()
534+
- begin: (?=[[:alpha:]_][[:alnum:]_]*(?:\s*\.\s*[[:alpha:]_][[:alnum:]_]*)*\s*\()
535535
end: (?=\s*\()
536536
patterns:
537537
- include: '#dotted_name'
@@ -603,7 +603,7 @@ repository:
603603
comments:
604604
patterns:
605605
- name: comment.line.note.python
606-
match: (#+)\s*(BUG|FIXME|TODO|XXX).*$\n?
606+
match: (#+)\s*(BUG|FIXME|TODO|XXX).*$
607607
captures:
608608
'1': {name: punctuation.definition.comment.python}
609609
'2': {name: comment.line.note.notation.python}
@@ -614,7 +614,7 @@ repository:
614614

615615
constant_placeholder:
616616
name: constant.other.placeholder.python
617-
match: (?i:%(\([\p{Lower}_]+\))?#?0?\-?[ ]?\+?([0-9]*|\*)(\.([0-9]*|\*))?[hL]?[\p{Lower}%])
617+
match: (?i:%(\([[:lower:]_]+\))?#?0?\-?[ ]?\+?([0-9]*|\*)(\.([0-9]*|\*))?[hL]?[[:lower:]%])
618618

619619
docstrings:
620620
patterns:
@@ -633,23 +633,23 @@ repository:
633633
begin: |-
634634
(?x)(?=
635635
(?:\.(?!\s+import)\s*)?
636-
[\p{Alpha}_][\p{Alnum}_]*
637-
(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*
636+
[[:alpha:]_][[:alnum:]_]*
637+
(?:\s*\.\s*[[:alpha:]_][[:alnum:]_]*)*
638638
)
639-
end: (?![\p{Alnum}_\.\s])|(?=(?<!\.)\s+[^.])|$
639+
end: (?![[:alnum:]_\.\s])|(?=(?<!\.)\s+[^.])|$
640640
patterns:
641-
- begin: (\.)(?=[\p{Alpha}_][\p{Alnum}_]*)
641+
- begin: (\.)(?=[[:alpha:]_][[:alnum:]_]*)
642642
beginCaptures:
643643
'1': {name: meta.dot.python}
644-
end: (?![\p{Alnum}_])
644+
end: (?![[:alnum:]_])
645645
patterns:
646646
- include: '#builtin_functions_name'
647647
- include: '#magic_function_names'
648648
- include: '#magic_variable_names'
649649
- include: '#generic_names'
650650
- include: '#illegal_names'
651-
- begin: (?<!\.)(?=[\p{Alpha}_][\p{Alnum}_]*)
652-
end: (?![\p{Alnum}_])
651+
- begin: (?<!\.)(?=[[:alpha:]_][[:alnum:]_]*)
652+
end: (?![[:alnum:]_])
653653
patterns:
654654
- include: '#builtin_types'
655655
- include: '#builtin_functions_name'
@@ -688,18 +688,18 @@ repository:
688688
Memory | Name | NotImplemented | OS | Overflow | Reference | Runtime |
689689
Recursion | Standard | Syntax | System | Tab | Type | UnboundLocal |
690690
Unicode(Encode | Decode | Translate)? | Value | VMS | Windows |
691-
ZeroDivision | ([\p{Alpha}_][\p{Alnum}_]*))
691+
ZeroDivision | ([[:alpha:]_][[:alnum:]_]*))
692692
?Error
693693
|
694694
(
695695
(Pending)?Deprecation | Bytes | Future | Import | Resource |
696-
Runtime | Syntax | Unicode | User | [\p{Alpha}_][\p{Alnum}_]*)
696+
Runtime | Syntax | Unicode | User | [[:alpha:]_][[:alnum:]_]*)
697697
?Warning
698698
|
699699
SystemExit | Stop(Async)?Iteration | NotImplemented |
700700
KeyboardInterrupt | GeneratorExit
701701
|
702-
([\p{Alpha}_][\p{Alnum}_]*)
702+
([[:alpha:]_][[:alnum:]_]*)
703703
?Exception
704704
)
705705
\b
@@ -744,10 +744,10 @@ repository:
744744

745745
generic_names:
746746
name: meta.identifier.python
747-
match: '[\p{Alpha}_][\p{Alnum}_]*'
747+
match: '[[:alpha:]_][[:alnum:]_]*'
748748

749749
generic_object_names:
750-
match: (\.\b([\p{Alpha}_][\p{Alnum}_]*)\b(?!\(|\[)|\b([\p{Alpha}_][\p{Alnum}_]*)\b\.)
750+
match: (\.\b([[:alpha:]_][[:alnum:]_]*)\b(?!\(|\[)|\b([[:alpha:]_][[:alnum:]_]*)\b\.)
751751

752752
illegal_names:
753753
comment: 'from Lib/keyword.py, in kwlist. `async` and `await` not keywords
@@ -763,7 +763,7 @@ repository:
763763
\b
764764
765765
keyword_arguments:
766-
begin: \b([\p{Alpha}_][\p{Alnum}_]*)\s*(=)(?!=)
766+
begin: \b([[:alpha:]_][[:alnum:]_]*)\s*(=)(?!=)
767767
beginCaptures:
768768
'1': {name: variable.parameter.function.keyword.python}
769769
'2': {name: keyword.operator.assignment.python}
@@ -847,7 +847,7 @@ repository:
847847
endCaptures:
848848
'1': {name: punctuation.definition.arguments.end.python}
849849
patterns:
850-
- begin: (?=[\p{Alpha}_][\p{Alnum}_]*(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*\s*\()
850+
- begin: (?=[[:alpha:]_][[:alnum:]_]*(?:\s*\.\s*[[:alpha:]_][[:alnum:]_]*)*\s*\()
851851
end: (?=\s*\()
852852
patterns:
853853
- include: '#dotted_name'
@@ -891,7 +891,7 @@ repository:
891891
(
892892
(?<argname>
893893
(
894-
(?<identifier>([\p{Alpha}_][\p{Alnum}_]*)) |
894+
(?<identifier>([[:alpha:]_][[:alnum:]_]*)) |
895895
(?<integer>
896896
([1-9]\d* | 0) |
897897
(
@@ -1428,6 +1428,6 @@ repository:
14281428
author: Matt Morrison @MattDMo [email protected]
14291429
bundleUUID: EB590797-FBEE-4BEA-A140-8339AFD2CE1B
14301430
firstLineMatch: ^#!/.*\bpython[0-9.-]*\b
1431-
foldingStartMarker: ^\s*(((?:async\s+)?def)|class)\s+([.\p{Alnum}_ <]+)\s*(\((.*)\))?\s*:|\{\s*$|\(\s*$|\[\s*$|^\s*"""(?=.)(?!.*""")
1431+
foldingStartMarker: ^\s*(((?:async\s+)?def)|class)\s+([.[:alnum:]_ <]+)\s*(\((.*)\))?\s*:|\{\s*$|\(\s*$|\[\s*$|^\s*"""(?=.)(?!.*""")
14321432
foldingStopMarker: ^\s*$|^\s*\}|^\s*\]|^\s*\)|^\s*"""\s*$
14331433
keyEquivalent: ^~P

0 commit comments

Comments
 (0)