@mojir/lits 2.0.20 → 2.0.22
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 +26 -16
- package/dist/cli/src/Lits/Lits.d.ts +3 -1
- package/dist/cli/src/tokenizer/minifyTokenStream.d.ts +4 -0
- package/dist/index.esm.js +25 -15
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +25 -15
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +25 -15
- package/dist/lits.iife.js.map +1 -1
- package/dist/src/Lits/Lits.d.ts +3 -1
- package/dist/src/tokenizer/minifyTokenStream.d.ts +4 -0
- package/dist/testFramework.esm.js +25 -15
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +25 -15
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/cli.js
CHANGED
|
@@ -92,7 +92,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
92
92
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
var version = "2.0.
|
|
95
|
+
var version = "2.0.22";
|
|
96
96
|
|
|
97
97
|
var AstNodeType;
|
|
98
98
|
(function (AstNodeType) {
|
|
@@ -6111,6 +6111,28 @@ function analyze(ast, params) {
|
|
|
6111
6111
|
};
|
|
6112
6112
|
}
|
|
6113
6113
|
|
|
6114
|
+
function minifyTokenStream(tokenStream, _a) {
|
|
6115
|
+
var removeWhiteSpace = _a.removeWhiteSpace;
|
|
6116
|
+
var tokens = tokenStream.tokens
|
|
6117
|
+
.filter(function (token) {
|
|
6118
|
+
if (isP_CommentToken(token)
|
|
6119
|
+
|| isA_CommentToken(token)
|
|
6120
|
+
|| isA_MultiLineCommentToken(token)
|
|
6121
|
+
|| (removeWhiteSpace && isA_WhitespaceToken(token))
|
|
6122
|
+
|| (removeWhiteSpace && isP_WhitespaceToken(token))) {
|
|
6123
|
+
return false;
|
|
6124
|
+
}
|
|
6125
|
+
return true;
|
|
6126
|
+
})
|
|
6127
|
+
.map(function (token) {
|
|
6128
|
+
if (isA_WhitespaceToken(token) || isP_WhitespaceToken(token)) {
|
|
6129
|
+
return __assign(__assign({}, token), { value: ' ' });
|
|
6130
|
+
}
|
|
6131
|
+
return token;
|
|
6132
|
+
});
|
|
6133
|
+
return __assign(__assign({}, tokenStream), { tokens: tokens });
|
|
6134
|
+
}
|
|
6135
|
+
|
|
6114
6136
|
function parseSymbol(tokenStream, parseState) {
|
|
6115
6137
|
var _a;
|
|
6116
6138
|
var tkn = asToken(tokenStream.tokens[parseState.position++]);
|
|
@@ -7629,7 +7651,7 @@ function parsePolishToken(tokenStream, parseState) {
|
|
|
7629
7651
|
}
|
|
7630
7652
|
|
|
7631
7653
|
function parse(tokenStream) {
|
|
7632
|
-
tokenStream =
|
|
7654
|
+
tokenStream = minifyTokenStream(tokenStream, { removeWhiteSpace: true });
|
|
7633
7655
|
var algebraic = tokenStream.algebraic;
|
|
7634
7656
|
var ast = {
|
|
7635
7657
|
b: [],
|
|
@@ -7650,19 +7672,6 @@ function parse(tokenStream) {
|
|
|
7650
7672
|
}
|
|
7651
7673
|
return ast;
|
|
7652
7674
|
}
|
|
7653
|
-
function removeUnnecessaryTokens(tokenStream) {
|
|
7654
|
-
var tokens = tokenStream.tokens.filter(function (token) {
|
|
7655
|
-
if (isP_CommentToken(token)
|
|
7656
|
-
|| isA_CommentToken(token)
|
|
7657
|
-
|| isA_MultiLineCommentToken(token)
|
|
7658
|
-
|| isA_WhitespaceToken(token)
|
|
7659
|
-
|| isP_WhitespaceToken(token)) {
|
|
7660
|
-
return false;
|
|
7661
|
-
}
|
|
7662
|
-
return true;
|
|
7663
|
-
});
|
|
7664
|
-
return __assign(__assign({}, tokenStream), { tokens: tokens });
|
|
7665
|
-
}
|
|
7666
7675
|
function parseToken(tokenStream, parseState) {
|
|
7667
7676
|
return parsePolishToken(tokenStream, parseState);
|
|
7668
7677
|
}
|
|
@@ -8490,7 +8499,8 @@ var Lits = /** @class */ (function () {
|
|
|
8490
8499
|
if (tokenizeParams === void 0) { tokenizeParams = {}; }
|
|
8491
8500
|
var debug = this.debug;
|
|
8492
8501
|
var algebraic = this.algebraic;
|
|
8493
|
-
|
|
8502
|
+
var tokenStream = tokenize(program, __assign(__assign({}, tokenizeParams), { debug: debug, algebraic: algebraic }));
|
|
8503
|
+
return tokenizeParams.minify ? minifyTokenStream(tokenStream, { removeWhiteSpace: false }) : tokenStream;
|
|
8494
8504
|
};
|
|
8495
8505
|
Lits.prototype.parse = function (tokenStream) {
|
|
8496
8506
|
return parse(tokenStream);
|
|
@@ -40,7 +40,9 @@ export declare class Lits {
|
|
|
40
40
|
run(program: string, params?: LitsParams): unknown;
|
|
41
41
|
context(program: string, params?: LitsParams): Context;
|
|
42
42
|
analyze(program: string, params?: LitsParams): Analysis;
|
|
43
|
-
tokenize(program: string, tokenizeParams?: Pick<TokenizeParams, 'filePath'>
|
|
43
|
+
tokenize(program: string, tokenizeParams?: Pick<TokenizeParams, 'filePath'> & {
|
|
44
|
+
minify?: boolean;
|
|
45
|
+
}): TokenStream;
|
|
44
46
|
parse(tokenStream: TokenStream): Ast;
|
|
45
47
|
evaluate(ast: Ast, params: LitsParams): Any;
|
|
46
48
|
transform(tokenStream: TokenStream, transformer: (name: string) => string): TokenStream;
|
package/dist/index.esm.js
CHANGED
|
@@ -6141,6 +6141,28 @@ function analyze(ast, params) {
|
|
|
6141
6141
|
};
|
|
6142
6142
|
}
|
|
6143
6143
|
|
|
6144
|
+
function minifyTokenStream(tokenStream, _a) {
|
|
6145
|
+
var removeWhiteSpace = _a.removeWhiteSpace;
|
|
6146
|
+
var tokens = tokenStream.tokens
|
|
6147
|
+
.filter(function (token) {
|
|
6148
|
+
if (isP_CommentToken(token)
|
|
6149
|
+
|| isA_CommentToken(token)
|
|
6150
|
+
|| isA_MultiLineCommentToken(token)
|
|
6151
|
+
|| (removeWhiteSpace && isA_WhitespaceToken(token))
|
|
6152
|
+
|| (removeWhiteSpace && isP_WhitespaceToken(token))) {
|
|
6153
|
+
return false;
|
|
6154
|
+
}
|
|
6155
|
+
return true;
|
|
6156
|
+
})
|
|
6157
|
+
.map(function (token) {
|
|
6158
|
+
if (isA_WhitespaceToken(token) || isP_WhitespaceToken(token)) {
|
|
6159
|
+
return __assign(__assign({}, token), { value: ' ' });
|
|
6160
|
+
}
|
|
6161
|
+
return token;
|
|
6162
|
+
});
|
|
6163
|
+
return __assign(__assign({}, tokenStream), { tokens: tokens });
|
|
6164
|
+
}
|
|
6165
|
+
|
|
6144
6166
|
function parseSymbol(tokenStream, parseState) {
|
|
6145
6167
|
var _a;
|
|
6146
6168
|
var tkn = asToken(tokenStream.tokens[parseState.position++]);
|
|
@@ -7659,7 +7681,7 @@ function parsePolishToken(tokenStream, parseState) {
|
|
|
7659
7681
|
}
|
|
7660
7682
|
|
|
7661
7683
|
function parse(tokenStream) {
|
|
7662
|
-
tokenStream =
|
|
7684
|
+
tokenStream = minifyTokenStream(tokenStream, { removeWhiteSpace: true });
|
|
7663
7685
|
var algebraic = tokenStream.algebraic;
|
|
7664
7686
|
var ast = {
|
|
7665
7687
|
b: [],
|
|
@@ -7680,19 +7702,6 @@ function parse(tokenStream) {
|
|
|
7680
7702
|
}
|
|
7681
7703
|
return ast;
|
|
7682
7704
|
}
|
|
7683
|
-
function removeUnnecessaryTokens(tokenStream) {
|
|
7684
|
-
var tokens = tokenStream.tokens.filter(function (token) {
|
|
7685
|
-
if (isP_CommentToken(token)
|
|
7686
|
-
|| isA_CommentToken(token)
|
|
7687
|
-
|| isA_MultiLineCommentToken(token)
|
|
7688
|
-
|| isA_WhitespaceToken(token)
|
|
7689
|
-
|| isP_WhitespaceToken(token)) {
|
|
7690
|
-
return false;
|
|
7691
|
-
}
|
|
7692
|
-
return true;
|
|
7693
|
-
});
|
|
7694
|
-
return __assign(__assign({}, tokenStream), { tokens: tokens });
|
|
7695
|
-
}
|
|
7696
7705
|
function parseToken(tokenStream, parseState) {
|
|
7697
7706
|
return parsePolishToken(tokenStream, parseState);
|
|
7698
7707
|
}
|
|
@@ -8520,7 +8529,8 @@ var Lits = /** @class */ (function () {
|
|
|
8520
8529
|
if (tokenizeParams === void 0) { tokenizeParams = {}; }
|
|
8521
8530
|
var debug = this.debug;
|
|
8522
8531
|
var algebraic = this.algebraic;
|
|
8523
|
-
|
|
8532
|
+
var tokenStream = tokenize(program, __assign(__assign({}, tokenizeParams), { debug: debug, algebraic: algebraic }));
|
|
8533
|
+
return tokenizeParams.minify ? minifyTokenStream(tokenStream, { removeWhiteSpace: false }) : tokenStream;
|
|
8524
8534
|
};
|
|
8525
8535
|
Lits.prototype.parse = function (tokenStream) {
|
|
8526
8536
|
return parse(tokenStream);
|