@witchcraft/expressit 0.0.2 → 0.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 +6 -4
- package/dist/Lexer.d.ts +146 -0
- package/dist/Lexer.d.ts.map +1 -0
- package/dist/Lexer.js +960 -0
- package/dist/Parser.d.ts +140 -0
- package/dist/Parser.d.ts.map +1 -0
- package/dist/Parser.js +668 -0
- package/dist/ast/builders/token.js +1 -1
- package/dist/ast/handlers.d.ts +3 -3
- package/dist/ast/handlers.d.ts.map +1 -1
- package/dist/ast/index.d.ts.map +1 -1
- package/dist/examples/index.d.ts +2 -0
- package/dist/examples/index.d.ts.map +1 -0
- package/dist/examples/index.js +4 -0
- package/dist/examples/shortcutContextParser.d.ts +2 -1
- package/dist/examples/shortcutContextParser.d.ts.map +1 -1
- package/dist/examples/shortcutContextParser.js +9 -5
- package/dist/helpers/errors.d.ts.map +1 -1
- package/dist/helpers/errors.js +3 -1
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/parser/checkParserOpts.d.ts.map +1 -1
- package/dist/helpers/parser/checkParserOpts.js +3 -2
- package/dist/helpers/parser/extractPosition.d.ts +2 -6
- package/dist/helpers/parser/extractPosition.d.ts.map +1 -1
- package/dist/helpers/parser/extractPosition.js +3 -3
- package/dist/helpers/parser/getUnclosedRightParenCount.d.ts +2 -3
- package/dist/helpers/parser/getUnclosedRightParenCount.d.ts.map +1 -1
- package/dist/helpers/parser/getUnclosedRightParenCount.js +4 -4
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/methods/autocomplete.d.ts.map +1 -1
- package/dist/methods/autocomplete.js +1 -1
- package/dist/methods/autoreplace.js +1 -1
- package/dist/methods/autosuggest.js +1 -1
- package/dist/methods/evaluate.d.ts.map +1 -1
- package/dist/methods/evaluate.js +3 -1
- package/dist/methods/getIndexes.d.ts.map +1 -1
- package/dist/methods/getIndexes.js +2 -1
- package/dist/methods/normalize.d.ts +0 -2
- package/dist/methods/normalize.d.ts.map +1 -1
- package/dist/methods/normalize.js +2 -3
- package/dist/methods/validate.d.ts.map +1 -1
- package/dist/methods/validate.js +3 -1
- package/dist/package.json.js +44 -37
- package/dist/types/ast.d.ts +2 -8
- package/dist/types/ast.d.ts.map +1 -1
- package/dist/types/errors.d.ts +5 -17
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +0 -1
- package/dist/types/parser.d.ts +6 -2
- package/dist/types/parser.d.ts.map +1 -1
- package/dist/utils/extractTokens.js +1 -1
- package/dist/utils/getCursorInfo.d.ts +2 -2
- package/dist/utils/getCursorInfo.d.ts.map +1 -1
- package/dist/utils/getCursorInfo.js +3 -2
- package/dist/utils/getOppositeDelimiter.d.ts.map +1 -1
- package/dist/utils/getOppositeDelimiter.js +1 -1
- package/dist/utils/prettyAst.d.ts.map +1 -1
- package/dist/utils/prettyAst.js +15 -9
- package/package.json +42 -37
- package/src/Lexer.ts +704 -0
- package/src/Parser.ts +972 -0
- package/src/ast/builders/array.ts +2 -2
- package/src/ast/builders/condition.ts +1 -1
- package/src/ast/builders/expression.ts +1 -1
- package/src/ast/builders/group.ts +1 -1
- package/src/ast/builders/index.ts +1 -1
- package/src/ast/builders/pos.ts +1 -1
- package/src/ast/builders/token.ts +2 -2
- package/src/ast/builders/type.ts +1 -1
- package/src/ast/builders/variable.ts +1 -1
- package/src/ast/classes/ConditionNode.ts +1 -1
- package/src/ast/classes/ErrorToken.ts +1 -1
- package/src/ast/classes/ValidToken.ts +2 -2
- package/src/ast/classes/index.ts +1 -1
- package/src/ast/handlers.ts +6 -6
- package/src/ast/index.ts +2 -2
- package/src/examples/index.ts +3 -0
- package/src/examples/shortcutContextParser.ts +11 -6
- package/src/helpers/errors.ts +5 -3
- package/src/helpers/general/defaultConditionNormalizer.ts +1 -1
- package/src/helpers/general/index.ts +1 -1
- package/src/helpers/index.ts +3 -2
- package/src/helpers/parser/checkParserOpts.ts +13 -12
- package/src/helpers/parser/extractPosition.ts +4 -8
- package/src/helpers/parser/getUnclosedRightParenCount.ts +6 -6
- package/src/helpers/parser/index.ts +1 -1
- package/src/helpers/parser/parseParserOptions.ts +1 -1
- package/src/index.ts +2 -2
- package/src/methods/autocomplete.ts +5 -5
- package/src/methods/autoreplace.ts +2 -2
- package/src/methods/autosuggest.ts +3 -3
- package/src/methods/evaluate.ts +4 -2
- package/src/methods/getIndexes.ts +2 -1
- package/src/methods/normalize.ts +3 -4
- package/src/methods/validate.ts +4 -2
- package/src/types/ast.ts +2 -9
- package/src/types/errors.ts +12 -22
- package/src/types/parser.ts +6 -4
- package/src/utils/extractTokens.ts +1 -1
- package/src/utils/getCursorInfo.ts +6 -4
- package/src/utils/getOppositeDelimiter.ts +5 -2
- package/src/utils/prettyAst.ts +5 -3
- package/dist/examples/advancedValueComparer.d.ts +0 -3
- package/dist/examples/advancedValueComparer.d.ts.map +0 -1
- package/dist/examples/advancedValueComparer.js +0 -28
- package/dist/grammar/ParserBase.d.ts +0 -51
- package/dist/grammar/ParserBase.d.ts.map +0 -1
- package/dist/grammar/ParserBase.js +0 -516
- package/dist/grammar/createTokens.d.ts +0 -56
- package/dist/grammar/createTokens.d.ts.map +0 -1
- package/dist/grammar/createTokens.js +0 -843
- package/dist/grammar/index.d.ts +0 -3
- package/dist/grammar/index.d.ts.map +0 -1
- package/dist/grammar/index.js +0 -6
- package/dist/parser.d.ts +0 -58
- package/dist/parser.d.ts.map +0 -1
- package/dist/parser.js +0 -136
- package/src/examples/advancedValueComparer.ts +0 -31
- package/src/grammar/ParserBase.ts +0 -715
- package/src/grammar/createTokens.ts +0 -512
- package/src/grammar/index.ts +0 -4
- package/src/parser.ts +0 -183
package/dist/Parser.js
ADDED
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import { isArray } from "@alanscodelog/utils/isArray";
|
|
8
|
+
import { isWhitespace } from "@alanscodelog/utils/isWhitespace";
|
|
9
|
+
import { mixin } from "@alanscodelog/utils/mixin";
|
|
10
|
+
import { setReadOnly } from "@alanscodelog/utils/setReadOnly";
|
|
11
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
12
|
+
import { pos } from "./ast/builders/pos.js";
|
|
13
|
+
import { ArrayNode } from "./ast/classes/ArrayNode.js";
|
|
14
|
+
import { ConditionNode } from "./ast/classes/ConditionNode.js";
|
|
15
|
+
import { ErrorToken } from "./ast/classes/ErrorToken.js";
|
|
16
|
+
import { ExpressionNode } from "./ast/classes/ExpressionNode.js";
|
|
17
|
+
import { GroupNode } from "./ast/classes/GroupNode.js";
|
|
18
|
+
import { VariableNode } from "./ast/classes/VariableNode.js";
|
|
19
|
+
import { token, operator, expression, variable, condition, group, array, delimiter } from "./ast/handlers.js";
|
|
20
|
+
import { checkParserOpts } from "./helpers/parser/checkParserOpts.js";
|
|
21
|
+
import { extractPosition } from "./helpers/parser/extractPosition.js";
|
|
22
|
+
import { getUnclosedRightParenCount } from "./helpers/parser/getUnclosedRightParenCount.js";
|
|
23
|
+
import { parseParserOptions } from "./helpers/parser/parseParserOptions.js";
|
|
24
|
+
import { seal } from "./helpers/parser/seal.js";
|
|
25
|
+
import { Lexer, $C, $T } from "./Lexer.js";
|
|
26
|
+
import { AutocompleteMixin } from "./methods/autocomplete.js";
|
|
27
|
+
import { AutoreplaceMixin } from "./methods/autoreplace.js";
|
|
28
|
+
import { Autosuggest } from "./methods/autosuggest.js";
|
|
29
|
+
import { EvaluateMixin } from "./methods/evaluate.js";
|
|
30
|
+
import { GetBestIndexesMixin } from "./methods/getBestIndex.js";
|
|
31
|
+
import { GetIndexMixin } from "./methods/getIndexes.js";
|
|
32
|
+
import { NormalizeMixin } from "./methods/normalize.js";
|
|
33
|
+
import { ValidateMixin } from "./methods/validate.js";
|
|
34
|
+
import { TOKEN_TYPE } from "./types/ast.js";
|
|
35
|
+
class Parser {
|
|
36
|
+
constructor(options) {
|
|
37
|
+
// needed for evaluate and validate so they are only checked on demand
|
|
38
|
+
__publicField(this, "evaluationOptionsChecked", false);
|
|
39
|
+
__publicField(this, "validationOptionsChecked", false);
|
|
40
|
+
__publicField(this, "options");
|
|
41
|
+
__publicField(this, "lexer");
|
|
42
|
+
__publicField(this, "$");
|
|
43
|
+
__publicField(this, "$categories");
|
|
44
|
+
__publicField(this, "info");
|
|
45
|
+
__publicField(this, "state", {
|
|
46
|
+
rawInput: "",
|
|
47
|
+
lexedTokens: [],
|
|
48
|
+
index: 0,
|
|
49
|
+
shift: 0
|
|
50
|
+
});
|
|
51
|
+
__publicField(this, "subParserOne");
|
|
52
|
+
__publicField(this, "subParserTwo");
|
|
53
|
+
const opts = parseParserOptions(options ?? {});
|
|
54
|
+
checkParserOpts(opts);
|
|
55
|
+
this.options = opts;
|
|
56
|
+
this.lexer = new Lexer(opts);
|
|
57
|
+
this.$ = this.lexer.$;
|
|
58
|
+
this.$categories = this.lexer.$categories;
|
|
59
|
+
this.info = {
|
|
60
|
+
expandedSepAlsoCustom: this.lexer.symbols.expandedSepAlsoCustom,
|
|
61
|
+
customOpAlsoNegation: this.lexer.symbols.customOpAlsoNegation
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
65
|
+
_checkEvaluationOptions() {
|
|
66
|
+
if (!this.evaluationOptionsChecked) {
|
|
67
|
+
checkParserOpts(this.options, true);
|
|
68
|
+
this.evaluationOptionsChecked = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
72
|
+
_checkValidationOptions() {
|
|
73
|
+
if (!this.validationOptionsChecked) {
|
|
74
|
+
checkParserOpts(this.options, false, true);
|
|
75
|
+
this.validationOptionsChecked = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* This is exposed mainly for debugging purposes. Use parse directly instead.
|
|
80
|
+
*/
|
|
81
|
+
lex(input) {
|
|
82
|
+
if (isWhitespace(input)) {
|
|
83
|
+
return { tokens: [], shift: 0, rawInput: input };
|
|
84
|
+
}
|
|
85
|
+
let lexed = this.lexer.tokenize(input);
|
|
86
|
+
const shift = getUnclosedRightParenCount(lexed);
|
|
87
|
+
const rawInput = input;
|
|
88
|
+
if (shift) {
|
|
89
|
+
input = "(".repeat(shift) + input;
|
|
90
|
+
lexed = this.lexer.tokenize(input);
|
|
91
|
+
}
|
|
92
|
+
const lexedTokens = lexed.filter((token2) => {
|
|
93
|
+
const tokenType = this.getTokenType(token2.type);
|
|
94
|
+
if (tokenType) {
|
|
95
|
+
return !tokenType.skip;
|
|
96
|
+
} else {
|
|
97
|
+
throw new Error(`Unknown token type ${token2.type}`);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
return { tokens: lexedTokens, shift, rawInput };
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Parse an input string into an AST.
|
|
104
|
+
* It can also parse the result from `lex`, but that is really only for internal use.
|
|
105
|
+
*/
|
|
106
|
+
parse(input) {
|
|
107
|
+
var _a;
|
|
108
|
+
const doSeal = ((_a = arguments[1]) == null ? void 0 : _a.seal) ?? true;
|
|
109
|
+
if (typeof input === "string" && isWhitespace(input)) {
|
|
110
|
+
return token.value(void 0, { start: 0, end: 0 });
|
|
111
|
+
}
|
|
112
|
+
const { tokens: lexedTokens, shift, rawInput } = typeof input === "string" ? this.lex(input) : input;
|
|
113
|
+
this.state = {
|
|
114
|
+
rawInput,
|
|
115
|
+
shift,
|
|
116
|
+
index: -1,
|
|
117
|
+
lexedTokens
|
|
118
|
+
};
|
|
119
|
+
const res = this.ruleMain();
|
|
120
|
+
if (doSeal) {
|
|
121
|
+
seal(res);
|
|
122
|
+
}
|
|
123
|
+
this.state = {
|
|
124
|
+
rawInput: "",
|
|
125
|
+
shift: 0,
|
|
126
|
+
index: -1,
|
|
127
|
+
lexedTokens: []
|
|
128
|
+
};
|
|
129
|
+
return res;
|
|
130
|
+
}
|
|
131
|
+
createSubParserIfNotExists(opts, which = "One") {
|
|
132
|
+
if (this[`subParser${which}`] === void 0) {
|
|
133
|
+
this[`subParser${which}`] = new Parser(opts);
|
|
134
|
+
}
|
|
135
|
+
return this[`subParser${which}`];
|
|
136
|
+
}
|
|
137
|
+
transformCategoryToken(token2, categoryToken) {
|
|
138
|
+
return {
|
|
139
|
+
...token2,
|
|
140
|
+
type: categoryToken.type
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
getCategoryTokens(type) {
|
|
144
|
+
var _a;
|
|
145
|
+
return (_a = this.$categories[type]) == null ? void 0 : _a.entries;
|
|
146
|
+
}
|
|
147
|
+
getTokenType(type) {
|
|
148
|
+
return this.$[type];
|
|
149
|
+
}
|
|
150
|
+
isExactType(token2, type) {
|
|
151
|
+
if (this.$[type]) {
|
|
152
|
+
return this.isType(token2, type);
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
isType(token2, type) {
|
|
157
|
+
if (token2 === void 0)
|
|
158
|
+
return false;
|
|
159
|
+
if (token2.type === type)
|
|
160
|
+
return true;
|
|
161
|
+
const tokenType = this.getTokenType(token2.type);
|
|
162
|
+
if ((tokenType == null ? void 0 : tokenType.type) === type)
|
|
163
|
+
return true;
|
|
164
|
+
const category = this.$categories[type];
|
|
165
|
+
if ((category == null ? void 0 : category.entries[token2.type]) !== void 0) {
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
createErrorToken(type, index) {
|
|
171
|
+
return {
|
|
172
|
+
type,
|
|
173
|
+
value: "",
|
|
174
|
+
startOffset: index ?? this.state.index,
|
|
175
|
+
endOffset: index ?? this.state.index,
|
|
176
|
+
isError: true
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
processToken(token2) {
|
|
180
|
+
if (token2 === void 0) {
|
|
181
|
+
return [void 0, extractPosition({ startOffset: 0, endOffset: 0 }, this.state.shift)];
|
|
182
|
+
} else {
|
|
183
|
+
return [token2.value, extractPosition(token2, this.state.shift)];
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
peek(n = 1) {
|
|
187
|
+
return this.state.lexedTokens[this.state.index + n];
|
|
188
|
+
}
|
|
189
|
+
nextIsEof() {
|
|
190
|
+
return this.peek(1) === void 0;
|
|
191
|
+
}
|
|
192
|
+
consumeAny() {
|
|
193
|
+
var _a;
|
|
194
|
+
return this.consume((_a = this.peek(1)) == null ? void 0 : _a.type);
|
|
195
|
+
}
|
|
196
|
+
consume(type) {
|
|
197
|
+
if (type === void 0) {
|
|
198
|
+
throw new Error("type is undefined");
|
|
199
|
+
}
|
|
200
|
+
const nextToken = this.peek(1);
|
|
201
|
+
if (nextToken === void 0) {
|
|
202
|
+
throw new Error(`Reached end of input without consuming a token of type ${type}`);
|
|
203
|
+
}
|
|
204
|
+
if (this.$categories[type] !== void 0) {
|
|
205
|
+
const categoryToken = this.$categories[type];
|
|
206
|
+
const tokenType = categoryToken == null ? void 0 : categoryToken.entries[nextToken.type];
|
|
207
|
+
if (categoryToken && tokenType) {
|
|
208
|
+
this.state.index++;
|
|
209
|
+
return this.transformCategoryToken(nextToken, categoryToken);
|
|
210
|
+
} else {
|
|
211
|
+
throw new Error("here");
|
|
212
|
+
}
|
|
213
|
+
} else {
|
|
214
|
+
const tokenType = this.getTokenType(type);
|
|
215
|
+
if (tokenType !== void 0) {
|
|
216
|
+
if ((nextToken == null ? void 0 : nextToken.type) === tokenType.type) {
|
|
217
|
+
this.state.index++;
|
|
218
|
+
return nextToken;
|
|
219
|
+
} else {
|
|
220
|
+
throw new Error(`Expected token type ${tokenType.type}, got ${nextToken == null ? void 0 : nextToken.type}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
throw new Error(`Unknown token type ${type}`);
|
|
225
|
+
}
|
|
226
|
+
saveState() {
|
|
227
|
+
return { ...this.state };
|
|
228
|
+
}
|
|
229
|
+
restoreState(state) {
|
|
230
|
+
this.state = state;
|
|
231
|
+
}
|
|
232
|
+
ruleMain() {
|
|
233
|
+
const res = this.ruleBool("OR");
|
|
234
|
+
if (res === void 0) {
|
|
235
|
+
const error = token.value(void 0, { start: 0, end: 0 });
|
|
236
|
+
return error;
|
|
237
|
+
}
|
|
238
|
+
return res;
|
|
239
|
+
}
|
|
240
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
241
|
+
ruleBool(type) {
|
|
242
|
+
var _a;
|
|
243
|
+
const OP_TYPE = type === "AND" ? $C.OPERATOR_AND : $C.OPERATOR_OR;
|
|
244
|
+
const pairs = [];
|
|
245
|
+
let next = this.peek(1);
|
|
246
|
+
while (pairs.length < 1 || ((_a = pairs[pairs.length - 1]) == null ? void 0 : _a[1]) !== void 0) {
|
|
247
|
+
const exp = type === "AND" ? this.ruleCondition() : this.ruleBool("AND");
|
|
248
|
+
next = this.peek(1);
|
|
249
|
+
const canAttemptErrorRecovery = type === "AND" ? ["error", "and"].includes(this.options.onMissingBooleanOperator) : this.options.onMissingBooleanOperator === "or";
|
|
250
|
+
const extras = [];
|
|
251
|
+
if (canAttemptErrorRecovery && (this.isType(next, $C.VALUE) || this.isType(next, $C.QUOTE_ANY) || this.isType(next, $T.PAREN_L) || this.isType(next, $T.EXP_PROP_OP) || this.isType(next, $T.REGEX_START) || this.isType(next, $T.CUSTOM_PROP_OP))) {
|
|
252
|
+
let state = this.saveState();
|
|
253
|
+
let cond = this.ruleCondition();
|
|
254
|
+
if (type === "AND") {
|
|
255
|
+
let dummyOp;
|
|
256
|
+
while (cond !== void 0) {
|
|
257
|
+
if (this.options.onMissingBooleanOperator === "and") {
|
|
258
|
+
const prev = this.peek(-1);
|
|
259
|
+
const start = prev.endOffset + 1;
|
|
260
|
+
dummyOp = operator.and("", pos({ start }, { fill: true }));
|
|
261
|
+
}
|
|
262
|
+
extras.push([dummyOp, cond]);
|
|
263
|
+
state = this.saveState();
|
|
264
|
+
cond = this.ruleCondition();
|
|
265
|
+
}
|
|
266
|
+
this.restoreState(state);
|
|
267
|
+
} else {
|
|
268
|
+
const prev = this.peek(-1);
|
|
269
|
+
const start = prev.endOffset + 1;
|
|
270
|
+
const dummyOp = operator.or("", pos({ start }, { fill: true }));
|
|
271
|
+
extras.push([dummyOp, cond]);
|
|
272
|
+
}
|
|
273
|
+
next = this.peek(1);
|
|
274
|
+
}
|
|
275
|
+
const sepToken = this.isType(next, OP_TYPE) && next ? type === "AND" ? operator.and(...this.processToken(this.consume(next.type))) : operator.or(...this.processToken(this.consume(next.type))) : void 0;
|
|
276
|
+
pairs.push([
|
|
277
|
+
exp,
|
|
278
|
+
sepToken
|
|
279
|
+
]);
|
|
280
|
+
next = this.peek(1);
|
|
281
|
+
for (const extra of extras) {
|
|
282
|
+
pairs[pairs.length - 1].splice(1, 1, extra[0]);
|
|
283
|
+
pairs.push([extra[1]]);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (pairs.length === 0 && this.isType(this.peek(1), OP_TYPE)) {
|
|
287
|
+
next = this.peek(-1);
|
|
288
|
+
let state = this.saveState();
|
|
289
|
+
while (this.isType(next, $C.OPERATOR_AND)) {
|
|
290
|
+
const token2 = this.consume($C.OPERATOR_AND);
|
|
291
|
+
pairs.push([
|
|
292
|
+
void 0,
|
|
293
|
+
type === "AND" ? operator.and(...this.processToken(token2)) : operator.or(...this.processToken(token2))
|
|
294
|
+
]);
|
|
295
|
+
next = this.peek(-1);
|
|
296
|
+
while (this.isType(next, $C.VALUE) || this.isType(next, $C.QUOTE_ANY) || this.isType(next, $T.PAREN_L)) {
|
|
297
|
+
pairs.push([this.ruleCondition()]);
|
|
298
|
+
next = this.peek(-1);
|
|
299
|
+
}
|
|
300
|
+
state = this.saveState();
|
|
301
|
+
}
|
|
302
|
+
this.restoreState(state);
|
|
303
|
+
}
|
|
304
|
+
if (type === "AND" && pairs.length === 0)
|
|
305
|
+
return void 0;
|
|
306
|
+
let res = pairs[pairs.length - 1][0];
|
|
307
|
+
for (let i = pairs.length - 1; i > 0; i--) {
|
|
308
|
+
const before = pairs[i - 1];
|
|
309
|
+
if (type === "OR" && res === void 0 && before === void 0)
|
|
310
|
+
return void 0;
|
|
311
|
+
res = expression(before[0], before[1], res);
|
|
312
|
+
}
|
|
313
|
+
return res;
|
|
314
|
+
}
|
|
315
|
+
ruleCondition() {
|
|
316
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
317
|
+
const not = this.ruleNot();
|
|
318
|
+
const property = this.ruleConditionProperty();
|
|
319
|
+
const propVal = ((_a = property == null ? void 0 : property.prop) == null ? void 0 : _a.value) === void 0 ? void 0 : property.prop.value instanceof ErrorToken ? "" : property.prop.value.value;
|
|
320
|
+
const propOpVal = ((_b = property == null ? void 0 : property.rest) == null ? void 0 : _b.propertyOperator) === void 0 ? void 0 : property.rest.propertyOperator instanceof ErrorToken ? "" : (_c = property.rest.propertyOperator) == null ? void 0 : _c.value;
|
|
321
|
+
const isExpanded = (((_d = property == null ? void 0 : property.rest) == null ? void 0 : _d.sepL) ?? ((_e = property == null ? void 0 : property.rest) == null ? void 0 : _e.sepR)) !== void 0;
|
|
322
|
+
const convertRegexValues = typeof this.options.regexValues === "function" && !this.options.regexValues(propVal, propOpVal, isExpanded);
|
|
323
|
+
const convertArrayValues = typeof this.options.arrayValues === "function" && !this.options.arrayValues(propVal, propOpVal, isExpanded);
|
|
324
|
+
let value = this.ruleConditionValue(property, { convertRegexValues, convertArrayValues });
|
|
325
|
+
let group$1;
|
|
326
|
+
if (!(value instanceof ArrayNode) && !isArray(value) && (!value || this.options.prefixableGroups) && this.isType(this.peek(1), $T.PAREN_L)) {
|
|
327
|
+
group$1 = this.rulePlainGroup({ onlyValues: property !== void 0, convertRegexValues, convertArrayValues });
|
|
328
|
+
}
|
|
329
|
+
if (isArray(value)) {
|
|
330
|
+
group$1 = value;
|
|
331
|
+
value = void 0;
|
|
332
|
+
}
|
|
333
|
+
if (convertRegexValues && value instanceof VariableNode && ((_f = value.quote) == null ? void 0 : _f.left.type) === TOKEN_TYPE.REGEX) {
|
|
334
|
+
value = variable(void 0, void 0, token.value(
|
|
335
|
+
(((_h = (_g = value.quote) == null ? void 0 : _g.left) == null ? void 0 : _h.value) ?? "") + (value.value.value ?? "") + (((_j = (_i = value.quote) == null ? void 0 : _i.right) == null ? void 0 : _j.value) ?? ""),
|
|
336
|
+
pos(value)
|
|
337
|
+
), void 0);
|
|
338
|
+
}
|
|
339
|
+
if (group$1) {
|
|
340
|
+
if (property) {
|
|
341
|
+
return condition(not, property == null ? void 0 : property.prop, property == null ? void 0 : property.rest, group(void 0, void 0, ...group$1));
|
|
342
|
+
}
|
|
343
|
+
if (value) {
|
|
344
|
+
return group(void 0, condition(not, void 0, void 0, value), ...group$1);
|
|
345
|
+
}
|
|
346
|
+
return group(not, value, ...group$1);
|
|
347
|
+
}
|
|
348
|
+
if ([not, property, value].every((_) => _ === void 0))
|
|
349
|
+
return void 0;
|
|
350
|
+
return condition(not, property == null ? void 0 : property.prop, property == null ? void 0 : property.rest, value);
|
|
351
|
+
}
|
|
352
|
+
ruleConditionValue(property, { convertRegexValues = false, convertArrayValues = false } = {}) {
|
|
353
|
+
const next = this.peek(1);
|
|
354
|
+
const next2 = this.peek(2);
|
|
355
|
+
const next3 = this.peek(3);
|
|
356
|
+
const next4 = this.peek(4);
|
|
357
|
+
if (this.options.prefixableGroups && property === void 0 && (next == null ? void 0 : next.type) !== $T.PAREN_L && (this.isType(next, $C.VALUE) && (this.isType(next2, $T.PAREN_L) || this.isType(next2, $C.QUOTE_ANY) && this.isType(next3, $T.PAREN_L)) || this.isType(next, $C.QUOTE_ANY) && (this.isType(next2, $T.PAREN_L) || this.isType(next2, $C.VALUE) && (this.isType(next3, $T.PAREN_L) || // "a(
|
|
358
|
+
this.isType(next3, $C.QUOTE_ANY) && this.isType(next4, $T.PAREN_L))))) {
|
|
359
|
+
const res = this.ruleVariable({ unprefixed: true });
|
|
360
|
+
if (res)
|
|
361
|
+
return res;
|
|
362
|
+
}
|
|
363
|
+
if (!this.isType(next, $T.PAREN_L)) {
|
|
364
|
+
const res = this.ruleVariable({ unprefixed: false });
|
|
365
|
+
if (res)
|
|
366
|
+
return res;
|
|
367
|
+
}
|
|
368
|
+
if (this.isType(next, $T.PAREN_L)) {
|
|
369
|
+
const res = this.rulePlainGroup({ onlyValues: property !== void 0, convertRegexValues, convertArrayValues });
|
|
370
|
+
if (res)
|
|
371
|
+
return res;
|
|
372
|
+
}
|
|
373
|
+
if (this.isType(next, $T.BRACKET_L)) {
|
|
374
|
+
const res = this.rulePlainBracketGroup({ convertArrayValues });
|
|
375
|
+
if (res)
|
|
376
|
+
return res;
|
|
377
|
+
}
|
|
378
|
+
return void 0;
|
|
379
|
+
}
|
|
380
|
+
rulePlainGroup({ onlyValues = false, convertRegexValues = false, convertArrayValues = false } = {}) {
|
|
381
|
+
const parenL = this.ruleParenL();
|
|
382
|
+
let parenLeftCount = 0;
|
|
383
|
+
let start;
|
|
384
|
+
let end;
|
|
385
|
+
const condition2 = !onlyValues ? this.ruleBool("OR") : void 0;
|
|
386
|
+
if (onlyValues && !this.nextIsEof()) {
|
|
387
|
+
while (!this.nextIsEof() && (!this.isType(this.peek(1), $T.PAREN_R) || parenLeftCount !== 0)) {
|
|
388
|
+
const token2 = this.consumeAny();
|
|
389
|
+
start ?? (start = extractPosition(token2, this.state.shift).start);
|
|
390
|
+
if (token2.type === $T.PAREN_L) {
|
|
391
|
+
parenLeftCount++;
|
|
392
|
+
}
|
|
393
|
+
if (token2.type === $T.PAREN_R) {
|
|
394
|
+
parenLeftCount--;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (start !== void 0) {
|
|
399
|
+
end ?? (end = extractPosition(this.peek(0), this.state.shift).end);
|
|
400
|
+
}
|
|
401
|
+
const parenR = this.isType(this.peek(1), $T.PAREN_R) ? this.ruleParenR() : void 0;
|
|
402
|
+
if (start !== void 0) {
|
|
403
|
+
const subInput = this.state.rawInput.slice(start, end);
|
|
404
|
+
this.createSubParserIfNotExists({
|
|
405
|
+
...this.options,
|
|
406
|
+
customPropertyOperators: [],
|
|
407
|
+
expandedPropertySeparator: void 0,
|
|
408
|
+
regexValues: convertRegexValues,
|
|
409
|
+
arrayValues: convertArrayValues
|
|
410
|
+
}, "One");
|
|
411
|
+
const parsed = this.subParserOne.parse(" ".repeat(start) + subInput, { seal: false });
|
|
412
|
+
return [parenL, parsed, parenR];
|
|
413
|
+
}
|
|
414
|
+
return [parenL, condition2, parenR];
|
|
415
|
+
}
|
|
416
|
+
rulePlainBracketGroup({ convertArrayValues = false } = {}) {
|
|
417
|
+
const bracketL = this.ruleBracketL();
|
|
418
|
+
const values = [];
|
|
419
|
+
if (!convertArrayValues) {
|
|
420
|
+
let state = this.saveState();
|
|
421
|
+
let variable2 = this.ruleVariable({ unprefixed: false });
|
|
422
|
+
while (variable2 !== void 0) {
|
|
423
|
+
values.push(variable2);
|
|
424
|
+
state = this.saveState();
|
|
425
|
+
variable2 = this.ruleVariable({ unprefixed: false });
|
|
426
|
+
}
|
|
427
|
+
this.restoreState(state);
|
|
428
|
+
} else if (convertArrayValues && !this.nextIsEof()) {
|
|
429
|
+
while (!this.nextIsEof() && !this.isType(this.peek(1), $T.BRACKET_R)) {
|
|
430
|
+
this.consumeAny();
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
const bracketR = this.isType(this.peek(1), $T.BRACKET_R) ? this.ruleBracketR() : void 0;
|
|
434
|
+
if (bracketL === void 0)
|
|
435
|
+
throw new Error("bracketL is undefined, peek before using rule.");
|
|
436
|
+
if (!convertArrayValues) {
|
|
437
|
+
return array(bracketL, values, bracketR);
|
|
438
|
+
}
|
|
439
|
+
const start = bracketL.start;
|
|
440
|
+
const end = bracketR == null ? void 0 : bracketR.end;
|
|
441
|
+
const subInput = this.state.rawInput.slice(start, end);
|
|
442
|
+
this.createSubParserIfNotExists({
|
|
443
|
+
...this.options,
|
|
444
|
+
customPropertyOperators: [],
|
|
445
|
+
expandedPropertySeparator: void 0,
|
|
446
|
+
arrayValues: false
|
|
447
|
+
}, "Two");
|
|
448
|
+
const parsed = this.subParserTwo.parse(" ".repeat(start) + subInput, { seal: false });
|
|
449
|
+
if (parsed instanceof ConditionNode) {
|
|
450
|
+
return parsed.value;
|
|
451
|
+
}
|
|
452
|
+
if (parsed instanceof ErrorToken || parsed instanceof ExpressionNode || parsed instanceof GroupNode) {
|
|
453
|
+
unreachable("parsed.value should not be an ErrorToken, ExpressionNode, or GroupNode.");
|
|
454
|
+
}
|
|
455
|
+
return parsed;
|
|
456
|
+
}
|
|
457
|
+
ruleConditionProperty() {
|
|
458
|
+
const current = this.peek(0);
|
|
459
|
+
const next = this.peek(1);
|
|
460
|
+
const next2 = this.peek(2);
|
|
461
|
+
if (this.isType(next, $T.EXP_PROP_OP) || this.isType(next, $T.CUSTOM_PROP_OP) || this.isType(next, $T.VALUE_UNQUOTED) && (this.isType(next2, $T.EXP_PROP_OP) || this.isType(next2, $T.CUSTOM_PROP_OP)) || this.info.customOpAlsoNegation && (this.isType(next2, $T.SYM_NOT) || this.isType(current, $T.SYM_NOT) && this.isType(next, $T.SYM_NOT))) {
|
|
462
|
+
return this.ruleProperty();
|
|
463
|
+
}
|
|
464
|
+
return void 0;
|
|
465
|
+
}
|
|
466
|
+
ruleProperty() {
|
|
467
|
+
const prop = this.ruleVariable({ unprefixed: true });
|
|
468
|
+
const next = this.peek(1);
|
|
469
|
+
let rest = {};
|
|
470
|
+
if (this.isType(next, $T.EXP_PROP_OP)) {
|
|
471
|
+
const sepL = token.sep(...this.processToken(this.consume($T.EXP_PROP_OP)));
|
|
472
|
+
const op = this.isType(this.peek(1), $T.VALUE_UNQUOTED) ? token.value(...this.processToken(this.consume($T.VALUE_UNQUOTED))) : void 0;
|
|
473
|
+
const sepR = this.isType(this.peek(1), $T.EXP_PROP_OP) ? token.sep(...this.processToken(this.consume($T.EXP_PROP_OP))) : void 0;
|
|
474
|
+
if (this.info.expandedSepAlsoCustom && op === void 0 && sepR === void 0) {
|
|
475
|
+
setReadOnly(sepL, "type", TOKEN_TYPE.OP_CUSTOM);
|
|
476
|
+
rest = {
|
|
477
|
+
sepL: void 0,
|
|
478
|
+
sepR,
|
|
479
|
+
propertyOperator: sepL
|
|
480
|
+
};
|
|
481
|
+
} else {
|
|
482
|
+
rest = { sepL, sepR, propertyOperator: op };
|
|
483
|
+
}
|
|
484
|
+
} else if (this.isType(next, $T.CUSTOM_PROP_OP)) {
|
|
485
|
+
const op = token.custom(...this.processToken(this.consume($T.CUSTOM_PROP_OP)));
|
|
486
|
+
rest = { propertyOperator: op };
|
|
487
|
+
} else if (this.info.customOpAlsoNegation && this.isType(next, $T.SYM_NOT)) {
|
|
488
|
+
const op = token.custom(...this.processToken(this.consume($T.SYM_NOT)));
|
|
489
|
+
rest = { propertyOperator: op };
|
|
490
|
+
}
|
|
491
|
+
return { prop, rest };
|
|
492
|
+
}
|
|
493
|
+
ruleVariable({
|
|
494
|
+
unprefixed = false
|
|
495
|
+
} = {}) {
|
|
496
|
+
const prefix = this.ruleVariablePrefix({ onlyToken: true, unprefixed });
|
|
497
|
+
const next = this.peek(1);
|
|
498
|
+
const next2 = this.peek(2);
|
|
499
|
+
const next3 = this.peek(3);
|
|
500
|
+
if (next && (this.isExactType(next, $T.QUOTE_DOUBLE) || this.isExactType(next, $T.QUOTE_SINGLE) || this.isExactType(next, $T.QUOTE_BACKTICK))) {
|
|
501
|
+
const quoteType = next.type;
|
|
502
|
+
if ((next2 == null ? void 0 : next2.type) === quoteType) {
|
|
503
|
+
const quoteL = this.ruleQuote(quoteType);
|
|
504
|
+
const quoteR = this.ruleQuote(quoteType);
|
|
505
|
+
return variable(void 0, quoteL, void 0, quoteR);
|
|
506
|
+
}
|
|
507
|
+
if ((next3 == null ? void 0 : next3.type) === next.type) {
|
|
508
|
+
const quoteL = this.ruleQuote(quoteType);
|
|
509
|
+
const value = this.isType(next2, $T.VALUE_UNQUOTED) ? this.ruleValueUnquoted({}) : this.ruleValueNot(quoteType);
|
|
510
|
+
const quoteR = this.ruleQuote(quoteType);
|
|
511
|
+
const prefixToken = prefix ? token.value(...this.processToken(prefix)) : void 0;
|
|
512
|
+
return variable(prefixToken, quoteL, value, quoteR);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
if (this.isType(next, $C.REGEX_ANY)) {
|
|
516
|
+
const quoteL = this.ruleRegexAny();
|
|
517
|
+
const maybeValue = this.peek(1);
|
|
518
|
+
const value = this.isType(maybeValue, $T.VALUE_REGEX) ? this.ruleValueNot($C.REGEX_ANY) : void 0;
|
|
519
|
+
const quoteR = this.isType(this.peek(1), $C.REGEX_ANY) ? this.ruleRegexAny() : void 0;
|
|
520
|
+
const args = isArray(quoteR) ? quoteR : [quoteR, void 0];
|
|
521
|
+
return variable(void 0, quoteL, value, args[0], args[1]);
|
|
522
|
+
}
|
|
523
|
+
if (this.isType(next, $T.VALUE_UNQUOTED) && this.isType(next2, $C.QUOTE_ANY)) {
|
|
524
|
+
const value = this.ruleValueUnquoted();
|
|
525
|
+
const quoteR = this.ruleValueDelimAny();
|
|
526
|
+
return variable(void 0, void 0, value, quoteR);
|
|
527
|
+
}
|
|
528
|
+
if (this.isType(next, $C.QUOTE_ANY)) {
|
|
529
|
+
const quoteToken = next;
|
|
530
|
+
const quoteL = this.ruleValueDelimAny();
|
|
531
|
+
const maybeValue = this.peek(1);
|
|
532
|
+
const value = !quoteL && this.isType(maybeValue, $T.VALUE_UNQUOTED) ? this.ruleValueUnquoted() : quoteL && this.isType(maybeValue, quoteToken.type.replace("QUOTE", "VALUE_FOR")) ? this.ruleValueNot(quoteToken.type) : void 0;
|
|
533
|
+
return variable(void 0, quoteL, value, void 0);
|
|
534
|
+
}
|
|
535
|
+
if (this.isType(next, $T.VALUE_UNQUOTED)) {
|
|
536
|
+
const value = this.ruleValueUnquoted();
|
|
537
|
+
return variable(void 0, void 0, value, void 0);
|
|
538
|
+
}
|
|
539
|
+
return void 0;
|
|
540
|
+
}
|
|
541
|
+
ruleValueDelimAny() {
|
|
542
|
+
const next = this.peek(1);
|
|
543
|
+
if (this.isType(next, $C.QUOTE_ANY)) {
|
|
544
|
+
const type = next.value === `"` ? "double" : next.value === "'" ? "single" : next.value === "`" ? "tick" : "regex";
|
|
545
|
+
return delimiter[type](...this.processToken(this.consume($C.QUOTE_ANY)));
|
|
546
|
+
}
|
|
547
|
+
return void 0;
|
|
548
|
+
}
|
|
549
|
+
ruleRegexAny() {
|
|
550
|
+
const value = this.consume($C.REGEX_ANY);
|
|
551
|
+
if (value.value.length > 1) {
|
|
552
|
+
const delim = {
|
|
553
|
+
value: "/",
|
|
554
|
+
startOffset: value.startOffset,
|
|
555
|
+
endOffset: value.startOffset
|
|
556
|
+
};
|
|
557
|
+
const flags = {
|
|
558
|
+
value: value.value.slice(1),
|
|
559
|
+
startOffset: value.startOffset + 1,
|
|
560
|
+
endOffset: value.endOffset
|
|
561
|
+
};
|
|
562
|
+
return [
|
|
563
|
+
// why the ! ??? todo
|
|
564
|
+
delimiter.regex(...this.processToken(delim)),
|
|
565
|
+
token.value(...this.processToken(flags))
|
|
566
|
+
];
|
|
567
|
+
}
|
|
568
|
+
return delimiter.regex(...this.processToken(value));
|
|
569
|
+
}
|
|
570
|
+
ruleValueNot(type) {
|
|
571
|
+
const realType = {
|
|
572
|
+
[$T.QUOTE_SINGLE]: $C.VALUE_FOR_SINGLE,
|
|
573
|
+
[$T.QUOTE_DOUBLE]: $C.VALUE_FOR_DOUBLE,
|
|
574
|
+
[$T.QUOTE_BACKTICK]: $C.VALUE_FOR_BACKTICK,
|
|
575
|
+
[$C.REGEX_ANY]: $T.VALUE_REGEX
|
|
576
|
+
}[type];
|
|
577
|
+
if (realType === void 0) {
|
|
578
|
+
unreachable(`Unknown quote/regex type ${type}`);
|
|
579
|
+
}
|
|
580
|
+
const value = this.consume(realType);
|
|
581
|
+
if (realType !== value.type) {
|
|
582
|
+
unreachable(`Expected value type ${realType}, got ${value.type}`);
|
|
583
|
+
}
|
|
584
|
+
return token.value(...this.processToken(value));
|
|
585
|
+
}
|
|
586
|
+
ruleQuote(type) {
|
|
587
|
+
const quote = this.peek(1);
|
|
588
|
+
if (type !== (quote == null ? void 0 : quote.type)) {
|
|
589
|
+
throw new Error(`Expected quote type ${type}, got ${quote == null ? void 0 : quote.type}`);
|
|
590
|
+
}
|
|
591
|
+
switch (type) {
|
|
592
|
+
case $T.QUOTE_SINGLE:
|
|
593
|
+
return delimiter.single(
|
|
594
|
+
...this.processToken(this.consume($T.QUOTE_SINGLE))
|
|
595
|
+
);
|
|
596
|
+
case $T.QUOTE_DOUBLE:
|
|
597
|
+
return delimiter.double(
|
|
598
|
+
...this.processToken(this.consume($T.QUOTE_DOUBLE))
|
|
599
|
+
);
|
|
600
|
+
case $T.QUOTE_BACKTICK:
|
|
601
|
+
return delimiter.tick(
|
|
602
|
+
...this.processToken(this.consume($T.QUOTE_BACKTICK))
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
throw new Error(`Expected quote type ${type}`);
|
|
606
|
+
}
|
|
607
|
+
ruleVariablePrefix({
|
|
608
|
+
onlyToken = false,
|
|
609
|
+
unprefixed = false
|
|
610
|
+
} = {}) {
|
|
611
|
+
const next = this.peek(1);
|
|
612
|
+
const next2 = this.peek(2);
|
|
613
|
+
const next4 = this.peek(4);
|
|
614
|
+
if (!unprefixed && this.options.prefixableStrings !== void 0 && this.isType(next2, $C.QUOTE_ANY) && next2 && this.isType(next4, next2.type) && next && this.options.prefixableStrings.includes(next.value)) {
|
|
615
|
+
return this.ruleValueUnquoted({ onlyToken });
|
|
616
|
+
}
|
|
617
|
+
if (onlyToken)
|
|
618
|
+
return void 0;
|
|
619
|
+
return token.value(...this.processToken());
|
|
620
|
+
}
|
|
621
|
+
ruleValueUnquoted({
|
|
622
|
+
onlyToken = false
|
|
623
|
+
} = {}) {
|
|
624
|
+
const t = this.consume($T.VALUE_UNQUOTED);
|
|
625
|
+
const res = onlyToken ? t : token.value(...this.processToken(t));
|
|
626
|
+
return res;
|
|
627
|
+
}
|
|
628
|
+
ruleParenL() {
|
|
629
|
+
const next = this.peek(1);
|
|
630
|
+
const value = (next == null ? void 0 : next.type) === $T.PAREN_L ? this.consume($T.PAREN_L) : this.createErrorToken($T.PAREN_L);
|
|
631
|
+
const loc = extractPosition(value, this.state.shift);
|
|
632
|
+
return this.state.shift === 0 || loc.start > 0 ? delimiter.parenL(value.isError ? void 0 : value.value, loc) : void 0;
|
|
633
|
+
}
|
|
634
|
+
ruleParenR() {
|
|
635
|
+
const value = this.consume($T.PAREN_R);
|
|
636
|
+
return delimiter.parenR(...this.processToken(value));
|
|
637
|
+
}
|
|
638
|
+
ruleBracketL() {
|
|
639
|
+
const next = this.peek(1);
|
|
640
|
+
const value = (next == null ? void 0 : next.type) === $T.BRACKET_L ? this.consume($T.BRACKET_L) : this.createErrorToken($T.BRACKET_L);
|
|
641
|
+
const loc = extractPosition(value, this.state.shift);
|
|
642
|
+
return this.state.shift === 0 || loc.start > 0 ? delimiter.bracketL(value.isError ? void 0 : value.value, loc) : void 0;
|
|
643
|
+
}
|
|
644
|
+
ruleBracketR() {
|
|
645
|
+
const value = this.consume($T.BRACKET_R);
|
|
646
|
+
return delimiter.bracketR(...this.processToken(value));
|
|
647
|
+
}
|
|
648
|
+
ruleNot() {
|
|
649
|
+
if (this.isType(this.peek(1), $C.OPERATOR_NOT)) {
|
|
650
|
+
const op = this.consume($C.OPERATOR_NOT);
|
|
651
|
+
return operator.not(...this.processToken(op));
|
|
652
|
+
}
|
|
653
|
+
return void 0;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
mixin(Parser, [
|
|
657
|
+
AutocompleteMixin,
|
|
658
|
+
AutoreplaceMixin,
|
|
659
|
+
Autosuggest,
|
|
660
|
+
EvaluateMixin,
|
|
661
|
+
ValidateMixin,
|
|
662
|
+
NormalizeMixin,
|
|
663
|
+
GetIndexMixin,
|
|
664
|
+
GetBestIndexesMixin
|
|
665
|
+
]);
|
|
666
|
+
export {
|
|
667
|
+
Parser
|
|
668
|
+
};
|
package/dist/ast/handlers.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ import { VariableNode } from "./classes/VariableNode.js";
|
|
|
8
8
|
import { type AnyToken, type Position, TOKEN_TYPE, type TokenBooleanTypes, type TokenQuoteTypes } from "../types/ast.js";
|
|
9
9
|
declare function error<T extends TOKEN_TYPE>(pos: number, expected: T[]): ErrorToken<T>;
|
|
10
10
|
export declare const token: {
|
|
11
|
-
value:
|
|
12
|
-
custom:
|
|
13
|
-
sep:
|
|
11
|
+
value: <TVal extends string | undefined>(value: TVal, pos: Position) => TVal extends string ? ValidToken<TOKEN_TYPE.VALUE> : ErrorToken<TOKEN_TYPE.VALUE>;
|
|
12
|
+
custom: <TVal_1 extends string | undefined>(value: TVal_1, pos: Position) => TVal_1 extends string ? ValidToken<TOKEN_TYPE.OP_CUSTOM> : ErrorToken<TOKEN_TYPE.OP_CUSTOM>;
|
|
13
|
+
sep: <TVal_2 extends string | undefined>(value: TVal_2, pos: Position) => TVal_2 extends string ? ValidToken<TOKEN_TYPE.OP_EXPANDED_SEP> : ErrorToken<TOKEN_TYPE.OP_EXPANDED_SEP>;
|
|
14
14
|
};
|
|
15
15
|
/** We want to handle all the types outside the grammar file. This makes it easier without trying to check the value. */
|
|
16
16
|
export declare const delimiter: {
|