@mojir/lits 2.1.28 → 2.1.29
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/dist/cli/cli.js +27 -27
- package/dist/cli/src/tokenizer/token.d.ts +3 -2
- package/dist/cli/src/tokenizer/tokenizers.d.ts +2 -2
- package/dist/index.esm.js +26 -26
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +26 -26
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +26 -26
- package/dist/lits.iife.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/tokenizer/token.d.ts +3 -2
- package/dist/src/tokenizer/tokenizers.d.ts +2 -2
- package/dist/testFramework.esm.js +26 -26
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +26 -26
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13346,7 +13346,7 @@ var tokenizeDocString = function (input, position) {
|
|
|
13346
13346
|
nextThreeChars = input.slice(position + length, position + length + 3);
|
|
13347
13347
|
}
|
|
13348
13348
|
if (!char) {
|
|
13349
|
-
|
|
13349
|
+
return [length, ['Error', value, undefined, "Unclosed doc string at position ".concat(position)]];
|
|
13350
13350
|
}
|
|
13351
13351
|
value += '"""'; // closing quote
|
|
13352
13352
|
return [length + 3, ['DocString', value]];
|
|
@@ -13373,7 +13373,7 @@ var tokenizeString = function (input, position) {
|
|
|
13373
13373
|
char = input[position + length];
|
|
13374
13374
|
}
|
|
13375
13375
|
if (!char) {
|
|
13376
|
-
|
|
13376
|
+
return [length, ['Error', value, undefined, "Unclosed string at position ".concat(position)]];
|
|
13377
13377
|
}
|
|
13378
13378
|
value += '"'; // closing quote
|
|
13379
13379
|
return [length + 1, ['String', value]];
|
|
@@ -13384,16 +13384,20 @@ var tokenizeRegexpShorthand = function (input, position) {
|
|
|
13384
13384
|
var _a = __read(tokenizeString(input, position + 1), 2), stringLength = _a[0], token = _a[1];
|
|
13385
13385
|
if (!token)
|
|
13386
13386
|
return NO_MATCH;
|
|
13387
|
+
if (token[0] === 'Error') {
|
|
13388
|
+
var errorToken = ['Error', "#".concat(token[1]), undefined, "Unclosed regexp at position ".concat(position)];
|
|
13389
|
+
return [stringLength + 1, errorToken];
|
|
13390
|
+
}
|
|
13387
13391
|
position += stringLength + 1;
|
|
13388
13392
|
var length = stringLength + 1;
|
|
13389
13393
|
var options = '';
|
|
13390
13394
|
while (input[position] === 'g' || input[position] === 'i') {
|
|
13391
|
-
if (options.includes(input[position])) {
|
|
13392
|
-
throw new LitsError("Duplicated regexp option \"".concat(input[position], "\" at position ").concat(position, "."), undefined);
|
|
13393
|
-
}
|
|
13394
13395
|
options += input[position];
|
|
13395
13396
|
length += 1;
|
|
13396
13397
|
position += 1;
|
|
13398
|
+
if (options.includes(input[position])) {
|
|
13399
|
+
return [length, ['Error', "#".concat(token[1]).concat(options), undefined, "Duplicated regexp option \"".concat(input[position], "\"")]];
|
|
13400
|
+
}
|
|
13397
13401
|
}
|
|
13398
13402
|
return [length, ['RegexpShorthand', "#".concat(token[1]).concat(options)]];
|
|
13399
13403
|
};
|
|
@@ -13437,7 +13441,7 @@ var tokenizeNumber = function (input, position) {
|
|
|
13437
13441
|
if (i === start) {
|
|
13438
13442
|
return NO_MATCH;
|
|
13439
13443
|
}
|
|
13440
|
-
|
|
13444
|
+
return [i - position + 1, ['Error', input.substring(position, i + 1), undefined, "Invalid number format at position ".concat(i + 1)]];
|
|
13441
13445
|
}
|
|
13442
13446
|
}
|
|
13443
13447
|
else if (char === '.') {
|
|
@@ -13445,7 +13449,7 @@ var tokenizeNumber = function (input, position) {
|
|
|
13445
13449
|
return NO_MATCH;
|
|
13446
13450
|
}
|
|
13447
13451
|
if (hasDecimalPoint || hasExponent) {
|
|
13448
|
-
|
|
13452
|
+
return [i - position + 1, ['Error', input.substring(position, i + 1), undefined, "Invalid number format at position ".concat(i + 1)]];
|
|
13449
13453
|
}
|
|
13450
13454
|
hasDecimalPoint = true;
|
|
13451
13455
|
}
|
|
@@ -13454,10 +13458,10 @@ var tokenizeNumber = function (input, position) {
|
|
|
13454
13458
|
return NO_MATCH;
|
|
13455
13459
|
}
|
|
13456
13460
|
if (hasExponent) {
|
|
13457
|
-
|
|
13461
|
+
return [i - position + 1, ['Error', input.substring(position, i + 1), undefined, "Invalid number format at position ".concat(i + 1)]];
|
|
13458
13462
|
}
|
|
13459
13463
|
if (input[i - 1] === '.' || input[i - 1] === '+' || input[i - 1] === '-') {
|
|
13460
|
-
|
|
13464
|
+
return [i - position + 1, ['Error', input.substring(position, i + 1), undefined, "Invalid number format at position ".concat(i + 1)]];
|
|
13461
13465
|
}
|
|
13462
13466
|
if (input[i + 1] === '+' || input[i + 1] === '-') {
|
|
13463
13467
|
i += 1;
|
|
@@ -13477,7 +13481,7 @@ var tokenizeNumber = function (input, position) {
|
|
|
13477
13481
|
}
|
|
13478
13482
|
var nextChar = input[i];
|
|
13479
13483
|
if (nextChar && nextChar !== ':' && !postNumberRegExp.test(nextChar)) {
|
|
13480
|
-
|
|
13484
|
+
return [i - position + 1, ['Error', input.substring(position, i + 1), undefined, "Invalid number format at position ".concat(i + 1)]];
|
|
13481
13485
|
}
|
|
13482
13486
|
return [length, ['Number', input.substring(position, i)]];
|
|
13483
13487
|
};
|
|
@@ -13527,7 +13531,7 @@ var tokenizeSymbol = function (input, position) {
|
|
|
13527
13531
|
var escaping = false;
|
|
13528
13532
|
while (char !== '\'' || escaping) {
|
|
13529
13533
|
if (char === undefined)
|
|
13530
|
-
|
|
13534
|
+
return [length_1, ['Error', value, undefined, "Unclosed quoted symbol at position ".concat(position)]];
|
|
13531
13535
|
length_1 += 1;
|
|
13532
13536
|
if (escaping) {
|
|
13533
13537
|
escaping = false;
|
|
@@ -13598,7 +13602,7 @@ var tokenizeMultiLineComment = function (input, position) {
|
|
|
13598
13602
|
length_2 += 1;
|
|
13599
13603
|
}
|
|
13600
13604
|
if (position + length_2 + 1 >= input.length) {
|
|
13601
|
-
|
|
13605
|
+
return [length_2, ['Error', value, undefined, "Unclosed multi-line comment at position ".concat(position)]];
|
|
13602
13606
|
}
|
|
13603
13607
|
value += '*/';
|
|
13604
13608
|
length_2 += 2;
|
|
@@ -13651,9 +13655,6 @@ function tokenize(input, debug, filePath) {
|
|
|
13651
13655
|
? createSourceCodeInfo(input, position, filePath)
|
|
13652
13656
|
: undefined;
|
|
13653
13657
|
var tokenDescriptor = getCurrentToken(input, position);
|
|
13654
|
-
if (!tokenDescriptor) {
|
|
13655
|
-
throw new LitsError("Unrecognized character '".concat(input[position], "'."), sourceCodeInfo);
|
|
13656
|
-
}
|
|
13657
13658
|
var _a = __read(tokenDescriptor, 2), count = _a[0], token = _a[1];
|
|
13658
13659
|
position += count;
|
|
13659
13660
|
if (token) {
|
|
@@ -13704,7 +13705,7 @@ function getCurrentToken(input, position) {
|
|
|
13704
13705
|
}
|
|
13705
13706
|
finally { if (e_1) throw e_1.error; }
|
|
13706
13707
|
}
|
|
13707
|
-
return
|
|
13708
|
+
return [1, ['Error', input[initialPosition], undefined, 'Unrecognized character']];
|
|
13708
13709
|
}
|
|
13709
13710
|
|
|
13710
13711
|
function isSymbolToken(token, symbolName) {
|
|
@@ -13992,6 +13993,11 @@ var Parser = /** @class */ (function () {
|
|
|
13992
13993
|
this.parseState.position += 1;
|
|
13993
13994
|
};
|
|
13994
13995
|
Parser.prototype.parse = function () {
|
|
13996
|
+
this.tokenStream.tokens.forEach(function (token) {
|
|
13997
|
+
if (token[0] === 'Error') {
|
|
13998
|
+
throw new LitsError(token[3], token[2]);
|
|
13999
|
+
}
|
|
14000
|
+
});
|
|
13995
14001
|
var nodes = [];
|
|
13996
14002
|
while (!this.isAtEnd()) {
|
|
13997
14003
|
nodes.push(this.parseExpression(0, true));
|
|
@@ -15058,20 +15064,14 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
15058
15064
|
this.suggestions = [];
|
|
15059
15065
|
this.suggestionIndex = null;
|
|
15060
15066
|
var partialProgram = this.originalProgram.slice(0, this.originalPosition);
|
|
15061
|
-
var tokenStream =
|
|
15062
|
-
try {
|
|
15063
|
-
tokenStream = lits.tokenize(partialProgram);
|
|
15064
|
-
}
|
|
15065
|
-
catch (_a) {
|
|
15066
|
-
// do nothing
|
|
15067
|
-
}
|
|
15068
|
-
if (!tokenStream) {
|
|
15069
|
-
return;
|
|
15070
|
-
}
|
|
15067
|
+
var tokenStream = lits.tokenize(partialProgram);
|
|
15071
15068
|
var lastToken = tokenStream.tokens.at(-1);
|
|
15072
15069
|
if (!lastToken) {
|
|
15073
15070
|
return;
|
|
15074
15071
|
}
|
|
15072
|
+
if (lastToken[0] === 'Error') {
|
|
15073
|
+
return;
|
|
15074
|
+
}
|
|
15075
15075
|
this.searchString = lastToken[1];
|
|
15076
15076
|
this.prefixProgram = this.originalProgram.slice(0, this.originalPosition - this.searchString.length);
|
|
15077
15077
|
this.suffixProgram = this.originalProgram.slice(this.prefixProgram.length + this.searchString.length);
|