@jbrowse/jexl 2.3.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 (89) hide show
  1. package/CHANGELOG.md +222 -0
  2. package/LICENSE.txt +19 -0
  3. package/README.md +216 -0
  4. package/dist/Expression.d.ts +38 -0
  5. package/dist/Expression.js +75 -0
  6. package/dist/Expression.js.map +1 -0
  7. package/dist/Jexl.d.ts +148 -0
  8. package/dist/Jexl.js +208 -0
  9. package/dist/Jexl.js.map +1 -0
  10. package/dist/Lexer.d.ts +130 -0
  11. package/dist/Lexer.js +321 -0
  12. package/dist/Lexer.js.map +1 -0
  13. package/dist/PromiseSync.d.ts +13 -0
  14. package/dist/PromiseSync.js +80 -0
  15. package/dist/PromiseSync.js.map +1 -0
  16. package/dist/evaluator/Evaluator.d.ts +92 -0
  17. package/dist/evaluator/Evaluator.js +153 -0
  18. package/dist/evaluator/Evaluator.js.map +1 -0
  19. package/dist/evaluator/handlers.d.ts +111 -0
  20. package/dist/evaluator/handlers.js +216 -0
  21. package/dist/evaluator/handlers.js.map +1 -0
  22. package/dist/grammar.d.ts +25 -0
  23. package/dist/grammar.js +179 -0
  24. package/dist/grammar.js.map +1 -0
  25. package/dist/index.d.ts +5 -0
  26. package/dist/index.js +20 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/package.json +1 -0
  29. package/dist/parser/Parser.d.ts +112 -0
  30. package/dist/parser/Parser.js +233 -0
  31. package/dist/parser/Parser.js.map +1 -0
  32. package/dist/parser/handlers.d.ts +112 -0
  33. package/dist/parser/handlers.js +302 -0
  34. package/dist/parser/handlers.js.map +1 -0
  35. package/dist/parser/states.d.ts +47 -0
  36. package/dist/parser/states.js +195 -0
  37. package/dist/parser/states.js.map +1 -0
  38. package/dist/types.d.ts +77 -0
  39. package/dist/types.js +7 -0
  40. package/dist/types.js.map +1 -0
  41. package/esm/Expression.d.ts +38 -0
  42. package/esm/Expression.js +70 -0
  43. package/esm/Expression.js.map +1 -0
  44. package/esm/Jexl.d.ts +148 -0
  45. package/esm/Jexl.js +202 -0
  46. package/esm/Jexl.js.map +1 -0
  47. package/esm/Lexer.d.ts +130 -0
  48. package/esm/Lexer.js +319 -0
  49. package/esm/Lexer.js.map +1 -0
  50. package/esm/PromiseSync.d.ts +13 -0
  51. package/esm/PromiseSync.js +78 -0
  52. package/esm/PromiseSync.js.map +1 -0
  53. package/esm/evaluator/Evaluator.d.ts +92 -0
  54. package/esm/evaluator/Evaluator.js +118 -0
  55. package/esm/evaluator/Evaluator.js.map +1 -0
  56. package/esm/evaluator/handlers.d.ts +111 -0
  57. package/esm/evaluator/handlers.js +202 -0
  58. package/esm/evaluator/handlers.js.map +1 -0
  59. package/esm/grammar.d.ts +25 -0
  60. package/esm/grammar.js +175 -0
  61. package/esm/grammar.js.map +1 -0
  62. package/esm/index.d.ts +5 -0
  63. package/esm/index.js +9 -0
  64. package/esm/index.js.map +1 -0
  65. package/esm/parser/Parser.d.ts +112 -0
  66. package/esm/parser/Parser.js +198 -0
  67. package/esm/parser/Parser.js.map +1 -0
  68. package/esm/parser/handlers.d.ts +112 -0
  69. package/esm/parser/handlers.js +280 -0
  70. package/esm/parser/handlers.js.map +1 -0
  71. package/esm/parser/states.d.ts +47 -0
  72. package/esm/parser/states.js +159 -0
  73. package/esm/parser/states.js.map +1 -0
  74. package/esm/types.d.ts +77 -0
  75. package/esm/types.js +6 -0
  76. package/esm/types.js.map +1 -0
  77. package/package.json +67 -0
  78. package/src/Expression.ts +95 -0
  79. package/src/Jexl.ts +232 -0
  80. package/src/Lexer.ts +344 -0
  81. package/src/PromiseSync.ts +86 -0
  82. package/src/evaluator/Evaluator.ts +153 -0
  83. package/src/evaluator/handlers.ts +226 -0
  84. package/src/grammar.ts +200 -0
  85. package/src/index.ts +10 -0
  86. package/src/parser/Parser.ts +235 -0
  87. package/src/parser/handlers.ts +309 -0
  88. package/src/parser/states.ts +177 -0
  89. package/src/types.ts +107 -0
