@jbrowse/jexl 4.0.1 → 5.0.1

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.
Files changed (110) hide show
  1. package/README.md +163 -20
  2. package/dist/Expression.d.ts +16 -0
  3. package/dist/Expression.js +28 -4
  4. package/dist/Expression.js.map +1 -1
  5. package/dist/Jexl.d.ts +20 -8
  6. package/dist/Jexl.js +34 -15
  7. package/dist/Jexl.js.map +1 -1
  8. package/dist/Lexer.d.ts +4 -3
  9. package/dist/Lexer.js +29 -21
  10. package/dist/Lexer.js.map +1 -1
  11. package/dist/analyze.d.ts +84 -0
  12. package/dist/analyze.js +259 -0
  13. package/dist/analyze.js.map +1 -0
  14. package/dist/check.d.ts +109 -0
  15. package/dist/check.js +1267 -0
  16. package/dist/check.js.map +1 -0
  17. package/dist/collections.d.ts +3 -0
  18. package/dist/collections.js +140 -0
  19. package/dist/collections.js.map +1 -0
  20. package/dist/conditions.d.ts +62 -0
  21. package/dist/conditions.js +207 -0
  22. package/dist/conditions.js.map +1 -0
  23. package/dist/errors.d.ts +5 -0
  24. package/dist/errors.js +18 -0
  25. package/dist/errors.js.map +1 -0
  26. package/dist/evaluator/compile.d.ts +10 -7
  27. package/dist/evaluator/compile.js +292 -99
  28. package/dist/evaluator/compile.js.map +1 -1
  29. package/dist/grammar.d.ts +22 -9
  30. package/dist/grammar.js +83 -55
  31. package/dist/grammar.js.map +1 -1
  32. package/dist/index.d.ts +9 -0
  33. package/dist/index.js +16 -1
  34. package/dist/index.js.map +1 -1
  35. package/dist/operators.d.ts +34 -0
  36. package/dist/operators.js +131 -0
  37. package/dist/operators.js.map +1 -0
  38. package/dist/parser/Parser.d.ts +48 -91
  39. package/dist/parser/Parser.js +347 -221
  40. package/dist/parser/Parser.js.map +1 -1
  41. package/dist/types.d.ts +11 -5
  42. package/esm/Expression.d.ts +16 -0
  43. package/esm/Expression.js +28 -4
  44. package/esm/Expression.js.map +1 -1
  45. package/esm/Jexl.d.ts +20 -8
  46. package/esm/Jexl.js +34 -15
  47. package/esm/Jexl.js.map +1 -1
  48. package/esm/Lexer.d.ts +4 -3
  49. package/esm/Lexer.js +29 -21
  50. package/esm/Lexer.js.map +1 -1
  51. package/esm/analyze.d.ts +84 -0
  52. package/esm/analyze.js +256 -0
  53. package/esm/analyze.js.map +1 -0
  54. package/esm/check.d.ts +109 -0
  55. package/esm/check.js +1260 -0
  56. package/esm/check.js.map +1 -0
  57. package/esm/collections.d.ts +3 -0
  58. package/esm/collections.js +137 -0
  59. package/esm/collections.js.map +1 -0
  60. package/esm/conditions.d.ts +62 -0
  61. package/esm/conditions.js +200 -0
  62. package/esm/conditions.js.map +1 -0
  63. package/esm/errors.d.ts +5 -0
  64. package/esm/errors.js +14 -0
  65. package/esm/errors.js.map +1 -0
  66. package/esm/evaluator/compile.d.ts +10 -7
  67. package/esm/evaluator/compile.js +292 -99
  68. package/esm/evaluator/compile.js.map +1 -1
  69. package/esm/grammar.d.ts +22 -9
  70. package/esm/grammar.js +79 -53
  71. package/esm/grammar.js.map +1 -1
  72. package/esm/index.d.ts +9 -0
  73. package/esm/index.js +4 -0
  74. package/esm/index.js.map +1 -1
  75. package/esm/operators.d.ts +34 -0
  76. package/esm/operators.js +123 -0
  77. package/esm/operators.js.map +1 -0
  78. package/esm/parser/Parser.d.ts +48 -91
  79. package/esm/parser/Parser.js +349 -192
  80. package/esm/parser/Parser.js.map +1 -1
  81. package/esm/types.d.ts +11 -5
  82. package/package.json +1 -1
  83. package/src/Expression.ts +34 -4
  84. package/src/Jexl.ts +52 -16
  85. package/src/Lexer.ts +32 -21
  86. package/src/analyze.ts +378 -0
  87. package/src/check.ts +1682 -0
  88. package/src/collections.ts +148 -0
  89. package/src/conditions.ts +262 -0
  90. package/src/errors.ts +15 -0
  91. package/src/evaluator/compile.ts +351 -102
  92. package/src/grammar.ts +137 -55
  93. package/src/index.ts +15 -0
  94. package/src/operators.ts +151 -0
  95. package/src/parser/Parser.ts +389 -199
  96. package/src/types.ts +13 -3
  97. package/dist/parser/handlers.d.ts +0 -115
  98. package/dist/parser/handlers.js +0 -352
  99. package/dist/parser/handlers.js.map +0 -1
  100. package/dist/parser/states.d.ts +0 -47
  101. package/dist/parser/states.js +0 -176
  102. package/dist/parser/states.js.map +0 -1
  103. package/esm/parser/handlers.d.ts +0 -115
  104. package/esm/parser/handlers.js +0 -328
  105. package/esm/parser/handlers.js.map +0 -1
  106. package/esm/parser/states.d.ts +0 -47
  107. package/esm/parser/states.js +0 -140
  108. package/esm/parser/states.js.map +0 -1
  109. package/src/parser/handlers.ts +0 -372
  110. package/src/parser/states.ts +0 -159
