@jbrowse/jexl 3.0.2 → 3.1.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 +11 -2
- package/dist/Expression.d.ts +16 -6
- package/dist/Expression.js +34 -8
- 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 -8
- package/dist/Lexer.js +58 -18
- 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 +261 -0
- package/dist/evaluator/compile.js.map +1 -0
- package/dist/grammar.d.ts +29 -9
- package/dist/grammar.js +19 -3
- package/dist/grammar.js.map +1 -1
- package/dist/parser/Parser.d.ts +5 -7
- package/dist/parser/Parser.js +17 -2
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/handlers.d.ts +0 -6
- package/dist/parser/handlers.js +54 -46
- package/dist/parser/handlers.js.map +1 -1
- package/dist/parser/states.d.ts +2 -2
- package/dist/parser/states.js +0 -20
- package/dist/parser/states.js.map +1 -1
- package/dist/types.d.ts +18 -7
- package/esm/Expression.d.ts +16 -6
- package/esm/Expression.js +34 -8
- 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 -8
- package/esm/Lexer.js +58 -18
- 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 +258 -0
- package/esm/evaluator/compile.js.map +1 -0
- package/esm/grammar.d.ts +29 -9
- package/esm/grammar.js +18 -3
- package/esm/grammar.js.map +1 -1
- package/esm/parser/Parser.d.ts +5 -7
- package/esm/parser/Parser.js +17 -2
- package/esm/parser/Parser.js.map +1 -1
- package/esm/parser/handlers.d.ts +0 -6
- package/esm/parser/handlers.js +54 -45
- package/esm/parser/handlers.js.map +1 -1
- package/esm/parser/states.d.ts +2 -2
- package/esm/parser/states.js +0 -20
- package/esm/parser/states.js.map +1 -1
- package/esm/types.d.ts +18 -7
- package/package.json +25 -28
- package/src/Expression.ts +33 -13
- package/src/Jexl.ts +59 -21
- package/src/Lexer.ts +60 -27
- package/src/evaluator/Evaluator.ts +27 -44
- package/src/evaluator/compile.ts +310 -0
- package/src/grammar.ts +66 -17
- package/src/parser/Parser.ts +24 -20
- package/src/parser/handlers.ts +96 -73
- package/src/parser/states.ts +2 -22
- 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
|
@@ -3,49 +3,20 @@
|
|
|
3
3
|
* Jexl
|
|
4
4
|
* Copyright 2020 Tom Shawver
|
|
5
5
|
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
-
var ownKeys = function(o) {
|
|
24
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
-
var ar = [];
|
|
26
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
return ownKeys(o);
|
|
30
|
-
};
|
|
31
|
-
return function (mod) {
|
|
32
|
-
if (mod && mod.__esModule) return mod;
|
|
33
|
-
var result = {};
|
|
34
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
-
__setModuleDefault(result, mod);
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
})();
|
|
39
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
const
|
|
7
|
+
const compile_ts_1 = require("./compile.js");
|
|
41
8
|
/**
|
|
42
|
-
* The Evaluator
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* When any of these things change, a new instance is required. However, a
|
|
47
|
-
* single instance can be used to simultaneously evaluate many different
|
|
9
|
+
* The Evaluator carries everything an expression is evaluated against: the
|
|
10
|
+
* grammar, the context, and a relative context to be used as the root for
|
|
11
|
+
* relative identifiers. When any of these change, a new instance is required.
|
|
12
|
+
* However, a single instance can be used to evaluate many different
|
|
48
13
|
* expressions, and does not have to be reinstantiated for each.
|
|
14
|
+
*
|
|
15
|
+
* The work of evaluation itself lives in {@link compileAst}, which lowers a
|
|
16
|
+
* tree to closures. Prefer compiling once and reusing the result — that is what
|
|
17
|
+
* {@link Expression} does — over calling {@link #eval}, which compiles the tree
|
|
18
|
+
* it is given every time.
|
|
19
|
+
*
|
|
49
20
|
* @param {{}} grammar A grammar object against which to evaluate the expression
|
|
50
21
|
* tree
|
|
51
22
|
* @param {{}} [context] A map of variable keys to their values. This will be
|
|
@@ -54,40 +25,24 @@ const handlers = __importStar(require("./handlers.js"));
|
|
|
54
25
|
* to resolve the value of a relative identifier.
|
|
55
26
|
*/
|
|
56
27
|
class Evaluator {
|
|
28
|
+
_grammar;
|
|
29
|
+
_context;
|
|
30
|
+
_relContext;
|
|
57
31
|
constructor(grammar, context, relativeContext) {
|
|
58
32
|
this._grammar = grammar;
|
|
59
33
|
this._context = context || {};
|
|
60
34
|
this._relContext = relativeContext || this._context;
|
|
61
35
|
}
|
|
62
36
|
/**
|
|
63
|
-
*
|
|
37
|
+
* Compiles and evaluates an expression tree within the configured context.
|
|
38
|
+
* Convenient for a one-shot evaluation; for repeated evaluation of the same
|
|
39
|
+
* tree, hold onto the closure from {@link compileAst} instead so the tree is
|
|
40
|
+
* only lowered once.
|
|
64
41
|
* @param {{}} ast An expression tree object
|
|
65
42
|
* @returns {*} the resulting value of the expression.
|
|
66
43
|
*/
|
|
67
44
|
eval(ast) {
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Evaluates each expression within an array, and delivers the response as an
|
|
72
|
-
* array with the resulting values at the same indexes as their originating
|
|
73
|
-
* expressions.
|
|
74
|
-
* @param {Array<string>} arr An array of expression strings to be evaluated
|
|
75
|
-
* @returns {Array<{}>} the result array
|
|
76
|
-
*/
|
|
77
|
-
evalArray(arr) {
|
|
78
|
-
return arr.map((elem) => this.eval(elem));
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Evaluates each expression within a map, and delivers the response as a map
|
|
82
|
-
* with the same keys, but with the evaluated result for each as their value.
|
|
83
|
-
* @param {{}} map A map of expression names to expression trees to be
|
|
84
|
-
* evaluated
|
|
85
|
-
* @returns {{}} the result map.
|
|
86
|
-
*/
|
|
87
|
-
evalMap(map) {
|
|
88
|
-
const entries = Object.entries(map);
|
|
89
|
-
const vals = entries.map(([_, ast]) => this.eval(ast));
|
|
90
|
-
return Object.fromEntries(entries.map(([key], idx) => [key, vals[idx]]));
|
|
45
|
+
return (0, compile_ts_1.compileAst)(ast, this._grammar)(this);
|
|
91
46
|
}
|
|
92
47
|
}
|
|
93
48
|
exports.default = Evaluator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Evaluator.js","sourceRoot":"","sources":["../../src/evaluator/Evaluator.ts"],"names":[],"mappings":";AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"Evaluator.js","sourceRoot":"","sources":["../../src/evaluator/Evaluator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAEH,6CAAyC;AAKzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,SAAS;IACb,QAAQ,CAAS;IACjB,QAAQ,CAA2B;IACnC,WAAW,CAA2B;IAEtC,YACE,OAAgB,EAChB,OAAmC,EACnC,eAA2C;QAE3C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAI,EAAE,CAAA;QAC7B,IAAI,CAAC,WAAW,GAAG,eAAe,IAAI,IAAI,CAAC,QAAQ,CAAA;IACrD,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,CAAC,GAAY;QACf,OAAO,IAAA,uBAAU,EAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAA;IAC7C,CAAC;CACF;AAED,kBAAe,SAAS,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Grammar } from '../grammar.ts';
|
|
2
|
+
import type { AstNode, JexlValue } from '../types.ts';
|
|
3
|
+
import type Evaluator from './Evaluator.ts';
|
|
4
|
+
/**
|
|
5
|
+
* An AST node lowered to a closure. Calling it with an Evaluator (which carries
|
|
6
|
+
* the context and grammar) produces the node's value.
|
|
7
|
+
*/
|
|
8
|
+
export type CompiledNode = (ev: Evaluator) => JexlValue;
|
|
9
|
+
/**
|
|
10
|
+
* Lowers an expression tree into a tree of closures, resolving each node's type
|
|
11
|
+
* and its operator's implementation once, at compile time, rather than
|
|
12
|
+
* re-dispatching on `node.type` for every node on every evaluation. An
|
|
13
|
+
* expression compiled once and evaluated per-item — the usual shape for
|
|
14
|
+
* per-feature config callbacks — pays the dispatch cost once instead of N
|
|
15
|
+
* times.
|
|
16
|
+
*
|
|
17
|
+
* Operators are bound here, so a grammar change after compilation requires
|
|
18
|
+
* recompiling, which is what {@link Expression#compile} already documents.
|
|
19
|
+
* Functions are looked up per call, since they are commonly registered after
|
|
20
|
+
* an expression has been compiled.
|
|
21
|
+
*
|
|
22
|
+
* @param {{}} ast An expression tree, as produced by the Parser
|
|
23
|
+
* @param {{}} grammar The grammar to resolve operators against
|
|
24
|
+
* @returns {function} a closure returning the expression's value
|
|
25
|
+
* @throws {Error} if the tree contains an unrecognized node type
|
|
26
|
+
*/
|
|
27
|
+
export declare function compileAst(ast: AstNode, grammar: Grammar): CompiledNode;
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Jexl
|
|
4
|
+
* Copyright 2020 Tom Shawver
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.compileAst = compileAst;
|
|
8
|
+
/** Renders an interpolated value for a template literal. */
|
|
9
|
+
function stringify(value) {
|
|
10
|
+
if (value == null) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
if (typeof value === 'string' ||
|
|
14
|
+
typeof value === 'number' ||
|
|
15
|
+
typeof value === 'boolean') {
|
|
16
|
+
return String(value);
|
|
17
|
+
}
|
|
18
|
+
return JSON.stringify(value);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Lowers an expression tree into a tree of closures, resolving each node's type
|
|
22
|
+
* and its operator's implementation once, at compile time, rather than
|
|
23
|
+
* re-dispatching on `node.type` for every node on every evaluation. An
|
|
24
|
+
* expression compiled once and evaluated per-item — the usual shape for
|
|
25
|
+
* per-feature config callbacks — pays the dispatch cost once instead of N
|
|
26
|
+
* times.
|
|
27
|
+
*
|
|
28
|
+
* Operators are bound here, so a grammar change after compilation requires
|
|
29
|
+
* recompiling, which is what {@link Expression#compile} already documents.
|
|
30
|
+
* Functions are looked up per call, since they are commonly registered after
|
|
31
|
+
* an expression has been compiled.
|
|
32
|
+
*
|
|
33
|
+
* @param {{}} ast An expression tree, as produced by the Parser
|
|
34
|
+
* @param {{}} grammar The grammar to resolve operators against
|
|
35
|
+
* @returns {function} a closure returning the expression's value
|
|
36
|
+
* @throws {Error} if the tree contains an unrecognized node type
|
|
37
|
+
*/
|
|
38
|
+
function compileAst(ast, grammar) {
|
|
39
|
+
switch (ast.type) {
|
|
40
|
+
case 'Literal': {
|
|
41
|
+
const { value } = ast;
|
|
42
|
+
return () => value;
|
|
43
|
+
}
|
|
44
|
+
case 'Identifier': {
|
|
45
|
+
const node = ast;
|
|
46
|
+
const name = node.value;
|
|
47
|
+
if (!node.from) {
|
|
48
|
+
return node.relative
|
|
49
|
+
? (ev) => ev._relContext[name]
|
|
50
|
+
: (ev) => ev._context[name];
|
|
51
|
+
}
|
|
52
|
+
const from = compileAst(node.from, grammar);
|
|
53
|
+
return (ev) => {
|
|
54
|
+
const context = from(ev);
|
|
55
|
+
if (context == null) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
// an identifier chained off an array reads through its first element
|
|
59
|
+
const ctx = Array.isArray(context) ? context[0] : context;
|
|
60
|
+
return ctx == null
|
|
61
|
+
? undefined
|
|
62
|
+
: ctx[name];
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
case 'BinaryExpression': {
|
|
66
|
+
const node = ast;
|
|
67
|
+
const op = grammar.elements[node.operator];
|
|
68
|
+
if (op?.type !== 'binaryOp') {
|
|
69
|
+
// matches the tree-walking behaviour: an unknown operator yields
|
|
70
|
+
// undefined without evaluating either operand
|
|
71
|
+
return () => undefined;
|
|
72
|
+
}
|
|
73
|
+
const left = compileAst(node.left, grammar);
|
|
74
|
+
const right = compileAst(node.right, grammar);
|
|
75
|
+
const { evalOnDemand } = op;
|
|
76
|
+
if (evalOnDemand) {
|
|
77
|
+
// operands stay unevaluated behind an `eval` thunk, so operators such
|
|
78
|
+
// as && and || can short-circuit
|
|
79
|
+
return (ev) => evalOnDemand({ eval: () => left(ev) }, { eval: () => right(ev) });
|
|
80
|
+
}
|
|
81
|
+
const fn = op.eval;
|
|
82
|
+
if (!fn) {
|
|
83
|
+
return (ev) => {
|
|
84
|
+
left(ev);
|
|
85
|
+
right(ev);
|
|
86
|
+
return undefined;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return (ev) => fn(left(ev), right(ev));
|
|
90
|
+
}
|
|
91
|
+
case 'UnaryExpression': {
|
|
92
|
+
const node = ast;
|
|
93
|
+
const right = compileAst(node.right, grammar);
|
|
94
|
+
const elem = grammar.elements[node.operator];
|
|
95
|
+
const fn = elem?.type === 'unaryOp'
|
|
96
|
+
? elem.eval
|
|
97
|
+
: elem?.type === 'binaryOp'
|
|
98
|
+
? elem.unaryEval
|
|
99
|
+
: undefined;
|
|
100
|
+
if (!fn) {
|
|
101
|
+
// the operand is still evaluated for an unknown operator, as before
|
|
102
|
+
return (ev) => {
|
|
103
|
+
right(ev);
|
|
104
|
+
return undefined;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return (ev) => fn(right(ev));
|
|
108
|
+
}
|
|
109
|
+
case 'ConditionalExpression': {
|
|
110
|
+
const node = ast;
|
|
111
|
+
const test = compileAst(node.test, grammar);
|
|
112
|
+
const consequent = node.consequent
|
|
113
|
+
? compileAst(node.consequent, grammar)
|
|
114
|
+
: undefined;
|
|
115
|
+
const alternate = node.alternate
|
|
116
|
+
? compileAst(node.alternate, grammar)
|
|
117
|
+
: undefined;
|
|
118
|
+
return (ev) => {
|
|
119
|
+
const res = test(ev);
|
|
120
|
+
if (res) {
|
|
121
|
+
// an omitted consequent ("a ?: b") yields the test result
|
|
122
|
+
return consequent ? consequent(ev) : res;
|
|
123
|
+
}
|
|
124
|
+
return alternate ? alternate(ev) : undefined;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
case 'FilterExpression': {
|
|
128
|
+
const node = ast;
|
|
129
|
+
if (node.relative) {
|
|
130
|
+
// thrown on evaluation rather than compilation, as before
|
|
131
|
+
return () => {
|
|
132
|
+
throw new Error('Relative filter expressions are not supported');
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
const subject = compileAst(node.subject, grammar);
|
|
136
|
+
const index = compileAst(node.expr, grammar);
|
|
137
|
+
return (ev) => {
|
|
138
|
+
const subjectVal = subject(ev);
|
|
139
|
+
const indexVal = index(ev);
|
|
140
|
+
if (subjectVal == null) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
return typeof indexVal === 'string' || typeof indexVal === 'number'
|
|
144
|
+
? subjectVal[indexVal]
|
|
145
|
+
: undefined;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
case 'ArrayLiteral': {
|
|
149
|
+
const items = ast.value.map((item) => compileAst(item, grammar));
|
|
150
|
+
const len = items.length;
|
|
151
|
+
return (ev) => {
|
|
152
|
+
const out = new Array(len);
|
|
153
|
+
for (let i = 0; i < len; i++) {
|
|
154
|
+
out[i] = items[i](ev);
|
|
155
|
+
}
|
|
156
|
+
return out;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
case 'ObjectLiteral': {
|
|
160
|
+
const entries = Object.entries(ast.value);
|
|
161
|
+
const keys = entries.map(([key]) => key);
|
|
162
|
+
const values = entries.map(([, node]) => compileAst(node, grammar));
|
|
163
|
+
const len = keys.length;
|
|
164
|
+
return (ev) => {
|
|
165
|
+
const out = {};
|
|
166
|
+
for (let i = 0; i < len; i++) {
|
|
167
|
+
out[keys[i]] = values[i](ev);
|
|
168
|
+
}
|
|
169
|
+
return out;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
case 'TemplateLiteral': {
|
|
173
|
+
// every part renders to a string, so these are narrower than CompiledNode
|
|
174
|
+
const parts = ast.parts.map((part) => {
|
|
175
|
+
if (part.type === 'static') {
|
|
176
|
+
const { value } = part;
|
|
177
|
+
return () => value;
|
|
178
|
+
}
|
|
179
|
+
const expr = compileAst(part.value, grammar);
|
|
180
|
+
return (ev) => stringify(expr(ev));
|
|
181
|
+
});
|
|
182
|
+
return (ev) => {
|
|
183
|
+
let out = '';
|
|
184
|
+
for (const part of parts) {
|
|
185
|
+
out += part(ev);
|
|
186
|
+
}
|
|
187
|
+
return out;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
case 'FunctionCall': {
|
|
191
|
+
const node = ast;
|
|
192
|
+
const { name } = node;
|
|
193
|
+
const args = node.args.map((arg) => compileAst(arg, grammar));
|
|
194
|
+
// hasOwn, so that inherited Object.prototype members such as `toString`
|
|
195
|
+
// and `constructor` aren't callable as Jexl functions. Resolved per call
|
|
196
|
+
// rather than baked in, since functions are routinely registered after
|
|
197
|
+
// an expression has been compiled.
|
|
198
|
+
const lookup = (ev) => {
|
|
199
|
+
const { functions } = ev._grammar;
|
|
200
|
+
if (!Object.hasOwn(functions, name)) {
|
|
201
|
+
throw new Error(`Jexl Function ${name} is not defined.`);
|
|
202
|
+
}
|
|
203
|
+
return functions[name];
|
|
204
|
+
};
|
|
205
|
+
// the small arities are spelled out so an ordinary call allocates no
|
|
206
|
+
// argument array and needs no spread
|
|
207
|
+
switch (args.length) {
|
|
208
|
+
case 0: {
|
|
209
|
+
return (ev) => lookup(ev)();
|
|
210
|
+
}
|
|
211
|
+
case 1: {
|
|
212
|
+
const [a0] = args;
|
|
213
|
+
return (ev) => lookup(ev)(a0(ev));
|
|
214
|
+
}
|
|
215
|
+
case 2: {
|
|
216
|
+
const [a0, a1] = args;
|
|
217
|
+
return (ev) => lookup(ev)(a0(ev), a1(ev));
|
|
218
|
+
}
|
|
219
|
+
case 3: {
|
|
220
|
+
const [a0, a1, a2] = args;
|
|
221
|
+
return (ev) => lookup(ev)(a0(ev), a1(ev), a2(ev));
|
|
222
|
+
}
|
|
223
|
+
default: {
|
|
224
|
+
const len = args.length;
|
|
225
|
+
return (ev) => {
|
|
226
|
+
const vals = new Array(len);
|
|
227
|
+
for (let i = 0; i < len; i++) {
|
|
228
|
+
vals[i] = args[i](ev);
|
|
229
|
+
}
|
|
230
|
+
return lookup(ev)(...vals);
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
case 'SequenceExpression': {
|
|
236
|
+
const exprs = ast.expressions.map((expr) => compileAst(expr, grammar));
|
|
237
|
+
const len = exprs.length;
|
|
238
|
+
return (ev) => {
|
|
239
|
+
let last;
|
|
240
|
+
for (let i = 0; i < len; i++) {
|
|
241
|
+
last = exprs[i](ev);
|
|
242
|
+
}
|
|
243
|
+
return last;
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
case 'AssignmentExpression': {
|
|
247
|
+
const node = ast;
|
|
248
|
+
const name = node.left.value;
|
|
249
|
+
const right = compileAst(node.right, grammar);
|
|
250
|
+
return (ev) => {
|
|
251
|
+
const value = right(ev);
|
|
252
|
+
ev._context[name] = value;
|
|
253
|
+
return value;
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
default: {
|
|
257
|
+
throw new Error(`Corrupt AST: unknown node type '${ast.type}'`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=compile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/evaluator/compile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AA4DH,gCAsPC;AAvRD,4DAA4D;AAC5D,SAAS,SAAS,CAAC,KA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AAA;YAC9C,OAAO,CAAC,EAAE,EAAE,EAAE;gBACZ,MAAM,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,CAAA;gBACvB,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;gBACzB,OAAO,KAAK,CAAA;YACd,CAAC,CAAA;QACH,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAA;QACjE,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/grammar.d.ts
CHANGED
|
@@ -1,24 +1,44 @@
|
|
|
1
|
+
import type { JexlValue } from './types.ts';
|
|
2
|
+
export type BinaryOpEval = (left: JexlValue, right: JexlValue) => JexlValue;
|
|
3
|
+
export type BinaryOpEvalOnDemand = (left: {
|
|
4
|
+
eval: () => JexlValue;
|
|
5
|
+
}, right: {
|
|
6
|
+
eval: () => JexlValue;
|
|
7
|
+
}) => JexlValue;
|
|
1
8
|
export interface BinaryOp {
|
|
2
9
|
type: 'binaryOp';
|
|
3
10
|
precedence: number;
|
|
4
|
-
eval?:
|
|
5
|
-
evalOnDemand?:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
eval?: BinaryOpEval;
|
|
12
|
+
evalOnDemand?: BinaryOpEvalOnDemand;
|
|
13
|
+
/**
|
|
14
|
+
* Evaluator for the operator's prefix form, if it has one. The Lexer emits a
|
|
15
|
+
* unaryOp token when such an operator appears where an operand is expected,
|
|
16
|
+
* which is how `-x` is distinguished from `a - x`.
|
|
17
|
+
*/
|
|
18
|
+
unaryEval?: (right: JexlValue) => JexlValue;
|
|
10
19
|
}
|
|
11
20
|
export interface UnaryOp {
|
|
12
21
|
type: 'unaryOp';
|
|
13
22
|
precedence: number;
|
|
14
|
-
eval: (right:
|
|
23
|
+
eval: (right: JexlValue) => JexlValue;
|
|
15
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The punctuation elements of the grammar. Unlike operators these carry no
|
|
27
|
+
* behavior of their own; the Parser's state machine gives them meaning. The
|
|
28
|
+
* type is a literal union rather than `string` so that `GrammarElement` is a
|
|
29
|
+
* discriminated union, letting operator properties be accessed without casts.
|
|
30
|
+
*/
|
|
16
31
|
export interface SimpleElement {
|
|
17
|
-
type:
|
|
32
|
+
type: 'dot' | 'openBracket' | 'closeBracket' | 'openCurl' | 'closeCurl' | 'colon' | 'comma' | 'openParen' | 'closeParen' | 'question' | 'semicolon';
|
|
18
33
|
}
|
|
19
34
|
export type GrammarElement = BinaryOp | UnaryOp | SimpleElement;
|
|
20
35
|
export interface Grammar {
|
|
21
36
|
elements: Record<string, GrammarElement>;
|
|
22
|
-
functions: Record<string, (...args:
|
|
37
|
+
functions: Record<string, (...args: JexlValue[]) => JexlValue>;
|
|
23
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Returns the binding power of a grammar element, or 0 for elements that
|
|
41
|
+
* aren't operators and therefore don't participate in precedence.
|
|
42
|
+
*/
|
|
43
|
+
export declare function precedenceOf(elem: GrammarElement | undefined): number;
|
|
24
44
|
export declare const getGrammar: () => Grammar;
|
package/dist/grammar.js
CHANGED
|
@@ -5,6 +5,16 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.getGrammar = void 0;
|
|
8
|
+
exports.precedenceOf = precedenceOf;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the binding power of a grammar element, or 0 for elements that
|
|
11
|
+
* aren't operators and therefore don't participate in precedence.
|
|
12
|
+
*/
|
|
13
|
+
function precedenceOf(elem) {
|
|
14
|
+
return elem && (elem.type === 'binaryOp' || elem.type === 'unaryOp')
|
|
15
|
+
? elem.precedence
|
|
16
|
+
: 0;
|
|
17
|
+
}
|
|
8
18
|
const getGrammar = () => ({
|
|
9
19
|
/**
|
|
10
20
|
* A map of all expression elements to their properties. Note that changes
|
|
@@ -31,7 +41,8 @@ const getGrammar = () => ({
|
|
|
31
41
|
'-': {
|
|
32
42
|
type: 'binaryOp',
|
|
33
43
|
precedence: 30,
|
|
34
|
-
eval: (left, right) => left - right
|
|
44
|
+
eval: (left, right) => left - right,
|
|
45
|
+
unaryEval: (right) => -right
|
|
35
46
|
},
|
|
36
47
|
'*': {
|
|
37
48
|
type: 'binaryOp',
|
|
@@ -56,7 +67,7 @@ const getGrammar = () => ({
|
|
|
56
67
|
'^': {
|
|
57
68
|
type: 'binaryOp',
|
|
58
69
|
precedence: 50,
|
|
59
|
-
eval: (left, right) =>
|
|
70
|
+
eval: (left, right) => left ** right
|
|
60
71
|
},
|
|
61
72
|
'==': {
|
|
62
73
|
type: 'binaryOp',
|
|
@@ -115,7 +126,12 @@ const getGrammar = () => ({
|
|
|
115
126
|
precedence: 20,
|
|
116
127
|
eval: (left, right) => {
|
|
117
128
|
if (typeof right === 'string') {
|
|
118
|
-
|
|
129
|
+
const leftStr = typeof left === 'string' ||
|
|
130
|
+
typeof left === 'number' ||
|
|
131
|
+
typeof left === 'boolean'
|
|
132
|
+
? String(left)
|
|
133
|
+
: '';
|
|
134
|
+
return right.includes(leftStr);
|
|
119
135
|
}
|
|
120
136
|
if (Array.isArray(right)) {
|
|
121
137
|
return right.includes(left);
|
package/dist/grammar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grammar.js","sourceRoot":"","sources":["../src/grammar.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"grammar.js","sourceRoot":"","sources":["../src/grammar.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgEH,oCAIC;AARD;;;GAGG;AACH,SAAgB,YAAY,CAAC,IAAgC;IAC3D,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;QAClE,CAAC,CAAC,IAAI,CAAC,UAAU;QACjB,CAAC,CAAC,CAA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ChC,CAAC;gBACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzB,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;gBAC7B,CAAC;gBACD,OAAO,KAAK,CAAA;YACd,CAAC;SACF;QACD,GAAG,EAAE;YACH,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,QAAQ;YACpB,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK;SACxB;QACD,GAAG,EAAE;YACH,IAAI,EAAE,UAAU;YAChB,UAAU,EAAE,CAAC;YACb,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;gBACtB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;YACjD,CAAC;SACF;KACF;IAED;;;;;;;;;;;;;OAaG;IACH,SAAS,EAAE,EAAE;CACd,CAAC,CAAA;AA1JW,QAAA,UAAU,cA0JrB"}
|
package/dist/parser/Parser.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type Lexer from '../Lexer.ts';
|
|
2
|
+
import type { Grammar } from '../grammar.ts';
|
|
2
3
|
import type { AstNode, Token } from '../types.ts';
|
|
3
|
-
interface Grammar {
|
|
4
|
-
elements: Record<string, any>;
|
|
5
|
-
}
|
|
6
4
|
/**
|
|
7
5
|
* The Parser is a state machine that converts tokens from the {@link Lexer}
|
|
8
6
|
* into an Abstract Syntax Tree (AST), capable of being evaluated in any
|
|
@@ -27,7 +25,7 @@ declare class Parser {
|
|
|
27
25
|
_tree: AstNode | null;
|
|
28
26
|
_exprStr: string;
|
|
29
27
|
_relative: boolean;
|
|
30
|
-
_stopMap: Record<string,
|
|
28
|
+
_stopMap: Record<string, string>;
|
|
31
29
|
_cursor?: AstNode | null;
|
|
32
30
|
_subParser?: Parser;
|
|
33
31
|
_parentStop?: boolean;
|
|
@@ -35,7 +33,7 @@ declare class Parser {
|
|
|
35
33
|
_nextIdentRelative?: boolean;
|
|
36
34
|
_curObjKey?: string;
|
|
37
35
|
_sequenceExpressions?: AstNode[];
|
|
38
|
-
constructor(grammar: Grammar, lexer: Lexer, prefix?: string, stopMap?: Record<string,
|
|
36
|
+
constructor(grammar: Grammar, lexer: Lexer, prefix?: string, stopMap?: Record<string, string>);
|
|
39
37
|
/**
|
|
40
38
|
* Processes a new token into the AST and manages the transitions of the state
|
|
41
39
|
* machine.
|
|
@@ -46,7 +44,7 @@ declare class Parser {
|
|
|
46
44
|
* @returns {boolean|*} the stopState value if this parser encountered a token
|
|
47
45
|
* in the stopState mapb false if tokens can continue.
|
|
48
46
|
*/
|
|
49
|
-
addToken(token: Token):
|
|
47
|
+
addToken(token: Token): string | false;
|
|
50
48
|
/**
|
|
51
49
|
* Processes an array of tokens iteratively through the {@link #addToken}
|
|
52
50
|
* function.
|
|
@@ -62,7 +60,7 @@ declare class Parser {
|
|
|
62
60
|
* @throws {Error} if the parser is not in a state where it's legal to end
|
|
63
61
|
* the expression, indicating that the expression is incomplete
|
|
64
62
|
*/
|
|
65
|
-
complete():
|
|
63
|
+
complete(): AstNode | null;
|
|
66
64
|
/**
|
|
67
65
|
* Indicates whether the expression tree contains a relative path identifier.
|
|
68
66
|
* @returns {boolean} true if a relative identifier exists false otherwise.
|
package/dist/parser/Parser.js
CHANGED
|
@@ -57,6 +57,20 @@ const states_ts_1 = require("./states.js");
|
|
|
57
57
|
* instead of boolean false.
|
|
58
58
|
*/
|
|
59
59
|
class Parser {
|
|
60
|
+
_grammar;
|
|
61
|
+
_lexer;
|
|
62
|
+
_state;
|
|
63
|
+
_tree;
|
|
64
|
+
_exprStr;
|
|
65
|
+
_relative;
|
|
66
|
+
_stopMap;
|
|
67
|
+
_cursor;
|
|
68
|
+
_subParser;
|
|
69
|
+
_parentStop;
|
|
70
|
+
_nextIdentEncapsulate;
|
|
71
|
+
_nextIdentRelative;
|
|
72
|
+
_curObjKey;
|
|
73
|
+
_sequenceExpressions;
|
|
60
74
|
constructor(grammar, lexer, prefix, stopMap) {
|
|
61
75
|
this._grammar = grammar;
|
|
62
76
|
this._lexer = lexer;
|
|
@@ -132,7 +146,9 @@ class Parser {
|
|
|
132
146
|
* the {@link Lexer#tokenize} function.
|
|
133
147
|
*/
|
|
134
148
|
addTokens(tokens) {
|
|
135
|
-
|
|
149
|
+
for (const token of tokens) {
|
|
150
|
+
this.addToken(token);
|
|
151
|
+
}
|
|
136
152
|
}
|
|
137
153
|
/**
|
|
138
154
|
* Marks this Parser instance as completed and retrieves the full AST.
|
|
@@ -191,7 +207,6 @@ class Parser {
|
|
|
191
207
|
this._tree = node;
|
|
192
208
|
}
|
|
193
209
|
else {
|
|
194
|
-
;
|
|
195
210
|
this._cursor.right = node;
|
|
196
211
|
this._setParent(node, this._cursor);
|
|
197
212
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Parser.js","sourceRoot":"","sources":["../../src/parser/Parser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,wDAAyC;AACzC,2CAAoC;
|
|
1
|
+
{"version":3,"file":"Parser.js","sourceRoot":"","sources":["../../src/parser/Parser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,wDAAyC;AACzC,2CAAoC;AAMpC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM;IACV,QAAQ,CAAS;IACjB,MAAM,CAAO;IACb,MAAM,CAAQ;IACd,KAAK,CAAgB;IACrB,QAAQ,CAAQ;IAChB,SAAS,CAAS;IAClB,QAAQ,CAAwB;IAChC,OAAO,CAAiB;IACxB,UAAU,CAAS;IACnB,WAAW,CAAU;IACrB,qBAAqB,CAAU;IAC/B,kBAAkB,CAAU;IAC5B,UAAU,CAAS;IACnB,oBAAoB,CAAY;IAEhC,YACE,OAAgB,EAChB,KAAY,EACZ,MAAe,EACf,OAAgC;QAEhC,IAAI,CAAC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