-
Notifications
You must be signed in to change notification settings - Fork 11
/
Regular Expressions (PythonImproved).YAML-tmLanguage
119 lines (105 loc) · 3.95 KB
/
Regular Expressions (PythonImproved).YAML-tmLanguage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# [PackageDev] target_format: plist, ext: hidden-tmLanguage
comment: Matches Python's regular expression syntax.
name: Regular Expressions (PythonImproved)
scopeName: source.regexp.python.improved
fileTypes: [re]
uuid: DD867ABF-1EC6-415D-B047-687F550A1D51
patterns:
# - match: \(.*$
- name: keyword.control.anchor.regexp
match: \\[bBAZzG]|\^|\$
- name: keyword.other.back-reference.regexp
match: \\[1-9][0-9]?
- name: keyword.operator.quantifier.regexp
match: '[?+*][?+]?|\{(\d+,\d+|\d+,|,\d+|\d+)\}\??'
- name: keyword.operator.or.regexp
match: \|
- name: comment.block.regexp
begin: \(\?\#
end: \)
- comment: We are restrictive in what we allow to go after the comment character to
avoid false positives, since the availability of comments depend on regexp flags.
name: comment.line.number-sign.regexp
match: (?<=^|\s)#\s[[[:alnum:],. \t?!-:][^\x{00}-\x{7F}]]*$
- name: keyword.other.option-toggle.regexp
match: \(\?[giLmsux]+\)
- name: keyword.other.back-reference.named.regexp
match: (\()(\?P=([[:alpha:]_][[:alnum:]_]*\w*))(\))
- name: meta.group.assertion.regexp
begin: (\()((\?=)|(\?!)|(\?<=)|(\?<!))
beginCaptures:
'1': {name: punctuation.definition.group.regexp}
'2': {name: punctuation.definition.group.assertion.regexp}
'3': {name: meta.assertion.look-ahead.regexp}
'4': {name: meta.assertion.negative-look-ahead.regexp}
'5': {name: meta.assertion.look-behind.regexp}
'6': {name: meta.assertion.negative-look-behind.regexp}
end: (\))
endCaptures:
'1': {name: punctuation.definition.group.regexp}
patterns:
- include: $self
- comment: we can make this more sophisticated to match the | character that separates
yes-pattern from no-pattern, but it's not really necessary.
name: meta.group.assertion.conditional.regexp
begin: (\()(\?\(([1-9][0-9]?|[[:alpha:]_][[:alnum:]_]*)\))
beginCaptures:
'1': {name: punctuation.definition.group.regexp}
'2': {name: punctuation.definition.group.assertion.conditional.regexp}
'3': {name: entity.name.section.back-reference.regexp}
end: (\))
patterns:
- include: $self
- name: meta.group.regexp
begin: (\()((\?P<)([[:alpha:]_][[:alnum:]_]*)(>)|(\?:))?
beginCaptures:
'1': {name: punctuation.definition.group.regexp}
'3': {name: punctuation.definition.group.capture.regexp}
'4': {name: entity.name.section.group.regexp}
'5': {name: punctuation.definition.group.capture.regexp}
'6': {name: punctuation.definition.group.no-capture.regexp}
end: (\))
endCaptures:
'1': {name: punctuation.definition.group.regexp}
patterns:
- include: $self
- include: '#character-class'
repository:
character-class:
patterns:
- match: |-
(?x)\\
(
(w) |
(W) |
(s) |
(S) |
(d) |
(D)
)
captures:
'2': {name: constant.character.character-class.word.regexp}
'3': {name: constant.character.character-class.non-word.regexp}
'4': {name: constant.character.character-class.whitespace.regexp}
'5': {name: constant.character.character-class.non-whitespace.regexp}
'6': {name: constant.character.character-class.digit.regexp}
'7': {name: constant.character.character-class.non-digit.regexp}
- name: constant.character.escape.backslash.regexp
match: \\.
- name: constant.other.character-class.set.regexp
begin: (\[)(\^)?
beginCaptures:
'1': {name: punctuation.definition.character-class.regexp}
'2': {name: keyword.operator.negation.regexp}
end: (\])
endCaptures:
'1': {name: punctuation.definition.character-class.regexp}
patterns:
- include: '#character-class'
- name: constant.other.character-class.range.regexp
match: ((\\.)|.)\-((\\.)|[^\]])
captures:
'2': {name: constant.character.escape.backslash.regexp}
'4': {name: constant.character.escape.backslash.regexp}
foldingStartMarker: (/\*|\{|\()
foldingStopMarker: (\*/|\}|\))