@@ -3,265 +3,391 @@
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 handlers = __importStar(require("./handlers.js"));
41
- const states_ts_1 = require("./states.js");
42
- /**
43
- * The handler to run for a token type when the state it appears in doesn't
44
- * name one of its own. Token types absent here — the brackets, parens and
45
- * separators — carry no behavior beyond the state transition the state machine
46
- * gives them.
47
- */
48
- const tokenHandlers = {
49
- binaryOp: handlers.binaryOp,
50
- dot: handlers.dot,
51
- identifier: handlers.identifier,
52
- literal: handlers.literal,
53
- semicolon: handlers.semicolon,
54
- templateString: handlers.templateString,
55
- unaryOp: handlers.unaryOp
56
- };
7
+ exports.JexlSyntaxError = void 0;
8
+ const errors_ts_1 = require("../errors.js");
9
+ const logical = new Set(['&&', '||']);
10
+ const omittedAlternateBefore = new Set([
11
+ 'closeParen',
12
+ 'closeBracket',
13
+ 'closeCurl',
14
+ 'comma',
15
+ 'semicolon'
16
+ ]);
17
+ var errors_ts_2 = require("../errors.js");
18
+ Object.defineProperty(exports, "JexlSyntaxError", { enumerable: true, get: function () { return errors_ts_2.JexlSyntaxError; } });
57
19
  /**
58
- * The Parser is a state machine that converts tokens from the {@link Lexer}
59
- * into an Abstract Syntax Tree (AST), capable of being evaluated in any
60
- * context by {@link compileAst}. The Parser expects that all tokens
61
- * provided to it are legal and typed properly according to the grammar, but
62
- * accepts that the tokens may still be in an invalid order or in some other
63
- * unparsable configuration that requires it to throw an Error.
64
- * @param {{}} grammar The grammar object to use to parse Jexl strings
65
- * @param {string} [prefix] A string prefix to prepend to the expression string
66
- * for error messaging purposes. This is useful for when a new Parser is
67
- * instantiated to parse an subexpression, as the parent Parser's
68
- * expression string thus far can be passed for a more user-friendly
69
- * error message.
70
- * @param {{}} [stopMap] A mapping of token types to any truthy value. When the
71
- * token type is encountered, the parser will return the mapped value
72
- * instead of boolean false.
20
+ * Converts the tokens from the {@link Lexer} into an Abstract Syntax Tree, for
21
+ * {@link compileAst} to lower to closures. A Pratt parser: each level of the
22
+ * grammar is a method, from `_sequence` (loosest) down to `_primary`, and
23
+ * binary operators are climbed by the precedence the grammar gives them, so
24
+ * operators a host registers slot in without the parser knowing them.
73
25
  */
