@codingame/monaco-vscode-editor-api 25.1.2 → 26.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 +2 -2
- package/vscode/src/vs/editor/editor.api.d.ts +27 -2
- package/vscode/src/vs/editor/standalone/browser/colorizer.js +26 -20
- package/vscode/src/vs/editor/standalone/browser/standaloneEditor.js +46 -23
- package/vscode/src/vs/editor/standalone/browser/standaloneLanguages.js +32 -30
- package/vscode/src/vs/editor/standalone/browser/standaloneWebWorker.js +6 -7
- package/vscode/src/vs/editor/standalone/common/monarch/monarchCommon.js +15 -17
- package/vscode/src/vs/editor/standalone/common/monarch/monarchCompile.js +232 -167
- package/vscode/src/vs/editor/standalone/common/monarch/monarchLexer.js +148 -109
|
@@ -10,7 +10,9 @@ import { LanguageId, MetadataConsts } from '@codingame/monaco-vscode-api/vscode/
|
|
|
10
10
|
var MonarchTokenizer_1;
|
|
11
11
|
const CACHE_STACK_DEPTH = 5;
|
|
12
12
|
class MonarchStackElementFactory {
|
|
13
|
-
static {
|
|
13
|
+
static {
|
|
14
|
+
this._INSTANCE = ( new MonarchStackElementFactory(CACHE_STACK_DEPTH));
|
|
15
|
+
}
|
|
14
16
|
static create(parent, state) {
|
|
15
17
|
return this._INSTANCE.create(parent, state);
|
|
16
18
|
}
|
|
@@ -24,7 +26,7 @@ class MonarchStackElementFactory {
|
|
|
24
26
|
}
|
|
25
27
|
let stackElementId = MonarchStackElement.getStackElementId(parent);
|
|
26
28
|
if (stackElementId.length > 0) {
|
|
27
|
-
stackElementId +=
|
|
29
|
+
stackElementId += "|";
|
|
28
30
|
}
|
|
29
31
|
stackElementId += state;
|
|
30
32
|
let result = this._entries[stackElementId];
|
|
@@ -43,10 +45,10 @@ class MonarchStackElement {
|
|
|
43
45
|
this.depth = (this.parent ? this.parent.depth : 0) + 1;
|
|
44
46
|
}
|
|
45
47
|
static getStackElementId(element) {
|
|
46
|
-
let result =
|
|
48
|
+
let result = "";
|
|
47
49
|
while (element !== null) {
|
|
48
50
|
if (result.length > 0) {
|
|
49
|
-
result +=
|
|
51
|
+
result += "|";
|
|
50
52
|
}
|
|
51
53
|
result += element.state;
|
|
52
54
|
element = element.parent;
|
|
@@ -95,8 +97,7 @@ class EmbeddedLanguageData {
|
|
|
95
97
|
this.state = state;
|
|
96
98
|
}
|
|
97
99
|
equals(other) {
|
|
98
|
-
return (this.languageId === other.languageId
|
|
99
|
-
&& this.state.equals(other.state));
|
|
100
|
+
return (this.languageId === other.languageId && this.state.equals(other.state));
|
|
100
101
|
}
|
|
101
102
|
clone() {
|
|
102
103
|
const stateClone = this.state.clone();
|
|
@@ -107,7 +108,9 @@ class EmbeddedLanguageData {
|
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
class MonarchLineStateFactory {
|
|
110
|
-
static {
|
|
111
|
+
static {
|
|
112
|
+
this._INSTANCE = ( new MonarchLineStateFactory(CACHE_STACK_DEPTH));
|
|
113
|
+
}
|
|
111
114
|
static create(stack, embeddedLanguageData) {
|
|
112
115
|
return this._INSTANCE.create(stack, embeddedLanguageData);
|
|
113
116
|
}
|
|
@@ -184,16 +187,17 @@ class MonarchClassicTokensCollector {
|
|
|
184
187
|
const nestedLanguageTokenizationSupport = TokenizationRegistry.get(nestedLanguageId);
|
|
185
188
|
if (!nestedLanguageTokenizationSupport) {
|
|
186
189
|
this.enterLanguage(nestedLanguageId);
|
|
187
|
-
this.emit(offsetDelta,
|
|
190
|
+
this.emit(offsetDelta, "");
|
|
188
191
|
return embeddedModeState;
|
|
189
192
|
}
|
|
190
193
|
const nestedResult = nestedLanguageTokenizationSupport.tokenize(embeddedLanguageLine, hasEOL, embeddedModeState);
|
|
191
194
|
if (offsetDelta !== 0) {
|
|
192
195
|
for (const token of nestedResult.tokens) {
|
|
193
|
-
this._tokens.push(
|
|
196
|
+
this._tokens.push(
|
|
197
|
+
new Token(token.offset + offsetDelta, token.type, token.language)
|
|
198
|
+
);
|
|
194
199
|
}
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
200
|
+
} else {
|
|
197
201
|
this._tokens = this._tokens.concat(nestedResult.tokens);
|
|
198
202
|
}
|
|
199
203
|
this._lastTokenType = null;
|
|
@@ -257,7 +261,7 @@ class MonarchModernTokensCollector {
|
|
|
257
261
|
const nestedLanguageTokenizationSupport = TokenizationRegistry.get(nestedLanguageId);
|
|
258
262
|
if (!nestedLanguageTokenizationSupport) {
|
|
259
263
|
this.enterLanguage(nestedLanguageId);
|
|
260
|
-
this.emit(offsetDelta,
|
|
264
|
+
this.emit(offsetDelta, "");
|
|
261
265
|
return embeddedModeState;
|
|
262
266
|
}
|
|
263
267
|
const nestedResult = nestedLanguageTokenizationSupport.tokenizeEncoded(embeddedLanguageLine, hasEOL, embeddedModeState);
|
|
@@ -273,11 +277,21 @@ class MonarchModernTokensCollector {
|
|
|
273
277
|
return nestedResult.endState;
|
|
274
278
|
}
|
|
275
279
|
finalize(endState) {
|
|
276
|
-
return new EncodedTokenizationResult(
|
|
280
|
+
return new EncodedTokenizationResult(
|
|
281
|
+
MonarchModernTokensCollector._merge(this._prependTokens, this._tokens, null),
|
|
282
|
+
[],
|
|
283
|
+
endState
|
|
284
|
+
);
|
|
277
285
|
}
|
|
278
286
|
}
|
|
279
287
|
let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Disposable {
|
|
280
|
-
constructor(
|
|
288
|
+
constructor(
|
|
289
|
+
languageService,
|
|
290
|
+
standaloneThemeService,
|
|
291
|
+
languageId,
|
|
292
|
+
lexer,
|
|
293
|
+
_configurationService
|
|
294
|
+
) {
|
|
281
295
|
super();
|
|
282
296
|
this._configurationService = _configurationService;
|
|
283
297
|
this._languageService = languageService;
|
|
@@ -287,7 +301,7 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
|
|
|
287
301
|
this._embeddedLanguages = Object.create(null);
|
|
288
302
|
this.embeddedLoaded = Promise.resolve(undefined);
|
|
289
303
|
let emitting = false;
|
|
290
|
-
this._register(TokenizationRegistry.onDidChange(
|
|
304
|
+
this._register(TokenizationRegistry.onDidChange(e => {
|
|
291
305
|
if (emitting) {
|
|
292
306
|
return;
|
|
293
307
|
}
|
|
@@ -305,12 +319,12 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
|
|
|
305
319
|
emitting = false;
|
|
306
320
|
}
|
|
307
321
|
}));
|
|
308
|
-
this._maxTokenizationLineLength = this._configurationService.getValue(
|
|
322
|
+
this._maxTokenizationLineLength = this._configurationService.getValue("editor.maxTokenizationLineLength", {
|
|
309
323
|
overrideIdentifier: this._languageId
|
|
310
324
|
});
|
|
311
325
|
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
|
312
|
-
if (e.affectsConfiguration(
|
|
313
|
-
this._maxTokenizationLineLength = this._configurationService.getValue(
|
|
326
|
+
if (e.affectsConfiguration("editor.maxTokenizationLineLength")) {
|
|
327
|
+
this._maxTokenizationLineLength = this._configurationService.getValue("editor.maxTokenizationLineLength", {
|
|
314
328
|
overrideIdentifier: this._languageId
|
|
315
329
|
});
|
|
316
330
|
}
|
|
@@ -357,7 +371,10 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
|
|
|
357
371
|
}
|
|
358
372
|
tokenizeEncoded(line, hasEOL, lineState) {
|
|
359
373
|
if (line.length >= this._maxTokenizationLineLength) {
|
|
360
|
-
return nullTokenizeEncoded(
|
|
374
|
+
return nullTokenizeEncoded(
|
|
375
|
+
this._languageService.languageIdCodec.encodeLanguageId(this._languageId),
|
|
376
|
+
lineState
|
|
377
|
+
);
|
|
361
378
|
}
|
|
362
379
|
const tokensCollector = ( new MonarchModernTokensCollector(
|
|
363
380
|
this._languageService,
|
|
@@ -369,8 +386,7 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
|
|
|
369
386
|
_tokenize(line, hasEOL, lineState, collector) {
|
|
370
387
|
if (lineState.embeddedLanguageData) {
|
|
371
388
|
return this._nestedTokenize(line, hasEOL, lineState, 0, collector);
|
|
372
|
-
}
|
|
373
|
-
else {
|
|
389
|
+
} else {
|
|
374
390
|
return this._myTokenize(line, hasEOL, lineState, 0, collector);
|
|
375
391
|
}
|
|
376
392
|
}
|
|
@@ -379,20 +395,20 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
|
|
|
379
395
|
if (!rules) {
|
|
380
396
|
rules = findRules(this._lexer, state.stack.state);
|
|
381
397
|
if (!rules) {
|
|
382
|
-
throw createError(this._lexer,
|
|
398
|
+
throw createError(this._lexer, "tokenizer state is not defined: " + state.stack.state);
|
|
383
399
|
}
|
|
384
400
|
}
|
|
385
401
|
let popOffset = -1;
|
|
386
402
|
let hasEmbeddedPopRule = false;
|
|
387
403
|
for (const rule of rules) {
|
|
388
|
-
if (!isIAction(rule.action) || !(rule.action.nextEmbedded ===
|
|
404
|
+
if (!isIAction(rule.action) || !(rule.action.nextEmbedded === "@pop" || rule.action.hasEmbeddedEndInCases)) {
|
|
389
405
|
continue;
|
|
390
406
|
}
|
|
391
407
|
hasEmbeddedPopRule = true;
|
|
392
408
|
let regex = rule.resolveRegex(state.stack.state);
|
|
393
409
|
const regexSource = regex.source;
|
|
394
|
-
if (regexSource.substr(0, 4) ===
|
|
395
|
-
const flags = (regex.ignoreCase ?
|
|
410
|
+
if (regexSource.substr(0, 4) === "^(?:" && regexSource.substr(regexSource.length - 1, 1) === ")") {
|
|
411
|
+
const flags = (regex.ignoreCase ? "i" : "") + (regex.unicode ? "u" : "");
|
|
396
412
|
regex = ( new RegExp(regexSource.substr(4, regexSource.length - 5), flags));
|
|
397
413
|
}
|
|
398
414
|
const result = line.search(regex);
|
|
@@ -404,7 +420,10 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
|
|
|
404
420
|
}
|
|
405
421
|
}
|
|
406
422
|
if (!hasEmbeddedPopRule) {
|
|
407
|
-
throw createError(
|
|
423
|
+
throw createError(
|
|
424
|
+
this._lexer,
|
|
425
|
+
"no rule containing nextEmbedded: \"@pop\" in tokenizer embedded state: " + state.stack.state
|
|
426
|
+
);
|
|
408
427
|
}
|
|
409
428
|
return popOffset;
|
|
410
429
|
}
|
|
@@ -425,12 +444,12 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
|
|
|
425
444
|
if (rule) {
|
|
426
445
|
return rule.name;
|
|
427
446
|
}
|
|
428
|
-
return
|
|
447
|
+
return "(unknown)";
|
|
429
448
|
}
|
|
430
449
|
_myTokenize(lineWithoutLF, hasEOL, lineState, offsetDelta, tokensCollector) {
|
|
431
450
|
tokensCollector.enterLanguage(this._languageId);
|
|
432
451
|
const lineWithoutLFLength = lineWithoutLF.length;
|
|
433
|
-
const line = (hasEOL && this._lexer.includeLF ? lineWithoutLF +
|
|
452
|
+
const line = (hasEOL && this._lexer.includeLF ? lineWithoutLF + "\n" : lineWithoutLF);
|
|
434
453
|
const lineLength = line.length;
|
|
435
454
|
let embeddedLanguageData = lineState.embeddedLanguageData;
|
|
436
455
|
let stack = lineState.stack;
|
|
@@ -456,8 +475,7 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
|
|
|
456
475
|
if (groupMatching.groups.length === 0) {
|
|
457
476
|
groupMatching = null;
|
|
458
477
|
}
|
|
459
|
-
}
|
|
460
|
-
else {
|
|
478
|
+
} else {
|
|
461
479
|
if (!forceEvaluation && pos >= lineLength) {
|
|
462
480
|
break;
|
|
463
481
|
}
|
|
@@ -466,7 +484,7 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
|
|
|
466
484
|
if (!rules) {
|
|
467
485
|
rules = findRules(this._lexer, state);
|
|
468
486
|
if (!rules) {
|
|
469
|
-
throw createError(this._lexer,
|
|
487
|
+
throw createError(this._lexer, "tokenizer state is not defined: " + state);
|
|
470
488
|
}
|
|
471
489
|
}
|
|
472
490
|
const restOfLine = line.substr(pos);
|
|
@@ -482,8 +500,8 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
|
|
|
482
500
|
}
|
|
483
501
|
}
|
|
484
502
|
if (!matches) {
|
|
485
|
-
matches = [
|
|
486
|
-
matched =
|
|
503
|
+
matches = [""];
|
|
504
|
+
matched = "";
|
|
487
505
|
}
|
|
488
506
|
if (!action) {
|
|
489
507
|
if (pos < lineLength) {
|
|
@@ -500,118 +518,133 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
|
|
|
500
518
|
action = action.test(matched, matches, state, pos === lineLength);
|
|
501
519
|
}
|
|
502
520
|
let result = null;
|
|
503
|
-
if (typeof action ===
|
|
521
|
+
if (typeof action === "string" || Array.isArray(action)) {
|
|
504
522
|
result = action;
|
|
505
|
-
}
|
|
506
|
-
else if (action.group) {
|
|
523
|
+
} else if (action.group) {
|
|
507
524
|
result = action.group;
|
|
508
|
-
}
|
|
509
|
-
else if (action.token !== null && action.token !== undefined) {
|
|
525
|
+
} else if (action.token !== null && action.token !== undefined) {
|
|
510
526
|
if (action.tokenSubst) {
|
|
511
527
|
result = substituteMatches(this._lexer, action.token, matched, matches, state);
|
|
512
|
-
}
|
|
513
|
-
else {
|
|
528
|
+
} else {
|
|
514
529
|
result = action.token;
|
|
515
530
|
}
|
|
516
531
|
if (action.nextEmbedded) {
|
|
517
|
-
if (action.nextEmbedded ===
|
|
532
|
+
if (action.nextEmbedded === "@pop") {
|
|
518
533
|
if (!embeddedLanguageData) {
|
|
519
|
-
throw createError(this._lexer,
|
|
534
|
+
throw createError(this._lexer, "cannot pop embedded language if not inside one");
|
|
520
535
|
}
|
|
521
536
|
embeddedLanguageData = null;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
537
|
+
} else if (embeddedLanguageData) {
|
|
538
|
+
throw createError(
|
|
539
|
+
this._lexer,
|
|
540
|
+
"cannot enter embedded language from within an embedded language"
|
|
541
|
+
);
|
|
542
|
+
} else {
|
|
527
543
|
enteringEmbeddedLanguage = substituteMatches(this._lexer, action.nextEmbedded, matched, matches, state);
|
|
528
544
|
}
|
|
529
545
|
}
|
|
530
546
|
if (action.goBack) {
|
|
531
547
|
pos = Math.max(0, pos - action.goBack);
|
|
532
548
|
}
|
|
533
|
-
if (action.switchTo && typeof action.switchTo ===
|
|
549
|
+
if (action.switchTo && typeof action.switchTo === "string") {
|
|
534
550
|
let nextState = substituteMatches(this._lexer, action.switchTo, matched, matches, state);
|
|
535
|
-
if (nextState[0] ===
|
|
551
|
+
if (nextState[0] === "@") {
|
|
536
552
|
nextState = nextState.substr(1);
|
|
537
553
|
}
|
|
538
554
|
if (!findRules(this._lexer, nextState)) {
|
|
539
|
-
throw createError(
|
|
540
|
-
|
|
541
|
-
|
|
555
|
+
throw createError(
|
|
556
|
+
this._lexer,
|
|
557
|
+
"trying to switch to a state '" + nextState + "' that is undefined in rule: " + this._safeRuleName(rule)
|
|
558
|
+
);
|
|
559
|
+
} else {
|
|
542
560
|
stack = stack.switchTo(nextState);
|
|
543
561
|
}
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
else if (action.next) {
|
|
549
|
-
if (action.next === '@push') {
|
|
562
|
+
} else if (action.transform && typeof action.transform === "function") {
|
|
563
|
+
throw createError(this._lexer, "action.transform not supported");
|
|
564
|
+
} else if (action.next) {
|
|
565
|
+
if (action.next === "@push") {
|
|
550
566
|
if (stack.depth >= this._lexer.maxStack) {
|
|
551
|
-
throw createError(
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
567
|
+
throw createError(
|
|
568
|
+
this._lexer,
|
|
569
|
+
"maximum tokenizer stack size reached: [" + stack.state + "," + stack.parent.state + ",...]"
|
|
570
|
+
);
|
|
571
|
+
} else {
|
|
555
572
|
stack = stack.push(state);
|
|
556
573
|
}
|
|
557
|
-
}
|
|
558
|
-
else if (action.next === '@pop') {
|
|
574
|
+
} else if (action.next === "@pop") {
|
|
559
575
|
if (stack.depth <= 1) {
|
|
560
|
-
throw createError(
|
|
561
|
-
|
|
562
|
-
|
|
576
|
+
throw createError(
|
|
577
|
+
this._lexer,
|
|
578
|
+
"trying to pop an empty stack in rule: " + this._safeRuleName(rule)
|
|
579
|
+
);
|
|
580
|
+
} else {
|
|
563
581
|
stack = stack.pop();
|
|
564
582
|
}
|
|
565
|
-
}
|
|
566
|
-
else if (action.next === '@popall') {
|
|
583
|
+
} else if (action.next === "@popall") {
|
|
567
584
|
stack = stack.popall();
|
|
568
|
-
}
|
|
569
|
-
else {
|
|
585
|
+
} else {
|
|
570
586
|
let nextState = substituteMatches(this._lexer, action.next, matched, matches, state);
|
|
571
|
-
if (nextState[0] ===
|
|
587
|
+
if (nextState[0] === "@") {
|
|
572
588
|
nextState = nextState.substr(1);
|
|
573
589
|
}
|
|
574
590
|
if (!findRules(this._lexer, nextState)) {
|
|
575
|
-
throw createError(
|
|
576
|
-
|
|
577
|
-
|
|
591
|
+
throw createError(
|
|
592
|
+
this._lexer,
|
|
593
|
+
"trying to set a next state '" + nextState + "' that is undefined in rule: " + this._safeRuleName(rule)
|
|
594
|
+
);
|
|
595
|
+
} else {
|
|
578
596
|
stack = stack.push(nextState);
|
|
579
597
|
}
|
|
580
598
|
}
|
|
581
599
|
}
|
|
582
|
-
if (action.log && typeof (action.log) ===
|
|
583
|
-
log(
|
|
600
|
+
if (action.log && typeof (action.log) === "string") {
|
|
601
|
+
log(
|
|
602
|
+
this._lexer,
|
|
603
|
+
this._lexer.languageId + ": " + substituteMatches(this._lexer, action.log, matched, matches, state)
|
|
604
|
+
);
|
|
584
605
|
}
|
|
585
606
|
}
|
|
586
607
|
if (result === null) {
|
|
587
|
-
throw createError(
|
|
608
|
+
throw createError(
|
|
609
|
+
this._lexer,
|
|
610
|
+
"lexer rule has no well-defined action in rule: " + this._safeRuleName(rule)
|
|
611
|
+
);
|
|
588
612
|
}
|
|
589
|
-
const computeNewStateForEmbeddedLanguage =
|
|
590
|
-
const languageId = (this._languageService.getLanguageIdByLanguageName(enteringEmbeddedLanguage)
|
|
591
|
-
|| this._languageService.getLanguageIdByMimeType(enteringEmbeddedLanguage)
|
|
592
|
-
|| enteringEmbeddedLanguage);
|
|
613
|
+
const computeNewStateForEmbeddedLanguage = enteringEmbeddedLanguage => {
|
|
614
|
+
const languageId = (this._languageService.getLanguageIdByLanguageName(enteringEmbeddedLanguage) || this._languageService.getLanguageIdByMimeType(enteringEmbeddedLanguage) || enteringEmbeddedLanguage);
|
|
593
615
|
const embeddedLanguageData = this._getNestedEmbeddedLanguageData(languageId);
|
|
594
616
|
if (pos < lineLength) {
|
|
595
617
|
const restOfLine = lineWithoutLF.substr(pos);
|
|
596
|
-
return this._nestedTokenize(
|
|
597
|
-
|
|
598
|
-
|
|
618
|
+
return this._nestedTokenize(
|
|
619
|
+
restOfLine,
|
|
620
|
+
hasEOL,
|
|
621
|
+
MonarchLineStateFactory.create(stack, embeddedLanguageData),
|
|
622
|
+
offsetDelta + pos,
|
|
623
|
+
tokensCollector
|
|
624
|
+
);
|
|
625
|
+
} else {
|
|
599
626
|
return MonarchLineStateFactory.create(stack, embeddedLanguageData);
|
|
600
627
|
}
|
|
601
628
|
};
|
|
602
629
|
if (Array.isArray(result)) {
|
|
603
630
|
if (groupMatching && groupMatching.groups.length > 0) {
|
|
604
|
-
throw createError(this._lexer,
|
|
631
|
+
throw createError(this._lexer, "groups cannot be nested: " + this._safeRuleName(rule));
|
|
605
632
|
}
|
|
606
633
|
if (matches.length !== result.length + 1) {
|
|
607
|
-
throw createError(
|
|
634
|
+
throw createError(
|
|
635
|
+
this._lexer,
|
|
636
|
+
"matched number of groups does not match the number of actions in rule: " + this._safeRuleName(rule)
|
|
637
|
+
);
|
|
608
638
|
}
|
|
609
639
|
let totalLen = 0;
|
|
610
640
|
for (let i = 1; i < matches.length; i++) {
|
|
611
641
|
totalLen += matches[i].length;
|
|
612
642
|
}
|
|
613
643
|
if (totalLen !== matched.length) {
|
|
614
|
-
throw createError(
|
|
644
|
+
throw createError(
|
|
645
|
+
this._lexer,
|
|
646
|
+
"with groups, all characters should be matched in consecutive groups in rule: " + this._safeRuleName(rule)
|
|
647
|
+
);
|
|
615
648
|
}
|
|
616
649
|
groupMatching = {
|
|
617
650
|
rule: rule,
|
|
@@ -626,13 +659,12 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
|
|
|
626
659
|
}
|
|
627
660
|
pos -= matched.length;
|
|
628
661
|
continue;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
if (result === '@rematch') {
|
|
662
|
+
} else {
|
|
663
|
+
if (result === "@rematch") {
|
|
632
664
|
pos -= matched.length;
|
|
633
|
-
matched =
|
|
665
|
+
matched = "";
|
|
634
666
|
matches = null;
|
|
635
|
-
result =
|
|
667
|
+
result = "";
|
|
636
668
|
if (enteringEmbeddedLanguage !== null) {
|
|
637
669
|
return computeNewStateForEmbeddedLanguage(enteringEmbeddedLanguage);
|
|
638
670
|
}
|
|
@@ -640,22 +672,26 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
|
|
|
640
672
|
if (matched.length === 0) {
|
|
641
673
|
if (lineLength === 0 || stackLen0 !== stack.depth || state !== stack.state || (!groupMatching ? 0 : groupMatching.groups.length) !== groupLen0) {
|
|
642
674
|
continue;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
|
|
675
|
+
} else {
|
|
676
|
+
throw createError(
|
|
677
|
+
this._lexer,
|
|
678
|
+
"no progress in tokenizer in rule: " + this._safeRuleName(rule)
|
|
679
|
+
);
|
|
646
680
|
}
|
|
647
681
|
}
|
|
648
682
|
let tokenType = null;
|
|
649
|
-
if (isString(result) && result.indexOf(
|
|
650
|
-
const rest = result.substr(
|
|
683
|
+
if (isString(result) && result.indexOf("@brackets") === 0) {
|
|
684
|
+
const rest = result.substr("@brackets".length);
|
|
651
685
|
const bracket = findBracket(this._lexer, matched);
|
|
652
686
|
if (!bracket) {
|
|
653
|
-
throw createError(
|
|
687
|
+
throw createError(
|
|
688
|
+
this._lexer,
|
|
689
|
+
"@brackets token returned but no bracket defined as: " + matched
|
|
690
|
+
);
|
|
654
691
|
}
|
|
655
692
|
tokenType = sanitize(bracket.token + rest);
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
const token = (result === '' ? '' : result + this._lexer.tokenPostfix);
|
|
693
|
+
} else {
|
|
694
|
+
const token = (result === "" ? "" : result + this._lexer.tokenPostfix);
|
|
659
695
|
tokenType = sanitize(token);
|
|
660
696
|
}
|
|
661
697
|
if (pos0 < lineWithoutLFLength) {
|
|
@@ -684,9 +720,7 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
|
|
|
684
720
|
return ( new EmbeddedLanguageData(languageId, NullState));
|
|
685
721
|
}
|
|
686
722
|
};
|
|
687
|
-
MonarchTokenizer = MonarchTokenizer_1 = ( __decorate([
|
|
688
|
-
( __param(4, IConfigurationService))
|
|
689
|
-
], MonarchTokenizer));
|
|
723
|
+
MonarchTokenizer = MonarchTokenizer_1 = ( __decorate([( __param(4, IConfigurationService))], MonarchTokenizer));
|
|
690
724
|
function findBracket(lexer, matched) {
|
|
691
725
|
if (!matched) {
|
|
692
726
|
return null;
|
|
@@ -695,10 +729,15 @@ function findBracket(lexer, matched) {
|
|
|
695
729
|
const brackets = lexer.brackets;
|
|
696
730
|
for (const bracket of brackets) {
|
|
697
731
|
if (bracket.open === matched) {
|
|
698
|
-
return {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
732
|
+
return {
|
|
733
|
+
token: bracket.token,
|
|
734
|
+
bracketType: MonarchBracket.Open
|
|
735
|
+
};
|
|
736
|
+
} else if (bracket.close === matched) {
|
|
737
|
+
return {
|
|
738
|
+
token: bracket.token,
|
|
739
|
+
bracketType: MonarchBracket.Close
|
|
740
|
+
};
|
|
702
741
|
}
|
|
703
742
|
}
|
|
704
743
|
return null;
|