@@ -0,0 +1,112 @@
1
+ import type Lexer from '../Lexer.ts';
2
+ import type { AstNode, Token } from '../types.ts';
3
+ interface Grammar {
4
+ elements: Record<string, any>;
5
+ }
6
+ /**
7
+ * The Parser is a state machine that converts tokens from the {@link Lexer}
8
+ * into an Abstract Syntax Tree (AST), capable of being evaluated in any
9
+ * context by the {@link Evaluator}. The Parser expects that all tokens
10
+ * provided to it are legal and typed properly according to the grammar, but
11
+ * accepts that the tokens may still be in an invalid order or in some other
12
+ * unparsable configuration that requires it to throw an Error.
13
+ * @param {{}} grammar The grammar object to use to parse Jexl strings
14
+ * @param {string} [prefix] A string prefix to prepend to the expression string
15
+ * for error messaging purposes. This is useful for when a new Parser is
16
+ * instantiated to parse an subexpression, as the parent Parser's
17
+ * expression string thus far can be passed for a more user-friendly
18
+ * error message.
19
+ * @param {{}} [stopMap] A mapping of token types to any truthy value. When the
20
+ * token type is encountered, the parser will return the mapped value
21
+ * instead of boolean false.
22
+ */
23
+ declare class Parser {
24
+ _grammar: Grammar;
25
+ _lexer: Lexer;
26
+ _state: string;
27
+ _tree: AstNode | null;
28
+ _exprStr: string;
29
+ _relative: boolean;
30
+ _stopMap: Record<string, any>;
31
+ _cursor?: AstNode | null;
32
+ _subParser?: Parser;
33
+ _parentStop?: boolean;
34
+ _nextIdentEncapsulate?: boolean;
35
+ _nextIdentRelative?: boolean;
36
+ _curObjKey?: string;
37
+ _sequenceExpressions?: AstNode[];
38
+ constructor(grammar: Grammar, lexer: Lexer, prefix?: string, stopMap?: Record<string, any>);
39
+ /**
40
+ * Processes a new token into the AST and manages the transitions of the state
41
+ * machine.
42
+ * @param {{type: <string>}} token A token object, as provided by the
43
+ * {@link Lexer#tokenize} function.
44
+ * @throws {Error} if a token is added when the Parser has been marked as
45
+ * complete by {@link #complete}, or if an unexpected token type is added.
46
+ * @returns {boolean|*} the stopState value if this parser encountered a token
47
+ * in the stopState mapb false if tokens can continue.
48
+ */
49
+ addToken(token: Token): any;
50
+ /**
51
+ * Processes an array of tokens iteratively through the {@link #addToken}
52
+ * function.
53
+ * @param {Array<{type: <string>}>} tokens An array of tokens, as provided by
54
+ * the {@link Lexer#tokenize} function.
55
+ */
56
+ addTokens(tokens: Token[]): void;
57
+ /**
58
+ * Marks this Parser instance as completed and retrieves the full AST.
59
+ * @returns {{}|null} a full expression tree, ready for evaluation by the
60
+ * {@link Evaluator#eval} function, or null if no tokens were passed to
61
+ * the parser before complete was called
62
+ * @throws {Error} if the parser is not in a state where it's legal to end
63
+ * the expression, indicating that the expression is incomplete
64
+ */
65
+ complete(): any;
66
+ /**
67
+ * Indicates whether the expression tree contains a relative path identifier.
68
+ * @returns {boolean} true if a relative identifier exists false otherwise.
69
+ */
70
+ isRelative(): boolean;
71
+ /**
72
+ * Ends a subexpression by completing the subParser and passing its result
73
+ * to the subHandler configured in the current state.
74
+ * @private
75
+ */
76
+ _endSubExpression(): void;
77
+ /**
78
+ * Places a new tree node at the current position of the cursor (to the 'right'
79
+ * property) and then advances the cursor to the new node. This function also
80
+ * handles setting the parent of the new node.
81
+ * @param {{type: <string>}} node A node to be added to the AST
82
+ * @private
83
+ */
84
+ _placeAtCursor(node: AstNode): void;
85
+ /**
86
+ * Places a tree node before the current position of the cursor, replacing
87
+ * the node that the cursor currently points to. This should only be called in
88
+ * cases where the cursor is known to exist, and the provided node already
89
+ * contains a pointer to what's at the cursor currently.
90
+ * @param {{type: <string>}} node A node to be added to the AST
91
+ * @private
92
+ */
93
+ _placeBeforeCursor(node: AstNode): void;
94
+ /**
95
+ * Sets the parent of a node by creating a non-enumerable _parent property
96
+ * that points to the supplied parent argument.
97
+ * @param {{type: <string>}} node A node of the AST on which to set a new
98
+ * parent
99
+ * @param {{type: <string>}} parent An existing node of the AST to serve as the
100
+ * parent of the new node
101
+ * @private
102
+ */
103
+ _setParent(node: AstNode, parent: AstNode): void;
104
+ /**
105
+ * Prepares the Parser to accept a subexpression by (re)instantiating the
106
+ * subParser.
107
+ * @param {string} [exprStr] The expression string to prefix to the new Parser
108
+ * @private
109
+ */
110
+ _startSubExpression(exprStr?: string): void;
111
+ }
112
+ export default Parser;
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ /*
3
+ * Jexl
4
+ * Copyright 2020 Tom Shawver
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
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ const handlers = __importStar(require("./handlers.js"));
41
+ const states_ts_1 = require("./states.js");
42
+ /**
43
+ * The Parser is a state machine that converts tokens from the {@link Lexer}
44
+ * into an Abstract Syntax Tree (AST), capable of being evaluated in any
45
+ * context by the {@link Evaluator}. The Parser expects that all tokens
46
+ * provided to it are legal and typed properly according to the grammar, but
47
+ * accepts that the tokens may still be in an invalid order or in some other
48
+ * unparsable configuration that requires it to throw an Error.
49
+ * @param {{}} grammar The grammar object to use to parse Jexl strings
50
+ * @param {string} [prefix] A string prefix to prepend to the expression string
51
+ * for error messaging purposes. This is useful for when a new Parser is
52
+ * instantiated to parse an subexpression, as the parent Parser's
53
+ * expression string thus far can be passed for a more user-friendly
54
+ * error message.
55
+ * @param {{}} [stopMap] A mapping of token types to any truthy value. When the
56
+ * token type is encountered, the parser will return the mapped value
57
+ * instead of boolean false.
58
+ */
59
+ class Parser {
60
+ constructor(grammar, lexer, prefix, stopMap) {
61
+ this._grammar = grammar;
62
+ this._lexer = lexer;
63
+ this._state = 'expectOperand';
64
+ this._tree = null;
65
+ this._exprStr = prefix || '';
66
+ this._relative = false;
67
+ this._stopMap = stopMap || {};
68
+ }
69
+ /**
70
+ * Processes a new token into the AST and manages the transitions of the state
71
+ * machine.
72
+ * @param {{type: <string>}} token A token object, as provided by the
73
+ * {@link Lexer#tokenize} function.
74
+ * @throws {Error} if a token is added when the Parser has been marked as
75
+ * complete by {@link #complete}, or if an unexpected token type is added.
76
+ * @returns {boolean|*} the stopState value if this parser encountered a token
77
+ * in the stopState mapb false if tokens can continue.
78
+ */
79
+ addToken(token) {
80
+ if (this._state === 'complete') {
81
+ throw new Error('Cannot add a new token to a completed Parser');
82
+ }
83
+ const state = states_ts_1.states[this._state];
84
+ const startExpr = this._exprStr;
85
+ this._exprStr += token.raw;
86
+ if (state.subHandler) {
87
+ if (!this._subParser) {
88
+ this._startSubExpression(startExpr);
89
+ }
90
+ const stopState = this._subParser.addToken(token);
91
+ if (stopState) {
92
+ this._endSubExpression();
93
+ if (this._parentStop) {
94
+ return stopState;
95
+ }
96
+ this._state = stopState;
97
+ }
98
+ }
99
+ else if (state.tokenTypes?.[token.type]) {
100
+ const typeOpts = state.tokenTypes[token.type];
101
+ let handleFunc = handlers[token.type];
102
+ if (typeOpts.handler) {
103
+ handleFunc = typeOpts.handler;
104
+ }
105
+ if (handleFunc) {
106
+ handleFunc.call(this, token);
107
+ }
108
+ if (typeOpts.toState) {
109
+ this._state = typeOpts.toState;
110
+ }
111
+ }
112
+ else if (this._stopMap[token.type]) {
113
+ return this._stopMap[token.type];
114
+ }
115
+ else {
116
+ throw new Error(`Token ${token.raw} (${token.type}) unexpected in expression: ${this._exprStr}`);
117
+ }
118
+ return false;
119
+ }
120
+ /**
121
+ * Processes an array of tokens iteratively through the {@link #addToken}
122
+ * function.
123
+ * @param {Array<{type: <string>}>} tokens An array of tokens, as provided by
124
+ * the {@link Lexer#tokenize} function.
125
+ */
126
+ addTokens(tokens) {
127
+ tokens.forEach((token) => this.addToken(token));
128
+ }
129
+ /**
130
+ * Marks this Parser instance as completed and retrieves the full AST.
131
+ * @returns {{}|null} a full expression tree, ready for evaluation by the
132
+ * {@link Evaluator#eval} function, or null if no tokens were passed to
133
+ * the parser before complete was called
134
+ * @throws {Error} if the parser is not in a state where it's legal to end
135
+ * the expression, indicating that the expression is incomplete
136
+ */
137
+ complete() {
138
+ if (this._cursor && !states_ts_1.states[this._state].completable) {
139
+ throw new Error(`Unexpected end of expression: ${this._exprStr}`);
140
+ }
141
+ if (this._subParser) {
142
+ this._endSubExpression();
143
+ }
144
+ if (this._sequenceExpressions) {
145
+ this._sequenceExpressions.push(this._tree);
146
+ const sequence = {
147
+ type: 'SequenceExpression',
148
+ expressions: this._sequenceExpressions
149
+ };
150
+ this._state = 'complete';
151
+ return sequence;
152
+ }
153
+ this._state = 'complete';
154
+ return this._cursor ? this._tree : null;
155
+ }
156
+ /**
157
+ * Indicates whether the expression tree contains a relative path identifier.
158
+ * @returns {boolean} true if a relative identifier exists false otherwise.
159
+ */
160
+ isRelative() {
161
+ return this._relative;
162
+ }
163
+ /**
164
+ * Ends a subexpression by completing the subParser and passing its result
165
+ * to the subHandler configured in the current state.
166
+ * @private
167
+ */
168
+ _endSubExpression() {
169
+ states_ts_1.states[this._state].subHandler.call(this, this._subParser.complete());
170
+ this._subParser = undefined;
171
+ }
172
+ /**
173
+ * Places a new tree node at the current position of the cursor (to the 'right'
174
+ * property) and then advances the cursor to the new node. This function also
175
+ * handles setting the parent of the new node.
176
+ * @param {{type: <string>}} node A node to be added to the AST
177
+ * @private
178
+ */
179
+ _placeAtCursor(node) {
180
+ if (!this._cursor) {
181
+ this._tree = node;
182
+ }
183
+ else {
184
+ ;
185
+ this._cursor.right = node;
186
+ this._setParent(node, this._cursor);
187
+ }
188
+ this._cursor = node;
189
+ }
190
+ /**
191
+ * Places a tree node before the current position of the cursor, replacing
192
+ * the node that the cursor currently points to. This should only be called in
193
+ * cases where the cursor is known to exist, and the provided node already
194
+ * contains a pointer to what's at the cursor currently.
195
+ * @param {{type: <string>}} node A node to be added to the AST
196
+ * @private
197
+ */
198
+ _placeBeforeCursor(node) {
199
+ this._cursor = this._cursor?._parent;
200
+ this._placeAtCursor(node);
201
+ }
202
+ /**
203
+ * Sets the parent of a node by creating a non-enumerable _parent property
204
+ * that points to the supplied parent argument.
205
+ * @param {{type: <string>}} node A node of the AST on which to set a new
206
+ * parent
207
+ * @param {{type: <string>}} parent An existing node of the AST to serve as the
208
+ * parent of the new node
209
+ * @private
210
+ */
211
+ _setParent(node, parent) {
212
+ Object.defineProperty(node, '_parent', {
213
+ value: parent,
214
+ writable: true
215
+ });
216
+ }
217
+ /**
218
+ * Prepares the Parser to accept a subexpression by (re)instantiating the
219
+ * subParser.
220
+ * @param {string} [exprStr] The expression string to prefix to the new Parser
221
+ * @private
222
+ */
223
+ _startSubExpression(exprStr) {
224
+ let endStates = states_ts_1.states[this._state].endStates;
225
+ if (!endStates) {
226
+ this._parentStop = true;
227
+ endStates = this._stopMap;
228
+ }
229
+ this._subParser = new Parser(this._grammar, this._lexer, exprStr, endStates);
230
+ }
231
+ }
232
+ exports.default = Parser;
233
+ //# sourceMappingURL=Parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Parser.js","sourceRoot":"","sources":["../../src/parser/Parser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;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D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;IACrB,CAAC;IAED;;;;;;;OAOG;IACH,kBAAkB,CAAC,IAAa;QAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,CAAA;QACpC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAED;;;;;;;;OAQG;IACH,UAAU,CAAC,IAAa,EAAE,MAAe;QACvC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE;YACrC,KAAK,EAAE,MAAM;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CAAA;IACJ,CAAC;IAED;;;;;OAKG;IACH,mBAAmB,CAAC,OAAgB;QAClC,IAAI,SAAS,GAAG,kBAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,SAAS,CAAA;QAC7C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;YACvB,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC3B,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;IAC9E,CAAC;CACF;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,112 @@
1
+ import type { AstNode, Token } from '../types.ts';
2
+ import type Parser from './Parser.ts';
3
+ /**
4
+ * Handles a subexpression that's used to define a transform argument's value.
5
+ * @param {{type: <string>}} ast The subexpression tree
6
+ */
7
+ export declare function argVal(this: Parser, ast: AstNode | null): void;
8
+ /**
9
+ * Handles new array literals by adding them as a new node in the AST,
10
+ * initialized with an empty array.
11
+ */
12
+ export declare function arrayStart(this: Parser): void;
13
+ /**
14
+ * Handles a subexpression representing an element of an array literal.
15
+ * @param {{type: <string>}} ast The subexpression tree
16
+ */
17
+ export declare function arrayVal(this: Parser, ast: AstNode | null): void;
18
+ /**
19
+ * Handles tokens of type 'binaryOp', indicating an operation that has two
20
+ * inputs: a left side and a right side.
21
+ * @param {{type: <string>}} token A token object
22
+ */
23
+ export declare function binaryOp(this: Parser, token: Token): void;
24
+ /**
25
+ * Handles successive nodes in an identifier chain. More specifically, it
26
+ * sets values that determine how the following identifier gets placed in the
27
+ * AST.
28
+ */
29
+ export declare function dot(this: Parser): void;
30
+ /**
31
+ * Handles a subexpression used for filtering an array returned by an
32
+ * identifier chain.
33
+ * @param {{type: <string>}} ast The subexpression tree
34
+ */
35
+ export declare function filter(this: Parser, ast: AstNode | null): void;
36
+ /**
37
+ * Handles identifier tokens when used to indicate the name of a function to
38
+ * be called.
39
+ * @param {{type: <string>}} token A token object
40
+ */
41
+ export declare function functionCall(this: Parser): void;
42
+ /**
43
+ * Handles identifier tokens by adding them as a new node in the AST.
44
+ * @param {{type: <string>}} token A token object
45
+ */
46
+ export declare function identifier(this: Parser, token: Token): void;
47
+ /**
48
+ * Handles literal values, such as strings, booleans, and numerics, by adding
49
+ * them as a new node in the AST.
50
+ * @param {{type: <string>}} token A token object
51
+ */
52
+ export declare function literal(this: Parser, token: Token): void;
53
+ /**
54
+ * Handles template string tokens by parsing their interpolation expressions
55
+ * and creating a TemplateLiteral AST node.
56
+ * @param {{type: <string>}} token A token object
57
+ */
58
+ export declare function templateString(this: Parser, token: Token): void;
59
+ /**
60
+ * Queues a new object literal key to be written once a value is collected.
61
+ * @param {{type: <string>}} token A token object
62
+ */
63
+ export declare function objKey(this: Parser, token: Token): void;
64
+ /**
65
+ * Handles new object literals by adding them as a new node in the AST,
66
+ * initialized with an empty object.
67
+ */
68
+ export declare function objStart(this: Parser): void;
69
+ /**
70
+ * Handles an object value by adding its AST to the queued key on the object
71
+ * literal node currently at the cursor.
72
+ * @param {{type: <string>}} ast The subexpression tree
73
+ */
74
+ export declare function objVal(this: Parser, ast: AstNode | null): void;
75
+ /**
76
+ * Handles traditional subexpressions, delineated with the groupStart and
77
+ * groupEnd elements.
78
+ * @param {{type: <string>}} ast The subexpression tree
79
+ */
80
+ export declare function subExpression(this: Parser, ast: AstNode | null): void;
81
+ /**
82
+ * Handles a completed alternate subexpression of a ternary operator.
83
+ * @param {{type: <string>}} ast The subexpression tree
84
+ */
85
+ export declare function ternaryEnd(this: Parser, ast: AstNode | null): void;
86
+ /**
87
+ * Handles a completed consequent subexpression of a ternary operator.
88
+ * @param {{type: <string>}} ast The subexpression tree
89
+ */
90
+ export declare function ternaryMid(this: Parser, ast: AstNode | null): void;
91
+ /**
92
+ * Handles the start of a new ternary expression by encapsulating the entire
93
+ * AST in a ConditionalExpression node, and using the existing tree as the
94
+ * test element.
95
+ */
96
+ export declare function ternaryStart(this: Parser): void;
97
+ /**
98
+ * Handles identifier tokens when used to indicate the name of a transform to
99
+ * be applied.
100
+ * @param {{type: <string>}} token A token object
101
+ */
102
+ export declare function transform(this: Parser, token: Token): void;
103
+ /**
104
+ * Handles token of type 'unaryOp', indicating that the operation has only
105
+ * one input: a right side.
106
+ * @param {{type: <string>}} token A token object
107
+ */
108
+ export declare function unaryOp(this: Parser, token: Token): void;
109
+ /**
110
+ * Handles semicolon separator between expressions
111
+ */
112
+ export declare function semicolon(this: Parser): void;