@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
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Grammar } from '../grammar.ts';
|
|
2
|
-
import type { AstNode, JexlValue } from '../types.ts';
|
|
3
|
-
/**
|
|
4
|
-
* The Evaluator carries everything an expression is evaluated against: the
|
|
5
|
-
* grammar, the context, and a relative context to be used as the root for
|
|
6
|
-
* relative identifiers. When any of these change, a new instance is required.
|
|
7
|
-
* However, a single instance can be used to evaluate many different
|
|
8
|
-
* expressions, and does not have to be reinstantiated for each.
|
|
9
|
-
*
|
|
10
|
-
* The work of evaluation itself lives in {@link compileAst}, which lowers a
|
|
11
|
-
* tree to closures. Prefer compiling once and reusing the result — that is what
|
|
12
|
-
* {@link Expression} does — over calling {@link #eval}, which compiles the tree
|
|
13
|
-
* it is given every time.
|
|
14
|
-
*
|
|
15
|
-
* @param {{}} grammar A grammar object against which to evaluate the expression
|
|
16
|
-
* tree
|
|
17
|
-
* @param {{}} [context] A map of variable keys to their values. This will be
|
|
18
|
-
* accessed to resolve the value of each non-relative identifier.
|
|
19
|
-
* @param {{}|Array<{}|Array>} [relativeContext] A map or array to be accessed
|
|
20
|
-
* to resolve the value of a relative identifier.
|
|
21
|
-
*/
|
|
22
|
-
declare class Evaluator {
|
|
23
|
-
_grammar: Grammar;
|
|
24
|
-
_context: Record<string, JexlValue>;
|
|
25
|
-
_relContext: Record<string, JexlValue>;
|
|
26
|
-
constructor(grammar: Grammar, context?: Record<string, JexlValue>, relativeContext?: Record<string, JexlValue>);
|
|
27
|
-
/**
|
|
28
|
-
* Compiles and evaluates an expression tree within the configured context.
|
|
29
|
-
* Convenient for a one-shot evaluation; for repeated evaluation of the same
|
|
30
|
-
* tree, hold onto the closure from {@link compileAst} instead so the tree is
|
|
31
|
-
* only lowered once.
|
|
32
|
-
* @param {{}} ast An expression tree object
|
|
33
|
-
* @returns {*} the resulting value of the expression.
|
|
34
|
-
*/
|
|
35
|
-
eval(ast: AstNode): JexlValue;
|
|
36
|
-
}
|
|
37
|
-
export default Evaluator;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Jexl
|
|
3
|
-
* Copyright 2020 Tom Shawver
|
|
4
|
-
*/
|
|
5
|
-
import { compileAst } from "./compile.js";
|
|
6
|
-
/**
|
|
7
|
-
* The Evaluator carries everything an expression is evaluated against: the
|
|
8
|
-
* grammar, the context, and a relative context to be used as the root for
|
|
9
|
-
* relative identifiers. When any of these change, a new instance is required.
|
|
10
|
-
* However, a single instance can be used to evaluate many different
|
|
11
|
-
* expressions, and does not have to be reinstantiated for each.
|
|
12
|
-
*
|
|
13
|
-
* The work of evaluation itself lives in {@link compileAst}, which lowers a
|
|
14
|
-
* tree to closures. Prefer compiling once and reusing the result — that is what
|
|
15
|
-
* {@link Expression} does — over calling {@link #eval}, which compiles the tree
|
|
16
|
-
* it is given every time.
|
|
17
|
-
*
|
|
18
|
-
* @param {{}} grammar A grammar object against which to evaluate the expression
|
|
19
|
-
* tree
|
|
20
|
-
* @param {{}} [context] A map of variable keys to their values. This will be
|
|
21
|
-
* accessed to resolve the value of each non-relative identifier.
|
|
22
|
-
* @param {{}|Array<{}|Array>} [relativeContext] A map or array to be accessed
|
|
23
|
-
* to resolve the value of a relative identifier.
|
|
24
|
-
*/
|
|
25
|
-
class Evaluator {
|
|
26
|
-
_grammar;
|
|
27
|
-
_context;
|
|
28
|
-
_relContext;
|
|
29
|
-
constructor(grammar, context, relativeContext) {
|
|
30
|
-
this._grammar = grammar;
|
|
31
|
-
this._context = context || {};
|
|
32
|
-
this._relContext = relativeContext || this._context;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Compiles and evaluates an expression tree within the configured context.
|
|
36
|
-
* Convenient for a one-shot evaluation; for repeated evaluation of the same
|
|
37
|
-
* tree, hold onto the closure from {@link compileAst} instead so the tree is
|
|
38
|
-
* only lowered once.
|
|
39
|
-
* @param {{}} ast An expression tree object
|
|
40
|
-
* @returns {*} the resulting value of the expression.
|
|
41
|
-
*/
|
|
42
|
-
eval(ast) {
|
|
43
|
-
return compileAst(ast, this._grammar)(this);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
export default Evaluator;
|
|
47
|
-
//# sourceMappingURL=Evaluator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Evaluator.js","sourceRoot":"","sources":["../../src/evaluator/Evaluator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;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,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAA;IAC7C,CAAC;CACF;AAED,eAAe,SAAS,CAAA"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Jexl
|
|
3
|
-
* Copyright 2020 Tom Shawver
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { compileAst } from './compile.ts'
|
|
7
|
-
|
|
8
|
-
import type { Grammar } from '../grammar.ts'
|
|
9
|
-
import type { AstNode, JexlValue } from '../types.ts'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The Evaluator carries everything an expression is evaluated against: the
|
|
13
|
-
* grammar, the context, and a relative context to be used as the root for
|
|
14
|
-
* relative identifiers. When any of these change, a new instance is required.
|
|
15
|
-
* However, a single instance can be used to evaluate many different
|
|
16
|
-
* expressions, and does not have to be reinstantiated for each.
|
|
17
|
-
*
|
|
18
|
-
* The work of evaluation itself lives in {@link compileAst}, which lowers a
|
|
19
|
-
* tree to closures. Prefer compiling once and reusing the result — that is what
|
|
20
|
-
* {@link Expression} does — over calling {@link #eval}, which compiles the tree
|
|
21
|
-
* it is given every time.
|
|
22
|
-
*
|
|
23
|
-
* @param {{}} grammar A grammar object against which to evaluate the expression
|
|
24
|
-
* tree
|
|
25
|
-
* @param {{}} [context] A map of variable keys to their values. This will be
|
|
26
|
-
* accessed to resolve the value of each non-relative identifier.
|
|
27
|
-
* @param {{}|Array<{}|Array>} [relativeContext] A map or array to be accessed
|
|
28
|
-
* to resolve the value of a relative identifier.
|
|
29
|
-
*/
|
|
30
|
-
class Evaluator {
|
|
31
|
-
_grammar: Grammar
|
|
32
|
-
_context: Record<string, JexlValue>
|
|
33
|
-
_relContext: Record<string, JexlValue>
|
|
34
|
-
|
|
35
|
-
constructor(
|
|
36
|
-
grammar: Grammar,
|
|
37
|
-
context?: Record<string, JexlValue>,
|
|
38
|
-
relativeContext?: Record<string, JexlValue>
|
|
39
|
-
) {
|
|
40
|
-
this._grammar = grammar
|
|
41
|
-
this._context = context || {}
|
|
42
|
-
this._relContext = relativeContext || this._context
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Compiles and evaluates an expression tree within the configured context.
|
|
47
|
-
* Convenient for a one-shot evaluation; for repeated evaluation of the same
|
|
48
|
-
* tree, hold onto the closure from {@link compileAst} instead so the tree is
|
|
49
|
-
* only lowered once.
|
|
50
|
-
* @param {{}} ast An expression tree object
|
|
51
|
-
* @returns {*} the resulting value of the expression.
|
|
52
|
-
*/
|
|
53
|
-
eval(ast: AstNode): JexlValue {
|
|
54
|
-
return compileAst(ast, this._grammar)(this)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default Evaluator
|