@jbrowse/jexl 3.2.0 → 4.0.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/dist/Expression.js +1 -2
- package/dist/Expression.js.map +1 -1
- package/dist/Jexl.d.ts +8 -8
- package/dist/Jexl.js +7 -1
- package/dist/Jexl.js.map +1 -1
- package/dist/Lexer.d.ts +10 -8
- package/dist/Lexer.js +46 -35
- package/dist/Lexer.js.map +1 -1
- package/dist/evaluator/compile.d.ts +6 -4
- package/dist/evaluator/compile.js +42 -52
- package/dist/evaluator/compile.js.map +1 -1
- package/dist/grammar.d.ts +19 -2
- package/dist/grammar.js +1 -1
- package/dist/grammar.js.map +1 -1
- package/dist/parser/Parser.d.ts +2 -9
- package/dist/parser/Parser.js +2 -12
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/handlers.d.ts +6 -3
- package/dist/parser/handlers.js +45 -28
- package/dist/parser/handlers.js.map +1 -1
- package/dist/parser/states.js +3 -5
- package/dist/parser/states.js.map +1 -1
- package/dist/types.d.ts +0 -3
- package/esm/Expression.js +1 -2
- package/esm/Expression.js.map +1 -1
- package/esm/Jexl.d.ts +8 -8
- package/esm/Jexl.js +7 -1
- package/esm/Jexl.js.map +1 -1
- package/esm/Lexer.d.ts +10 -8
- package/esm/Lexer.js +46 -35
- package/esm/Lexer.js.map +1 -1
- package/esm/evaluator/compile.d.ts +6 -4
- package/esm/evaluator/compile.js +42 -52
- package/esm/evaluator/compile.js.map +1 -1
- package/esm/grammar.d.ts +19 -2
- package/esm/grammar.js +1 -1
- package/esm/grammar.js.map +1 -1
- package/esm/parser/Parser.d.ts +2 -9
- package/esm/parser/Parser.js +2 -12
- package/esm/parser/Parser.js.map +1 -1
- package/esm/parser/handlers.d.ts +6 -3
- package/esm/parser/handlers.js +45 -28
- package/esm/parser/handlers.js.map +1 -1
- package/esm/parser/states.js +3 -5
- package/esm/parser/states.js.map +1 -1
- package/esm/types.d.ts +0 -3
- package/package.json +2 -1
- package/src/Expression.ts +1 -2
- package/src/Jexl.ts +20 -11
- package/src/Lexer.ts +47 -36
- package/src/evaluator/compile.ts +53 -68
- package/src/grammar.ts +23 -3
- package/src/parser/Parser.ts +2 -13
- package/src/parser/handlers.ts +48 -31
- package/src/parser/states.ts +3 -5
- package/src/types.ts +0 -3
- package/dist/evaluator/Evaluator.d.ts +0 -37
- package/dist/evaluator/Evaluator.js +0 -49
- package/dist/evaluator/Evaluator.js.map +0 -1
- package/esm/evaluator/Evaluator.d.ts +0 -37
- package/esm/evaluator/Evaluator.js +0 -47
- package/esm/evaluator/Evaluator.js.map +0 -1
- package/src/evaluator/Evaluator.ts +0 -58
package/dist/Expression.js
CHANGED
|
@@ -8,7 +8,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
8
8
|
};
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
const Lexer_ts_1 = __importDefault(require("./Lexer.js"));
|
|
11
|
-
const Evaluator_ts_1 = __importDefault(require("./evaluator/Evaluator.js"));
|
|
12
11
|
const compile_ts_1 = require("./evaluator/compile.js");
|
|
13
12
|
const Parser_ts_1 = __importDefault(require("./parser/Parser.js"));
|
|
14
13
|
class Expression {
|
|
@@ -67,7 +66,7 @@ class Expression {
|
|
|
67
66
|
if (!this._fn) {
|
|
68
67
|
return undefined;
|
|
69
68
|
}
|
|
70
|
-
return this._fn(
|
|
69
|
+
return this._fn(context);
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
72
|
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,
|
|
1
|
+
{"version":3,"file":"Expression.js","sourceRoot":"","sources":["../src/Expression.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAEH,0DAA8B;AAC9B,u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AqE;QACrE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACd,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAC1B,CAAC;CACF;AAED,kBAAe,UAAU,CAAA"}
|
package/dist/Jexl.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Expression from './Expression.ts';
|
|
2
2
|
import Lexer from './Lexer.ts';
|
|
3
|
-
import type {
|
|
3
|
+
import type { BinaryOpEvalOnDemand, Grammar, GrammarElement, GrammarFn, UncheckedFn } from './grammar.ts';
|
|
4
4
|
import type { JexlValue } from './types.ts';
|
|
5
5
|
/**
|
|
6
6
|
* Jexl is the Javascript Expression Language, capable of parsing and
|
|
@@ -16,9 +16,9 @@ declare class Jexl {
|
|
|
16
16
|
* Adds a binary operator to Jexl at the specified precedence. The higher the
|
|
17
17
|
* precedence, the earlier the operator is applied in the order of operations.
|
|
18
18
|
* For example, * has a higher precedence than +, because multiplication comes
|
|
19
|
-
* before
|
|
19
|
+
* before addition.
|
|
20
20
|
*
|
|
21
|
-
* Please see grammar.
|
|
21
|
+
* Please see grammar.ts for a listing of all default operators and their
|
|
22
22
|
* precedence values in order to choose the appropriate precedence for the
|
|
23
23
|
* new operator.
|
|
24
24
|
* @param {string} operator The operator string to be added
|
|
@@ -31,7 +31,7 @@ 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: UncheckedFn, manualEval?: false): void;
|
|
35
35
|
addBinaryOp(operator: string, precedence: number, fn: BinaryOpEvalOnDemand, manualEval: true): void;
|
|
36
36
|
/**
|
|
37
37
|
* Adds or replaces an expression function in this Jexl instance.
|
|
@@ -41,14 +41,14 @@ declare class Jexl {
|
|
|
41
41
|
* expression function is invoked. It will be provided with each argument
|
|
42
42
|
* supplied in the expression, in the same order.
|
|
43
43
|
*/
|
|
44
|
-
addFunction(name: string, fn:
|
|
44
|
+
addFunction(name: string, fn: UncheckedFn): void;
|
|
45
45
|
/**
|
|
46
46
|
* Syntactic sugar for calling {@link #addFunction} repeatedly. This function
|
|
47
47
|
* accepts a map of one or more expression function names to their javascript
|
|
48
48
|
* function counterpart.
|
|
49
49
|
* @param {{}} map A map of expression function names to javascript functions
|
|
50
50
|
*/
|
|
51
|
-
addFunctions(map: Record<string,
|
|
51
|
+
addFunctions(map: Record<string, UncheckedFn>): void;
|
|
52
52
|
/**
|
|
53
53
|
* Adds a unary operator to Jexl. Unary operators are currently only supported
|
|
54
54
|
* on the left side of the value on which it will operate.
|
|
@@ -57,7 +57,7 @@ declare class Jexl {
|
|
|
57
57
|
* will be called with one argument: the literal value to the right of the
|
|
58
58
|
* operator. It should return the resulting value.
|
|
59
59
|
*/
|
|
60
|
-
addUnaryOp(operator: string, fn:
|
|
60
|
+
addUnaryOp(operator: string, fn: UncheckedFn): void;
|
|
61
61
|
/**
|
|
62
62
|
* Creates an Expression object from the given Jexl expression string, and
|
|
63
63
|
* immediately compiles it. The returned Expression object can then be
|
|
@@ -79,7 +79,7 @@ declare class Jexl {
|
|
|
79
79
|
* @param {string} name The name of the expression function
|
|
80
80
|
* @returns {function} The expression function
|
|
81
81
|
*/
|
|
82
|
-
getFunction(name: string):
|
|
82
|
+
getFunction(name: string): GrammarFn | undefined;
|
|
83
83
|
/**
|
|
84
84
|
* Evaluates a Jexl string within an optional context.
|
|
85
85
|
* @param {string} expression The Jexl expression to be evaluated
|
package/dist/Jexl.js
CHANGED
|
@@ -36,7 +36,11 @@ class Jexl {
|
|
|
36
36
|
precedence,
|
|
37
37
|
evalOnDemand: fn
|
|
38
38
|
}
|
|
39
|
-
: {
|
|
39
|
+
: {
|
|
40
|
+
type: 'binaryOp',
|
|
41
|
+
precedence,
|
|
42
|
+
eval: fn
|
|
43
|
+
});
|
|
40
44
|
}
|
|
41
45
|
/**
|
|
42
46
|
* Adds or replaces an expression function in this Jexl instance.
|
|
@@ -47,6 +51,8 @@ class Jexl {
|
|
|
47
51
|
* supplied in the expression, in the same order.
|
|
48
52
|
*/
|
|
49
53
|
addFunction(name, fn) {
|
|
54
|
+
// jexl hands the function whatever the operands evaluated to, which it
|
|
55
|
+
// cannot reconcile with the caller's parameter types — see UncheckedFn
|
|
50
56
|
this._grammar.functions[name] = fn;
|
|
51
57
|
}
|
|
52
58
|
/**
|
package/dist/Jexl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Jexl.js","sourceRoot":"","sources":["../src/Jexl.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,oEAAwC;AACxC,0DAA8B;AAC9B,6CAAyC;
|
|
1
|
+
{"version":3,"file":"Jexl.js","sourceRoot":"","sources":["../src/Jexl.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,oEAAwC;AACxC,0DAA8B;AAC9B,6CAAyC;AAazC;;;;;GAKG;AACH,MAAM,IAAI;IACR,QAAQ,CAAS;IACjB,0EAA0E;IAC1E,gEAAgE;IAChE,MAAM,CAAO;IAEb;QACE,IAAI,CAAC,QAAQ,GAAG,IAAA,uBAAU,GAAE,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IAiCD,WAAW,CACT,QAAgB,EAChB,UAAkB,EAClB,EAAsC,EACtC,UAAoB;QAEpB,sEAAsE;QACtE,iEAAiE;QACjE,IAAI,CAAC,kBAAkB,CACrB,QAAQ,EACR,UAAU;YACR,CAAC,CAAC;gBACE,IAAI,EAAE,UAAU;gBAChB,UAAU;gBACV,YAAY,EAAE,EAA0B;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AG,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,14 +1,16 @@
|
|
|
1
1
|
import type { Grammar } from './grammar.ts';
|
|
2
2
|
import type { TemplatePart, Token } from './types.ts';
|
|
3
3
|
/**
|
|
4
|
-
* Lexer
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
4
|
+
* Lexer handles the lexical parsing of a Jexl string. Its responsibility is to
|
|
5
|
+
* identify the "parts of speech" of a Jexl expression, and tokenize and label
|
|
6
|
+
* each, but to do only the most minimal syntax checking; the only errors the
|
|
7
|
+
* Lexer should be concerned with are if it's unable to identify the utility of
|
|
8
|
+
* any of its tokens. Errors stemming from these tokens not being in a sensible
|
|
9
|
+
* configuration should be left for the Parser to handle.
|
|
10
|
+
*
|
|
11
|
+
* An instance is bound to one grammar and memoizes the regex that splits an
|
|
12
|
+
* expression into elements, which is expensive to build; {@link #_clearCache}
|
|
13
|
+
* discards it when the grammar's elements change.
|
|
12
14
|
*/
|
|
13
15
|
declare class Lexer {
|
|
14
16
|
_grammar: Grammar;
|
package/dist/Lexer.js
CHANGED
|
@@ -4,12 +4,25 @@
|
|
|
4
4
|
* Copyright 2020 Tom Shawver
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
// what an identifier and a number look like, written once: the split regex
|
|
8
|
+
// below carves elements out of the expression with these, and _createToken
|
|
9
|
+
// then re-tests the elements it produced. Two spellings of either would
|
|
10
|
+
// disagree on some input, and each disagreement is an "Invalid expression
|
|
11
|
+
// token" for something the splitter was happy to produce.
|
|
12
|
+
const identChars = String.raw `a-zA-Zа-яА-Я_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$`;
|
|
13
|
+
const identPattern = `[${identChars}][${identChars}0-9]*`;
|
|
14
|
+
// unsigned: whether a leading '-' negates is decided separately, in getTokens
|
|
15
|
+
const numberPattern = String.raw `(?:(?:[0-9]*\.[0-9]+)|[0-9]+)`;
|
|
16
|
+
const numericRegex = new RegExp(`^-?${numberPattern}$`);
|
|
17
|
+
const identRegex = new RegExp(`^${identPattern}$`);
|
|
9
18
|
const escEscRegex = /\\\\/g;
|
|
10
19
|
// a string literal opens with one of exactly two quote characters, so the two
|
|
11
20
|
// unescaping regexes can just be named rather than built and cached per quote
|
|
12
21
|
const escQuoteRegex = { "'": /\\'/g, '"': /\\"/g };
|
|
22
|
+
// the escapes a template string's static text recognizes. One pass, so the
|
|
23
|
+
// backslash an escaped backslash yields can't be re-read as the start of the
|
|
24
|
+
// escape that follows it
|
|
25
|
+
const templateEscRegex = /\\([`$\\])/g;
|
|
13
26
|
const whitespaceRegex = /^\s*$/;
|
|
14
27
|
const preOpRegexElems = [
|
|
15
28
|
// Template strings
|
|
@@ -23,12 +36,7 @@ const preOpRegexElems = [
|
|
|
23
36
|
String.raw `\btrue\b`,
|
|
24
37
|
String.raw `\bfalse\b`
|
|
25
38
|
];
|
|
26
|
-
const postOpRegexElems = [
|
|
27
|
-
// Identifiers
|
|
28
|
-
'[a-zA-Zа-яА-Я_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\\$][a-zA-Z0-9а-яА-Я_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\\$]*',
|
|
29
|
-
// Numerics (without negative symbol)
|
|
30
|
-
String.raw `(?:(?:[0-9]*\.[0-9]+)|[0-9]+)`
|
|
31
|
-
];
|
|
39
|
+
const postOpRegexElems = [identPattern, numberPattern];
|
|
32
40
|
const unaryMinusToken = () => ({
|
|
33
41
|
type: 'unaryOp',
|
|
34
42
|
value: '-',
|
|
@@ -45,14 +53,16 @@ const minusNegatesAfter = new Set([
|
|
|
45
53
|
'semicolon'
|
|
46
54
|
]);
|
|
47
55
|
/**
|
|
48
|
-
* Lexer
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
+
* Lexer handles the lexical parsing of a Jexl string. Its responsibility is to
|
|
57
|
+
* identify the "parts of speech" of a Jexl expression, and tokenize and label
|
|
58
|
+
* each, but to do only the most minimal syntax checking; the only errors the
|
|
59
|
+
* Lexer should be concerned with are if it's unable to identify the utility of
|
|
60
|
+
* any of its tokens. Errors stemming from these tokens not being in a sensible
|
|
61
|
+
* configuration should be left for the Parser to handle.
|
|
62
|
+
*
|
|
63
|
+
* An instance is bound to one grammar and memoizes the regex that splits an
|
|
64
|
+
* expression into elements, which is expensive to build; {@link #_clearCache}
|
|
65
|
+
* discards it when the grammar's elements change.
|
|
56
66
|
*/
|
|
57
67
|
class Lexer {
|
|
58
68
|
_grammar;
|
|
@@ -90,10 +100,14 @@ class Lexer {
|
|
|
90
100
|
*/
|
|
91
101
|
getTokens(elements) {
|
|
92
102
|
const tokens = [];
|
|
93
|
-
|
|
103
|
+
// a prefix minus, held back until the element it applies to is known. It
|
|
104
|
+
// carries its own raw so that whitespace arriving before that element ("-
|
|
105
|
+
// 1") accumulates on the minus rather than on the token before it, which
|
|
106
|
+
// is what lets the parser's error messages quote the expression verbatim.
|
|
107
|
+
let pendingMinus;
|
|
94
108
|
for (const element of elements) {
|
|
95
109
|
if (this._isWhitespace(element)) {
|
|
96
|
-
const last = tokens.at(-1);
|
|
110
|
+
const last = pendingMinus ?? tokens.at(-1);
|
|
97
111
|
if (last) {
|
|
98
112
|
last.raw += element;
|
|
99
113
|
}
|
|
@@ -101,30 +115,32 @@ class Lexer {
|
|
|
101
115
|
else if (element === '-' && this._isNegative(tokens)) {
|
|
102
116
|
// a second prefix minus in a row ("- -x"): emit the pending one as a
|
|
103
117
|
// unary operator so this one can negate whatever comes next
|
|
104
|
-
if (
|
|
105
|
-
tokens.push(
|
|
118
|
+
if (pendingMinus) {
|
|
119
|
+
tokens.push(pendingMinus);
|
|
106
120
|
}
|
|
107
|
-
|
|
121
|
+
pendingMinus = unaryMinusToken();
|
|
108
122
|
}
|
|
109
|
-
else if (
|
|
110
|
-
negate = false;
|
|
123
|
+
else if (pendingMinus) {
|
|
111
124
|
if (numericRegex.exec(element)) {
|
|
112
125
|
// fold the sign into the number, so "-1" stays a single literal
|
|
113
|
-
|
|
126
|
+
const token = this._createToken('-' + element);
|
|
127
|
+
token.raw = pendingMinus.raw + element;
|
|
128
|
+
tokens.push(token);
|
|
114
129
|
}
|
|
115
130
|
else {
|
|
116
131
|
// anything else gets a standalone prefix operator, letting "-x",
|
|
117
132
|
// "-(a + b)" and "-foo.bar" negate a computed value
|
|
118
|
-
tokens.push(
|
|
133
|
+
tokens.push(pendingMinus, this._createToken(element));
|
|
119
134
|
}
|
|
135
|
+
pendingMinus = undefined;
|
|
120
136
|
}
|
|
121
137
|
else {
|
|
122
138
|
tokens.push(this._createToken(element));
|
|
123
139
|
}
|
|
124
140
|
}
|
|
125
141
|
// Catch a - at the end of the string. Let the parser handle that issue.
|
|
126
|
-
if (
|
|
127
|
-
tokens.push(
|
|
142
|
+
if (pendingMinus) {
|
|
143
|
+
tokens.push(pendingMinus);
|
|
128
144
|
}
|
|
129
145
|
return tokens;
|
|
130
146
|
}
|
|
@@ -251,10 +267,8 @@ class Lexer {
|
|
|
251
267
|
* @private
|
|
252
268
|
*/
|
|
253
269
|
_isNegative(tokens) {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
return minusNegatesAfter.has(tokens[tokens.length - 1].type);
|
|
270
|
+
const last = tokens.at(-1);
|
|
271
|
+
return !last || minusNegatesAfter.has(last.type);
|
|
258
272
|
}
|
|
259
273
|
/**
|
|
260
274
|
* A utility function to determine if a string consists of only space
|
|
@@ -350,10 +364,7 @@ class Lexer {
|
|
|
350
364
|
return parts;
|
|
351
365
|
}
|
|
352
366
|
_unescapeTemplateString(str) {
|
|
353
|
-
return str
|
|
354
|
-
.replaceAll('\\`', '`')
|
|
355
|
-
.replaceAll(String.raw `\$`, '$')
|
|
356
|
-
.replaceAll('\\\\', '\\');
|
|
367
|
+
return str.replaceAll(templateEscRegex, '$1');
|
|
357
368
|
}
|
|
358
369
|
}
|
|
359
370
|
exports.default = Lexer;
|
package/dist/Lexer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Lexer.js","sourceRoot":"","sources":["../src/Lexer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAKH,MAAM,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"Lexer.js","sourceRoot":"","sources":["../src/Lexer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAKH,2EAA2E;AAC3E,2EAA2E;AAC3E,wEAAwE;AACxE,0EAA0E;AAC1E,0DAA0D;AAC1D,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAA,uDAAuD,CAAA;AACpF,MAAM,YAAY,GAAG,IAAI,UAAU,KAAK,UAAU,OAAO,CAAA;AACzD,8EAA8E;AAC9E,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA,+BAA+B,CAAA;AAE/D,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAA;AACvD,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,IAAI,YAAY,GAAG,CAAC,CAAA;AAClD,MAAM,WAAW,GAAG,OAAO,CAAA;AAC3B,8EAA8E;AAC9E,8EAA8E;AAC9E,MAAM,aAAa,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAA;AAClD,2EAA2E;AAC3E,6EAA6E;AAC7E,yBAAyB;AACzB,MAAM,gBAAgB,GAAG,aAAa,CAAA;AACtC,MAAM,eAAe,GAAG,OAAO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AC,EAAE,CAAC;oBACrB,MAAM,IAAI,KAAK,CAAC,8CAA8C,GAAG,EAAE,CAAC,CAAA;gBACtE,CAAC;gBAED,KAAK,CAAC,IAAI,CAAC;oBACT,IAAI,EAAE,eAAe;oBACrB,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,GAAG,CAAC,CAAC;iBAC3C,CAAC,CAAA;gBAEF,WAAW,GAAG,OAAO,CAAA;YACvB,CAAC;iBAAM,CAAC;gBACN,OAAO,EAAE,CAAA;YACX,CAAC;QACH,CAAC;QAED,IAAI,OAAO,GAAG,WAAW,EAAE,CAAC;YAC1B,KAAK,CAAC,IAAI,CAAC;gBACT,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC;aACvC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC;IAED,uBAAuB,CAAC,GAAW;QACjC,OAAO,GAAG,CAAC,UAAU,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAA;IAC/C,CAAC;CACF;AAED,kBAAe,KAAK,CAAA"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { Grammar } from '../grammar.ts';
|
|
2
2
|
import type { AstNode, JexlValue } from '../types.ts';
|
|
3
|
-
|
|
3
|
+
/** The variables an expression is evaluated against. */
|
|
4
|
+
export type Context = Record<string, JexlValue>;
|
|
4
5
|
/**
|
|
5
|
-
* An AST node lowered to a closure. Calling it with
|
|
6
|
-
*
|
|
6
|
+
* An AST node lowered to a closure. Calling it with a context produces the
|
|
7
|
+
* node's value. The grammar is captured when the closure is built, so it is not
|
|
8
|
+
* a parameter.
|
|
7
9
|
*/
|
|
8
|
-
export type CompiledNode = (
|
|
10
|
+
export type CompiledNode = (context: Context) => JexlValue;
|
|
9
11
|
/**
|
|
10
12
|
* Lowers an expression tree into a tree of closures, resolving each node's type
|
|
11
13
|
* and its operator's implementation once, at compile time, rather than
|
|
@@ -66,21 +66,17 @@ function compileAst(ast, grammar) {
|
|
|
66
66
|
case 'Identifier': {
|
|
67
67
|
const name = node.value;
|
|
68
68
|
if (!node.from) {
|
|
69
|
-
return
|
|
70
|
-
? (ev) => ev._relContext[name]
|
|
71
|
-
: (ev) => ev._context[name];
|
|
69
|
+
return (ctx) => ctx[name];
|
|
72
70
|
}
|
|
73
71
|
const from = compileAst(node.from, grammar);
|
|
74
|
-
return (
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
72
|
+
return (ctx) => {
|
|
73
|
+
const subject = from(ctx);
|
|
74
|
+
if (subject == null) {
|
|
77
75
|
return undefined;
|
|
78
76
|
}
|
|
79
77
|
// an identifier chained off an array reads through its first element
|
|
80
|
-
const
|
|
81
|
-
return
|
|
82
|
-
? undefined
|
|
83
|
-
: ctx[name];
|
|
78
|
+
const target = Array.isArray(subject) ? subject[0] : subject;
|
|
79
|
+
return target == null ? undefined : target[name];
|
|
84
80
|
};
|
|
85
81
|
}
|
|
86
82
|
case 'BinaryExpression': {
|
|
@@ -96,17 +92,17 @@ function compileAst(ast, grammar) {
|
|
|
96
92
|
if (evalOnDemand) {
|
|
97
93
|
// operands stay unevaluated behind an `eval` thunk, so operators such
|
|
98
94
|
// as && and || can short-circuit
|
|
99
|
-
return (
|
|
95
|
+
return (ctx) => evalOnDemand({ eval: () => left(ctx) }, { eval: () => right(ctx) });
|
|
100
96
|
}
|
|
101
97
|
const fn = op.eval;
|
|
102
98
|
if (!fn) {
|
|
103
|
-
return (
|
|
104
|
-
left(
|
|
105
|
-
right(
|
|
99
|
+
return (ctx) => {
|
|
100
|
+
left(ctx);
|
|
101
|
+
right(ctx);
|
|
106
102
|
return undefined;
|
|
107
103
|
};
|
|
108
104
|
}
|
|
109
|
-
return (
|
|
105
|
+
return (ctx) => fn(left(ctx), right(ctx));
|
|
110
106
|
}
|
|
111
107
|
case 'UnaryExpression': {
|
|
112
108
|
const right = compileAst(node.right, grammar);
|
|
@@ -118,12 +114,12 @@ function compileAst(ast, grammar) {
|
|
|
118
114
|
: undefined;
|
|
119
115
|
if (!fn) {
|
|
120
116
|
// the operand is still evaluated for an unknown operator, as before
|
|
121
|
-
return (
|
|
122
|
-
right(
|
|
117
|
+
return (ctx) => {
|
|
118
|
+
right(ctx);
|
|
123
119
|
return undefined;
|
|
124
120
|
};
|
|
125
121
|
}
|
|
126
|
-
return (
|
|
122
|
+
return (ctx) => fn(right(ctx));
|
|
127
123
|
}
|
|
128
124
|
case 'ConditionalExpression': {
|
|
129
125
|
const test = compileAst(node.test, grammar);
|
|
@@ -133,27 +129,21 @@ function compileAst(ast, grammar) {
|
|
|
133
129
|
const alternate = node.alternate
|
|
134
130
|
? compileAst(node.alternate, grammar)
|
|
135
131
|
: undefined;
|
|
136
|
-
return (
|
|
137
|
-
const res = test(
|
|
132
|
+
return (ctx) => {
|
|
133
|
+
const res = test(ctx);
|
|
138
134
|
if (res) {
|
|
139
135
|
// an omitted consequent ("a ?: b") yields the test result
|
|
140
|
-
return consequent ? consequent(
|
|
136
|
+
return consequent ? consequent(ctx) : res;
|
|
141
137
|
}
|
|
142
|
-
return alternate ? alternate(
|
|
138
|
+
return alternate ? alternate(ctx) : undefined;
|
|
143
139
|
};
|
|
144
140
|
}
|
|
145
141
|
case 'FilterExpression': {
|
|
146
|
-
if (node.relative) {
|
|
147
|
-
// thrown on evaluation rather than compilation, as before
|
|
148
|
-
return () => {
|
|
149
|
-
throw new Error('Relative filter expressions are not supported');
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
142
|
const subject = compileAst(node.subject, grammar);
|
|
153
143
|
const index = compileAst(node.expr, grammar);
|
|
154
|
-
return (
|
|
155
|
-
const subjectVal = subject(
|
|
156
|
-
const indexVal = index(
|
|
144
|
+
return (ctx) => {
|
|
145
|
+
const subjectVal = subject(ctx);
|
|
146
|
+
const indexVal = index(ctx);
|
|
157
147
|
if (subjectVal == null) {
|
|
158
148
|
return undefined;
|
|
159
149
|
}
|
|
@@ -165,10 +155,10 @@ function compileAst(ast, grammar) {
|
|
|
165
155
|
case 'ArrayLiteral': {
|
|
166
156
|
const items = node.value.map((item) => compileAst(item, grammar));
|
|
167
157
|
const len = items.length;
|
|
168
|
-
return (
|
|
158
|
+
return (ctx) => {
|
|
169
159
|
const out = new Array(len);
|
|
170
160
|
for (let i = 0; i < len; i++) {
|
|
171
|
-
out[i] = items[i](
|
|
161
|
+
out[i] = items[i](ctx);
|
|
172
162
|
}
|
|
173
163
|
return out;
|
|
174
164
|
};
|
|
@@ -180,10 +170,10 @@ function compileAst(ast, grammar) {
|
|
|
180
170
|
const len = keys.length;
|
|
181
171
|
// resolved once, here, so the common case keeps its plain store
|
|
182
172
|
const store = keys.includes('__proto__') ? defineOwn : assignOwn;
|
|
183
|
-
return (
|
|
173
|
+
return (ctx) => {
|
|
184
174
|
const out = {};
|
|
185
175
|
for (let i = 0; i < len; i++) {
|
|
186
|
-
store(out, keys[i], values[i](
|
|
176
|
+
store(out, keys[i], values[i](ctx));
|
|
187
177
|
}
|
|
188
178
|
return out;
|
|
189
179
|
};
|
|
@@ -196,12 +186,12 @@ function compileAst(ast, grammar) {
|
|
|
196
186
|
return () => value;
|
|
197
187
|
}
|
|
198
188
|
const expr = compileAst(part.value, grammar);
|
|
199
|
-
return (
|
|
189
|
+
return (ctx) => stringify(expr(ctx));
|
|
200
190
|
});
|
|
201
|
-
return (
|
|
191
|
+
return (ctx) => {
|
|
202
192
|
let out = '';
|
|
203
193
|
for (const part of parts) {
|
|
204
|
-
out += part(
|
|
194
|
+
out += part(ctx);
|
|
205
195
|
}
|
|
206
196
|
return out;
|
|
207
197
|
};
|
|
@@ -213,8 +203,8 @@ function compileAst(ast, grammar) {
|
|
|
213
203
|
// and `constructor` aren't callable as Jexl functions. Resolved per call
|
|
214
204
|
// rather than baked in, since functions are routinely registered after
|
|
215
205
|
// an expression has been compiled.
|
|
216
|
-
const lookup = (
|
|
217
|
-
const { functions } =
|
|
206
|
+
const lookup = () => {
|
|
207
|
+
const { functions } = grammar;
|
|
218
208
|
if (!Object.hasOwn(functions, name)) {
|
|
219
209
|
throw new Error(`Jexl Function ${name} is not defined.`);
|
|
220
210
|
}
|
|
@@ -224,28 +214,28 @@ function compileAst(ast, grammar) {
|
|
|
224
214
|
// argument array and needs no spread
|
|
225
215
|
switch (args.length) {
|
|
226
216
|
case 0: {
|
|
227
|
-
return (
|
|
217
|
+
return () => lookup()();
|
|
228
218
|
}
|
|
229
219
|
case 1: {
|
|
230
220
|
const [a0] = args;
|
|
231
|
-
return (
|
|
221
|
+
return (ctx) => lookup()(a0(ctx));
|
|
232
222
|
}
|
|
233
223
|
case 2: {
|
|
234
224
|
const [a0, a1] = args;
|
|
235
|
-
return (
|
|
225
|
+
return (ctx) => lookup()(a0(ctx), a1(ctx));
|
|
236
226
|
}
|
|
237
227
|
case 3: {
|
|
238
228
|
const [a0, a1, a2] = args;
|
|
239
|
-
return (
|
|
229
|
+
return (ctx) => lookup()(a0(ctx), a1(ctx), a2(ctx));
|
|
240
230
|
}
|
|
241
231
|
default: {
|
|
242
232
|
const len = args.length;
|
|
243
|
-
return (
|
|
233
|
+
return (ctx) => {
|
|
244
234
|
const vals = new Array(len);
|
|
245
235
|
for (let i = 0; i < len; i++) {
|
|
246
|
-
vals[i] = args[i](
|
|
236
|
+
vals[i] = args[i](ctx);
|
|
247
237
|
}
|
|
248
|
-
return lookup(
|
|
238
|
+
return lookup()(...vals);
|
|
249
239
|
};
|
|
250
240
|
}
|
|
251
241
|
}
|
|
@@ -253,10 +243,10 @@ function compileAst(ast, grammar) {
|
|
|
253
243
|
case 'SequenceExpression': {
|
|
254
244
|
const exprs = node.expressions.map((expr) => compileAst(expr, grammar));
|
|
255
245
|
const len = exprs.length;
|
|
256
|
-
return (
|
|
246
|
+
return (ctx) => {
|
|
257
247
|
let last;
|
|
258
248
|
for (let i = 0; i < len; i++) {
|
|
259
|
-
last = exprs[i](
|
|
249
|
+
last = exprs[i](ctx);
|
|
260
250
|
}
|
|
261
251
|
return last;
|
|
262
252
|
};
|
|
@@ -265,9 +255,9 @@ function compileAst(ast, grammar) {
|
|
|
265
255
|
const name = node.left.value;
|
|
266
256
|
const right = compileAst(node.right, grammar);
|
|
267
257
|
const store = name === '__proto__' ? defineOwn : assignOwn;
|
|
268
|
-
return (
|
|
269
|
-
const value = right(
|
|
270
|
-
store(
|
|
258
|
+
return (ctx) => {
|
|
259
|
+
const value = right(ctx);
|
|
260
|
+
store(ctx, name, value);
|
|
271
261
|
return value;
|
|
272
262
|
};
|
|
273
263
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/evaluator/compile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/evaluator/compile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAoEH,gCAsOC;AA3RD;;;;;;GAMG;AACH,SAAS,SAAS,CAAC,MAAe,EAAE,GAAW,EAAE,KAAgB;IAC/D,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;QACjC,KAAK;QACL,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,IAAI;KACnB,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,MAAe,EAAE,GAAW,EAAE,KAAgB;IAC/D,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AACrB,CAAC;AAED,4DAA4D;AAC5D,SAAS,SAAS,CAAC,KAAgB;IACjC,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,EAAE,CAAA;IACX,CAAC;IACD,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS,EAC1B,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;IACD,OAAO,IAAI,CAAC,SA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