-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.regexp.posix.js
148 lines (146 loc) · 4.48 KB
/
source.regexp.posix.js
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/Alhadis/language-regexp>
// and licensed `isc`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
dependencies: ['source.regexp'],
extensions: [],
names: [],
patterns: [{include: '#main'}],
repository: {
anchor: {
captures: {0: {patterns: [{include: 'source.regexp#anchor'}]}},
match: '\\^|\\$'
},
bound: {
patterns: [{match: '\\\\{,'}, {include: 'source.regexp#quantifier'}]
},
brackets: {
patterns: [
{
captures: {
1: {
name: 'punctuation.definition.character-class.set.begin.regexp'
},
2: {name: 'punctuation.definition.character-class.set.end.regexp'}
},
match: '(\\[)(\\])',
name: 'meta.character-class.set.empty.regexp'
},
{
begin: '\\[',
beginCaptures: {
0: {name: 'punctuation.definition.character-class.set.begin.regexp'}
},
end: '(?!\\G)-?\\]',
endCaptures: {
0: {name: 'punctuation.definition.character-class.set.end.regexp'}
},
name: 'meta.character-class.set.regexp',
patterns: [
{
captures: {
1: {patterns: [{include: 'source.regexp#classInnards'}]}
},
match: '\\G(\\^)(?:-|\\])?'
},
{include: '#charRange'},
{include: '#localeClasses'}
]
}
]
},
charClass: {
captures: {
1: {name: 'punctuation.definition.character-class.set.begin.regexp'},
2: {name: 'keyword.operator.logical.not.regexp'},
3: {name: 'support.constant.posix-class.regexp'},
4: {name: 'punctuation.definition.character-class.set.end.regexp'}
},
match: '(\\[:)(\\^?)(\\w+)(:\\])',
name: 'constant.language.$2-char.character-class.regexp.posix'
},
charRange: {
patterns: [
{
match: '(?<=[^-])-[^\\[\\]\\\\]',
name: 'invalid.illegal.range.ambiguous-endpoint.regexp'
},
{
captures: {1: {name: 'punctuation.separator.range.dash.regexp'}},
name: '(?:[^\\]\\\\]|(?<=\\]))(-)(?:[^\\[\\]\\\\]|(?=[^\\\\[\\]\\\\]))'
}
]
},
collatingElement: {
captures: {
1: {name: 'punctuation.definition.collating-element.set.begin.regexp'},
2: {name: 'storage.type.var.regexp'},
3: {name: 'punctuation.definition.collating-element.set.end.regexp'}
},
match: '(\\[\\.)(.*?)(\\.\\])',
name: 'constant.language.collating-element.regexp.posix'
},
equivalenceClass: {
captures: {
1: {name: 'punctuation.definition.class.begin.regexp'},
2: {name: 'storage.type.class.regexp'},
3: {name: 'punctuation.definition.class.end.regexp'}
},
match: '(\\[=)(.*?)(=\\])',
name: 'constant.language.posix.equivalence-class.regexp'
},
escape: {patterns: [{include: '#escapeMeta'}, {include: '#escapeOther'}]},
escapeMeta: {
match: '\\\\[.^\\[$\\(\\)|*+?{\\\\]',
name: 'constant.character.escape.literal-metacharacter.regexp'
},
escapeOther: {
match: '\\\\.',
name: 'constant.character.escape.misc.regexp'
},
group: {
patterns: [
{
captures: {
1: {name: 'punctuation.definition.group.begin.regexp'},
2: {name: 'punctuation.definition.group.end.regexp'}
},
match: '(\\()(\\))',
name: 'meta.group.empty.regexp'
},
{
begin: '\\(',
beginCaptures: {
0: {name: 'punctuation.definition.group.begin.regexp'}
},
end: '\\)',
endCaptures: {0: {name: 'punctuation.definition.group.end.regexp'}},
name: 'meta.group.regexp',
patterns: [{include: '#main'}]
}
]
},
localeClasses: {
patterns: [{include: '#collatingElement'}, {include: '#equivalenceClass'}]
},
main: {
patterns: [
{include: 'source.regexp#alternation'},
{include: 'source.regexp#wildcard'},
{include: '#escape'},
{include: '#brackets'},
{include: '#bound'},
{include: '#anchor'},
{include: '#group'}
]
}
},
scopeName: 'source.regexp.posix'
}
export default grammar