@mojir/lits 2.0.4 → 2.0.5
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 +25 -17
- package/dist/cli/src/Lits/Lits.d.ts +2 -3
- package/dist/cli/src/tokenizer/interface.d.ts +2 -2
- package/dist/index.esm.js +25 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +25 -17
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +25 -17
- package/dist/lits.iife.js.map +1 -1
- package/dist/src/Lits/Lits.d.ts +2 -3
- package/dist/src/tokenizer/interface.d.ts +2 -2
- package/dist/testFramework.esm.js +25 -17
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +25 -17
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
package/dist/testFramework.js
CHANGED
|
@@ -3125,7 +3125,7 @@ var mathNormalExpression = {
|
|
|
3125
3125
|
},
|
|
3126
3126
|
};
|
|
3127
3127
|
|
|
3128
|
-
var version = "2.0.
|
|
3128
|
+
var version = "2.0.5";
|
|
3129
3129
|
|
|
3130
3130
|
var uuidTemplate = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
3131
3131
|
var xyRegexp = /[xy]/g;
|
|
@@ -7347,14 +7347,22 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7347
7347
|
return parseReservedSymbol(this.tokenStream, this.parseState);
|
|
7348
7348
|
case 'PolNotation': {
|
|
7349
7349
|
this.parseState.algebraic = false;
|
|
7350
|
-
var
|
|
7350
|
+
var astNodes = [];
|
|
7351
7351
|
this.advance();
|
|
7352
7352
|
do {
|
|
7353
|
-
|
|
7353
|
+
astNodes.push(this.parseState.parseToken(this.tokenStream, this.parseState));
|
|
7354
7354
|
} while (!isEndNotationToken(this.peek()));
|
|
7355
7355
|
this.advance();
|
|
7356
7356
|
this.parseState.algebraic = true;
|
|
7357
|
-
|
|
7357
|
+
if (astNodes.length === 1) {
|
|
7358
|
+
return astNodes[0];
|
|
7359
|
+
}
|
|
7360
|
+
return {
|
|
7361
|
+
t: AstNodeType.SpecialExpression,
|
|
7362
|
+
n: 'do',
|
|
7363
|
+
p: astNodes,
|
|
7364
|
+
token: getTokenDebugData(token) && token,
|
|
7365
|
+
};
|
|
7358
7366
|
}
|
|
7359
7367
|
case 'AlgNotation': {
|
|
7360
7368
|
this.advance();
|
|
@@ -8775,10 +8783,9 @@ var Lits = /** @class */ (function () {
|
|
|
8775
8783
|
return analyze(ast, params);
|
|
8776
8784
|
};
|
|
8777
8785
|
Lits.prototype.tokenize = function (program, tokenizeParams) {
|
|
8778
|
-
var _a, _b;
|
|
8779
8786
|
if (tokenizeParams === void 0) { tokenizeParams = {}; }
|
|
8780
|
-
var debug =
|
|
8781
|
-
var algebraic =
|
|
8787
|
+
var debug = this.debug;
|
|
8788
|
+
var algebraic = this.algebraic;
|
|
8782
8789
|
return tokenize(program, __assign(__assign({}, tokenizeParams), { debug: debug, algebraic: algebraic }));
|
|
8783
8790
|
};
|
|
8784
8791
|
Lits.prototype.parse = function (tokenStream) {
|
|
@@ -8798,12 +8805,7 @@ var Lits = /** @class */ (function () {
|
|
|
8798
8805
|
var _a;
|
|
8799
8806
|
if (params === void 0) { params = {}; }
|
|
8800
8807
|
var fnName = 'FN_2eb7b316-471c-5bfa-90cb-d3dfd9164a59';
|
|
8801
|
-
var
|
|
8802
|
-
.map(function (_, index) {
|
|
8803
|
-
return "".concat(fnName, "_").concat(index);
|
|
8804
|
-
})
|
|
8805
|
-
.join(' ');
|
|
8806
|
-
var program = "(".concat(fnName, " ").concat(paramsString, ")");
|
|
8808
|
+
var program = this.generateApplyFunctionCall(fnName, fnParams);
|
|
8807
8809
|
var ast = this.generateAst(program, params);
|
|
8808
8810
|
var hostValues = fnParams.reduce(function (result, param, index) {
|
|
8809
8811
|
result["".concat(fnName, "_").concat(index)] = param;
|
|
@@ -8812,20 +8814,26 @@ var Lits = /** @class */ (function () {
|
|
|
8812
8814
|
params.values = __assign(__assign({}, params.values), hostValues);
|
|
8813
8815
|
return this.evaluate(ast, params);
|
|
8814
8816
|
};
|
|
8817
|
+
Lits.prototype.generateApplyFunctionCall = function (fnName, fnParams) {
|
|
8818
|
+
var paramsString = fnParams
|
|
8819
|
+
.map(function (_, index) {
|
|
8820
|
+
return "".concat(fnName, "_").concat(index);
|
|
8821
|
+
})
|
|
8822
|
+
.join(this.algebraic ? ', ' : ' ');
|
|
8823
|
+
return this.algebraic ? "".concat(fnName, "(").concat(paramsString, ")") : "(".concat(fnName, " ").concat(paramsString, ")");
|
|
8824
|
+
};
|
|
8815
8825
|
Lits.prototype.generateAst = function (program, params) {
|
|
8816
|
-
var _a
|
|
8826
|
+
var _a;
|
|
8817
8827
|
if (this.astCache) {
|
|
8818
8828
|
var cachedAst = this.astCache.get(program);
|
|
8819
8829
|
if (cachedAst)
|
|
8820
8830
|
return cachedAst;
|
|
8821
8831
|
}
|
|
8822
8832
|
var tokenStream = this.tokenize(program, {
|
|
8823
|
-
debug: (_a = params.debug) !== null && _a !== void 0 ? _a : this.debug,
|
|
8824
8833
|
filePath: params.filePath,
|
|
8825
|
-
algebraic: (_b = params.algebraic) !== null && _b !== void 0 ? _b : this.algebraic,
|
|
8826
8834
|
});
|
|
8827
8835
|
var ast = this.parse(tokenStream);
|
|
8828
|
-
(
|
|
8836
|
+
(_a = this.astCache) === null || _a === void 0 ? void 0 : _a.set(program, ast);
|
|
8829
8837
|
return ast;
|
|
8830
8838
|
};
|
|
8831
8839
|
return Lits;
|