@mojir/lits 2.0.21 → 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 +15 -7
- package/dist/cli/src/tokenizer/minifyTokenStream.d.ts +3 -1
- package/dist/index.esm.js +14 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +14 -6
- package/dist/lits.iife.js.map +1 -1
- package/dist/src/tokenizer/minifyTokenStream.d.ts +3 -1
- package/dist/testFramework.esm.js +14 -6
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +14 -6
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { TokenStream } from './interface';
|
|
2
|
-
export declare function minifyTokenStream(tokenStream: TokenStream
|
|
2
|
+
export declare function minifyTokenStream(tokenStream: TokenStream, { removeWhiteSpace }: {
|
|
3
|
+
removeWhiteSpace: boolean;
|
|
4
|
+
}): TokenStream;
|
|
@@ -6103,16 +6103,24 @@ function analyze(ast, params) {
|
|
|
6103
6103
|
};
|
|
6104
6104
|
}
|
|
6105
6105
|
|
|
6106
|
-
function minifyTokenStream(tokenStream) {
|
|
6107
|
-
var
|
|
6106
|
+
function minifyTokenStream(tokenStream, _a) {
|
|
6107
|
+
var removeWhiteSpace = _a.removeWhiteSpace;
|
|
6108
|
+
var tokens = tokenStream.tokens
|
|
6109
|
+
.filter(function (token) {
|
|
6108
6110
|
if (isP_CommentToken(token)
|
|
6109
6111
|
|| isA_CommentToken(token)
|
|
6110
6112
|
|| isA_MultiLineCommentToken(token)
|
|
6111
|
-
|| isA_WhitespaceToken(token)
|
|
6112
|
-
|| isP_WhitespaceToken(token)) {
|
|
6113
|
+
|| (removeWhiteSpace && isA_WhitespaceToken(token))
|
|
6114
|
+
|| (removeWhiteSpace && isP_WhitespaceToken(token))) {
|
|
6113
6115
|
return false;
|
|
6114
6116
|
}
|
|
6115
6117
|
return true;
|
|
6118
|
+
})
|
|
6119
|
+
.map(function (token) {
|
|
6120
|
+
if (isA_WhitespaceToken(token) || isP_WhitespaceToken(token)) {
|
|
6121
|
+
return __assign(__assign({}, token), { value: ' ' });
|
|
6122
|
+
}
|
|
6123
|
+
return token;
|
|
6116
6124
|
});
|
|
6117
6125
|
return __assign(__assign({}, tokenStream), { tokens: tokens });
|
|
6118
6126
|
}
|
|
@@ -7635,7 +7643,7 @@ function parsePolishToken(tokenStream, parseState) {
|
|
|
7635
7643
|
}
|
|
7636
7644
|
|
|
7637
7645
|
function parse(tokenStream) {
|
|
7638
|
-
tokenStream = minifyTokenStream(tokenStream);
|
|
7646
|
+
tokenStream = minifyTokenStream(tokenStream, { removeWhiteSpace: true });
|
|
7639
7647
|
var algebraic = tokenStream.algebraic;
|
|
7640
7648
|
var ast = {
|
|
7641
7649
|
b: [],
|
|
@@ -8483,7 +8491,7 @@ var Lits = /** @class */ (function () {
|
|
|
8483
8491
|
var debug = this.debug;
|
|
8484
8492
|
var algebraic = this.algebraic;
|
|
8485
8493
|
var tokenStream = tokenize(program, __assign(__assign({}, tokenizeParams), { debug: debug, algebraic: algebraic }));
|
|
8486
|
-
return tokenizeParams.minify ? minifyTokenStream(tokenStream) : tokenStream;
|
|
8494
|
+
return tokenizeParams.minify ? minifyTokenStream(tokenStream, { removeWhiteSpace: false }) : tokenStream;
|
|
8487
8495
|
};
|
|
8488
8496
|
Lits.prototype.parse = function (tokenStream) {
|
|
8489
8497
|
return parse(tokenStream);
|