1{
2	"information_for_contributors": [
3		"This file has been converted from https://github.com/MagicStack/MagicPython/blob/master/grammars/MagicRegExp.tmLanguage",
4		"If you want to provide a fix or improvement, please create a pull request against the original repository.",
5		"Once accepted there, we are happy to receive an update request."
6	],
7	"version": "https://github.com/MagicStack/MagicPython/commit/c9b3409deb69acec31bbf7913830e93a046b30cc",
8	"name": "MagicRegExp",
9	"scopeName": "source.regexp.python",
10	"patterns": [
11		{
12			"include": "#regexp-expression"
13		}
14	],
15	"repository": {
16		"regexp-base-expression": {
17			"patterns": [
18				{
19					"include": "#regexp-quantifier"
20				},
21				{
22					"include": "#regexp-base-common"
23				}
24			]
25		},
26		"fregexp-base-expression": {
27			"patterns": [
28				{
29					"include": "#fregexp-quantifier"
30				},
31				{
32					"include": "#fstring-formatting-braces"
33				},
34				{
35					"match": "\\{.*?\\}"
36				},
37				{
38					"include": "#regexp-base-common"
39				}
40			]
41		},
42		"fstring-formatting-braces": {
43			"patterns": [
44				{
45					"comment": "empty braces are illegal",
46					"match": "({)(\\s*?)(})",
47					"captures": {
48						"1": {
49							"name": "constant.character.format.placeholder.other.python"
50						},
51						"2": {
52							"name": "invalid.illegal.brace.python"
53						},
54						"3": {
55							"name": "constant.character.format.placeholder.other.python"
56						}
57					}
58				},
59				{
60					"name": "constant.character.escape.python",
61					"match": "({{|}})"
62				}
63			]
64		},
65		"regexp-base-common": {
66			"patterns": [
67				{
68					"name": "support.other.match.any.regexp",
69					"match": "\\."
70				},
71				{
72					"name": "support.other.match.begin.regexp",
73					"match": "\\^"
74				},
75				{
76					"name": "support.other.match.end.regexp",
77					"match": "\\$"
78				},
79				{
80					"name": "keyword.operator.quantifier.regexp",
81					"match": "[+*?]\\??"
82				},
83				{
84					"name": "keyword.operator.disjunction.regexp",
85					"match": "\\|"
86				},
87				{
88					"include": "#regexp-escape-sequence"
89				}
90			]
91		},
92		"regexp-quantifier": {
93			"name": "keyword.operator.quantifier.regexp",
94			"match": "(?x)\n  \\{(\n    \\d+ | \\d+,(\\d+)? | ,\\d+\n  )\\}\n"
95		},
96		"fregexp-quantifier": {
97			"name": "keyword.operator.quantifier.regexp",
98			"match": "(?x)\n  \\{\\{(\n    \\d+ | \\d+,(\\d+)? | ,\\d+\n  )\\}\\}\n"
99		},
100		"regexp-backreference-number": {
101			"name": "meta.backreference.regexp",
102			"match": "(\\\\[1-9]\\d?)",
103			"captures": {
104				"1": {
105					"name": "entity.name.tag.backreference.regexp"
106				}
107			}
108		},
109		"regexp-backreference": {
110			"name": "meta.backreference.named.regexp",
111			"match": "(?x)\n  (\\()  (\\?P= \\w+(?:\\s+[[:alnum:]]+)?)  (\\))\n",
112			"captures": {
113				"1": {
114					"name": "support.other.parenthesis.regexp punctuation.parenthesis.backreference.named.begin.regexp"
115				},
116				"2": {
117					"name": "entity.name.tag.named.backreference.regexp"
118				},
119				"3": {
120					"name": "support.other.parenthesis.regexp punctuation.parenthesis.backreference.named.end.regexp"
121				}
122			}
123		},
124		"regexp-flags": {
125			"name": "storage.modifier.flag.regexp",
126			"match": "\\(\\?[aiLmsux]+\\)"
127		},
128		"regexp-escape-special": {
129			"name": "support.other.escape.special.regexp",
130			"match": "\\\\([AbBdDsSwWZ])"
131		},
132		"regexp-escape-character": {
133			"name": "constant.character.escape.regexp",
134			"match": "(?x)\n  \\\\ (\n        x[0-9A-Fa-f]{2}\n        | 0[0-7]{1,2}\n        | [0-7]{3}\n     )\n"
135		},
136		"regexp-escape-unicode": {
137			"name": "constant.character.unicode.regexp",
138			"match": "(?x)\n  \\\\ (\n        u[0-9A-Fa-f]{4}\n        | U[0-9A-Fa-f]{8}\n     )\n"
139		},
140		"regexp-escape-catchall": {
141			"name": "constant.character.escape.regexp",
142			"match": "\\\\(.|\\n)"
143		},
144		"regexp-escape-sequence": {
145			"patterns": [
146				{
147					"include": "#regexp-escape-special"
148				},
149				{
150					"include": "#regexp-escape-character"
151				},
152				{
153					"include": "#regexp-escape-unicode"
154				},
155				{
156					"include": "#regexp-backreference-number"
157				},
158				{
159					"include": "#regexp-escape-catchall"
160				}
161			]
162		},
163		"regexp-charecter-set-escapes": {
164			"patterns": [
165				{
166					"name": "constant.character.escape.regexp",
167					"match": "\\\\[abfnrtv\\\\]"
168				},
169				{
170					"include": "#regexp-escape-special"
171				},
172				{
173					"name": "constant.character.escape.regexp",
174					"match": "\\\\([0-7]{1,3})"
175				},
176				{
177					"include": "#regexp-escape-character"
178				},
179				{
180					"include": "#regexp-escape-unicode"
181				},
182				{
183					"include": "#regexp-escape-catchall"
184				}
185			]
186		},
187		"codetags": {
188			"match": "(?:\\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\\b)",
189			"captures": {
190				"1": {
191					"name": "keyword.codetag.notation.python"
192				}
193			}
194		},
195		"regexp-expression": {
196			"patterns": [
197				{
198					"include": "#regexp-base-expression"
199				},
200				{
201					"include": "#regexp-character-set"
202				},
203				{
204					"include": "#regexp-comments"
205				},
206				{
207					"include": "#regexp-flags"
208				},
209				{
210					"include": "#regexp-named-group"
211				},
212				{
213					"include": "#regexp-backreference"
214				},
215				{
216					"include": "#regexp-lookahead"
217				},
218				{
219					"include": "#regexp-lookahead-negative"
220				},
221				{
222					"include": "#regexp-lookbehind"
223				},
224				{
225					"include": "#regexp-lookbehind-negative"
226				},
227				{
228					"include": "#regexp-conditional"
229				},
230				{
231					"include": "#regexp-parentheses-non-capturing"
232				},
233				{
234					"include": "#regexp-parentheses"
235				}
236			]
237		},
238		"regexp-character-set": {
239			"patterns": [
240				{
241					"match": "(?x)\n  \\[ \\^? \\] (?! .*?\\])\n"
242				},
243				{
244					"name": "meta.character.set.regexp",
245					"begin": "(\\[)(\\^)?(\\])?",
246					"end": "(\\])",
247					"beginCaptures": {
248						"1": {
249							"name": "punctuation.character.set.begin.regexp constant.other.set.regexp"
250						},
251						"2": {
252							"name": "keyword.operator.negation.regexp"
253						},
254						"3": {
255							"name": "constant.character.set.regexp"
256						}
257					},
258					"endCaptures": {
259						"1": {
260							"name": "punctuation.character.set.end.regexp constant.other.set.regexp"
261						},
262						"2": {
263							"name": "invalid.illegal.newline.python"
264						}
265					},
266					"patterns": [
267						{
268							"include": "#regexp-charecter-set-escapes"
269						},
270						{
271							"name": "constant.character.set.regexp",
272							"match": "[^\\n]"
273						}
274					]
275				}
276			]
277		},
278		"regexp-named-group": {
279			"name": "meta.named.regexp",
280			"begin": "(?x)\n  (\\()  (\\?P <\\w+(?:\\s+[[:alnum:]]+)?>)\n",
281			"end": "(\\))",
282			"beginCaptures": {
283				"1": {
284					"name": "support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp"
285				},
286				"2": {
287					"name": "entity.name.tag.named.group.regexp"
288				}
289			},
290			"endCaptures": {
291				"1": {
292					"name": "support.other.parenthesis.regexp punctuation.parenthesis.named.end.regexp"
293				},
294				"2": {
295					"name": "invalid.illegal.newline.python"
296				}
297			},
298			"patterns": [
299				{
300					"include": "#regexp-expression"
301				}
302			]
303		},
304		"regexp-comments": {
305			"name": "comment.regexp",
306			"begin": "\\(\\?#",
307			"end": "(\\))",
308			"beginCaptures": {
309				"0": {
310					"name": "punctuation.comment.begin.regexp"
311				}
312			},
313			"endCaptures": {
314				"1": {
315					"name": "punctuation.comment.end.regexp"
316				},
317				"2": {
318					"name": "invalid.illegal.newline.python"
319				}
320			},
321			"patterns": [
322				{
323					"include": "#codetags"
324				}
325			]
326		},
327		"regexp-lookahead": {
328			"begin": "(\\()\\?=",
329			"end": "(\\))",
330			"beginCaptures": {
331				"0": {
332					"name": "keyword.operator.lookahead.regexp"
333				},
334				"1": {
335					"name": "punctuation.parenthesis.lookahead.begin.regexp"
336				}
337			},
338			"endCaptures": {
339				"1": {
340					"name": "keyword.operator.lookahead.regexp punctuation.parenthesis.lookahead.end.regexp"
341				},
342				"2": {
343					"name": "invalid.illegal.newline.python"
344				}
345			},
346			"patterns": [
347				{
348					"include": "#regexp-expression"
349				}
350			]
351		},
352		"regexp-lookahead-negative": {
353			"begin": "(\\()\\?!",
354			"end": "(\\))",
355			"beginCaptures": {
356				"0": {
357					"name": "keyword.operator.lookahead.negative.regexp"
358				},
359				"1": {
360					"name": "punctuation.parenthesis.lookahead.begin.regexp"
361				}
362			},
363			"endCaptures": {
364				"1": {
365					"name": "keyword.operator.lookahead.negative.regexp punctuation.parenthesis.lookahead.end.regexp"
366				},
367				"2": {
368					"name": "invalid.illegal.newline.python"
369				}
370			},
371			"patterns": [
372				{
373					"include": "#regexp-expression"
374				}
375			]
376		},
377		"regexp-lookbehind": {
378			"begin": "(\\()\\?<=",
379			"end": "(\\))",
380			"beginCaptures": {
381				"0": {
382					"name": "keyword.operator.lookbehind.regexp"
383				},
384				"1": {
385					"name": "punctuation.parenthesis.lookbehind.begin.regexp"
386				}
387			},
388			"endCaptures": {
389				"1": {
390					"name": "keyword.operator.lookbehind.regexp punctuation.parenthesis.lookbehind.end.regexp"
391				},
392				"2": {
393					"name": "invalid.illegal.newline.python"
394				}
395			},
396			"patterns": [
397				{
398					"include": "#regexp-expression"
399				}
400			]
401		},
402		"regexp-lookbehind-negative": {
403			"begin": "(\\()\\?<!",
404			"end": "(\\))",
405			"beginCaptures": {
406				"0": {
407					"name": "keyword.operator.lookbehind.negative.regexp"
408				},
409				"1": {
410					"name": "punctuation.parenthesis.lookbehind.begin.regexp"
411				}
412			},
413			"endCaptures": {
414				"1": {
415					"name": "keyword.operator.lookbehind.negative.regexp punctuation.parenthesis.lookbehind.end.regexp"
416				},
417				"2": {
418					"name": "invalid.illegal.newline.python"
419				}
420			},
421			"patterns": [
422				{
423					"include": "#regexp-expression"
424				}
425			]
426		},
427		"regexp-conditional": {
428			"begin": "(\\()\\?\\((\\w+(?:\\s+[[:alnum:]]+)?|\\d+)\\)",
429			"end": "(\\))",
430			"beginCaptures": {
431				"0": {
432					"name": "keyword.operator.conditional.regexp"
433				},
434				"1": {
435					"name": "punctuation.parenthesis.conditional.begin.regexp"
436				}
437			},
438			"endCaptures": {
439				"1": {
440					"name": "keyword.operator.conditional.negative.regexp punctuation.parenthesis.conditional.end.regexp"
441				},
442				"2": {
443					"name": "invalid.illegal.newline.python"
444				}
445			},
446			"patterns": [
447				{
448					"include": "#regexp-expression"
449				}
450			]
451		},
452		"regexp-parentheses-non-capturing": {
453			"begin": "\\(\\?:",
454			"end": "(\\))",
455			"beginCaptures": {
456				"0": {
457					"name": "support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.begin.regexp"
458				}
459			},
460			"endCaptures": {
461				"1": {
462					"name": "support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.end.regexp"
463				},
464				"2": {
465					"name": "invalid.illegal.newline.python"
466				}
467			},
468			"patterns": [
469				{
470					"include": "#regexp-expression"
471				}
472			]
473		},
474		"regexp-parentheses": {
475			"begin": "\\(",
476			"end": "(\\))",
477			"beginCaptures": {
478				"0": {
479					"name": "support.other.parenthesis.regexp punctuation.parenthesis.begin.regexp"
480				}
481			},
482			"endCaptures": {
483				"1": {
484					"name": "support.other.parenthesis.regexp punctuation.parenthesis.end.regexp"
485				},
486				"2": {
487					"name": "invalid.illegal.newline.python"
488				}
489			},
490			"patterns": [
491				{
492					"include": "#regexp-expression"
493				}
494			]
495		}
496	}
497}