@codingame/monaco-vscode-api 2.0.0-rework-ci.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/services.js +0 -1
- package/editor.api.d.ts +0 -8
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/colors.js +0 -7
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/diffEditorItemTemplate.js +0 -199
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorViewModel.js +0 -62
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorWidget.js +0 -59
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorWidgetImpl.js +0 -225
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/objectPool.js +0 -46
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/style.css.js +0 -4
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/utils.js +0 -11
- package/vscode/src/vs/editor/editor.api.js +0 -49
- package/vscode/src/vs/editor/standalone/browser/colorizer.js +0 -174
- package/vscode/src/vs/editor/standalone/browser/standalone-tokens.css.js +0 -4
- package/vscode/src/vs/editor/standalone/browser/standaloneEditor.js +0 -342
- package/vscode/src/vs/editor/standalone/browser/standaloneLanguages.js +0 -425
- package/vscode/src/vs/editor/standalone/common/monarch/monarchCommon.js +0 -88
- package/vscode/src/vs/editor/standalone/common/monarch/monarchCompile.js +0 -446
- package/vscode/src/vs/editor/standalone/common/monarch/monarchLexer.js +0 -703
|
@@ -1,446 +0,0 @@
|
|
|
1
|
-
import { createError, fixCase, empty, stateExists, substituteMatches } from './monarchCommon.js';
|
|
2
|
-
function isArrayOf(elemType, obj) {
|
|
3
|
-
if (!obj) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
if (!(Array.isArray(obj))) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
for (const el of obj) {
|
|
10
|
-
if (!(elemType(el))) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
function bool(prop, defValue) {
|
|
17
|
-
if (typeof prop === 'boolean') {
|
|
18
|
-
return prop;
|
|
19
|
-
}
|
|
20
|
-
return defValue;
|
|
21
|
-
}
|
|
22
|
-
function string(prop, defValue) {
|
|
23
|
-
if (typeof (prop) === 'string') {
|
|
24
|
-
return prop;
|
|
25
|
-
}
|
|
26
|
-
return defValue;
|
|
27
|
-
}
|
|
28
|
-
function arrayToHash(array) {
|
|
29
|
-
const result = {};
|
|
30
|
-
for (const e of array) {
|
|
31
|
-
result[e] = true;
|
|
32
|
-
}
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
function createKeywordMatcher(arr, caseInsensitive = false) {
|
|
36
|
-
if (caseInsensitive) {
|
|
37
|
-
arr = ( arr.map(function (x) { return x.toLowerCase(); }));
|
|
38
|
-
}
|
|
39
|
-
const hash = arrayToHash(arr);
|
|
40
|
-
if (caseInsensitive) {
|
|
41
|
-
return function (word) {
|
|
42
|
-
return hash[word.toLowerCase()] !== undefined && hash.hasOwnProperty(word.toLowerCase());
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
return function (word) {
|
|
47
|
-
return hash[word] !== undefined && hash.hasOwnProperty(word);
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function compileRegExp(lexer, str) {
|
|
52
|
-
str = str.replace(/@@/g, `\x01`);
|
|
53
|
-
let n = 0;
|
|
54
|
-
let hadExpansion;
|
|
55
|
-
do {
|
|
56
|
-
hadExpansion = false;
|
|
57
|
-
str = str.replace(/@(\w+)/g, function (s, attr) {
|
|
58
|
-
hadExpansion = true;
|
|
59
|
-
let sub = '';
|
|
60
|
-
if (typeof (lexer[attr]) === 'string') {
|
|
61
|
-
sub = lexer[attr];
|
|
62
|
-
}
|
|
63
|
-
else if (lexer[attr] && lexer[attr] instanceof RegExp) {
|
|
64
|
-
sub = lexer[attr].source;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
if (lexer[attr] === undefined) {
|
|
68
|
-
throw createError(lexer, 'language definition does not contain attribute \'' + attr + '\', used at: ' + str);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
throw createError(lexer, 'attribute reference \'' + attr + '\' must be a string, used at: ' + str);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return (empty(sub) ? '' : '(?:' + sub + ')');
|
|
75
|
-
});
|
|
76
|
-
n++;
|
|
77
|
-
} while (hadExpansion && n < 5);
|
|
78
|
-
str = str.replace(/\x01/g, '@');
|
|
79
|
-
const flags = (lexer.ignoreCase ? 'i' : '') + (lexer.unicode ? 'u' : '');
|
|
80
|
-
return ( new RegExp(str, flags));
|
|
81
|
-
}
|
|
82
|
-
function selectScrutinee(id, matches, state, num) {
|
|
83
|
-
if (num < 0) {
|
|
84
|
-
return id;
|
|
85
|
-
}
|
|
86
|
-
if (num < matches.length) {
|
|
87
|
-
return matches[num];
|
|
88
|
-
}
|
|
89
|
-
if (num >= 100) {
|
|
90
|
-
num = num - 100;
|
|
91
|
-
const parts = state.split('.');
|
|
92
|
-
parts.unshift(state);
|
|
93
|
-
if (num < parts.length) {
|
|
94
|
-
return parts[num];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
function createGuard(lexer, ruleName, tkey, val) {
|
|
100
|
-
let scrut = -1;
|
|
101
|
-
let oppat = tkey;
|
|
102
|
-
let matches = tkey.match(/^\$(([sS]?)(\d\d?)|#)(.*)$/);
|
|
103
|
-
if (matches) {
|
|
104
|
-
if (matches[3]) {
|
|
105
|
-
scrut = parseInt(matches[3]);
|
|
106
|
-
if (matches[2]) {
|
|
107
|
-
scrut = scrut + 100;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
oppat = matches[4];
|
|
111
|
-
}
|
|
112
|
-
let op = '~';
|
|
113
|
-
let pat = oppat;
|
|
114
|
-
if (!oppat || oppat.length === 0) {
|
|
115
|
-
op = '!=';
|
|
116
|
-
pat = '';
|
|
117
|
-
}
|
|
118
|
-
else if (/^\w*$/.test(pat)) {
|
|
119
|
-
op = '==';
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
matches = oppat.match(/^(@|!@|~|!~|==|!=)(.*)$/);
|
|
123
|
-
if (matches) {
|
|
124
|
-
op = matches[1];
|
|
125
|
-
pat = matches[2];
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
let tester;
|
|
129
|
-
if ((op === '~' || op === '!~') && /^(\w|\|)*$/.test(pat)) {
|
|
130
|
-
const inWords = createKeywordMatcher(pat.split('|'), lexer.ignoreCase);
|
|
131
|
-
tester = function (s) { return (op === '~' ? inWords(s) : !inWords(s)); };
|
|
132
|
-
}
|
|
133
|
-
else if (op === '@' || op === '!@') {
|
|
134
|
-
const words = lexer[pat];
|
|
135
|
-
if (!words) {
|
|
136
|
-
throw createError(lexer, 'the @ match target \'' + pat + '\' is not defined, in rule: ' + ruleName);
|
|
137
|
-
}
|
|
138
|
-
if (!(isArrayOf(function (elem) { return (typeof (elem) === 'string'); }, words))) {
|
|
139
|
-
throw createError(lexer, 'the @ match target \'' + pat + '\' must be an array of strings, in rule: ' + ruleName);
|
|
140
|
-
}
|
|
141
|
-
const inWords = createKeywordMatcher(words, lexer.ignoreCase);
|
|
142
|
-
tester = function (s) { return (op === '@' ? inWords(s) : !inWords(s)); };
|
|
143
|
-
}
|
|
144
|
-
else if (op === '~' || op === '!~') {
|
|
145
|
-
if (pat.indexOf('$') < 0) {
|
|
146
|
-
const re = compileRegExp(lexer, '^' + pat + '$');
|
|
147
|
-
tester = function (s) { return (op === '~' ? re.test(s) : !re.test(s)); };
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
tester = function (s, id, matches, state) {
|
|
151
|
-
const re = compileRegExp(lexer, '^' + substituteMatches(lexer, pat, id, matches, state) + '$');
|
|
152
|
-
return re.test(s);
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
if (pat.indexOf('$') < 0) {
|
|
158
|
-
const patx = fixCase(lexer, pat);
|
|
159
|
-
tester = function (s) { return (op === '==' ? s === patx : s !== patx); };
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
const patx = fixCase(lexer, pat);
|
|
163
|
-
tester = function (s, id, matches, state, eos) {
|
|
164
|
-
const patexp = substituteMatches(lexer, patx, id, matches, state);
|
|
165
|
-
return (op === '==' ? s === patexp : s !== patexp);
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
if (scrut === -1) {
|
|
170
|
-
return {
|
|
171
|
-
name: tkey, value: val, test: function (id, matches, state, eos) {
|
|
172
|
-
return tester(id, id, matches, state, eos);
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
return {
|
|
178
|
-
name: tkey, value: val, test: function (id, matches, state, eos) {
|
|
179
|
-
const scrutinee = selectScrutinee(id, matches, state, scrut);
|
|
180
|
-
return tester(!scrutinee ? '' : scrutinee, id, matches, state, eos);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
function compileAction(lexer, ruleName, action) {
|
|
186
|
-
if (!action) {
|
|
187
|
-
return { token: '' };
|
|
188
|
-
}
|
|
189
|
-
else if (typeof (action) === 'string') {
|
|
190
|
-
return action;
|
|
191
|
-
}
|
|
192
|
-
else if (action.token || action.token === '') {
|
|
193
|
-
if (typeof (action.token) !== 'string') {
|
|
194
|
-
throw createError(lexer, 'a \'token\' attribute must be of type string, in rule: ' + ruleName);
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
const newAction = { token: action.token };
|
|
198
|
-
if (action.token.indexOf('$') >= 0) {
|
|
199
|
-
newAction.tokenSubst = true;
|
|
200
|
-
}
|
|
201
|
-
if (typeof (action.bracket) === 'string') {
|
|
202
|
-
if (action.bracket === '@open') {
|
|
203
|
-
newAction.bracket = 1 ;
|
|
204
|
-
}
|
|
205
|
-
else if (action.bracket === '@close') {
|
|
206
|
-
newAction.bracket = -1 ;
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
throw createError(lexer, 'a \'bracket\' attribute must be either \'@open\' or \'@close\', in rule: ' + ruleName);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
if (action.next) {
|
|
213
|
-
if (typeof (action.next) !== 'string') {
|
|
214
|
-
throw createError(lexer, 'the next state must be a string value in rule: ' + ruleName);
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
let next = action.next;
|
|
218
|
-
if (!/^(@pop|@push|@popall)$/.test(next)) {
|
|
219
|
-
if (next[0] === '@') {
|
|
220
|
-
next = next.substr(1);
|
|
221
|
-
}
|
|
222
|
-
if (next.indexOf('$') < 0) {
|
|
223
|
-
if (!stateExists(lexer, substituteMatches(lexer, next, '', [], ''))) {
|
|
224
|
-
throw createError(lexer, 'the next state \'' + action.next + '\' is not defined in rule: ' + ruleName);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
newAction.next = next;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
if (typeof (action.goBack) === 'number') {
|
|
232
|
-
newAction.goBack = action.goBack;
|
|
233
|
-
}
|
|
234
|
-
if (typeof (action.switchTo) === 'string') {
|
|
235
|
-
newAction.switchTo = action.switchTo;
|
|
236
|
-
}
|
|
237
|
-
if (typeof (action.log) === 'string') {
|
|
238
|
-
newAction.log = action.log;
|
|
239
|
-
}
|
|
240
|
-
if (typeof (action.nextEmbedded) === 'string') {
|
|
241
|
-
newAction.nextEmbedded = action.nextEmbedded;
|
|
242
|
-
lexer.usesEmbedded = true;
|
|
243
|
-
}
|
|
244
|
-
return newAction;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
else if (Array.isArray(action)) {
|
|
248
|
-
const results = [];
|
|
249
|
-
for (let i = 0, len = action.length; i < len; i++) {
|
|
250
|
-
results[i] = compileAction(lexer, ruleName, action[i]);
|
|
251
|
-
}
|
|
252
|
-
return { group: results };
|
|
253
|
-
}
|
|
254
|
-
else if (action.cases) {
|
|
255
|
-
const cases = [];
|
|
256
|
-
for (const tkey in action.cases) {
|
|
257
|
-
if (action.cases.hasOwnProperty(tkey)) {
|
|
258
|
-
const val = compileAction(lexer, ruleName, action.cases[tkey]);
|
|
259
|
-
if (tkey === '@default' || tkey === '@' || tkey === '') {
|
|
260
|
-
cases.push({ test: undefined, value: val, name: tkey });
|
|
261
|
-
}
|
|
262
|
-
else if (tkey === '@eos') {
|
|
263
|
-
cases.push({ test: function (id, matches, state, eos) { return eos; }, value: val, name: tkey });
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
cases.push(createGuard(lexer, ruleName, tkey, val));
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
const def = lexer.defaultToken;
|
|
271
|
-
return {
|
|
272
|
-
test: function (id, matches, state, eos) {
|
|
273
|
-
for (const _case of cases) {
|
|
274
|
-
const didmatch = (!_case.test || _case.test(id, matches, state, eos));
|
|
275
|
-
if (didmatch) {
|
|
276
|
-
return _case.value;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
return def;
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
else {
|
|
284
|
-
throw createError(lexer, 'an action must be a string, an object with a \'token\' or \'cases\' attribute, or an array of actions; in rule: ' + ruleName);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
class Rule {
|
|
288
|
-
constructor(name) {
|
|
289
|
-
this.regex = ( new RegExp(''));
|
|
290
|
-
this.action = { token: '' };
|
|
291
|
-
this.matchOnlyAtLineStart = false;
|
|
292
|
-
this.name = '';
|
|
293
|
-
this.name = name;
|
|
294
|
-
}
|
|
295
|
-
setRegex(lexer, re) {
|
|
296
|
-
let sregex;
|
|
297
|
-
if (typeof (re) === 'string') {
|
|
298
|
-
sregex = re;
|
|
299
|
-
}
|
|
300
|
-
else if (re instanceof RegExp) {
|
|
301
|
-
sregex = re.source;
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
throw createError(lexer, 'rules must start with a match string or regular expression: ' + this.name);
|
|
305
|
-
}
|
|
306
|
-
this.matchOnlyAtLineStart = (sregex.length > 0 && sregex[0] === '^');
|
|
307
|
-
this.name = this.name + ': ' + sregex;
|
|
308
|
-
this.regex = compileRegExp(lexer, '^(?:' + (this.matchOnlyAtLineStart ? sregex.substr(1) : sregex) + ')');
|
|
309
|
-
}
|
|
310
|
-
setAction(lexer, act) {
|
|
311
|
-
this.action = compileAction(lexer, this.name, act);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
function compile(languageId, json) {
|
|
315
|
-
if (!json || typeof (json) !== 'object') {
|
|
316
|
-
throw new Error('Monarch: expecting a language definition object');
|
|
317
|
-
}
|
|
318
|
-
const lexer = {};
|
|
319
|
-
lexer.languageId = languageId;
|
|
320
|
-
lexer.includeLF = bool(json.includeLF, false);
|
|
321
|
-
lexer.noThrow = false;
|
|
322
|
-
lexer.maxStack = 100;
|
|
323
|
-
lexer.start = (typeof json.start === 'string' ? json.start : null);
|
|
324
|
-
lexer.ignoreCase = bool(json.ignoreCase, false);
|
|
325
|
-
lexer.unicode = bool(json.unicode, false);
|
|
326
|
-
lexer.tokenPostfix = string(json.tokenPostfix, '.' + lexer.languageId);
|
|
327
|
-
lexer.defaultToken = string(json.defaultToken, 'source');
|
|
328
|
-
lexer.usesEmbedded = false;
|
|
329
|
-
const lexerMin = json;
|
|
330
|
-
lexerMin.languageId = languageId;
|
|
331
|
-
lexerMin.includeLF = lexer.includeLF;
|
|
332
|
-
lexerMin.ignoreCase = lexer.ignoreCase;
|
|
333
|
-
lexerMin.unicode = lexer.unicode;
|
|
334
|
-
lexerMin.noThrow = lexer.noThrow;
|
|
335
|
-
lexerMin.usesEmbedded = lexer.usesEmbedded;
|
|
336
|
-
lexerMin.stateNames = json.tokenizer;
|
|
337
|
-
lexerMin.defaultToken = lexer.defaultToken;
|
|
338
|
-
function addRules(state, newrules, rules) {
|
|
339
|
-
for (const rule of rules) {
|
|
340
|
-
let include = rule.include;
|
|
341
|
-
if (include) {
|
|
342
|
-
if (typeof (include) !== 'string') {
|
|
343
|
-
throw createError(lexer, 'an \'include\' attribute must be a string at: ' + state);
|
|
344
|
-
}
|
|
345
|
-
if (include[0] === '@') {
|
|
346
|
-
include = include.substr(1);
|
|
347
|
-
}
|
|
348
|
-
if (!json.tokenizer[include]) {
|
|
349
|
-
throw createError(lexer, 'include target \'' + include + '\' is not defined at: ' + state);
|
|
350
|
-
}
|
|
351
|
-
addRules(state + '.' + include, newrules, json.tokenizer[include]);
|
|
352
|
-
}
|
|
353
|
-
else {
|
|
354
|
-
const newrule = ( new Rule(state));
|
|
355
|
-
if (Array.isArray(rule) && rule.length >= 1 && rule.length <= 3) {
|
|
356
|
-
newrule.setRegex(lexerMin, rule[0]);
|
|
357
|
-
if (rule.length >= 3) {
|
|
358
|
-
if (typeof (rule[1]) === 'string') {
|
|
359
|
-
newrule.setAction(lexerMin, { token: rule[1], next: rule[2] });
|
|
360
|
-
}
|
|
361
|
-
else if (typeof (rule[1]) === 'object') {
|
|
362
|
-
const rule1 = rule[1];
|
|
363
|
-
rule1.next = rule[2];
|
|
364
|
-
newrule.setAction(lexerMin, rule1);
|
|
365
|
-
}
|
|
366
|
-
else {
|
|
367
|
-
throw createError(lexer, 'a next state as the last element of a rule can only be given if the action is either an object or a string, at: ' + state);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
else {
|
|
371
|
-
newrule.setAction(lexerMin, rule[1]);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
if (!rule.regex) {
|
|
376
|
-
throw createError(lexer, 'a rule must either be an array, or an object with a \'regex\' or \'include\' field at: ' + state);
|
|
377
|
-
}
|
|
378
|
-
if (rule.name) {
|
|
379
|
-
if (typeof rule.name === 'string') {
|
|
380
|
-
newrule.name = rule.name;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
if (rule.matchOnlyAtStart) {
|
|
384
|
-
newrule.matchOnlyAtLineStart = bool(rule.matchOnlyAtLineStart, false);
|
|
385
|
-
}
|
|
386
|
-
newrule.setRegex(lexerMin, rule.regex);
|
|
387
|
-
newrule.setAction(lexerMin, rule.action);
|
|
388
|
-
}
|
|
389
|
-
newrules.push(newrule);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
if (!json.tokenizer || typeof (json.tokenizer) !== 'object') {
|
|
394
|
-
throw createError(lexer, 'a language definition must define the \'tokenizer\' attribute as an object');
|
|
395
|
-
}
|
|
396
|
-
lexer.tokenizer = [];
|
|
397
|
-
for (const key in json.tokenizer) {
|
|
398
|
-
if (json.tokenizer.hasOwnProperty(key)) {
|
|
399
|
-
if (!lexer.start) {
|
|
400
|
-
lexer.start = key;
|
|
401
|
-
}
|
|
402
|
-
const rules = json.tokenizer[key];
|
|
403
|
-
lexer.tokenizer[key] = ( new Array());
|
|
404
|
-
addRules('tokenizer.' + key, lexer.tokenizer[key], rules);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
lexer.usesEmbedded = lexerMin.usesEmbedded;
|
|
408
|
-
if (json.brackets) {
|
|
409
|
-
if (!(Array.isArray(json.brackets))) {
|
|
410
|
-
throw createError(lexer, 'the \'brackets\' attribute must be defined as an array');
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
else {
|
|
414
|
-
json.brackets = [
|
|
415
|
-
{ open: '{', close: '}', token: 'delimiter.curly' },
|
|
416
|
-
{ open: '[', close: ']', token: 'delimiter.square' },
|
|
417
|
-
{ open: '(', close: ')', token: 'delimiter.parenthesis' },
|
|
418
|
-
{ open: '<', close: '>', token: 'delimiter.angle' }
|
|
419
|
-
];
|
|
420
|
-
}
|
|
421
|
-
const brackets = [];
|
|
422
|
-
for (const el of json.brackets) {
|
|
423
|
-
let desc = el;
|
|
424
|
-
if (desc && Array.isArray(desc) && desc.length === 3) {
|
|
425
|
-
desc = { token: desc[2], open: desc[0], close: desc[1] };
|
|
426
|
-
}
|
|
427
|
-
if (desc.open === desc.close) {
|
|
428
|
-
throw createError(lexer, 'open and close brackets in a \'brackets\' attribute must be different: ' + desc.open +
|
|
429
|
-
'\n hint: use the \'bracket\' attribute if matching on equal brackets is required.');
|
|
430
|
-
}
|
|
431
|
-
if (typeof desc.open === 'string' && typeof desc.token === 'string' && typeof desc.close === 'string') {
|
|
432
|
-
brackets.push({
|
|
433
|
-
token: desc.token + lexer.tokenPostfix,
|
|
434
|
-
open: fixCase(lexer, desc.open),
|
|
435
|
-
close: fixCase(lexer, desc.close)
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
else {
|
|
439
|
-
throw createError(lexer, 'every element in the \'brackets\' array must be a \'{open,close,token}\' object or array');
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
lexer.brackets = brackets;
|
|
443
|
-
lexer.noThrow = true;
|
|
444
|
-
return lexer;
|
|
445
|
-
}
|
|
446
|
-
export { compile };
|