Skip to content

Commit 01061ce

Browse files
committed
Convert from MagicRegExp.tmLanguage to MagicRegExp.sublime-syntax
1 parent c40dfed commit 01061ce

File tree

2 files changed

+254
-746
lines changed

2 files changed

+254
-746
lines changed

grammars/MagicRegExp.sublime-syntax

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
%YAML 1.2
2+
---
3+
# http://www.sublimetext.com/docs/3/syntax.html
4+
name: MagicRegExp
5+
file_extensions:
6+
- re
7+
scope: source.regexp.python
8+
contexts:
9+
main:
10+
- include: regexp-expression
11+
codetags:
12+
- match: (?:\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\b)
13+
captures:
14+
1: keyword.codetag.notation.python
15+
fregexp-base-expression:
16+
- include: fregexp-quantifier
17+
- include: fstring-formatting-braces
18+
- match: '\{.*?\}'
19+
- include: regexp-base-common
20+
fregexp-quantifier:
21+
- match: |-
22+
(?x)
23+
\{\{(
24+
\d+ | \d+,(\d+)? | ,\d+
25+
)\}\}
26+
scope: keyword.operator.quantifier.regexp
27+
fstring-formatting-braces:
28+
- match: '({)(\s*?)(})'
29+
comment: empty braces are illegal
30+
captures:
31+
1: constant.character.format.placeholder.other.python
32+
2: invalid.illegal.brace.python
33+
3: constant.character.format.placeholder.other.python
34+
- match: "({{|}})"
35+
scope: constant.character.escape.python
36+
regexp-backreference:
37+
- match: |-
38+
(?x)
39+
(\() (\?P= \w+(?:\s+[[:alnum:]]+)?) (\))
40+
scope: meta.backreference.named.regexp
41+
captures:
42+
1: support.other.parenthesis.regexp punctuation.parenthesis.backreference.named.begin.regexp
43+
2: entity.name.tag.named.backreference.regexp
44+
3: support.other.parenthesis.regexp punctuation.parenthesis.backreference.named.end.regexp
45+
regexp-backreference-number:
46+
- match: '(\\[1-9]\d?)'
47+
scope: meta.backreference.regexp
48+
captures:
49+
1: entity.name.tag.backreference.regexp
50+
regexp-base-common:
51+
- match: \.
52+
scope: support.other.match.any.regexp
53+
- match: \^
54+
scope: support.other.match.begin.regexp
55+
- match: \$
56+
scope: support.other.match.end.regexp
57+
- match: '[+*?]\??'
58+
scope: keyword.operator.quantifier.regexp
59+
- match: \|
60+
scope: keyword.operator.disjunction.regexp
61+
- include: regexp-escape-sequence
62+
regexp-base-expression:
63+
- include: regexp-quantifier
64+
- include: regexp-base-common
65+
regexp-character-set:
66+
- match: |-
67+
(?x)
68+
\[ \^? \] (?! .*?\])
69+
- match: '(\[)(\^)?(\])?'
70+
captures:
71+
1: punctuation.character.set.begin.regexp constant.other.set.regexp
72+
2: keyword.operator.negation.regexp
73+
3: constant.character.set.regexp
74+
push:
75+
- meta_scope: meta.character.set.regexp
76+
- match: '(\])'
77+
captures:
78+
1: punctuation.character.set.end.regexp constant.other.set.regexp
79+
2: invalid.illegal.newline.python
80+
pop: true
81+
- include: regexp-charecter-set-escapes
82+
- match: '[^\n]'
83+
scope: constant.character.set.regexp
84+
regexp-charecter-set-escapes:
85+
- match: '\\[abfnrtv\\]'
86+
scope: constant.character.escape.regexp
87+
- include: regexp-escape-special
88+
- match: '\\([0-7]{1,3})'
89+
scope: constant.character.escape.regexp
90+
- include: regexp-escape-character
91+
- include: regexp-escape-unicode
92+
- include: regexp-escape-catchall
93+
regexp-comments:
94+
- match: '\(\?#'
95+
captures:
96+
0: punctuation.comment.begin.regexp
97+
push:
98+
- meta_scope: comment.regexp
99+
- match: (\))
100+
captures:
101+
1: punctuation.comment.end.regexp
102+
2: invalid.illegal.newline.python
103+
pop: true
104+
- include: codetags
105+
regexp-conditional:
106+
- match: '(\()\?\((\w+(?:\s+[[:alnum:]]+)?|\d+)\)'
107+
captures:
108+
0: keyword.operator.conditional.regexp
109+
1: punctuation.parenthesis.conditional.begin.regexp
110+
push:
111+
- match: (\))
112+
captures:
113+
1: keyword.operator.conditional.negative.regexp punctuation.parenthesis.conditional.end.regexp
114+
2: invalid.illegal.newline.python
115+
pop: true
116+
- include: regexp-expression
117+
regexp-escape-catchall:
118+
- match: \\(.|\n)
119+
scope: constant.character.escape.regexp
120+
regexp-escape-character:
121+
- match: |-
122+
(?x)
123+
\\ (
124+
x[0-9A-Fa-f]{2}
125+
| 0[0-7]{1,2}
126+
| [0-7]{3}
127+
)
128+
scope: constant.character.escape.regexp
129+
regexp-escape-sequence:
130+
- include: regexp-escape-special
131+
- include: regexp-escape-character
132+
- include: regexp-escape-unicode
133+
- include: regexp-backreference-number
134+
- include: regexp-escape-catchall
135+
regexp-escape-special:
136+
- match: '\\([AbBdDsSwWZ])'
137+
scope: support.other.escape.special.regexp
138+
regexp-escape-unicode:
139+
- match: |-
140+
(?x)
141+
\\ (
142+
u[0-9A-Fa-f]{4}
143+
| U[0-9A-Fa-f]{8}
144+
)
145+
scope: constant.character.unicode.regexp
146+
regexp-expression:
147+
- include: regexp-base-expression
148+
- include: regexp-character-set
149+
- include: regexp-comments
150+
- include: regexp-flags
151+
- include: regexp-named-group
152+
- include: regexp-backreference
153+
- include: regexp-lookahead
154+
- include: regexp-lookahead-negative
155+
- include: regexp-lookbehind
156+
- include: regexp-lookbehind-negative
157+
- include: regexp-conditional
158+
- include: regexp-parentheses-non-capturing
159+
- include: regexp-parentheses
160+
regexp-flags:
161+
- match: '\(\?[aiLmsux]+\)'
162+
scope: storage.modifier.flag.regexp
163+
regexp-lookahead:
164+
- match: (\()\?=
165+
captures:
166+
0: keyword.operator.lookahead.regexp
167+
1: punctuation.parenthesis.lookahead.begin.regexp
168+
push:
169+
- match: (\))
170+
captures:
171+
1: keyword.operator.lookahead.regexp punctuation.parenthesis.lookahead.end.regexp
172+
2: invalid.illegal.newline.python
173+
pop: true
174+
- include: regexp-expression
175+
regexp-lookahead-negative:
176+
- match: (\()\?!
177+
captures:
178+
0: keyword.operator.lookahead.negative.regexp
179+
1: punctuation.parenthesis.lookahead.begin.regexp
180+
push:
181+
- match: (\))
182+
captures:
183+
1: keyword.operator.lookahead.negative.regexp punctuation.parenthesis.lookahead.end.regexp
184+
2: invalid.illegal.newline.python
185+
pop: true
186+
- include: regexp-expression
187+
regexp-lookbehind:
188+
- match: (\()\?<=
189+
captures:
190+
0: keyword.operator.lookbehind.regexp
191+
1: punctuation.parenthesis.lookbehind.begin.regexp
192+
push:
193+
- match: (\))
194+
captures:
195+
1: keyword.operator.lookbehind.regexp punctuation.parenthesis.lookbehind.end.regexp
196+
2: invalid.illegal.newline.python
197+
pop: true
198+
- include: regexp-expression
199+
regexp-lookbehind-negative:
200+
- match: (\()\?<!
201+
captures:
202+
0: keyword.operator.lookbehind.negative.regexp
203+
1: punctuation.parenthesis.lookbehind.begin.regexp
204+
push:
205+
- match: (\))
206+
captures:
207+
1: keyword.operator.lookbehind.negative.regexp punctuation.parenthesis.lookbehind.end.regexp
208+
2: invalid.illegal.newline.python
209+
pop: true
210+
- include: regexp-expression
211+
regexp-named-group:
212+
- match: |-
213+
(?x)
214+
(\() (\?P <\w+(?:\s+[[:alnum:]]+)?>)
215+
captures:
216+
1: support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp
217+
2: entity.name.tag.named.group.regexp
218+
push:
219+
- meta_scope: meta.named.regexp
220+
- match: (\))
221+
captures:
222+
1: support.other.parenthesis.regexp punctuation.parenthesis.named.end.regexp
223+
2: invalid.illegal.newline.python
224+
pop: true
225+
- include: regexp-expression
226+
regexp-parentheses:
227+
- match: \(
228+
captures:
229+
0: support.other.parenthesis.regexp punctuation.parenthesis.begin.regexp
230+
push:
231+
- match: (\))
232+
captures:
233+
1: support.other.parenthesis.regexp punctuation.parenthesis.end.regexp
234+
2: invalid.illegal.newline.python
235+
pop: true
236+
- include: regexp-expression
237+
regexp-parentheses-non-capturing:
238+
- match: '\(\?:'
239+
captures:
240+
0: support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.begin.regexp
241+
push:
242+
- match: (\))
243+
captures:
244+
1: support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.end.regexp
245+
2: invalid.illegal.newline.python
246+
pop: true
247+
- include: regexp-expression
248+
regexp-quantifier:
249+
- match: |-
250+
(?x)
251+
\{(
252+
\d+ | \d+,(\d+)? | ,\d+
253+
)\}
254+
scope: keyword.operator.quantifier.regexp

0 commit comments

Comments
 (0)