@jbrowse/jexl 3.0.2 → 3.2.0
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/README.md +26 -2
- package/dist/Expression.d.ts +19 -7
- package/dist/Expression.js +32 -11
- package/dist/Expression.js.map +1 -1
- package/dist/Jexl.d.ts +13 -12
- package/dist/Jexl.js +31 -30
- package/dist/Jexl.js.map +1 -1
- package/dist/Lexer.d.ts +9 -9
- package/dist/Lexer.js +61 -24
- package/dist/Lexer.js.map +1 -1
- package/dist/evaluator/Evaluator.d.ts +20 -34
- package/dist/evaluator/Evaluator.js +19 -64
- package/dist/evaluator/Evaluator.js.map +1 -1
- package/dist/evaluator/compile.d.ts +27 -0
- package/dist/evaluator/compile.js +279 -0
- package/dist/evaluator/compile.js.map +1 -0
- package/dist/grammar.d.ts +29 -9
- package/dist/grammar.js +23 -7
- package/dist/grammar.js.map +1 -1
- package/dist/parser/Parser.d.ts +7 -8
- package/dist/parser/Parser.js +46 -14
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/handlers.d.ts +8 -8
- package/dist/parser/handlers.js +84 -51
- package/dist/parser/handlers.js.map +1 -1
- package/dist/parser/states.d.ts +2 -2
- package/dist/parser/states.js +19 -40
- package/dist/parser/states.js.map +1 -1
- package/dist/types.d.ts +18 -7
- package/esm/Expression.d.ts +19 -7
- package/esm/Expression.js +32 -11
- package/esm/Expression.js.map +1 -1
- package/esm/Jexl.d.ts +13 -12
- package/esm/Jexl.js +31 -30
- package/esm/Jexl.js.map +1 -1
- package/esm/Lexer.d.ts +9 -9
- package/esm/Lexer.js +61 -24
- package/esm/Lexer.js.map +1 -1
- package/esm/evaluator/Evaluator.d.ts +20 -34
- package/esm/evaluator/Evaluator.js +19 -31
- package/esm/evaluator/Evaluator.js.map +1 -1
- package/esm/evaluator/compile.d.ts +27 -0
- package/esm/evaluator/compile.js +276 -0
- package/esm/evaluator/compile.js.map +1 -0
- package/esm/grammar.d.ts +29 -9
- package/esm/grammar.js +22 -7
- package/esm/grammar.js.map +1 -1
- package/esm/parser/Parser.d.ts +7 -8
- package/esm/parser/Parser.js +46 -14
- package/esm/parser/Parser.js.map +1 -1
- package/esm/parser/handlers.d.ts +8 -8
- package/esm/parser/handlers.js +81 -50
- package/esm/parser/handlers.js.map +1 -1
- package/esm/parser/states.d.ts +2 -2
- package/esm/parser/states.js +19 -40
- package/esm/parser/states.js.map +1 -1
- package/esm/types.d.ts +18 -7
- package/package.json +25 -28
- package/src/Expression.ts +31 -17
- package/src/Jexl.ts +59 -21
- package/src/Lexer.ts +63 -33
- package/src/evaluator/Evaluator.ts +27 -44
- package/src/evaluator/compile.ts +317 -0
- package/src/grammar.ts +69 -21
- package/src/parser/Parser.ts +50 -28
- package/src/parser/handlers.ts +122 -76
- package/src/parser/states.ts +22 -42
- package/src/types.ts +22 -7
- package/CHANGELOG.md +0 -249
- package/dist/evaluator/handlers.d.ts +0 -112
- package/dist/evaluator/handlers.js +0 -208
- package/dist/evaluator/handlers.js.map +0 -1
- package/esm/evaluator/handlers.d.ts +0 -112
- package/esm/evaluator/handlers.js +0 -194
- package/esm/evaluator/handlers.js.map +0 -1
- package/src/evaluator/handlers.ts +0 -212
package/README.md
CHANGED
|
@@ -83,14 +83,15 @@ jexl.eval('`Price: \\$100`')
|
|
|
83
83
|
|
|
84
84
|
### Operators
|
|
85
85
|
|
|
86
|
-
**Unary:** `!` (
|
|
86
|
+
**Unary:** `!` (logical negation), `-` (arithmetic negation)
|
|
87
87
|
|
|
88
88
|
**Binary:**
|
|
89
89
|
|
|
90
90
|
- Arithmetic: `+`, `-`, `*`, `/`, `//` (floor division), `%`, `^` (power)
|
|
91
91
|
- Comparison: `==`, `!=`, `>`, `>=`, `<`, `<=`, `in`
|
|
92
92
|
- Logical: `&&`, `||`
|
|
93
|
-
- Assignment: `=` (assigns value to variable
|
|
93
|
+
- Assignment: `=` (assigns a value to a bare variable name; `a.b = 1` is not
|
|
94
|
+
supported)
|
|
94
95
|
|
|
95
96
|
**Ternary:** `condition ? consequent : alternate`
|
|
96
97
|
|
|
@@ -128,6 +129,21 @@ jexl.eval('max(temperature, threshold)')
|
|
|
128
129
|
// evaluates with context
|
|
129
130
|
```
|
|
130
131
|
|
|
132
|
+
Functions live in one global pool and have no receiver, so a call written
|
|
133
|
+
against a value passes that value as the first argument: `a.b(x)` means
|
|
134
|
+
`b(a, x)`. Since functions are conventionally written to take their subject
|
|
135
|
+
first, the two spellings read differently but do the same thing:
|
|
136
|
+
|
|
137
|
+
```javascript
|
|
138
|
+
jexl.addFunction('split', (str, sep) => String(str ?? '').split(sep))
|
|
139
|
+
|
|
140
|
+
jexl.eval("refName.split(' ')[0]", { refName: 'chr1 description' }) // "chr1"
|
|
141
|
+
jexl.eval("split(refName, ' ')[0]", { refName: 'chr1 description' }) // "chr1"
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Note that this is a naming convention, not method dispatch: `a.b(x)` calls the
|
|
145
|
+
function named `b` in the pool, never a method on the value of `a`.
|
|
146
|
+
|
|
131
147
|
### Variable Assignment
|
|
132
148
|
|
|
133
149
|
Assign values to variables using `=` (no `let`, `var`, or `const` needed). Assignments mutate the context and return the assigned value:
|
|
@@ -206,3 +222,11 @@ jexl.eval('~3.7') // 3
|
|
|
206
222
|
## License
|
|
207
223
|
|
|
208
224
|
MIT License, same as TomFrost/Jexl
|
|
225
|
+
|
|
226
|
+
## Publishing
|
|
227
|
+
|
|
228
|
+
[Trusted publishing](https://docs.npmjs.com/about-trusted-publishing) via GitHub Actions.
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
npm version patch # or minor/major
|
|
232
|
+
```
|
package/dist/Expression.d.ts
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
|
+
import Lexer from './Lexer.ts';
|
|
2
|
+
import type { CompiledNode } from './evaluator/compile.ts';
|
|
3
|
+
import type { Grammar } from './grammar.ts';
|
|
1
4
|
import type { AstNode } from './types.ts';
|
|
2
|
-
interface Grammar {
|
|
3
|
-
elements: Record<string, any>;
|
|
4
|
-
[key: string]: any;
|
|
5
|
-
}
|
|
6
5
|
declare class Expression {
|
|
7
6
|
_grammar: Grammar;
|
|
8
7
|
_exprStr: string;
|
|
8
|
+
/** The parsed tree, exposed for inspection. Legitimately null for an
|
|
9
|
+
* expression with no tokens, which is why compilation is tracked by
|
|
10
|
+
* `_compiled` rather than by this being set. */
|
|
9
11
|
_ast: AstNode | null;
|
|
10
|
-
|
|
12
|
+
_lexer: Lexer;
|
|
13
|
+
_compiled: boolean;
|
|
14
|
+
_fn: CompiledNode | null;
|
|
15
|
+
/**
|
|
16
|
+
* @param {{}} grammar The grammar to compile and evaluate against
|
|
17
|
+
* @param {string} exprStr The Jexl expression string
|
|
18
|
+
* @param {Lexer} [lexer] A Lexer to reuse. Lexers memoize the regex used to
|
|
19
|
+
* split expressions, which is expensive to build, so passing a shared
|
|
20
|
+
* one avoids paying that cost per expression. It must be invalidated
|
|
21
|
+
* via {@link Lexer#_clearCache} whenever the grammar's elements change.
|
|
22
|
+
*/
|
|
23
|
+
constructor(grammar: Grammar, exprStr: string, lexer?: Lexer);
|
|
11
24
|
/**
|
|
12
25
|
* Forces a compilation of the expression string that this Expression object
|
|
13
26
|
* was constructed with. This function can be called multiple times; useful
|
|
@@ -22,7 +35,6 @@ declare class Expression {
|
|
|
22
35
|
* @returns {*} the result of the evaluation.
|
|
23
36
|
* @throws {*} on error
|
|
24
37
|
*/
|
|
25
|
-
eval(context?: {}):
|
|
26
|
-
_getAst(): AstNode | null;
|
|
38
|
+
eval(context?: {}): import("./types.ts").JexlValue;
|
|
27
39
|
}
|
|
28
40
|
export default Expression;
|
package/dist/Expression.js
CHANGED
|
@@ -9,12 +9,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
const Lexer_ts_1 = __importDefault(require("./Lexer.js"));
|
|
11
11
|
const Evaluator_ts_1 = __importDefault(require("./evaluator/Evaluator.js"));
|
|
12
|
+
const compile_ts_1 = require("./evaluator/compile.js");
|
|
12
13
|
const Parser_ts_1 = __importDefault(require("./parser/Parser.js"));
|
|
13
14
|
class Expression {
|
|
14
|
-
|
|
15
|
+
_grammar;
|
|
16
|
+
_exprStr;
|
|
17
|
+
/** The parsed tree, exposed for inspection. Legitimately null for an
|
|
18
|
+
* expression with no tokens, which is why compilation is tracked by
|
|
19
|
+
* `_compiled` rather than by this being set. */
|
|
20
|
+
_ast;
|
|
21
|
+
_lexer;
|
|
22
|
+
_compiled = false;
|
|
23
|
+
// the AST lowered to closures, so repeated eval() calls skip node dispatch
|
|
24
|
+
_fn = null;
|
|
25
|
+
/**
|
|
26
|
+
* @param {{}} grammar The grammar to compile and evaluate against
|
|
27
|
+
* @param {string} exprStr The Jexl expression string
|
|
28
|
+
* @param {Lexer} [lexer] A Lexer to reuse. Lexers memoize the regex used to
|
|
29
|
+
* split expressions, which is expensive to build, so passing a shared
|
|
30
|
+
* one avoids paying that cost per expression. It must be invalidated
|
|
31
|
+
* via {@link Lexer#_clearCache} whenever the grammar's elements change.
|
|
32
|
+
*/
|
|
33
|
+
constructor(grammar, exprStr, lexer) {
|
|
15
34
|
this._grammar = grammar;
|
|
16
35
|
this._exprStr = exprStr;
|
|
17
36
|
this._ast = null;
|
|
37
|
+
this._lexer = lexer ?? new Lexer_ts_1.default(grammar);
|
|
18
38
|
}
|
|
19
39
|
/**
|
|
20
40
|
* Forces a compilation of the expression string that this Expression object
|
|
@@ -23,11 +43,13 @@ class Expression {
|
|
|
23
43
|
* @returns {Expression} this Expression instance, for convenience
|
|
24
44
|
*/
|
|
25
45
|
compile() {
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const tokens = lexer.tokenize(this._exprStr);
|
|
46
|
+
const parser = new Parser_ts_1.default(this._grammar, this._lexer);
|
|
47
|
+
const tokens = this._lexer.tokenize(this._exprStr);
|
|
29
48
|
parser.addTokens(tokens);
|
|
30
49
|
this._ast = parser.complete();
|
|
50
|
+
// lower the tree to closures once, here, so that eval() is just a call
|
|
51
|
+
this._fn = this._ast ? (0, compile_ts_1.compileAst)(this._ast, this._grammar) : null;
|
|
52
|
+
this._compiled = true;
|
|
31
53
|
return this;
|
|
32
54
|
}
|
|
33
55
|
/**
|
|
@@ -38,15 +60,14 @@ class Expression {
|
|
|
38
60
|
* @throws {*} on error
|
|
39
61
|
*/
|
|
40
62
|
eval(context = {}) {
|
|
41
|
-
|
|
42
|
-
const evaluator = new Evaluator_ts_1.default(this._grammar, context);
|
|
43
|
-
return evaluator.eval(ast);
|
|
44
|
-
}
|
|
45
|
-
_getAst() {
|
|
46
|
-
if (!this._ast) {
|
|
63
|
+
if (!this._compiled) {
|
|
47
64
|
this.compile();
|
|
48
65
|
}
|
|
49
|
-
|
|
66
|
+
// an expression with no tokens (empty or whitespace-only) has no AST
|
|
67
|
+
if (!this._fn) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return this._fn(new Evaluator_ts_1.default(this._grammar, context));
|
|
50
71
|
}
|
|
51
72
|
}
|
|
52
73
|
exports.default = Expression;
|
package/dist/Expression.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Expression.js","sourceRoot":"","sources":["../src/Expression.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAEH,0DAA8B;AAC9B,4EAAgD;AAChD,mEAAuC;
|
|
1
|
+
{"version":3,"file":"Expression.js","sourceRoot":"","sources":["../src/Expression.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAEH,0DAA8B;AAC9B,4EAAgD;AAChD,uDAAmD;AACnD,mEAAuC;AAMvC,MAAM,UAAU;IACd,QAAQ,CAAS;IACjB,QAAQ,CAAQ;IAChB;;oDAEgD;IAChD,IAAI,CAAgB;IACpB,MAAM,CAAO;IACb,SAAS,GAAG,KAAK,CAAA;IACjB,2EAA2E;IAC3E,GAAG,GAAwB,IAAI,CAAA;IAE/B;;;;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,UAAU,CAAA"}
|
package/dist/Jexl.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import Expression from './Expression.ts';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
2
|
+
import Lexer from './Lexer.ts';
|
|
3
|
+
import type { BinaryOpEval, BinaryOpEvalOnDemand, Grammar, GrammarElement } from './grammar.ts';
|
|
4
|
+
import type { JexlValue } from './types.ts';
|
|
6
5
|
/**
|
|
7
6
|
* Jexl is the Javascript Expression Language, capable of parsing and
|
|
8
7
|
* evaluating basic to complex expression strings, combined with advanced
|
|
@@ -11,6 +10,7 @@ interface Grammar {
|
|
|
11
10
|
*/
|
|
12
11
|
declare class Jexl {
|
|
13
12
|
_grammar: Grammar;
|
|
13
|
+
_lexer: Lexer;
|
|
14
14
|
constructor();
|
|
15
15
|
/**
|
|
16
16
|
* Adds a binary operator to Jexl at the specified precedence. The higher the
|
|
@@ -31,7 +31,8 @@ declare class Jexl {
|
|
|
31
31
|
* left.eval() or right.eval() will return that operand's actual value.
|
|
32
32
|
* This is useful to conditionally evaluate operands.
|
|
33
33
|
*/
|
|
34
|
-
addBinaryOp(operator: string, precedence: number, fn:
|
|
34
|
+
addBinaryOp(operator: string, precedence: number, fn: BinaryOpEval, manualEval?: false): void;
|
|
35
|
+
addBinaryOp(operator: string, precedence: number, fn: BinaryOpEvalOnDemand, manualEval: true): void;
|
|
35
36
|
/**
|
|
36
37
|
* Adds or replaces an expression function in this Jexl instance.
|
|
37
38
|
* @param {string} name The name of the expression function, as it will be
|
|
@@ -40,14 +41,14 @@ declare class Jexl {
|
|
|
40
41
|
* expression function is invoked. It will be provided with each argument
|
|
41
42
|
* supplied in the expression, in the same order.
|
|
42
43
|
*/
|
|
43
|
-
addFunction(name: string, fn: (...args:
|
|
44
|
+
addFunction(name: string, fn: (...args: JexlValue[]) => JexlValue): void;
|
|
44
45
|
/**
|
|
45
46
|
* Syntactic sugar for calling {@link #addFunction} repeatedly. This function
|
|
46
47
|
* accepts a map of one or more expression function names to their javascript
|
|
47
48
|
* function counterpart.
|
|
48
49
|
* @param {{}} map A map of expression function names to javascript functions
|
|
49
50
|
*/
|
|
50
|
-
addFunctions(map: Record<string, (...args:
|
|
51
|
+
addFunctions(map: Record<string, (...args: JexlValue[]) => JexlValue>): void;
|
|
51
52
|
/**
|
|
52
53
|
* Adds a unary operator to Jexl. Unary operators are currently only supported
|
|
53
54
|
* on the left side of the value on which it will operate.
|
|
@@ -56,7 +57,7 @@ declare class Jexl {
|
|
|
56
57
|
* will be called with one argument: the literal value to the right of the
|
|
57
58
|
* operator. It should return the resulting value.
|
|
58
59
|
*/
|
|
59
|
-
addUnaryOp(operator: string, fn: (right:
|
|
60
|
+
addUnaryOp(operator: string, fn: (right: JexlValue) => JexlValue): void;
|
|
60
61
|
/**
|
|
61
62
|
* Creates an Expression object from the given Jexl expression string, and
|
|
62
63
|
* immediately compiles it. The returned Expression object can then be
|
|
@@ -78,7 +79,7 @@ declare class Jexl {
|
|
|
78
79
|
* @param {string} name The name of the expression function
|
|
79
80
|
* @returns {function} The expression function
|
|
80
81
|
*/
|
|
81
|
-
getFunction(name: string): (...args:
|
|
82
|
+
getFunction(name: string): ((...args: JexlValue[]) => JexlValue) | undefined;
|
|
82
83
|
/**
|
|
83
84
|
* Evaluates a Jexl string within an optional context.
|
|
84
85
|
* @param {string} expression The Jexl expression to be evaluated
|
|
@@ -87,14 +88,14 @@ declare class Jexl {
|
|
|
87
88
|
* @returns {*} the result of the evaluation.
|
|
88
89
|
* @throws {*} on error
|
|
89
90
|
*/
|
|
90
|
-
eval(expression: string, context?: {}):
|
|
91
|
+
eval(expression: string, context?: {}): JexlValue;
|
|
91
92
|
/**
|
|
92
93
|
* A JavaScript template literal to allow expressions to be defined by the
|
|
93
94
|
* syntax: expr`40 + 2`
|
|
94
95
|
* @param {Array<string>} strs
|
|
95
96
|
* @param {...any} args
|
|
96
97
|
*/
|
|
97
|
-
expr(strs: TemplateStringsArray, ...args:
|
|
98
|
+
expr(strs: TemplateStringsArray, ...args: JexlValue[]): Expression;
|
|
98
99
|
/**
|
|
99
100
|
* Removes a binary or unary operator from the Jexl grammar.
|
|
100
101
|
* @param {string} operator The operator string to be removed
|
|
@@ -107,7 +108,7 @@ declare class Jexl {
|
|
|
107
108
|
* grammar element
|
|
108
109
|
* @private
|
|
109
110
|
*/
|
|
110
|
-
_addGrammarElement(str: string, obj:
|
|
111
|
+
_addGrammarElement(str: string, obj: GrammarElement): void;
|
|
111
112
|
}
|
|
112
113
|
declare const jexlInstance: Jexl;
|
|
113
114
|
export default jexlInstance;
|
package/dist/Jexl.js
CHANGED
|
@@ -9,6 +9,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.Jexl = void 0;
|
|
11
11
|
const Expression_ts_1 = __importDefault(require("./Expression.js"));
|
|
12
|
+
const Lexer_ts_1 = __importDefault(require("./Lexer.js"));
|
|
12
13
|
const grammar_ts_1 = require("./grammar.js");
|
|
13
14
|
/**
|
|
14
15
|
* Jexl is the Javascript Expression Language, capable of parsing and
|
|
@@ -17,35 +18,25 @@ const grammar_ts_1 = require("./grammar.js");
|
|
|
17
18
|
* @constructor
|
|
18
19
|
*/
|
|
19
20
|
class Jexl {
|
|
21
|
+
_grammar;
|
|
22
|
+
// shared by every Expression this instance creates, so that the expensive
|
|
23
|
+
// element-splitting regex is built once rather than per compile
|
|
24
|
+
_lexer;
|
|
20
25
|
constructor() {
|
|
21
26
|
this._grammar = (0, grammar_ts_1.getGrammar)();
|
|
27
|
+
this._lexer = new Lexer_ts_1.default(this._grammar);
|
|
22
28
|
this.expr = this.expr.bind(this);
|
|
23
29
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Adds a binary operator to Jexl at the specified precedence. The higher the
|
|
26
|
-
* precedence, the earlier the operator is applied in the order of operations.
|
|
27
|
-
* For example, * has a higher precedence than +, because multiplication comes
|
|
28
|
-
* before division.
|
|
29
|
-
*
|
|
30
|
-
* Please see grammar.js for a listing of all default operators and their
|
|
31
|
-
* precedence values in order to choose the appropriate precedence for the
|
|
32
|
-
* new operator.
|
|
33
|
-
* @param {string} operator The operator string to be added
|
|
34
|
-
* @param {number} precedence The operator's precedence
|
|
35
|
-
* @param {function} fn A function to run to calculate the result. The function
|
|
36
|
-
* will be called with two arguments: left and right, denoting the values
|
|
37
|
-
* on either side of the operator. It should return the resulting value.
|
|
38
|
-
* @param {boolean} [manualEval] If true, the `left` and `right` arguments
|
|
39
|
-
* will be wrapped in objects with an `eval` function. Calling
|
|
40
|
-
* left.eval() or right.eval() will return that operand's actual value.
|
|
41
|
-
* This is useful to conditionally evaluate operands.
|
|
42
|
-
*/
|
|
43
30
|
addBinaryOp(operator, precedence, fn, manualEval) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
31
|
+
// the overloads above pair `fn` with `manualEval`; the implementation
|
|
32
|
+
// signature can't express that correlation, hence the assertions
|
|
33
|
+
this._addGrammarElement(operator, manualEval
|
|
34
|
+
? {
|
|
35
|
+
type: 'binaryOp',
|
|
36
|
+
precedence,
|
|
37
|
+
evalOnDemand: fn
|
|
38
|
+
}
|
|
39
|
+
: { type: 'binaryOp', precedence, eval: fn });
|
|
49
40
|
}
|
|
50
41
|
/**
|
|
51
42
|
* Adds or replaces an expression function in this Jexl instance.
|
|
@@ -78,7 +69,7 @@ class Jexl {
|
|
|
78
69
|
addUnaryOp(operator, fn) {
|
|
79
70
|
this._addGrammarElement(operator, {
|
|
80
71
|
type: 'unaryOp',
|
|
81
|
-
|
|
72
|
+
precedence: Infinity,
|
|
82
73
|
eval: fn
|
|
83
74
|
});
|
|
84
75
|
}
|
|
@@ -101,7 +92,7 @@ class Jexl {
|
|
|
101
92
|
* @returns {Expression} The Expression object representing the given string
|
|
102
93
|
*/
|
|
103
94
|
createExpression(expression) {
|
|
104
|
-
return new Expression_ts_1.default(this._grammar, expression);
|
|
95
|
+
return new Expression_ts_1.default(this._grammar, expression, this._lexer);
|
|
105
96
|
}
|
|
106
97
|
/**
|
|
107
98
|
* Retrieves a previously set expression function.
|
|
@@ -131,10 +122,18 @@ class Jexl {
|
|
|
131
122
|
*/
|
|
132
123
|
expr(strs, ...args) {
|
|
133
124
|
let exprStr = '';
|
|
134
|
-
for (
|
|
135
|
-
exprStr +=
|
|
125
|
+
for (const [idx, str] of strs.entries()) {
|
|
126
|
+
exprStr += str;
|
|
136
127
|
if (idx < args.length) {
|
|
137
|
-
|
|
128
|
+
const arg = args[idx];
|
|
129
|
+
if (typeof arg === 'string' ||
|
|
130
|
+
typeof arg === 'number' ||
|
|
131
|
+
typeof arg === 'boolean') {
|
|
132
|
+
exprStr += String(arg);
|
|
133
|
+
}
|
|
134
|
+
else if (arg != null) {
|
|
135
|
+
exprStr += JSON.stringify(arg);
|
|
136
|
+
}
|
|
138
137
|
}
|
|
139
138
|
}
|
|
140
139
|
return this.createExpression(exprStr);
|
|
@@ -145,8 +144,9 @@ class Jexl {
|
|
|
145
144
|
*/
|
|
146
145
|
removeOp(operator) {
|
|
147
146
|
const elem = this._grammar.elements[operator];
|
|
148
|
-
if (elem
|
|
147
|
+
if (elem?.type === 'binaryOp' || elem?.type === 'unaryOp') {
|
|
149
148
|
Reflect.deleteProperty(this._grammar.elements, operator);
|
|
149
|
+
this._lexer._clearCache();
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
@@ -158,6 +158,7 @@ class Jexl {
|
|
|
158
158
|
*/
|
|
159
159
|
_addGrammarElement(str, obj) {
|
|
160
160
|
this._grammar.elements[str] = obj;
|
|
161
|
+
this._lexer._clearCache();
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
164
|
exports.Jexl = Jexl;
|
package/dist/Jexl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Jexl.js","sourceRoot":"","sources":["../src/Jexl.ts"],"names":[],"m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GAAG,CAAC,CAAA;gBACxB,CAAC;qBAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;oBACvB,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACvC,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,QAAgB;QACvB,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;QAC7C,IAAI,IAAI,EAAE,IAAI,KAAK,UAAU,IAAI,IAAI,EAAE,IAAI,KAAK,SAAS,EAAE,CAAC;YAC1D,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;YACxD,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAA;QAC3B,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,kBAAkB,CAAC,GAAW,EAAE,GAAmB;QACjD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;QACjC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAA;IAC3B,CAAC;CACF;AAIQ,oBAAI;AAFb,MAAM,YAAY,GAAG,IAAI,IAAI,EAAE,CAAA;AAC/B,kBAAe,YAAY,CAAA"}
|
package/dist/Lexer.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
elements: Record<string, any>;
|
|
4
|
-
}
|
|
1
|
+
import type { Grammar } from './grammar.ts';
|
|
2
|
+
import type { TemplatePart, Token } from './types.ts';
|
|
5
3
|
/**
|
|
6
4
|
* Lexer is a collection of stateless, statically-accessed functions for the
|
|
7
5
|
* lexical parsing of a Jexl string. Its responsibility is to identify the
|
|
@@ -15,8 +13,13 @@ interface Grammar {
|
|
|
15
13
|
declare class Lexer {
|
|
16
14
|
_grammar: Grammar;
|
|
17
15
|
_splitRegex?: RegExp;
|
|
18
|
-
_escQuoteRegexCache: Map<string, RegExp>;
|
|
19
16
|
constructor(grammar: Grammar);
|
|
17
|
+
/**
|
|
18
|
+
* Discards the memoized split regex, so that it is rebuilt on the next
|
|
19
|
+
* tokenize. Must be called whenever the grammar's elements change, since the
|
|
20
|
+
* regex is derived from their keys.
|
|
21
|
+
*/
|
|
22
|
+
_clearCache(): void;
|
|
20
23
|
/**
|
|
21
24
|
* Splits a Jexl expression string into an array of expression elements.
|
|
22
25
|
* @param {string} str A Jexl expression string
|
|
@@ -121,10 +124,7 @@ declare class Lexer {
|
|
|
121
124
|
* @private
|
|
122
125
|
*/
|
|
123
126
|
_unquote(str: string): string;
|
|
124
|
-
_parseTemplateString(str: string):
|
|
125
|
-
type: "static" | "interpolation";
|
|
126
|
-
value: string;
|
|
127
|
-
}[];
|
|
127
|
+
_parseTemplateString(str: string): TemplatePart[];
|
|
128
128
|
_unescapeTemplateString(str: string): string;
|
|
129
129
|
}
|
|
130
130
|
export default Lexer;
|
package/dist/Lexer.js
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const numericRegex = /^-?(?:(?:[0-9]*\.[0-9]+)|[0-9]+)$/;
|
|
8
8
|
const identRegex = /^[a-zA-Zа-яА-Я_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$][a-zA-Zа-яА-Я0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$]*$/;
|
|
9
|
-
const escEscRegex =
|
|
9
|
+
const escEscRegex = /\\\\/g;
|
|
10
|
+
// a string literal opens with one of exactly two quote characters, so the two
|
|
11
|
+
// unescaping regexes can just be named rather than built and cached per quote
|
|
12
|
+
const escQuoteRegex = { "'": /\\'/g, '"': /\\"/g };
|
|
10
13
|
const whitespaceRegex = /^\s*$/;
|
|
11
14
|
const preOpRegexElems = [
|
|
12
15
|
// Template strings
|
|
@@ -26,6 +29,11 @@ const postOpRegexElems = [
|
|
|
26
29
|
// Numerics (without negative symbol)
|
|
27
30
|
String.raw `(?:(?:[0-9]*\.[0-9]+)|[0-9]+)`
|
|
28
31
|
];
|
|
32
|
+
const unaryMinusToken = () => ({
|
|
33
|
+
type: 'unaryOp',
|
|
34
|
+
value: '-',
|
|
35
|
+
raw: '-'
|
|
36
|
+
});
|
|
29
37
|
const minusNegatesAfter = new Set([
|
|
30
38
|
'binaryOp',
|
|
31
39
|
'unaryOp',
|
|
@@ -47,10 +55,19 @@ const minusNegatesAfter = new Set([
|
|
|
47
55
|
* @type {{}}
|
|
48
56
|
*/
|
|
49
57
|
class Lexer {
|
|
58
|
+
_grammar;
|
|
59
|
+
_splitRegex;
|
|
50
60
|
constructor(grammar) {
|
|
51
|
-
this._escQuoteRegexCache = new Map();
|
|
52
61
|
this._grammar = grammar;
|
|
53
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Discards the memoized split regex, so that it is rebuilt on the next
|
|
65
|
+
* tokenize. Must be called whenever the grammar's elements change, since the
|
|
66
|
+
* regex is derived from their keys.
|
|
67
|
+
*/
|
|
68
|
+
_clearCache() {
|
|
69
|
+
this._splitRegex = undefined;
|
|
70
|
+
}
|
|
54
71
|
/**
|
|
55
72
|
* Splits a Jexl expression string into an array of expression elements.
|
|
56
73
|
* @param {string} str A Jexl expression string
|
|
@@ -74,21 +91,35 @@ class Lexer {
|
|
|
74
91
|
getTokens(elements) {
|
|
75
92
|
const tokens = [];
|
|
76
93
|
let negate = false;
|
|
77
|
-
for (
|
|
78
|
-
if (this._isWhitespace(
|
|
79
|
-
|
|
80
|
-
|
|
94
|
+
for (const element of elements) {
|
|
95
|
+
if (this._isWhitespace(element)) {
|
|
96
|
+
const last = tokens.at(-1);
|
|
97
|
+
if (last) {
|
|
98
|
+
last.raw += element;
|
|
81
99
|
}
|
|
82
100
|
}
|
|
83
|
-
else if (
|
|
101
|
+
else if (element === '-' && this._isNegative(tokens)) {
|
|
102
|
+
// a second prefix minus in a row ("- -x"): emit the pending one as a
|
|
103
|
+
// unary operator so this one can negate whatever comes next
|
|
104
|
+
if (negate) {
|
|
105
|
+
tokens.push(unaryMinusToken());
|
|
106
|
+
}
|
|
84
107
|
negate = true;
|
|
85
108
|
}
|
|
86
|
-
else {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
109
|
+
else if (negate) {
|
|
110
|
+
negate = false;
|
|
111
|
+
if (numericRegex.exec(element)) {
|
|
112
|
+
// fold the sign into the number, so "-1" stays a single literal
|
|
113
|
+
tokens.push(this._createToken('-' + element));
|
|
90
114
|
}
|
|
91
|
-
|
|
115
|
+
else {
|
|
116
|
+
// anything else gets a standalone prefix operator, letting "-x",
|
|
117
|
+
// "-(a + b)" and "-foo.bar" negate a computed value
|
|
118
|
+
tokens.push(unaryMinusToken(), this._createToken(element));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
tokens.push(this._createToken(element));
|
|
92
123
|
}
|
|
93
124
|
}
|
|
94
125
|
// Catch a - at the end of the string. Let the parser handle that issue.
|
|
@@ -158,7 +189,7 @@ class Lexer {
|
|
|
158
189
|
else if (element === 'true' || element === 'false') {
|
|
159
190
|
token.value = element === 'true';
|
|
160
191
|
}
|
|
161
|
-
else if (this._grammar.elements
|
|
192
|
+
else if (Object.hasOwn(this._grammar.elements, element)) {
|
|
162
193
|
token.type = this._grammar.elements[element].type;
|
|
163
194
|
}
|
|
164
195
|
else if (identRegex.exec(element)) {
|
|
@@ -248,16 +279,11 @@ class Lexer {
|
|
|
248
279
|
* @private
|
|
249
280
|
*/
|
|
250
281
|
_unquote(str) {
|
|
251
|
-
const quote = str
|
|
252
|
-
let escQuoteRegex = this._escQuoteRegexCache.get(quote);
|
|
253
|
-
if (!escQuoteRegex) {
|
|
254
|
-
escQuoteRegex = new RegExp('\\\\' + quote, 'g');
|
|
255
|
-
this._escQuoteRegexCache.set(quote, escQuoteRegex);
|
|
256
|
-
}
|
|
282
|
+
const quote = str.startsWith('"') ? '"' : "'";
|
|
257
283
|
return str
|
|
258
284
|
.slice(1, -1)
|
|
259
|
-
.
|
|
260
|
-
.
|
|
285
|
+
.replaceAll(escQuoteRegex[quote], quote)
|
|
286
|
+
.replaceAll(escEscRegex, '\\');
|
|
261
287
|
}
|
|
262
288
|
_parseTemplateString(str) {
|
|
263
289
|
const parts = [];
|
|
@@ -279,14 +305,25 @@ class Lexer {
|
|
|
279
305
|
const interpStart = current + 2;
|
|
280
306
|
current += 2;
|
|
281
307
|
while (current < str.length && braceDepth > 0) {
|
|
282
|
-
|
|
308
|
+
const char = str[current];
|
|
309
|
+
if (char === '\\') {
|
|
283
310
|
current += 2;
|
|
284
311
|
continue;
|
|
285
312
|
}
|
|
286
|
-
|
|
313
|
+
// skip over string literals so that braces inside them, as in
|
|
314
|
+
// `${ f('}') }`, don't unbalance the depth count
|
|
315
|
+
if (char === '"' || char === "'") {
|
|
316
|
+
current++;
|
|
317
|
+
while (current < str.length && str[current] !== char) {
|
|
318
|
+
current += str[current] === '\\' ? 2 : 1;
|
|
319
|
+
}
|
|
320
|
+
current++;
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
if (char === '{') {
|
|
287
324
|
braceDepth++;
|
|
288
325
|
}
|
|
289
|
-
if (
|
|
326
|
+
else if (char === '}') {
|
|
290
327
|
braceDepth--;
|
|
291
328
|
}
|
|
292
329
|
current++;
|
package/dist/Lexer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Lexer.js","sourceRoot":"","sources":["../src/Lexer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;
|
|
1
|
+
{"version":3,"file":"Lexer.js","sourceRoot":"","sources":["../src/Lexer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAKH,MAAM,YAAY,GAAG,mCAAmC,CAAA;AACxD,MAAM,UAAU,GACd,sHAAsH,CAAA;AACx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