-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.lex.regexp.js
151 lines (149 loc) · 5.15 KB
/
source.lex.regexp.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
149
150
151
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/Alhadis/language-grammars>
// and licensed `isc`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: [],
names: [],
patterns: [{include: '#main'}],
repository: {
alternation: {match: '\\|', name: 'keyword.operator.logical.or.lex'},
anchors: {
patterns: [
{match: '\\^', name: 'keyword.control.anchor.line-start.lex'},
{match: '\\$', name: 'keyword.control.anchor.line-end.lex'},
{
captures: {
1: {name: 'punctuation.definition.angle.bracket.begin.lex'},
2: {name: 'punctuation.definition.angle.bracket.end.lex'}
},
match: '(<<)EOF(>>)',
name: 'keyword.control.anchor.eof.lex'
}
]
},
class: {
begin: '(\\[)(\\^)?(-)?',
beginCaptures: {
1: {name: 'punctuation.definition.character-class.set.begin.lex'},
2: {name: 'keyword.operator.logical.not.lex'},
3: {name: 'constant.single.character.character-class.lex'}
},
end: '\\]',
endCaptures: {
0: {name: 'punctuation.definition.character-class.set.end.lex'}
},
name: 'meta.character-class.set.lex',
patterns: [
{include: '#escapes'},
{include: '#expressions'},
{match: '-(?!\\])', name: 'punctuation.separator.range.dash.lex'},
{match: '.', name: 'constant.single.character.character-class.lex'}
]
},
escapes: {
patterns: [
{
match: '\\\\[0-7]{3}',
name: 'constant.character.escape.codepoint.octal.lex'
},
{
match: '\\\\[xX][A-Fa-f0-9]{2}',
name: 'constant.character.escape.codepoint.hexadecimal.hex.lex'
},
{match: '\\\\.', name: 'constant.character.escape.lex'}
]
},
expansion: {
captures: {
1: {name: 'punctuation.definition.expansion.bracket.curly.begin.lex'},
2: {name: 'variable.parameter.reference.lex'},
3: {name: 'punctuation.definition.expansion.bracket.curly.end.lex'}
},
match: '(\\{)([^{}\\s]+)(\\})',
name: 'meta.expansion.lex'
},
expressions: {
captures: {
1: {name: 'punctuation.definition.character-class.set.begin.lex'},
2: {name: 'support.constant.posix-class.lex'},
3: {name: 'punctuation.definition.character-class.set.end.lex'}
},
match:
'(?x)\n(\\[:)\n(alnum|alpha|blank|cntrl|digit|graph\n|lower|print|punct|space|upper|xdigit)\n(:\\])',
name: 'constant.language.posix.$2-char.character-class.lex'
},
lookahead: {match: '/', name: 'keyword.operator.logical.and.lookahead.lex'},
main: {
patterns: [
{include: '#wildcard'},
{include: '#alternation'},
{include: '#lookahead'},
{include: '#anchors'},
{include: '#start-condition'},
{include: '#quantifier'},
{include: '#string'},
{include: '#expansion'},
{include: '#quantifier-range'},
{include: '#class'},
{include: '#subpattern'},
{include: '#escapes'}
]
},
quantifier: {match: '[*+?]', name: 'keyword.operator.quantifier.lex'},
'quantifier-range': {
captures: {
1: {name: 'punctuation.definition.quantifier.bracket.curly.begin.lex'},
2: {name: 'keyword.operator.quantifier.min.lex'},
3: {name: 'punctuation.delimiter.comma.lex'},
4: {name: 'keyword.operator.quantifier.max.lex'},
5: {name: 'punctuation.delimiter.comma.lex'},
6: {name: 'keyword.operator.quantifier.max.lex'},
7: {name: 'punctuation.definition.quantifier.bracket.curly.end.lex'}
},
match: '({)(?:([0-9]+)(?:(,)([0-9]*))?|(,)([0-9]+))(})',
name: 'keyword.operator.quantifier.specific.lex'
},
'start-condition': {
begin: '<',
beginCaptures: {
0: {name: 'punctuation.definition.angle.bracket.begin.lex'}
},
end: '>|(?=$)',
endCaptures: {0: {name: 'punctuation.definition.angle.bracket.end.lex'}},
name: 'meta.start-condition.lex',
patterns: [
{match: '\\*', name: 'keyword.operator.wildcard.condition.lex'},
{match: ',', name: 'punctuation.delimiter.separator.comma.lex'},
{match: '[^<>*,\\s]+', name: 'constant.language.condition.name.lex'}
]
},
string: {
begin: '"',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.lex'}},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.lex'}},
name: 'string.quoted.double.lex',
patterns: [{include: '#escapes'}]
},
subpattern: {
begin: '\\(',
beginCaptures: {0: {name: 'punctuation.definition.group.begin.lex'}},
end: '\\)',
endCaptures: {0: {name: 'punctuation.definition.group.end.lex'}},
name: 'meta.group.regexp',
patterns: [{include: '#main'}]
},
wildcard: {
match: '\\.',
name: 'constant.character.wildcard.dot.match.any.lex'
}
},
scopeName: 'source.lex.regexp'
}
export default grammar