@mojir/lits 2.1.11 → 2.1.12
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 +33 -19
- package/dist/cli/src/tokenizer/operators.d.ts +1 -1
- package/dist/index.esm.js +32 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +32 -18
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +32 -18
- package/dist/lits.iife.js.map +1 -1
- package/dist/src/tokenizer/operators.d.ts +1 -1
- package/dist/testFramework.esm.js +32 -18
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +32 -18
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const binaryOperators: readonly ["^", "*", "/", "%", "+", "-", "<<", ">>", ">>>", "++", "<", "<=", "≤", ">", ">=", "≥", "=", "!=", "≠", "&", "xor", "|", "&&", "||", "??", "|>"];
|
|
2
|
-
declare const symbolicOperators: readonly ["^", "*", "/", "%", "+", "-", "<<", ">>", ">>>", "++", "<", "<=", "≤", ">", ">=", "≥", "=", "!=", "≠", "&", "xor", "|", "&&", "||", "??", "|>", "->", "...", ".", ",", ":=", ";"];
|
|
2
|
+
declare const symbolicOperators: readonly ["^", "*", "/", "%", "+", "-", "<<", ">>", ">>>", "++", "<", "<=", "≤", ">", ">=", "≥", "=", "!=", "≠", "&", "xor", "|", "&&", "||", "??", "|>", "?", ":", "->", "...", ".", ",", ":=", ";"];
|
|
3
3
|
export declare function isFunctionOperator(operator: string): boolean;
|
|
4
4
|
export type SymbolicBinaryOperator = typeof binaryOperators[number];
|
|
5
5
|
export type SymbolicOperator = typeof symbolicOperators[number];
|
|
@@ -12877,6 +12877,8 @@ var binaryOperators = [
|
|
|
12877
12877
|
'|>', // pipe
|
|
12878
12878
|
];
|
|
12879
12879
|
var otherOperators = [
|
|
12880
|
+
'?', // conditional operator
|
|
12881
|
+
':', // conditional operator
|
|
12880
12882
|
'->', // lambda
|
|
12881
12883
|
'...', // rest
|
|
12882
12884
|
'.', // property accessor
|
|
@@ -12886,17 +12888,12 @@ var otherOperators = [
|
|
|
12886
12888
|
];
|
|
12887
12889
|
var symbolicOperators = __spreadArray(__spreadArray([], __read(binaryOperators), false), __read(otherOperators), false);
|
|
12888
12890
|
var nonFunctionOperators = [
|
|
12889
|
-
'??',
|
|
12890
|
-
'&&',
|
|
12891
|
-
'||',
|
|
12892
12891
|
'comment',
|
|
12893
12892
|
'cond',
|
|
12894
12893
|
'def',
|
|
12895
12894
|
'defined?',
|
|
12896
|
-
// 'defn',
|
|
12897
12895
|
'do',
|
|
12898
12896
|
'doseq',
|
|
12899
|
-
// 'fn',
|
|
12900
12897
|
'if',
|
|
12901
12898
|
'let',
|
|
12902
12899
|
'loop',
|
|
@@ -13474,8 +13471,9 @@ function untokenize(tokenStream) {
|
|
|
13474
13471
|
}, '');
|
|
13475
13472
|
}
|
|
13476
13473
|
|
|
13477
|
-
var exponentiationPrecedence =
|
|
13478
|
-
var binaryFunctionalOperatorPrecedence =
|
|
13474
|
+
var exponentiationPrecedence = 12;
|
|
13475
|
+
var binaryFunctionalOperatorPrecedence = 3;
|
|
13476
|
+
var conditionalOperatorPrecedence = 1;
|
|
13479
13477
|
var placeholderRegexp = /^\$([1-9]\d?)?$/;
|
|
13480
13478
|
function withSourceCodeInfo(node, sourceCodeInfo) {
|
|
13481
13479
|
if (sourceCodeInfo) {
|
|
@@ -13490,38 +13488,39 @@ function getPrecedence(operatorSign, sourceCodeInfo) {
|
|
|
13490
13488
|
case '*': // multiplication
|
|
13491
13489
|
case '/': // division
|
|
13492
13490
|
case '%': // remainder
|
|
13493
|
-
return
|
|
13491
|
+
return 11;
|
|
13494
13492
|
case '+': // addition
|
|
13495
13493
|
case '-': // subtraction
|
|
13496
|
-
return
|
|
13494
|
+
return 10;
|
|
13497
13495
|
case '<<': // left shift
|
|
13498
13496
|
case '>>': // signed right shift
|
|
13499
13497
|
case '>>>': // unsigned right shift
|
|
13500
|
-
return
|
|
13498
|
+
return 9;
|
|
13501
13499
|
case '++': // string concatenation
|
|
13502
|
-
return
|
|
13500
|
+
return 8;
|
|
13503
13501
|
case '<': // less than
|
|
13504
13502
|
case '<=': // less than or equal
|
|
13505
13503
|
case '≤': // less than or equal
|
|
13506
13504
|
case '>': // greater than
|
|
13507
13505
|
case '>=': // greater than or equal
|
|
13508
13506
|
case '≥': // greater than or equal
|
|
13509
|
-
return
|
|
13507
|
+
return 7;
|
|
13510
13508
|
case '=': // equal
|
|
13511
13509
|
case '!=': // not equal
|
|
13512
13510
|
case '≠': // not equal
|
|
13513
|
-
return
|
|
13511
|
+
return 6;
|
|
13514
13512
|
case '&': // bitwise AND
|
|
13515
13513
|
case 'xor': // bitwise XOR
|
|
13516
13514
|
case '|': // bitwise OR
|
|
13517
|
-
return
|
|
13515
|
+
return 5;
|
|
13518
13516
|
case '&&': // logical AND
|
|
13519
13517
|
case '||': // logical OR
|
|
13520
13518
|
case '??': // nullish coalescing
|
|
13521
|
-
return
|
|
13519
|
+
return 4;
|
|
13520
|
+
// leave room for binaryFunctionalOperatorPrecedence = 3
|
|
13522
13521
|
case '|>': // pipe
|
|
13523
|
-
return
|
|
13524
|
-
// leave room for
|
|
13522
|
+
return 2;
|
|
13523
|
+
// leave room for conditionalOperatorPrecedence = 1
|
|
13525
13524
|
/* v8 ignore next 2 */
|
|
13526
13525
|
default:
|
|
13527
13526
|
throw new LitsError("Unknown binary operator: ".concat(operatorSign), sourceCodeInfo);
|
|
@@ -13569,13 +13568,15 @@ function fromBinaryOperatorToNode(operator, symbolNode, left, right, sourceCodeI
|
|
|
13569
13568
|
case '||':
|
|
13570
13569
|
case '??':
|
|
13571
13570
|
return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes[operatorName], [left, right]]], sourceCodeInfo);
|
|
13572
|
-
/* v8 ignore next
|
|
13571
|
+
/* v8 ignore next 11 */
|
|
13573
13572
|
case '.':
|
|
13574
13573
|
case ';':
|
|
13575
13574
|
case ':=':
|
|
13576
13575
|
case ',':
|
|
13577
13576
|
case '->':
|
|
13578
13577
|
case '...':
|
|
13578
|
+
case '?':
|
|
13579
|
+
case ':':
|
|
13579
13580
|
throw new LitsError("Unknown binary operator: ".concat(operatorName), sourceCodeInfo);
|
|
13580
13581
|
default:
|
|
13581
13582
|
throw new LitsError("Unknown binary operator: ".concat(operatorName), sourceCodeInfo);
|
|
@@ -13691,6 +13692,19 @@ var Parser = /** @class */ (function () {
|
|
|
13691
13692
|
}
|
|
13692
13693
|
left = createNamedNormalExpressionNode(operatorSymbol, [left, right], operator[2]);
|
|
13693
13694
|
}
|
|
13695
|
+
else if ((operator === null || operator === void 0 ? void 0 : operator[1]) === '?') {
|
|
13696
|
+
if (conditionalOperatorPrecedence <= precedence) {
|
|
13697
|
+
break;
|
|
13698
|
+
}
|
|
13699
|
+
this.advance();
|
|
13700
|
+
var trueNode = this.parseExpression();
|
|
13701
|
+
if (!isOperatorToken(this.peek(), ':')) {
|
|
13702
|
+
throw new LitsError('Expected :', this.peekSourceCodeInfo());
|
|
13703
|
+
}
|
|
13704
|
+
this.advance();
|
|
13705
|
+
var falseNode = this.parseExpression();
|
|
13706
|
+
left = withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.if, [left, trueNode, falseNode]]], left[2]);
|
|
13707
|
+
}
|
|
13694
13708
|
else {
|
|
13695
13709
|
break;
|
|
13696
13710
|
}
|