74
26
  class Parser {
75
27
  _grammar;
76
28
  _lexer;
77
- _state;
78
- _tree;
79
- _exprStr;
80
- _stopMap;
81
- _cursor;
82
- _subParser;
83
- _parentStop;
84
- _nextIdentEncapsulate;
85
- _curObjKey;
86
- _sequenceExpressions;
87
- constructor(grammar, lexer, prefix, stopMap) {
29
+ _tokens = [];
30
+ _pos = 0;
31
+ _offset;
32
+ _grouped;
33
+ _lambdaDepth = 0;
34
+ /**
35
+ * @param offset where the tokens start in the source, so that an error
36
+ * inside a template interpolation reports its place in the whole
37
+ */
38
+ constructor(grammar, lexer, offset = 0) {
88
39
  this._grammar = grammar;
89
40
  this._lexer = lexer;
90
- this._state = 'expectOperand';
91
- this._tree = null;
92
- this._exprStr = prefix || '';
93
- this._stopMap = stopMap || {};
41
+ this._offset = offset;
42
+ }
43
+ parse(source) {
44
+ const start = this._offset;
45
+ this._offset += source.length - source.trimStart().length;
46
+ try {
47
+ this.addTokens(this._lexer.tokenize(source));
48
+ }
49
+ catch (error) {
50
+ if (error instanceof errors_ts_1.JexlSyntaxError) {
51
+ error.offset += start;
52
+ }
53
+ throw error;
54
+ }
55
+ return this.complete();
56
+ }
57
+ addTokens(tokens) {
58
+ this._tokens = this._tokens.concat(tokens);
94
59
  }
95
60
  /**
96
- * Processes a new token into the AST and manages the transitions of the state
97
- * machine.
98
- * @param {{type: <string>}} token A token object, as provided by the
99
- * {@link Lexer#tokenize} function.
100
- * @throws {Error} if a token is added when the Parser has been marked as
101
- * complete by {@link #complete}, or if an unexpected token type is added.
102
- * @returns {boolean|*} the stopState value if this parser encountered a token
103
- * in the stopState mapb false if tokens can continue.
61
+ * @returns the expression tree, or null for an expression with no tokens
62
+ * @throws {JexlSyntaxError} if the tokens do not form exactly one expression
104
63
  */
105
- addToken(token) {
106
- if (this._state === 'complete') {
107
- throw new Error('Cannot add a new token to a completed Parser');
64
+ complete() {
65
+ if (this._tokens.length === 0) {
66
+ return null;
108
67
  }
109
- const state = states_ts_1.states[this._state];
110
- const startExpr = this._exprStr;
111
- this._exprStr += token.raw;
112
- if (state.subHandler) {
113
- const subParser = this._subParser ?? this._startSubExpression(startExpr);
114
- const stopState = subParser.addToken(token);
115
- if (stopState) {
116
- this._endSubExpression();
117
- if (stopState === '_semicolon') {
118
- handlers.semicolon.call(this);
119
- }
120
- else if (this._parentStop) {
121
- return stopState;
122
- }
123
- else {
124
- this._state = stopState;
125
- }
68
+ const ast = this._sequence();
69
+ if (this._pos < this._tokens.length) {
70
+ throw this._unexpected(this._pos);
71
+ }
72
+ return ast;
73
+ }
74
+ _sequence() {
75
+ const first = this._assignment();
76
+ if (this._peek()?.type !== 'semicolon') {
77
+ return first;
78
+ }
79
+ const expressions = [first];
80
+ while (this._eat('semicolon')) {
81
+ const next = this._peek();
82
+ if (!next || next.type === 'closeParen') {
83
+ break;
126
84
  }
85
+ expressions.push(this._assignment());
86
+ }
87
+ return { type: 'SequenceExpression', expressions };
88
+ }
89
+ _assignment() {
90
+ if (this._atLambda()) {
91
+ return this._lambda();
127
92
  }
128
- else if (token.type === 'semicolon' && this._stopMap[token.type]) {
129
- return this._stopMap[token.type];
93
+ const left = this._ternary();
94
+ const token = this._peek();
95
+ if (token?.type !== 'binaryOp' || token.value !== '=') {
96
+ return left;
130
97
  }
131
- else if (state.tokenTypes?.[token.type]) {
132
- const typeOpts = state.tokenTypes[token.type];
133
- // the state's own handler wins over the token type's default one, and a
134
- // token type with neither only drives the transition below
135
- const handleFunc = typeOpts.handler ?? tokenHandlers[token.type];
136
- handleFunc?.call(this, token);
137
- if (typeOpts.toState) {
138
- this._state = typeOpts.toState;
98
+ if (left.type !== 'Identifier' || left.from) {
99
+ throw this._error('Left side of assignment must be a variable name', this._pos);
100
+ }
101
+ if (this._lambdaDepth > 0) {
102
+ throw this._error('Assignment is not supported in a lambda', this._pos);
103
+ }
104
+ this._pos++;
105
+ return {
106
+ type: 'AssignmentExpression',
107
+ operator: '=',
108
+ left,
109
+ right: this._assignment()
110
+ };
111
+ }
112
+ _atLambda() {
113
+ let i = this._pos;
114
+ if (this._tokens[i]?.type === 'identifier') {
115
+ return this._tokens[i + 1]?.type === 'arrow';
116
+ }
117
+ if (this._tokens[i]?.type !== 'openParen') {
118
+ return false;
119
+ }
120
+ i++;
121
+ while (this._tokens[i]?.type === 'identifier') {
122
+ i++;
123
+ if (this._tokens[i]?.type !== 'comma') {
124
+ break;
139
125
  }
126
+ i++;
140
127
  }
141
- else if (this._stopMap[token.type]) {
142
- return this._stopMap[token.type];
128
+ return (this._tokens[i]?.type === 'closeParen' &&
129
+ this._tokens[i + 1]?.type === 'arrow');
130
+ }
131
+ /** Parses the lambda {@link _atLambda} found, whose shape it has checked. */
132
+ _lambda() {
133
+ const params = [];
134
+ if (this._eat('openParen')) {
135
+ while (!this._eat('closeParen')) {
136
+ params.push(this._next().value);
137
+ this._eat('comma');
138
+ }
143
139
  }
144
140
  else {
145
- throw new Error(`Token ${token.raw} (${token.type}) unexpected in expression: ${this._exprStr}`);
141
+ params.push(this._next().value);
146
142
  }
147
- return false;
143
+ if (new Set(params).size < params.length) {
144
+ throw this._error('Duplicate lambda parameter name', this._pos);
145
+ }
146
+ this._pos++;
147
+ this._lambdaDepth++;
148
+ const body = this._assignment();
149
+ this._lambdaDepth--;
150
+ return { type: 'Lambda', params, body };
148
151
  }
149
- /**
150
- * Processes an array of tokens iteratively through the {@link #addToken}
151
- * function.
152
- * @param {Array<{type: <string>}>} tokens An array of tokens, as provided by
153
- * the {@link Lexer#tokenize} function.
154
- */
155
- addTokens(tokens) {
156
- for (const token of tokens) {
157
- this.addToken(token);
152
+ _ternary() {
153
+ const test = this._binary(-Infinity);
154
+ if (!this._eat('question')) {
155
+ return test;
156
+ }
157
+ const node = { type: 'ConditionalExpression', test };
158
+ if (!this._eat('colon')) {
159
+ node.consequent = this._assignment();
160
+ this._expect('colon');
158
161
  }
162
+ const next = this._peek();
163
+ if (next && !omittedAlternateBefore.has(next.type)) {
164
+ node.alternate = this._assignment();
165
+ }
166
+ return node;
159
167
  }
160
168
  /**
161
- * Marks this Parser instance as completed and retrieves the full AST.
162
- * @returns {{}|null} a full expression tree, ready for evaluation by the
163
- * {@link compileAst} function, or null if no tokens were passed to
164
- * the parser before complete was called
165
- * @throws {Error} if the parser is not in a state where it's legal to end
166
- * the expression, indicating that the expression is incomplete
169
+ * Parses operands joined by binary operators that bind tighter than `floor`.
170
+ * One exactly at `floor` binds only when it continues a right-associative
171
+ * chain, which is how `a ^ b ^ c` groups from the right.
167
172
  */
168
- complete() {
169
- // `_subParser` counts as unfinished business alongside `_cursor`: a group
170
- // that opened before anything was placed in the tree, as in "(1", leaves
171
- // the cursor null, and testing the cursor alone let the missing ")" pass
172
- // silently and evaluate as if it were closed.
173
- if ((this._cursor || this._subParser) &&
174
- !states_ts_1.states[this._state].completable) {
175
- throw new Error(`Unexpected end of expression: ${this._exprStr}`);
173
+ _binary(floor, rightAssociative = false) {
174
+ let left = this._unary();
175
+ for (;;) {
176
+ const token = this._peek();
177
+ if (token?.type !== 'binaryOp' || token.value === '=') {
178
+ return left;
179
+ }
180
+ const operator = token.value;
181
+ const op = this._grammar.elements[operator];
182
+ if (op.type !== 'binaryOp' ||
183
+ op.precedence < floor ||
184
+ (op.precedence === floor && !(rightAssociative && op.rightAssociative))) {
185
+ return left;
186
+ }
187
+ const at = this._pos++;
188
+ const right = this._binary(op.precedence, op.rightAssociative);
189
+ if (this._mixesNullish(operator, left, right)) {
190
+ throw this._error('Parenthesize ?? when mixing it with && or ||', at);
191
+ }
192
+ left = { type: 'BinaryExpression', operator, left, right };
176
193
  }
177
- if (this._subParser) {
178
- this._endSubExpression();
194
+ }
195
+ /** `a ?? b || c` has no grouping a reader can guess; JS refuses it too. */
196
+ _mixesNullish(operator, ...operands) {
197
+ return operands.some((operand) => operand.type === 'BinaryExpression' &&
198
+ !this._grouped?.has(operand) &&
199
+ (operator === '??'
200
+ ? logical.has(operand.operator)
201
+ : logical.has(operator) && operand.operator === '??'));
202
+ }
203
+ _unary() {
204
+ const token = this._peek();
205
+ if (token?.type !== 'unaryOp') {
206
+ return this._postfix(this._primary());
179
207
  }
180
- if (this._sequenceExpressions) {
181
- if (this._tree) {
182
- this._sequenceExpressions.push(this._tree);
208
+ this._pos++;
209
+ const operator = token.value;
210
+ const op = this._grammar.elements[operator];
211
+ return {
212
+ type: 'UnaryExpression',
213
+ operator,
214
+ right: this._binary(op?.type === 'unaryOp' ? op.precedence : Infinity)
215
+ };
216
+ }
217
+ _postfix(subject) {
218
+ let node = subject;
219
+ for (;;) {
220
+ switch (this._peek()?.type) {
221
+ case 'dot': {
222
+ this._pos++;
223
+ node = {
224
+ type: 'Identifier',
225
+ value: this._expect('identifier').value,
226
+ from: node
227
+ };
228
+ break;
229
+ }
230
+ case 'openBracket': {
231
+ this._pos++;
232
+ const expr = this._assignment();
233
+ this._expect('closeBracket');
234
+ node = { type: 'FilterExpression', expr, subject: node };
235
+ break;
236
+ }
237
+ case 'openParen': {
238
+ if (node.type !== 'Identifier' ||
239
+ this._tokens[this._pos - 1].type !== 'identifier') {
240
+ throw this._error('Functions must be called by name', this._pos);
241
+ }
242
+ this._pos++;
243
+ const { from, value } = node;
244
+ const args = this._list('closeParen');
245
+ node = {
246
+ type: 'FunctionCall',
247
+ name: value,
248
+ args: from ? [from, ...args] : args
249
+ };
250
+ break;
251
+ }
252
+ default: {
253
+ return node;
254
+ }
183
255
  }
184
- const sequence = {
185
- type: 'SequenceExpression',
186
- expressions: this._sequenceExpressions
187
- };
188
- this._state = 'complete';
189
- return sequence;
190
256
  }
191
- this._state = 'complete';
192
- return this._cursor ? this._tree : null;
193
257
  }
194
- /**
195
- * Ends a subexpression by completing the subParser and passing its result
196
- * to the subHandler configured in the current state.
197
- * @private
198
- */
199
- _endSubExpression() {
200
- states_ts_1.states[this._state].subHandler.call(this, this._subParser.complete());
201
- this._subParser = undefined;
202
- }
203
- /**
204
- * Places a new tree node at the current position of the cursor (to the 'right'
205
- * property) and then advances the cursor to the new node. This function also
206
- * handles setting the parent of the new node.
207
- * @param {{type: <string>}} node A node to be added to the AST
208
- * @private
209
- */
210
- _placeAtCursor(node) {
211
- if (!this._cursor) {
212
- this._tree = node;
258
+ _primary() {
259
+ const token = this._next();
260
+ switch (token.type) {
261
+ case 'literal': {
262
+ return {
263
+ type: 'Literal',
264
+ value: token.value
265
+ };
266
+ }
267
+ case 'identifier': {
268
+ return { type: 'Identifier', value: token.value };
269
+ }
270
+ case 'templateString': {
271
+ return this._template(token.value, this._pos - 1);
272
+ }
273
+ case 'openParen': {
274
+ const node = this._sequence();
275
+ this._expect('closeParen');
276
+ this._grouped ??= new WeakSet();
277
+ this._grouped.add(node);
278
+ return node;
279
+ }
280
+ case 'openBracket': {
281
+ return { type: 'ArrayLiteral', value: this._list('closeBracket') };
282
+ }
283
+ case 'openCurl': {
284
+ return this._object();
285
+ }
286
+ case 'dot': {
287
+ throw this._error('Relative paths are not supported', this._pos - 1);
288
+ }
289
+ default: {
290
+ throw this._unexpected(this._pos - 1);
291
+ }
213
292
  }
214
- else {
215
- this._cursor.right = node;
216
- this._setParent(node, this._cursor);
293
+ }
294
+ _list(close) {
295
+ const items = [];
296
+ while (!this._eat(close)) {
297
+ items.push(this._assignment());
298
+ if (!this._eat('comma')) {
299
+ this._expect(close);
300
+ break;
301
+ }
217
302
  }
218
- this._cursor = node;
303
+ return items;
219
304
  }
220
- /**
221
- * Places a tree node before the current position of the cursor, replacing
222
- * the node that the cursor currently points to. This should only be called in
223
- * cases where the cursor is known to exist, and the provided node already
224
- * contains a pointer to what's at the cursor currently.
225
- * @param {{type: <string>}} node A node to be added to the AST
226
- * @private
227
- */
228
- _placeBeforeCursor(node) {
229
- this._cursor = this._cursor?._parent;
230
- this._placeAtCursor(node);
305
+ _object() {
306
+ const node = { type: 'ObjectLiteral', value: {} };
307
+ while (!this._eat('closeCurl')) {
308
+ const key = this._next();
309
+ if (key.type !== 'identifier' && key.type !== 'literal') {
310
+ throw this._unexpected(this._pos - 1);
311
+ }
312
+ this._expect('colon');
313
+ // defined rather than assigned, so that "__proto__" is an ordinary key
314
+ Object.defineProperty(node.value, String(key.value), {
315
+ value: this._assignment(),
316
+ writable: true,
317
+ enumerable: true,
318
+ configurable: true
319
+ });
320
+ if (!this._eat('comma')) {
321
+ this._expect('closeCurl');
322
+ break;
323
+ }
324
+ }
325
+ return node;
231
326
  }
232
- /**
233
- * Sets the parent of a node by creating a non-enumerable _parent property
234
- * that points to the supplied parent argument.
235
- * @param {{type: <string>}} node A node of the AST on which to set a new
236
- * parent
237
- * @param {{type: <string>}} parent An existing node of the AST to serve as the
238
- * parent of the new node
239
- * @private
240
- */
241
- _setParent(node, parent) {
242
- Object.defineProperty(node, '_parent', {
243
- value: parent,
244
- writable: true
327
+ _template(tokenParts, index) {
328
+ let offset = this._offsetOf(index) + '`'.length;
329
+ const parts = tokenParts.map((part) => {
330
+ if (part.type === 'static') {
331
+ offset += part.value.length;
332
+ return {
333
+ type: 'static',
334
+ value: this._lexer._unescapeTemplateString(part.value)
335
+ };
336
+ }
337
+ const start = offset + '${'.length;
338
+ offset = start + part.value.length + '}'.length;
339
+ const sub = new Parser(this._grammar, this._lexer, start);
340
+ sub._lambdaDepth = this._lambdaDepth;
341
+ const value = sub.parse(part.value);
342
+ if (!value) {
343
+ throw new errors_ts_1.JexlSyntaxError('Empty interpolation in template string', start);
344
+ }
345
+ return { type: 'expression', value };
245
346
  });
347
+ return { type: 'TemplateLiteral', parts };
246
348
  }
247
- /**
248
- * Prepares the Parser to accept a subexpression by (re)instantiating the
249
- * subParser.
250
- * @param {string} [exprStr] The expression string to prefix to the new Parser
251
- * @returns {Parser} the new subParser, also stored on this instance
252
- * @private
253
- */
254
- _startSubExpression(exprStr) {
255
- let endStates = states_ts_1.states[this._state].endStates;
256
- if (!endStates) {
257
- this._parentStop = true;
258
- endStates = this._stopMap;
349
+ _peek() {
350
+ return this._tokens[this._pos];
351
+ }
352
+ _next() {
353
+ const token = this._tokens[this._pos];
354
+ if (!token) {
355
+ throw this._error('Unexpected end of expression', this._pos);
356
+ }
357
+ this._pos++;
358
+ return token;
359
+ }
360
+ _eat(type) {
361
+ if (this._tokens[this._pos]?.type !== type) {
362
+ return false;
259
363
  }
260
- if (states_ts_1.states[this._state].completable && !endStates.semicolon) {
261
- endStates = { ...endStates, semicolon: '_semicolon' };
364
+ this._pos++;
365
+ return true;
366
+ }
367
+ _expect(type) {
368
+ const token = this._next();
369
+ if (token.type !== type) {
370
+ throw this._unexpected(this._pos - 1);
371
+ }
372
+ return token;
373
+ }
374
+ _unexpected(index) {
375
+ const { raw, type } = this._tokens[index];
376
+ return this._error(`Token ${raw} (${type}) unexpected in expression`, index);
377
+ }
378
+ _error(message, index) {
379
+ const source = this._tokens
380
+ .slice(0, index + 1)
381
+ .map((token) => token.raw)
382
+ .join('');
383
+ return new errors_ts_1.JexlSyntaxError(`${message}: ${source}`, this._offsetOf(index));
384
+ }
385
+ _offsetOf(index) {
386
+ let offset = this._offset;
387
+ for (let i = 0; i < index; i++) {
388
+ offset += this._tokens[i].raw.length;
262
389
  }
263
- this._subParser = new Parser(this._grammar, this._lexer, exprStr, endStates);
264
- return this._subParser;
390
+ return offset;
265
391
  }
266
392
  }
267
393
  exports.default = Parser;
@@ -1 +1 @@
1
- {"version":3,"file":"Parser.js","sourceRoot":"","sources":["../../src/parser/Parser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,wDAAyC;AACzC,2CAAoC;AAMpC;;;;;GAKG;AACH,MAAM,aAAa,GAGf;IACF,QAAQ,EAAE,QAAQ,CAAC,QAAQ;IAC3B,GAAG,EAAE,QAAQ,CAAC,GAAG;IACjB,UAAU,EAAE,QAAQ,CAAC,UAAU;IAC/B,OAAO,EAAE,QAAQ,CAAC,OAAO;IACzB,SAAS,EAAE,QAAQ,CAA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