@traqula/chevrotain 1.0.5 → 1.0.6

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.
@@ -1 +1,2308 @@
1
- export * from 'chevrotain';
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ export declare const VERSION: string;
4
+ export type ParserMethod<ARGS extends unknown[], R> = (...args: ARGS) => R;
5
+ /**
6
+ * This class does not actually exist nor is exposed at runtime.
7
+ * This is just a helper to avoid duplications in the Type Definitions
8
+ * Of `CstParser` and `EmbeddedActionsParser`
9
+ */
10
+ export declare abstract class BaseParser {
11
+ /**
12
+ * This must be called at the end of a Parser constructor.
13
+ * See: http://chevrotain.io/docs/tutorial/step2_parsing.html#under-the-hood
14
+ */
15
+ protected performSelfAnalysis(): void;
16
+ /**
17
+ * It is recommended to reuse the same Parser instance
18
+ * by passing an empty array to the input argument
19
+ * and only later setting the input by using the input property.
20
+ * See: http://chevrotain.io/docs/FAQ.html#major-performance-benefits
21
+ *
22
+ * @param tokenVocabulary - A data structure containing all the Tokens used by the Parser.
23
+ * @param config - The Parser's configuration.
24
+ */
25
+ constructor(tokenVocabulary: TokenVocabulary, config?: IParserConfig);
26
+ errors: IRecognitionException[];
27
+ /**
28
+ * Flag indicating the Parser is at the recording phase.
29
+ * Can be used to implement methods similar to {@link BaseParser.ACTION}
30
+ * Or any other logic to requires knowledge of the recording phase.
31
+ * See:
32
+ * - https://chevrotain.io/docs/guide/internals.html#grammar-recording
33
+ * to learn more on the recording phase and how Chevrotain works.
34
+ */
35
+ RECORDING_PHASE: boolean;
36
+ /**
37
+ * Resets the parser state, should be overridden for custom parsers which "carry" additional state.
38
+ * When overriding, remember to also invoke the super implementation!
39
+ */
40
+ reset(): void;
41
+ getBaseCstVisitorConstructor<IN = any, OUT = any>(): {
42
+ new (...args: any[]): ICstVisitor<IN, OUT>;
43
+ };
44
+ getBaseCstVisitorConstructorWithDefaults<IN = any, OUT = any>(): {
45
+ new (...args: any[]): ICstVisitor<IN, OUT>;
46
+ };
47
+ getGAstProductions(): Record<string, Rule>;
48
+ getSerializedGastProductions(): ISerializedGast[];
49
+ /**
50
+ * @param startRuleName
51
+ * @param precedingInput - The token vector up to (not including) the content assist point
52
+ */
53
+ computeContentAssist(startRuleName: string, precedingInput: IToken[]): ISyntacticContentAssistPath[];
54
+ /**
55
+ * @param grammarRule - The rule to try and parse in backtracking mode.
56
+ * @param args - argument to be passed to the grammar rule execution
57
+ *
58
+ * @return a lookahead function that will try to parse the given grammarRule and will return true if succeed.
59
+ */
60
+ protected BACKTRACK<T>(grammarRule: (...args: any[]) => T, args?: any[]): () => boolean;
61
+ /**
62
+ * The Semantic Actions wrapper.
63
+ * Should be used to wrap semantic actions that either:
64
+ * - May fail when executing in "recording phase".
65
+ * - Have global side effects that should be avoided during "recording phase".
66
+ *
67
+ * For more information see:
68
+ * - https://chevrotain.io/docs/guide/internals.html#grammar-recording
69
+ */
70
+ protected ACTION<T>(impl: () => T): T;
71
+ /**
72
+ * Like `CONSUME` with the numerical suffix as a parameter, e.g:
73
+ * consume(0, X) === CONSUME(X)
74
+ * consume(1, X) === CONSUME1(X)
75
+ * consume(2, X) === CONSUME2(X)
76
+ * ...
77
+ * @see CONSUME
78
+ */
79
+ protected consume(idx: number, tokType: TokenType, options?: ConsumeMethodOpts): IToken;
80
+ /**
81
+ * Like `OPTION` with the numerical suffix as a parameter, e.g:
82
+ * option(0, X) === OPTION(X)
83
+ * option(1, X) === OPTION1(X)
84
+ * option(2, X) === OPTION2(X)
85
+ * ...
86
+ * @see OPTION
87
+ */
88
+ protected option<OUT>(idx: number, actionORMethodDef: GrammarAction<OUT> | DSLMethodOpts<OUT>): OUT | undefined;
89
+ /**
90
+ * Like `OR` with the numerical suffix as a parameter, e.g:
91
+ * or(0, X) === OR(X)
92
+ * or(1, X) === OR1(X)
93
+ * or(2, X) === OR2(X)
94
+ * ...
95
+ * @see OR
96
+ */
97
+ protected or(idx: number, altsOrOpts: IOrAlt<any>[] | OrMethodOpts<any>): any;
98
+ protected or<T>(idx: number, altsOrOpts: IOrAlt<T>[] | OrMethodOpts<T>): T;
99
+ /**
100
+ * Like `MANY` with the numerical suffix as a parameter, e.g:
101
+ * many(0, X) === MANY(X)
102
+ * many(1, X) === MANY1(X)
103
+ * many(2, X) === MANY2(X)
104
+ * ...
105
+ * @see MANY
106
+ */
107
+ protected many(idx: number, actionORMethodDef: GrammarAction<any> | DSLMethodOpts<any>): void;
108
+ /**
109
+ * Like `AT_LEAST_ONE` with the numerical suffix as a parameter, e.g:
110
+ * atLeastOne(0, X) === AT_LEAST_ONE(X)
111
+ * atLeastOne(1, X) === AT_LEAST_ONE1(X)
112
+ * atLeastOne(2, X) === AT_LEAST_ONE2(X)
113
+ * ...
114
+ * @see AT_LEAST_ONE
115
+ */
116
+ protected atLeastOne(idx: number, actionORMethodDef: GrammarAction<any> | DSLMethodOptsWithErr<any>): void;
117
+ /**
118
+ *
119
+ * A Parsing DSL method use to consume a single Token.
120
+ * In EBNF terms this is equivalent to a Terminal.
121
+ *
122
+ * A Token will be consumed, IFF the next token in the token vector matches `tokType`.
123
+ * otherwise the parser may attempt to perform error recovery (if enabled).
124
+ *
125
+ * The index in the method name indicates the unique occurrence of a terminal consumption
126
+ * inside a the top level rule. What this means is that if a terminal appears
127
+ * more than once in a single rule, each appearance must have a **different** index.
128
+ *
129
+ * For example:
130
+ * ```
131
+ * this.RULE("qualifiedName", () => {
132
+ * this.CONSUME1(Identifier);
133
+ * this.MANY(() => {
134
+ * this.CONSUME1(Dot);
135
+ * // here we use CONSUME2 because the terminal
136
+ * // 'Identifier' has already appeared previously in the
137
+ * // the rule 'parseQualifiedName'
138
+ * this.CONSUME2(Identifier);
139
+ * });
140
+ * })
141
+ * ```
142
+ *
143
+ * - See more details on the [unique suffixes requirement](http://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES).
144
+ *
145
+ * @param tokType - The Type of the token to be consumed.
146
+ * @param options - optional properties to modify the behavior of CONSUME.
147
+ */
148
+ protected CONSUME(tokType: TokenType, options?: ConsumeMethodOpts): IToken;
149
+ /**
150
+ * @see CONSUME
151
+ * @hidden
152
+ */
153
+ protected CONSUME1(tokType: TokenType, options?: ConsumeMethodOpts): IToken;
154
+ /**
155
+ * @see CONSUME
156
+ * @hidden
157
+ */
158
+ protected CONSUME2(tokType: TokenType, options?: ConsumeMethodOpts): IToken;
159
+ /**
160
+ * @see CONSUME
161
+ * @hidden
162
+ */
163
+ protected CONSUME3(tokType: TokenType, options?: ConsumeMethodOpts): IToken;
164
+ /**
165
+ * @see CONSUME
166
+ * @hidden
167
+ */
168
+ protected CONSUME4(tokType: TokenType, options?: ConsumeMethodOpts): IToken;
169
+ /**
170
+ * @see CONSUME
171
+ * @hidden
172
+ */
173
+ protected CONSUME5(tokType: TokenType, options?: ConsumeMethodOpts): IToken;
174
+ /**
175
+ * @see CONSUME
176
+ * @hidden
177
+ */
178
+ protected CONSUME6(tokType: TokenType, options?: ConsumeMethodOpts): IToken;
179
+ /**
180
+ * @see CONSUME
181
+ * @hidden
182
+ */
183
+ protected CONSUME7(tokType: TokenType, options?: ConsumeMethodOpts): IToken;
184
+ /**
185
+ * @see CONSUME
186
+ * @hidden
187
+ */
188
+ protected CONSUME8(tokType: TokenType, options?: ConsumeMethodOpts): IToken;
189
+ /**
190
+ * @see CONSUME
191
+ * @hidden
192
+ */
193
+ protected CONSUME9(tokType: TokenType, options?: ConsumeMethodOpts): IToken;
194
+ /**
195
+ * Parsing DSL Method that Indicates an Optional production.
196
+ * in EBNF notation this is equivalent to: "[...]".
197
+ *
198
+ * Note that there are two syntax forms:
199
+ * - Passing the grammar action directly:
200
+ * ```
201
+ * this.OPTION(() => {
202
+ * this.CONSUME(Digit)}
203
+ * );
204
+ * ```
205
+ *
206
+ * - using an "options" object:
207
+ * ```
208
+ * this.OPTION({
209
+ * GATE:predicateFunc,
210
+ * DEF: () => {
211
+ * this.CONSUME(Digit)
212
+ * }});
213
+ * ```
214
+ *
215
+ * The optional 'GATE' property in "options" object form can be used to add constraints
216
+ * to invoking the grammar action.
217
+ *
218
+ * As in CONSUME the index in the method name indicates the occurrence
219
+ * of the optional production in it's top rule.
220
+ *
221
+ * @param actionORMethodDef - The grammar action to optionally invoke once
222
+ * or an "OPTIONS" object describing the grammar action and optional properties.
223
+ *
224
+ * @returns The `GrammarAction` return value (OUT) if the optional syntax is encountered
225
+ * or `undefined` if not.
226
+ */
227
+ protected OPTION<OUT>(actionORMethodDef: GrammarAction<OUT> | DSLMethodOpts<OUT>): OUT | undefined;
228
+ /**
229
+ * @see OPTION
230
+ * @hidden
231
+ */
232
+ protected OPTION1<OUT>(actionORMethodDef: GrammarAction<OUT> | DSLMethodOpts<OUT>): OUT | undefined;
233
+ /**
234
+ * @see OPTION
235
+ * @hidden
236
+ */
237
+ protected OPTION2<OUT>(actionORMethodDef: GrammarAction<OUT> | DSLMethodOpts<OUT>): OUT | undefined;
238
+ /**
239
+ * @see OPTION
240
+ * @hidden
241
+ */
242
+ protected OPTION3<OUT>(actionORMethodDef: GrammarAction<OUT> | DSLMethodOpts<OUT>): OUT | undefined;
243
+ /**
244
+ * @see OPTION
245
+ * @hidden
246
+ */
247
+ protected OPTION4<OUT>(actionORMethodDef: GrammarAction<OUT> | DSLMethodOpts<OUT>): OUT | undefined;
248
+ /**
249
+ * @see OPTION
250
+ * @hidden
251
+ */
252
+ protected OPTION5<OUT>(actionORMethodDef: GrammarAction<OUT> | DSLMethodOpts<OUT>): OUT | undefined;
253
+ /**
254
+ * @see OPTION
255
+ * @hidden
256
+ */
257
+ protected OPTION6<OUT>(actionORMethodDef: GrammarAction<OUT> | DSLMethodOpts<OUT>): OUT | undefined;
258
+ /**
259
+ * @see OPTION
260
+ * @hidden
261
+ */
262
+ protected OPTION7<OUT>(actionORMethodDef: GrammarAction<OUT> | DSLMethodOpts<OUT>): OUT | undefined;
263
+ /**
264
+ * @see OPTION
265
+ * @hidden
266
+ */
267
+ protected OPTION8<OUT>(actionORMethodDef: GrammarAction<OUT> | DSLMethodOpts<OUT>): OUT | undefined;
268
+ /**
269
+ * @see OPTION
270
+ * @hidden
271
+ */
272
+ protected OPTION9<OUT>(actionORMethodDef: GrammarAction<OUT> | DSLMethodOpts<OUT>): OUT | undefined;
273
+ /**
274
+ * Parsing DSL method that indicates a choice between a set of alternatives must be made.
275
+ * This is equivalent to an EBNF alternation (A | B | C | D ...), except
276
+ * that the alternatives are ordered like in a PEG grammar.
277
+ * This means that the **first** matching alternative is always chosen.
278
+ *
279
+ * There are several forms for the inner alternatives array:
280
+ *
281
+ * - Passing alternatives array directly:
282
+ * ```
283
+ * this.OR([
284
+ * { ALT:() => { this.CONSUME(One) }},
285
+ * { ALT:() => { this.CONSUME(Two) }},
286
+ * { ALT:() => { this.CONSUME(Three) }}
287
+ * ])
288
+ * ```
289
+ *
290
+ * - Passing alternative array directly with predicates (GATE):
291
+ * ```
292
+ * this.OR([
293
+ * { GATE: predicateFunc1, ALT:() => { this.CONSUME(One) }},
294
+ * { GATE: predicateFuncX, ALT:() => { this.CONSUME(Two) }},
295
+ * { GATE: predicateFuncX, ALT:() => { this.CONSUME(Three) }}
296
+ * ])
297
+ * ```
298
+ *
299
+ * - These syntax forms can also be mixed:
300
+ * ```
301
+ * this.OR([
302
+ * {
303
+ * GATE: predicateFunc1,
304
+ * ALT:() => { this.CONSUME(One) }
305
+ * },
306
+ * { ALT:() => { this.CONSUME(Two) }},
307
+ * { ALT:() => { this.CONSUME(Three) }}
308
+ * ])
309
+ * ```
310
+ *
311
+ * - Additionally an "options" object may be used:
312
+ * ```
313
+ * this.OR({
314
+ * DEF:[
315
+ * { ALT:() => { this.CONSUME(One) }},
316
+ * { ALT:() => { this.CONSUME(Two) }},
317
+ * { ALT:() => { this.CONSUME(Three) }}
318
+ * ],
319
+ * // OPTIONAL property
320
+ * ERR_MSG: "A Number"
321
+ * })
322
+ * ```
323
+ *
324
+ * The 'predicateFuncX' in the long form can be used to add constraints to choosing the alternative.
325
+ *
326
+ * As in CONSUME the index in the method name indicates the occurrence
327
+ * of the alternation production in it's top rule.
328
+ *
329
+ * @param altsOrOpts - A set of alternatives or an "OPTIONS" object describing the alternatives and optional properties.
330
+ *
331
+ * @returns The result of invoking the chosen alternative.
332
+ */
333
+ protected OR<T>(altsOrOpts: IOrAlt<T>[] | OrMethodOpts<T>): T;
334
+ protected OR(altsOrOpts: IOrAlt<any>[] | OrMethodOpts<any>): any;
335
+ /**
336
+ * @see OR
337
+ * @hidden
338
+ */
339
+ protected OR1<T>(altsOrOpts: IOrAlt<T>[] | OrMethodOpts<T>): T;
340
+ protected OR1(altsOrOpts: IOrAlt<any>[] | OrMethodOpts<any>): any;
341
+ /**
342
+ * @see OR
343
+ * @hidden
344
+ */
345
+ protected OR2<T>(altsOrOpts: IOrAlt<T>[] | OrMethodOpts<T>): T;
346
+ protected OR2(altsOrOpts: IOrAlt<any>[] | OrMethodOpts<any>): any;
347
+ /**
348
+ * @see OR
349
+ * @hidden
350
+ */
351
+ protected OR3<T>(altsOrOpts: IOrAlt<T>[] | OrMethodOpts<T>): T;
352
+ protected OR3(altsOrOpts: IOrAlt<any>[] | OrMethodOpts<any>): any;
353
+ /**
354
+ * @see OR
355
+ * @hidden
356
+ */
357
+ protected OR4<T>(altsOrOpts: IOrAlt<T>[] | OrMethodOpts<T>): T;
358
+ protected OR4(altsOrOpts: IOrAlt<any>[] | OrMethodOpts<any>): any;
359
+ /**
360
+ * @see OR
361
+ * @hidden
362
+ */
363
+ protected OR5<T>(altsOrOpts: IOrAlt<T>[] | OrMethodOpts<T>): T;
364
+ protected OR5(altsOrOpts: IOrAlt<any>[] | OrMethodOpts<any>): any;
365
+ /**
366
+ * @see OR
367
+ * @hidden
368
+ */
369
+ protected OR6<T>(altsOrOpts: IOrAlt<T>[] | OrMethodOpts<T>): T;
370
+ protected OR6(altsOrOpts: IOrAlt<any>[] | OrMethodOpts<any>): any;
371
+ /**
372
+ * @see OR
373
+ * @hidden
374
+ */
375
+ protected OR7<T>(altsOrOpts: IOrAlt<T>[] | OrMethodOpts<T>): T;
376
+ protected OR7(altsOrOpts: IOrAlt<any>[] | OrMethodOpts<any>): any;
377
+ /**
378
+ * @see OR
379
+ * @hidden
380
+ */
381
+ protected OR8<T>(altsOrOpts: IOrAlt<T>[] | OrMethodOpts<T>): T;
382
+ protected OR8(altsOrOpts: IOrAlt<any>[] | OrMethodOpts<any>): any;
383
+ /**
384
+ * @see OR
385
+ * @hidden
386
+ */
387
+ protected OR9<T>(altsOrOpts: IOrAlt<T>[] | OrMethodOpts<T>): T;
388
+ protected OR9(altsOrOpts: IOrAlt<any>[] | OrMethodOpts<any>): any;
389
+ /**
390
+ * Parsing DSL method, that indicates a repetition of zero or more.
391
+ * This is equivalent to EBNF repetition \{...\}.
392
+ *
393
+ * Note that there are two syntax forms:
394
+ * - Passing the grammar action directly:
395
+ * ```
396
+ * this.MANY(() => {
397
+ * this.CONSUME(Comma)
398
+ * this.CONSUME(Digit)
399
+ * })
400
+ * ```
401
+ *
402
+ * - using an "options" object:
403
+ * ```
404
+ * this.MANY({
405
+ * GATE: predicateFunc,
406
+ * DEF: () => {
407
+ * this.CONSUME(Comma)
408
+ * this.CONSUME(Digit)
409
+ * }
410
+ * });
411
+ * ```
412
+ *
413
+ * The optional 'GATE' property in "options" object form can be used to add constraints
414
+ * to invoking the grammar action.
415
+ *
416
+ * As in CONSUME the index in the method name indicates the occurrence
417
+ * of the repetition production in it's top rule.
418
+ *
419
+ * @param actionORMethodDef - The grammar action to optionally invoke multiple times
420
+ * or an "OPTIONS" object describing the grammar action and optional properties.
421
+ *
422
+ */
423
+ protected MANY(actionORMethodDef: GrammarAction<any> | DSLMethodOpts<any>): void;
424
+ /**
425
+ * @see MANY
426
+ * @hidden
427
+ */
428
+ protected MANY1(actionORMethodDef: GrammarAction<any> | DSLMethodOpts<any>): void;
429
+ /**
430
+ * @see MANY
431
+ * @hidden
432
+ */
433
+ protected MANY2(actionORMethodDef: GrammarAction<any> | DSLMethodOpts<any>): void;
434
+ /**
435
+ * @see MANY
436
+ * @hidden
437
+ */
438
+ protected MANY3(actionORMethodDef: GrammarAction<any> | DSLMethodOpts<any>): void;
439
+ /**
440
+ * @see MANY
441
+ * @hidden
442
+ */
443
+ protected MANY4(actionORMethodDef: GrammarAction<any> | DSLMethodOpts<any>): void;
444
+ /**
445
+ * @see MANY
446
+ * @hidden
447
+ */
448
+ protected MANY5(actionORMethodDef: GrammarAction<any> | DSLMethodOpts<any>): void;
449
+ /**
450
+ * @see MANY
451
+ * @hidden
452
+ */
453
+ protected MANY6(actionORMethodDef: GrammarAction<any> | DSLMethodOpts<any>): void;
454
+ /**
455
+ * @see MANY
456
+ * @hidden
457
+ */
458
+ protected MANY7(actionORMethodDef: GrammarAction<any> | DSLMethodOpts<any>): void;
459
+ /**
460
+ * @see MANY
461
+ * @hidden
462
+ */
463
+ protected MANY8(actionORMethodDef: GrammarAction<any> | DSLMethodOpts<any>): void;
464
+ /**
465
+ * @see MANY
466
+ * @hidden
467
+ */
468
+ protected MANY9(actionORMethodDef: GrammarAction<any> | DSLMethodOpts<any>): void;
469
+ /**
470
+ * Parsing DSL method, that indicates a repetition of zero or more with a separator
471
+ * Token between the repetitions.
472
+ *
473
+ * Example:
474
+ *
475
+ * ```
476
+ * this.MANY_SEP({
477
+ * SEP:Comma,
478
+ * DEF: () => {
479
+ * this.CONSUME(Number};
480
+ * // ...
481
+ * })
482
+ * ```
483
+ *
484
+ * Note that because this DSL method always requires more than one argument the options object is always required
485
+ * and it is not possible to use a shorter form like in the MANY DSL method.
486
+ *
487
+ * Note that for the purposes of deciding on whether or not another iteration exists
488
+ * Only a single Token is examined (The separator). Therefore if the grammar being implemented is
489
+ * so "crazy" to require multiple tokens to identify an item separator please use the more basic DSL methods
490
+ * to implement it.
491
+ *
492
+ * As in CONSUME the index in the method name indicates the occurrence
493
+ * of the repetition production in it's top rule.
494
+ *
495
+ * @param options - An object defining the grammar of each iteration and the separator between iterations
496
+ *
497
+ */
498
+ protected MANY_SEP(options: ManySepMethodOpts<any>): void;
499
+ /**
500
+ * @see MANY_SEP
501
+ * @hidden
502
+ */
503
+ protected MANY_SEP1(options: ManySepMethodOpts<any>): void;
504
+ /**
505
+ * @see MANY_SEP
506
+ * @hidden
507
+ */
508
+ protected MANY_SEP2(options: ManySepMethodOpts<any>): void;
509
+ /**
510
+ * @see MANY_SEP
511
+ * @hidden
512
+ */
513
+ protected MANY_SEP3(options: ManySepMethodOpts<any>): void;
514
+ /**
515
+ * @see MANY_SEP
516
+ * @hidden
517
+ */
518
+ protected MANY_SEP4(options: ManySepMethodOpts<any>): void;
519
+ /**
520
+ * @see MANY_SEP
521
+ * @hidden
522
+ */
523
+ protected MANY_SEP5(options: ManySepMethodOpts<any>): void;
524
+ /**
525
+ * @see MANY_SEP
526
+ * @hidden
527
+ */
528
+ protected MANY_SEP6(options: ManySepMethodOpts<any>): void;
529
+ /**
530
+ * @see MANY_SEP
531
+ * @hidden
532
+ */
533
+ protected MANY_SEP7(options: ManySepMethodOpts<any>): void;
534
+ /**
535
+ * @see MANY_SEP
536
+ * @hidden
537
+ */
538
+ protected MANY_SEP8(options: ManySepMethodOpts<any>): void;
539
+ /**
540
+ * @see MANY_SEP
541
+ * @hidden
542
+ */
543
+ protected MANY_SEP9(options: ManySepMethodOpts<any>): void;
544
+ /**
545
+ * Convenience method, same as MANY but the repetition is of one or more.
546
+ * failing to match at least one repetition will result in a parsing error and
547
+ * cause a parsing error.
548
+ *
549
+ * @see MANY
550
+ *
551
+ * @param actionORMethodDef - The grammar action to optionally invoke multiple times
552
+ * or an "OPTIONS" object describing the grammar action and optional properties.
553
+ *
554
+ */
555
+ protected AT_LEAST_ONE(actionORMethodDef: GrammarAction<any> | DSLMethodOptsWithErr<any>): void;
556
+ /**
557
+ * @see AT_LEAST_ONE
558
+ * @hidden
559
+ */
560
+ protected AT_LEAST_ONE1(actionORMethodDef: GrammarAction<any> | DSLMethodOptsWithErr<any>): void;
561
+ /**
562
+ * @see AT_LEAST_ONE
563
+ * @hidden
564
+ */
565
+ protected AT_LEAST_ONE2(actionORMethodDef: GrammarAction<any> | DSLMethodOptsWithErr<any>): void;
566
+ /**
567
+ * @see AT_LEAST_ONE
568
+ * @hidden
569
+ */
570
+ protected AT_LEAST_ONE3(actionORMethodDef: GrammarAction<any> | DSLMethodOptsWithErr<any>): void;
571
+ /**
572
+ * @see AT_LEAST_ONE
573
+ * @hidden
574
+ */
575
+ protected AT_LEAST_ONE4(actionORMethodDef: GrammarAction<any> | DSLMethodOptsWithErr<any>): void;
576
+ /**
577
+ * @see AT_LEAST_ONE
578
+ * @hidden
579
+ */
580
+ protected AT_LEAST_ONE5(actionORMethodDef: GrammarAction<any> | DSLMethodOptsWithErr<any>): void;
581
+ /**
582
+ * @see AT_LEAST_ONE
583
+ * @hidden
584
+ */
585
+ protected AT_LEAST_ONE6(actionORMethodDef: GrammarAction<any> | DSLMethodOptsWithErr<any>): void;
586
+ /**
587
+ * @see AT_LEAST_ONE
588
+ * @hidden
589
+ */
590
+ protected AT_LEAST_ONE7(actionORMethodDef: GrammarAction<any> | DSLMethodOptsWithErr<any>): void;
591
+ /**
592
+ * @see AT_LEAST_ONE
593
+ * @hidden
594
+ */
595
+ protected AT_LEAST_ONE8(actionORMethodDef: GrammarAction<any> | DSLMethodOptsWithErr<any>): void;
596
+ /**
597
+ * @see AT_LEAST_ONE
598
+ * @hidden
599
+ */
600
+ protected AT_LEAST_ONE9(actionORMethodDef: GrammarAction<any> | DSLMethodOptsWithErr<any>): void;
601
+ /**
602
+ * Convenience method, same as MANY_SEP but the repetition is of one or more.
603
+ * failing to match at least one repetition will result in a parsing error and
604
+ * cause the parser to attempt error recovery.
605
+ *
606
+ * Note that an additional optional property ERR_MSG can be used to provide custom error messages.
607
+ *
608
+ * @see MANY_SEP
609
+ *
610
+ * @param options - An object defining the grammar of each iteration and the separator between iterations
611
+ *
612
+ * @return {ISeparatedIterationResult<OUT>}
613
+ */
614
+ protected AT_LEAST_ONE_SEP(options: AtLeastOneSepMethodOpts<any>): void;
615
+ /**
616
+ * @see AT_LEAST_ONE_SEP
617
+ * @hidden
618
+ */
619
+ protected AT_LEAST_ONE_SEP1(options: AtLeastOneSepMethodOpts<any>): void;
620
+ /**
621
+ * @see AT_LEAST_ONE_SEP
622
+ * @hidden
623
+ */
624
+ protected AT_LEAST_ONE_SEP2(options: AtLeastOneSepMethodOpts<any>): void;
625
+ /**
626
+ * @see AT_LEAST_ONE_SEP
627
+ * @hidden
628
+ */
629
+ protected AT_LEAST_ONE_SEP3(options: AtLeastOneSepMethodOpts<any>): void;
630
+ /**
631
+ * @see AT_LEAST_ONE_SEP
632
+ * @hidden
633
+ */
634
+ protected AT_LEAST_ONE_SEP4(options: AtLeastOneSepMethodOpts<any>): void;
635
+ /**
636
+ * @see AT_LEAST_ONE_SEP
637
+ * @hidden
638
+ */
639
+ protected AT_LEAST_ONE_SEP5(options: AtLeastOneSepMethodOpts<any>): void;
640
+ /**
641
+ * @see AT_LEAST_ONE_SEP
642
+ * @hidden
643
+ */
644
+ protected AT_LEAST_ONE_SEP6(options: AtLeastOneSepMethodOpts<any>): void;
645
+ /**
646
+ * @see AT_LEAST_ONE_SEP
647
+ * @hidden
648
+ */
649
+ protected AT_LEAST_ONE_SEP7(options: AtLeastOneSepMethodOpts<any>): void;
650
+ /**
651
+ * @see AT_LEAST_ONE_SEP
652
+ * @hidden
653
+ */
654
+ protected AT_LEAST_ONE_SEP8(options: AtLeastOneSepMethodOpts<any>): void;
655
+ /**
656
+ * @see AT_LEAST_ONE_SEP
657
+ * @hidden
658
+ */
659
+ protected AT_LEAST_ONE_SEP9(options: AtLeastOneSepMethodOpts<any>): void;
660
+ /**
661
+ * Returns an "imaginary" Token to insert when Single Token Insertion is done
662
+ * Override this if you require special behavior in your grammar.
663
+ * For example if an IntegerToken is required provide one with the image '0' so it would be valid syntactically.
664
+ */
665
+ protected getTokenToInsert(tokType: TokenType): IToken;
666
+ /**
667
+ * By default, all tokens type may be inserted. This behavior may be overridden in inheriting Recognizers
668
+ * for example: One may decide that only punctuation tokens may be inserted automatically as they have no additional
669
+ * semantic value. (A mandatory semicolon has no additional semantic meaning, but an Integer may have additional meaning
670
+ * depending on its int value and context (Inserting an integer 0 in cardinality: "[1..]" will cause semantic issues
671
+ * as the max of the cardinality will be greater than the min value (and this is a false error!).
672
+ */
673
+ protected canTokenTypeBeInsertedInRecovery(tokType: TokenType): boolean;
674
+ /**
675
+ * By default, all token types may be deleted. This behavior may be overridden in inheriting parsers.
676
+ * The method receives the expected token type. The token that would be deleted can be received with {@link LA}.
677
+ */
678
+ protected canTokenTypeBeDeletedInRecovery(tokType: TokenType): boolean;
679
+ /**
680
+ * @deprecated - will be removed in the future
681
+ */
682
+ protected getNextPossibleTokenTypes(grammarPath: ITokenGrammarPath): TokenType[];
683
+ set input(value: IToken[]);
684
+ get input(): IToken[];
685
+ /**
686
+ * Will consume a single token and return the **next** token, meaning
687
+ * the token **after** the skipped token.
688
+ */
689
+ protected SKIP_TOKEN(): IToken;
690
+ /**
691
+ * Look-Ahead for the Token Vector
692
+ * LA(1) is the next Token ahead.
693
+ * LA(n) is the nth Token ahead.
694
+ * LA(0) is the previously consumed Token.
695
+ *
696
+ * Looking beyond the end of the Token Vector or before its beginning
697
+ * will return in an IToken of type EOF {@link EOF}.
698
+ * This behavior can be used to avoid infinite loops.
699
+ *
700
+ * This is often used to implement custom lookahead logic for GATES.
701
+ * https://chevrotain.io/docs/features/gates.html
702
+ */
703
+ protected LA(howMuch: number): IToken;
704
+ /**
705
+ * Variant of LA with limited bounds checking.
706
+ * Not safe for LA(0) at start of input
707
+ * Nor for LA(J) when: J >= (tokenVector + maxLookahead)
708
+ *
709
+ * See: {@link BaseParser.LA}
710
+ */
711
+ protected LA_FAST(howMuch: number): IToken;
712
+ }
713
+ /**
714
+ * A Parser that outputs a Concrete Syntax Tree.
715
+ * See:
716
+ * - https://chevrotain.io/docs/tutorial/step3_adding_actions_root.html#alternatives
717
+ * - https://chevrotain.io/docs/guide/concrete_syntax_tree.html
718
+ * For in depth docs.
719
+ */
720
+ export declare class CstParser extends BaseParser {
721
+ /**
722
+ * Creates a Grammar Rule
723
+ *
724
+ * Note that any parameters of your implementation must be optional as it will
725
+ * be called without parameters during the grammar recording phase.
726
+ */
727
+ protected RULE<F extends () => void>(name: string, implementation: F, config?: IRuleConfig<CstNode>): ParserMethod<Parameters<F>, CstNode>;
728
+ /**
729
+ * Overrides a Grammar Rule
730
+ * See usage example in: https://github.com/chevrotain/chevrotain/blob/master/examples/parser/versioning/versioning.js
731
+ */
732
+ protected OVERRIDE_RULE<F extends () => void>(name: string, implementation: F, config?: IRuleConfig<CstNode>): ParserMethod<Parameters<F>, CstNode>;
733
+ /**
734
+ * Like `SUBRULE` with the numerical suffix as a parameter, e.g:
735
+ * subrule(0, X) === SUBRULE(X)
736
+ * subrule(1, X) === SUBRULE1(X)
737
+ * subrule(2, X) === SUBRULE2(X)
738
+ * ...
739
+ * @see SUBRULE
740
+ */
741
+ protected subrule<ARGS extends unknown[]>(idx: number, ruleToCall: ParserMethod<ARGS, CstNode>, options?: SubruleMethodOpts<ARGS>): CstNode;
742
+ /**
743
+ * The Parsing DSL Method is used by one rule to call another.
744
+ * It is equivalent to a non-Terminal in EBNF notation.
745
+ *
746
+ * This may seem redundant as it does not actually do much.
747
+ * However using it is **mandatory** for all sub rule invocations.
748
+ *
749
+ * Calling another rule without wrapping in SUBRULE(...)
750
+ * will cause errors/mistakes in the Parser's self analysis phase,
751
+ * which will lead to errors in error recovery/automatic lookahead calculation
752
+ * and any other functionality relying on the Parser's self analysis
753
+ * output.
754
+ *
755
+ * As in CONSUME the index in the method name indicates the occurrence
756
+ * of the sub rule invocation in its rule.
757
+ *
758
+ */
759
+ protected SUBRULE<ARGS extends unknown[]>(ruleToCall: ParserMethod<ARGS, CstNode>, options?: SubruleMethodOpts<ARGS>): CstNode;
760
+ /**
761
+ * @see SUBRULE
762
+ * @hidden
763
+ */
764
+ protected SUBRULE1<ARGS extends unknown[]>(ruleToCall: ParserMethod<ARGS, CstNode>, options?: SubruleMethodOpts<ARGS>): CstNode;
765
+ /**
766
+ * @see SUBRULE
767
+ * @hidden
768
+ */
769
+ protected SUBRULE2<ARGS extends unknown[]>(ruleToCall: ParserMethod<ARGS, CstNode>, options?: SubruleMethodOpts<ARGS>): CstNode;
770
+ /**
771
+ * @see SUBRULE
772
+ * @hidden
773
+ */
774
+ protected SUBRULE3<ARGS extends unknown[]>(ruleToCall: ParserMethod<ARGS, CstNode>, options?: SubruleMethodOpts<ARGS>): CstNode;
775
+ /**
776
+ * @see SUBRULE
777
+ * @hidden
778
+ */
779
+ protected SUBRULE4<ARGS extends unknown[]>(ruleToCall: ParserMethod<ARGS, CstNode>, options?: SubruleMethodOpts<ARGS>): CstNode;
780
+ /**
781
+ * @see SUBRULE
782
+ * @hidden
783
+ */
784
+ protected SUBRULE5<ARGS extends unknown[]>(ruleToCall: ParserMethod<ARGS, CstNode>, options?: SubruleMethodOpts<ARGS>): CstNode;
785
+ /**
786
+ * @see SUBRULE
787
+ * @hidden
788
+ */
789
+ protected SUBRULE6<ARGS extends unknown[]>(ruleToCall: ParserMethod<ARGS, CstNode>, options?: SubruleMethodOpts<ARGS>): CstNode;
790
+ /**
791
+ * @see SUBRULE
792
+ * @hidden
793
+ */
794
+ protected SUBRULE7<ARGS extends unknown[]>(ruleToCall: ParserMethod<ARGS, CstNode>, options?: SubruleMethodOpts<ARGS>): CstNode;
795
+ /**
796
+ * @see SUBRULE
797
+ * @hidden
798
+ */
799
+ protected SUBRULE8<ARGS extends unknown[]>(ruleToCall: ParserMethod<ARGS, CstNode>, options?: SubruleMethodOpts<ARGS>): CstNode;
800
+ /**
801
+ * @see SUBRULE
802
+ * @hidden
803
+ */
804
+ protected SUBRULE9<ARGS extends unknown[]>(ruleToCall: ParserMethod<ARGS, CstNode>, options?: SubruleMethodOpts<ARGS>): CstNode;
805
+ }
806
+ /**
807
+ * A Parser that relies on end user's embedded actions to control its output.
808
+ * For more details see:
809
+ * - https://chevrotain.io/docs/tutorial/step3_adding_actions_root.html#alternatives
810
+ * - https://chevrotain.io/docs/tutorial/step3b_adding_actions_embedded.html#simple-example
811
+ */
812
+ export declare class EmbeddedActionsParser extends BaseParser {
813
+ /**
814
+ * Creates a Grammar Rule
815
+ *
816
+ * Note that any parameters of your implementation must be optional as it will
817
+ * be called without parameters during the grammar recording phase.
818
+ */
819
+ protected RULE<F extends (...args: any[]) => any>(name: string, implementation: F, config?: IRuleConfig<ReturnType<F>>): ParserMethod<Parameters<F>, ReturnType<F>>;
820
+ /**
821
+ * Overrides a Grammar Rule
822
+ * See usage example in: https://github.com/chevrotain/chevrotain/blob/master/examples/parser/versioning/versioning.js
823
+ */
824
+ protected OVERRIDE_RULE<F extends (...args: any[]) => any>(name: string, implementation: F, config?: IRuleConfig<ReturnType<F>>): ParserMethod<Parameters<F>, ReturnType<F>>;
825
+ /**
826
+ * Like `SUBRULE` with the numerical suffix as a parameter, e.g:
827
+ * subrule(0, X) === SUBRULE(X)
828
+ * subrule(1, X) === SUBRULE1(X)
829
+ * subrule(2, X) === SUBRULE2(X)
830
+ * ...
831
+ * @see SUBRULE
832
+ */
833
+ protected subrule<ARGS extends unknown[], R>(idx: number, ruleToCall: ParserMethod<ARGS, R>, options?: SubruleMethodOpts<ARGS>): R;
834
+ /**
835
+ * The Parsing DSL Method is used by one rule to call another.
836
+ * It is equivalent to a non-Terminal in EBNF notation.
837
+ *
838
+ * This may seem redundant as it does not actually do much.
839
+ * However using it is **mandatory** for all sub rule invocations.
840
+ *
841
+ * Calling another rule without wrapping in SUBRULE(...)
842
+ * will cause errors/mistakes in the Parser's self analysis phase,
843
+ * which will lead to errors in error recovery/automatic lookahead calculation
844
+ * and any other functionality relying on the Parser's self analysis
845
+ * output.
846
+ *
847
+ * As in CONSUME the index in the method name indicates the occurrence
848
+ * of the sub rule invocation in its rule.
849
+ *
850
+ */
851
+ protected SUBRULE<ARGS extends unknown[], R>(ruleToCall: ParserMethod<ARGS, R>, options?: SubruleMethodOpts<ARGS>): R;
852
+ /**
853
+ * @see SUBRULE
854
+ * @hidden
855
+ */
856
+ protected SUBRULE1<ARGS extends unknown[], R>(ruleToCall: ParserMethod<ARGS, R>, options?: SubruleMethodOpts<ARGS>): R;
857
+ /**
858
+ * @see SUBRULE
859
+ * @hidden
860
+ */
861
+ protected SUBRULE2<ARGS extends unknown[], R>(ruleToCall: ParserMethod<ARGS, R>, options?: SubruleMethodOpts<ARGS>): R;
862
+ /**
863
+ * @see SUBRULE
864
+ * @hidden
865
+ */
866
+ protected SUBRULE3<ARGS extends unknown[], R>(ruleToCall: ParserMethod<ARGS, R>, options?: SubruleMethodOpts<ARGS>): R;
867
+ /**
868
+ * @see SUBRULE
869
+ * @hidden
870
+ */
871
+ protected SUBRULE4<ARGS extends unknown[], R>(ruleToCall: ParserMethod<ARGS, R>, options?: SubruleMethodOpts<ARGS>): R;
872
+ /**
873
+ * @see SUBRULE
874
+ * @hidden
875
+ */
876
+ protected SUBRULE5<ARGS extends unknown[], R>(ruleToCall: ParserMethod<ARGS, R>, options?: SubruleMethodOpts<ARGS>): R;
877
+ /**
878
+ * @see SUBRULE
879
+ * @hidden
880
+ */
881
+ protected SUBRULE6<ARGS extends unknown[], R>(ruleToCall: ParserMethod<ARGS, R>, options?: SubruleMethodOpts<ARGS>): R;
882
+ /**
883
+ * @see SUBRULE
884
+ * @hidden
885
+ */
886
+ protected SUBRULE7<ARGS extends unknown[], R>(ruleToCall: ParserMethod<ARGS, R>, options?: SubruleMethodOpts<ARGS>): R;
887
+ /**
888
+ * @see SUBRULE
889
+ * @hidden
890
+ */
891
+ protected SUBRULE8<ARGS extends unknown[], R>(ruleToCall: ParserMethod<ARGS, R>, options?: SubruleMethodOpts<ARGS>): R;
892
+ /**
893
+ * @see SUBRULE
894
+ * @hidden
895
+ */
896
+ protected SUBRULE9<ARGS extends unknown[], R>(ruleToCall: ParserMethod<ARGS, R>, options?: SubruleMethodOpts<ARGS>): R;
897
+ }
898
+ export interface ILexerDefinitionError {
899
+ message: string;
900
+ type: LexerDefinitionErrorType;
901
+ tokenTypes?: TokenType[];
902
+ }
903
+ export declare class Lexer {
904
+ static SKIPPED: string;
905
+ /**
906
+ * A Constant to mark "abstract" TokenTypes that are used
907
+ * purely as token categories.
908
+ * See: {@link ITokenConfig.categories}
909
+ */
910
+ static NA: RegExp;
911
+ lexerDefinitionErrors: ILexerDefinitionError[];
912
+ /**
913
+ * @param lexerDefinition -
914
+ * Structure composed of Tokens Types this lexer will identify.
915
+ *
916
+ * In the simple case the structure is an array of TokenTypes.
917
+ * In the case of {@link IMultiModeLexerDefinition} the structure is an object with two properties:
918
+ * 1. a "modes" property where each value is an array of TokenTypes.
919
+ * 2. a "defaultMode" property specifying the initial lexer mode.
920
+ *
921
+ * for example:
922
+ *
923
+ * ```
924
+ * {
925
+ * modes : {
926
+ * modeX : [Token1, Token2],
927
+ * modeY : [Token3, Token4]
928
+ * },
929
+ *
930
+ * defaultMode : "modeY"
931
+ * }
932
+ * ```
933
+ *
934
+ * A lexer with {@link MultiModesDefinition} is simply multiple Lexers where only one Lexer(mode) can be active at the same time.
935
+ * This is useful for lexing languages where there are different lexing rules depending on context.
936
+ *
937
+ * The current lexing mode is selected via a "mode stack".
938
+ * The last (peek) value in the stack will be the current mode of the lexer.
939
+ * Defining entering and exiting lexer modes is done using the "push_mode" and "pop_mode" properties
940
+ * of the {@link ITokenConfig} config properties.
941
+ *
942
+ * - The Lexer will match the **first** pattern that matches, Therefor the order of Token Types is significant.
943
+ * For example when one pattern may match a prefix of another pattern.
944
+ *
945
+ * Note that there are situations in which we may wish to order the longer pattern after the shorter one.
946
+ * For example: [keywords vs Identifiers](https://github.com/chevrotain/chevrotain/tree/master/examples/lexer/keywords_vs_identifiers).
947
+ */
948
+ constructor(lexerDefinition: TokenType[] | IMultiModeLexerDefinition, config?: ILexerConfig);
949
+ /**
950
+ * Will lex(Tokenize) a string.
951
+ * Note that this can be called repeatedly on different strings as this method
952
+ * does not modify the state of the Lexer.
953
+ *
954
+ * @param text - The string to lex
955
+ * @param [initialMode] - The initial Lexer Mode to start with, by default this will be the first mode in the lexer's
956
+ * definition. If the lexer has no explicit modes it will be the implicit single 'default_mode' mode.
957
+ */
958
+ tokenize(text: string, initialMode?: string): ILexingResult;
959
+ }
960
+ export interface ILexingResult {
961
+ tokens: IToken[];
962
+ groups: {
963
+ [groupName: string]: IToken[];
964
+ };
965
+ errors: ILexingError[];
966
+ }
967
+ export interface ILexingError {
968
+ offset: number;
969
+ line: number | undefined;
970
+ column: number | undefined;
971
+ length: number;
972
+ message: string;
973
+ }
974
+ export interface ILexerConfig {
975
+ /**
976
+ * An optional flag indicating that lexer definition errors
977
+ * should not automatically cause an error to be raised.
978
+ * This can be useful when wishing to indicate lexer errors in another manner
979
+ * than simply throwing an error (for example in an online playground).
980
+ */
981
+ deferDefinitionErrorsHandling?: boolean;
982
+ /**
983
+ * "full" location information means all six combinations of /(end|start)(Line|Column|Offset)/ properties.
984
+ * "onlyStart" means that only startLine, startColumn and startOffset will be tracked
985
+ * "onlyOffset" means that only the startOffset will be tracked.
986
+ *
987
+ * The less position tracking the faster the Lexer will be and the less memory used.
988
+ * However the difference is not large (~10% On V8), thus reduced location tracking options should only be used
989
+ * in edge cases where every last ounce of performance is needed.
990
+ */
991
+ // TODO: consider renaming this to LocationTracking to align with NodeLocationTracking option on the ParserConfig.
992
+ positionTracking?: "full" | "onlyStart" | "onlyOffset";
993
+ /**
994
+ * A regExp defining custom line terminators.
995
+ * This will be used to calculate the line and column information.
996
+ *
997
+ * Note that the regExp should use the global flag, for example: /\n/g
998
+ *
999
+ * The default is: /\n|\r\n?/g
1000
+ *
1001
+ * But some grammars have a different definition, for example in ECMAScript:
1002
+ * https://www.ecma-international.org/ecma-262/8.0/index.html#sec-line-terminators
1003
+ * U+2028 and U+2029 are also treated as line terminators.
1004
+ *
1005
+ * In that case we would use /\n|\r|\u2028|\u2029/g
1006
+ *
1007
+ * Note that it is also possible to supply an optimized RegExp like implementation
1008
+ * as only a subset of the RegExp APIs is needed, {@link ILineTerminatorsTester}
1009
+ * for details.
1010
+ *
1011
+ * keep in mind that for the default pattern: /\n|\r\n?/g an optimized implementation is already built-in.
1012
+ * This means the optimization is only relevant for lexers overriding the default pattern.
1013
+ */
1014
+ lineTerminatorsPattern?: RegExp | ILineTerminatorsTester;
1015
+ /**
1016
+ * Characters or CharCodes that represent line terminators for this lexer.
1017
+ * This always needs to be provided when using a custom {@link ILexerConfig.lineTerminatorsPattern}.
1018
+ * In the future this duplication may be removed or reduced.
1019
+ */
1020
+ lineTerminatorCharacters?: (number | string)[];
1021
+ /**
1022
+ * When true this flag will cause the Lexer to throw an Error
1023
+ * When it is unable to perform all of its performance optimizations.
1024
+ *
1025
+ * In addition error messages will be printed to the console with details
1026
+ * how to resolve the optimizations issues.
1027
+ *
1028
+ * Use this flag to guarantee higher lexer performance.
1029
+ * The optimizations can boost the lexer's performance anywhere from 30%
1030
+ * to 100%+ depending on the number of TokenTypes used.
1031
+ */
1032
+ ensureOptimizations?: boolean;
1033
+ /**
1034
+ * Can be used to disable lexer optimizations
1035
+ * If there is a suspicion they are causing incorrect behavior.
1036
+ * Note that this would have negative performance implications.
1037
+ */
1038
+ safeMode?: boolean;
1039
+ /**
1040
+ * A custom error message provider.
1041
+ * Can be used to override the default error messages.
1042
+ * For example:
1043
+ * - Translating the error messages to a different languages.
1044
+ * - Changing the formatting.
1045
+ */
1046
+ errorMessageProvider?: ILexerErrorMessageProvider;
1047
+ /**
1048
+ * Enabling this flag will print performance tracing logs during lexer
1049
+ * Initialization (constructor invocation), this is useful to narrow down the cause
1050
+ * of the initialization performance problem.
1051
+ *
1052
+ * You can also pass a numerical value which affects the verbosity
1053
+ * of the traces, this number is the maximum nesting level of the traces, e.g:
1054
+ * 0: Traces disabled === 'false'
1055
+ * 1: Top Level traces only.
1056
+ * 2: One level of nested inner traces.
1057
+ * ...
1058
+ *
1059
+ * Note that passing the boolean `true` is identical to passing the numerical value `infinity`
1060
+ */
1061
+ traceInitPerf?: boolean | number;
1062
+ /**
1063
+ * This flag will avoid running the Lexer validations during Lexer initialization.
1064
+ *
1065
+ * This can substantially improve the Lexer's initialization (constructor) time.
1066
+ * @see ILexerConfig.traceInitPerf to measure the Lexer validations cost for your Lexer.
1067
+ *
1068
+ * Note that the Lexer validations are **extremely useful** during development time,
1069
+ * e.g: Detecting empty/invalid regExp Patterns.
1070
+ * So they should not be skipped during development flows.
1071
+ * - For example: via a conditional that checks an env variable.
1072
+ */
1073
+ skipValidations?: boolean;
1074
+ /**
1075
+ * Should the lexer halt on the **first** error, or continue attempting to tokenize by dropping characters
1076
+ * until a match is found or the end of input is reached.
1077
+ *
1078
+ * Setting `recoveryEnabled` to `false` is useful when you want to **halt quickly** on faulty inputs,
1079
+ * particularly when dealing with **large** faulty inputs.
1080
+ *
1081
+ * By default, `recoveryEnabled` is `true`
1082
+ */
1083
+ recoveryEnabled?: boolean;
1084
+ }
1085
+ export interface ILexerErrorMessageProvider {
1086
+ /**
1087
+ * An Unexpected Character Error occurs when the lexer is unable to match a range of one or more
1088
+ * characters in the input text against any of the Token Types in it's Lexer definition
1089
+ *
1090
+ * @param fullText - Full original input text.
1091
+ *
1092
+ * @param startOffset - Offset in input text where error starts.
1093
+ *
1094
+ * @param length - Error length.
1095
+ *
1096
+ * @param line - Line number where the error occurred. (optional)
1097
+ * Will not be provided when lexer is not defined to track lines/columns
1098
+ *
1099
+ * @param column - Column number where the error occurred. (optional)
1100
+ * Will not be provided when lexer is not defined to track lines/columns
1101
+ *
1102
+ * @param mode - The current lexer mode.
1103
+ */
1104
+ buildUnexpectedCharactersMessage(fullText: string, startOffset: number, length: number, line?: number, column?: number, mode?: string): string;
1105
+ /**
1106
+ * Unable To Pop Lexer Mode Error happens when lexer tries to pop the last remaining mode from the mode stack
1107
+ * so that there is no longer any active lexer mode
1108
+ * This error only relevant for multi-mode lexers
1109
+ *
1110
+ * @param token - The Token that requested pop mode.
1111
+ */
1112
+ buildUnableToPopLexerModeMessage(token: IToken): string;
1113
+ }
1114
+ /**
1115
+ * This is the default logic Chevrotain uses to construct lexing error messages.
1116
+ * It can be used as a reference or as a starting point customize a lexer's
1117
+ * error messages.
1118
+ *
1119
+ * - See: {@link ILexerConfig.errorMessageProvider}
1120
+ */
1121
+ export declare const defaultLexerErrorProvider: ILexerErrorMessageProvider;
1122
+ /**
1123
+ * A subset of the regExp interface.
1124
+ * Needed to compute line/column info by a chevrotain lexer.
1125
+ */
1126
+ export interface ILineTerminatorsTester {
1127
+ /**
1128
+ * Just like regExp.test
1129
+ */
1130
+ test: (text: string) => boolean;
1131
+ /**
1132
+ * Just like the regExp lastIndex with the global flag enabled
1133
+ * It should be updated after every match to point to the offset where the next
1134
+ * match attempt starts.
1135
+ */
1136
+ lastIndex: number;
1137
+ }
1138
+ export type TokenPattern = RegExp | string | CustomPatternMatcherFunc | ICustomPattern;
1139
+ export interface ITokenConfig {
1140
+ name: string;
1141
+ /**
1142
+ * Categories enable polymorphism on Token Types.
1143
+ * A TokenType X with categories C1, C2, ... ,Cn can
1144
+ * be matched by the parser against any of those categories.
1145
+ * In practical terms this means that:
1146
+ * CONSUME(C1) can match a Token of type X.
1147
+ */
1148
+ categories?: TokenType | TokenType[];
1149
+ /**
1150
+ * The Label is a human readable name to be used
1151
+ * in error messages and syntax diagrams.
1152
+ *
1153
+ * For example a TokenType may be called LCurly, which is
1154
+ * short for "left curly brace". The much easier to understand
1155
+ * label could simply be "\{".
1156
+ */
1157
+ label?: string;
1158
+ /**
1159
+ * This defines what sequence of characters would be matched
1160
+ * To this TokenType when Lexing.
1161
+ *
1162
+ * For Custom Patterns see: http://chevrotain.io/docs/guide/custom_token_patterns.html
1163
+ */
1164
+ pattern?: TokenPattern;
1165
+ /**
1166
+ * The group property will cause the lexer to collect
1167
+ * Tokens of this type separately from the other Tokens.
1168
+ *
1169
+ * For example this could be used to collect comments for
1170
+ * post processing.
1171
+ *
1172
+ * See: https://github.com/chevrotain/chevrotain/tree/master/examples/lexer/token_groups
1173
+ */
1174
+ group?: string;
1175
+ /**
1176
+ * A name of a Lexer mode to "enter" once this Token Type has been matched.
1177
+ * Lexer modes can be used to support different sets of possible Tokens Types
1178
+ *
1179
+ * Lexer Modes work as a stack of Lexers, so "entering" a mode means pushing it to the top of the stack.
1180
+ *
1181
+ * See: https://github.com/chevrotain/chevrotain/tree/master/examples/lexer/multi_mode_lexer
1182
+ */
1183
+ push_mode?: string;
1184
+ /**
1185
+ * If "pop_mode" is true the Lexer will pop the last mode of the modes stack and
1186
+ * continue lexing using the new mode at the top of the stack.
1187
+ *
1188
+ * See: https://github.com/chevrotain/chevrotain/tree/master/examples/lexer/multi_mode_lexer
1189
+ */
1190
+ pop_mode?: boolean;
1191
+ /**
1192
+ * The "longer_alt" property will cause the Lexer to attempt matching against other Token Types
1193
+ * every time this Token Type has been matched.
1194
+ *
1195
+ * This feature can be useful when two or more Token Types have common prefixes which
1196
+ * cannot be resolved (only) by the ordering of the Tokens in the lexer definition.
1197
+ *
1198
+ * - Note that the `longer_alt` capability **cannot be chained**.
1199
+ * - Note that the **first** matched `longer_alt` takes precedence.
1200
+ *
1201
+ * For example see: https://github.com/chevrotain/chevrotain/tree/master/examples/lexer/keywords_vs_identifiers
1202
+ * For resolving the keywords vs Identifier ambiguity.
1203
+ */
1204
+ longer_alt?: TokenType | TokenType[];
1205
+ /**
1206
+ * Can a String matching this Token Type's pattern possibly contain a line terminator?
1207
+ * If true and the line_breaks property is not also true this will cause inaccuracies in the Lexer's line / column tracking.
1208
+ */
1209
+ line_breaks?: boolean;
1210
+ /**
1211
+ * Possible starting characters or charCodes of the pattern.
1212
+ * These will be used to optimize the Lexer's performance.
1213
+ *
1214
+ * These are normally **automatically** computed, however the option to explicitly
1215
+ * specify those can enable optimizations even when the automatic analysis fails.
1216
+ *
1217
+ * e.g:
1218
+ * * strings hints should be one character long.
1219
+ * ```
1220
+ * { start_chars_hint: ["a", "b"] }
1221
+ * ```
1222
+ *
1223
+ * * number hints are the result of running ".charCodeAt(0)" on the strings.
1224
+ * ```
1225
+ * { start_chars_hint: [97, 98] }
1226
+ * ```
1227
+ *
1228
+ * * For unicode characters outside the BMP use the first of their surrogate pairs.
1229
+ * for example: The '💩' character is represented by surrogate pairs: '\uD83D\uDCA9'
1230
+ * and D83D is 55357 in decimal.
1231
+ * * Note that "💩".charCodeAt(0) === 55357
1232
+ */
1233
+ start_chars_hint?: (string | number)[];
1234
+ }
1235
+ /**
1236
+ * Creates a new TokenType which can then be used
1237
+ * to define a Lexer and Parser
1238
+ */
1239
+ export declare function createToken(config: ITokenConfig): TokenType;
1240
+ /**
1241
+ * Utility to create Chevrotain IToken "instances"
1242
+ * Note that Chevrotain tokens are not real TokenTypes instances
1243
+ * and thus the instanceOf cannot be used with them.
1244
+ */
1245
+ export declare function createTokenInstance(tokType: TokenType, image: string, startOffset: number, endOffset: number, startLine: number, endLine: number, startColumn: number, endColumn: number): IToken;
1246
+ /**
1247
+ * API #1 [Custom Token Patterns](http://chevrotain.io/docs/guide/custom_token_patterns.html).
1248
+ */
1249
+ export declare type CustomPatternMatcherFunc = (
1250
+ /**
1251
+ * The full input string.
1252
+ */
1253
+ text: string,
1254
+ /**
1255
+ * The offset at which to attempt a match
1256
+ */
1257
+ offset: number,
1258
+ /**
1259
+ * Previously scanned Tokens
1260
+ */
1261
+ tokens: IToken[],
1262
+ /**
1263
+ * Token Groups
1264
+ */
1265
+ groups: {
1266
+ [groupName: string]: IToken[];
1267
+ }) => CustomPatternMatcherReturn | RegExpExecArray | null; // RegExpExecArray included for legacy reasons
1268
+ export type CustomPatternMatcherReturn = [
1269
+ string
1270
+ ] & {
1271
+ payload?: any;
1272
+ };
1273
+ export interface TokenType {
1274
+ name: string;
1275
+ GROUP?: string;
1276
+ PATTERN?: TokenPattern;
1277
+ LABEL?: string;
1278
+ LONGER_ALT?: TokenType | TokenType[];
1279
+ POP_MODE?: boolean;
1280
+ PUSH_MODE?: string;
1281
+ LINE_BREAKS?: boolean;
1282
+ CATEGORIES?: TokenType[];
1283
+ tokenTypeIdx?: number;
1284
+ categoryMatches?: number[];
1285
+ categoryMatchesMap?: {
1286
+ [tokType: number]: boolean;
1287
+ };
1288
+ isParent?: boolean;
1289
+ START_CHARS_HINT?: (string | number)[];
1290
+ }
1291
+ /**
1292
+ * API #2 for [Custom Token Patterns](http://chevrotain.io/docs/guide/custom_token_patterns.html).
1293
+ */
1294
+ export interface ICustomPattern {
1295
+ exec: CustomPatternMatcherFunc;
1296
+ }
1297
+ /**
1298
+ * Things to note:
1299
+ * - The offset range is inclusive to exclusive.
1300
+ *
1301
+ * - A lineTerminator as the last character does not effect the Token's line numbering.
1302
+ * In other words a new line only starts **after** a line terminator.
1303
+ *
1304
+ * - A Token's image is it's **literal** text.
1305
+ * e.g unicode escaping is untouched.
1306
+ */
1307
+ export interface IToken {
1308
+ /** The textual representation of the Token as it appeared in the text. */
1309
+ image: string;
1310
+ /** Offset of the first character of the Token. 0-indexed. */
1311
+ startOffset: number;
1312
+ /** Line of the first character of the Token. 1-indexed. */
1313
+ startLine?: number;
1314
+ /**
1315
+ * Column of the first character of the Token. 1-indexed.
1316
+ *
1317
+ * For token foo in the following line, startColumn will be 3 and endColumn will be 5.
1318
+ * ```
1319
+ * a foo
1320
+ * 123456
1321
+ * ```
1322
+ */
1323
+ startColumn?: number;
1324
+ /**
1325
+ * Offset of the last character of the Token. 0-indexed.
1326
+ * Note that this points at the last character, not the end of the token, so the original image would be
1327
+ * `input.substring(token.startOffset, token.endOffset + 1)`.
1328
+ */
1329
+ endOffset?: number;
1330
+ /** Line of the last character of the Token. 1-indexed. Will be the same as startLine for single-line tokens.*/
1331
+ endLine?: number;
1332
+ /** Column of the last character of the Token. 1-indexed. See also startColumn. */
1333
+ endColumn?: number;
1334
+ /** this marks if a Token does not really exist and has been inserted "artificially" during parsing in rule error recovery. */
1335
+ isInsertedInRecovery?: boolean;
1336
+ /** An number index representing the type of the Token use <getTokenConstructor> to get the Token Type from a token "instance" */
1337
+ tokenTypeIdx: number;
1338
+ /**
1339
+ * The actual Token Type of this Token "instance"
1340
+ * This is the same Object returned by the "createToken" API.
1341
+ * This property is very useful for debugging the Lexing and Parsing phases.
1342
+ */
1343
+ tokenType: TokenType;
1344
+ /**
1345
+ * Custom Payload value, this is an optional feature of Custom Token Patterns
1346
+ * For additional details see the docs:
1347
+ * https://chevrotain.io/docs/guide/custom_token_patterns.html#custom-payloads
1348
+ */
1349
+ payload?: any;
1350
+ }
1351
+ export declare function tokenName(tokType: TokenType): string;
1352
+ /**
1353
+ * Returns a human readable label for a TokenType if such exists,
1354
+ * otherwise will return the TokenType's name.
1355
+ *
1356
+ * Labels are useful in improving the readability of error messages and syntax diagrams.
1357
+ * To define labels provide the label property in the {@link createToken} config parameter.
1358
+ */
1359
+ export declare function tokenLabel(tokType: TokenType): string;
1360
+ /**
1361
+ * A Utility method to check if a token is of the type of the argument Token class.
1362
+ * This utility is needed because Chevrotain tokens support "categories" which means
1363
+ * A TokenType may have multiple categories.
1364
+ *
1365
+ * This means a simple comparison using the {@link IToken.tokenType} property may not suffice.
1366
+ * For example:
1367
+ *
1368
+ * ```
1369
+ * import { createToken, tokenMatcher, Lexer } from "chevrotain"
1370
+ *
1371
+ * // An "abstract" Token used only for categorization purposes.
1372
+ * const NumberTokType = createToken({ name: "NumberTokType", pattern: Lexer.NA })
1373
+ *
1374
+ * const IntegerTokType = createToken({
1375
+ * name: "IntegerTokType",
1376
+ * pattern: /\d+/,
1377
+ * // Integer "Is A" Number
1378
+ * categories: [NumberTokType]
1379
+ * })
1380
+ *
1381
+ * const DecimalTokType = createToken({
1382
+ * name: "DecimalTokType",
1383
+ * pattern: /\d+\.\d+/,
1384
+ * // Double "Is A" Number
1385
+ * categories: [NumberTokType]
1386
+ * })
1387
+ *
1388
+ * // Will always be false as the tokenType property can only
1389
+ * // be Integer or Double Token Types as the Number TokenType is "abstract".
1390
+ * if (myToken.tokenType === NumberTokType) { /* ... *\/ }
1391
+ *
1392
+ * // Will be true when myToken is of Type Integer or Double.
1393
+ * // Because the hierarchy defined by the categories is taken into account.
1394
+ * if (tokenMatcher(myToken, NumberTokType) { /* ... *\/ }
1395
+ * ```
1396
+ *
1397
+ * @returns true iff the token matches the TokenType.
1398
+ */
1399
+ export function tokenMatcher(token: IToken, tokType: TokenType): boolean;
1400
+ export declare type MultiModesDefinition = {
1401
+ [modeName: string]: TokenType[];
1402
+ };
1403
+ export interface IMultiModeLexerDefinition {
1404
+ modes: MultiModesDefinition;
1405
+ defaultMode: string;
1406
+ }
1407
+ export type TokenTypeDictionary = {
1408
+ [tokenName: string]: TokenType;
1409
+ };
1410
+ export declare type TokenVocabulary = TokenTypeDictionary | TokenType[] | IMultiModeLexerDefinition;
1411
+ export interface IRuleConfig<T> {
1412
+ /**
1413
+ * The function which will be invoked to produce the returned value for a production that have not been
1414
+ * successfully executed and the parser recovered from.
1415
+ */
1416
+ recoveryValueFunc?: (e: IRecognitionException) => T;
1417
+ /**
1418
+ * Enable/Disable re-sync error recovery for this specific production.
1419
+ */
1420
+ resyncEnabled?: boolean;
1421
+ }
1422
+ export interface DSLMethodOpts<T> {
1423
+ /**
1424
+ * The Grammar to process in this method.
1425
+ */
1426
+ DEF: GrammarAction<T>;
1427
+ /**
1428
+ * A semantic constraint on this DSL method
1429
+ * @see https://github.com/chevrotain/chevrotain/blob/master/examples/parser/predicate_lookahead/predicate_lookahead.js
1430
+ * For farther details.
1431
+ */
1432
+ GATE?: () => boolean;
1433
+ /**
1434
+ * Maximum number of "following tokens" which would be used to
1435
+ * Choose between the alternatives.
1436
+ *
1437
+ * By default this value is determined by the {@link IParserConfig.maxLookahead} value.
1438
+ * A Higher value may be used for a specific DSL method to resolve ambiguities
1439
+ * And a lower value may be used to resolve slow initialization times issues.
1440
+ *
1441
+ * TODO: create full docs and link
1442
+ */
1443
+ MAX_LOOKAHEAD?: number;
1444
+ }
1445
+ export interface DSLMethodOptsWithErr<T> extends DSLMethodOpts<T> {
1446
+ /**
1447
+ * Short title/classification to what is being matched.
1448
+ * Will be used in the error message,.
1449
+ * If none is provided, the error message will include the names of the expected
1450
+ * Tokens sequences which start the method's inner grammar
1451
+ */
1452
+ ERR_MSG?: string;
1453
+ }
1454
+ export interface OrMethodOpts<T> {
1455
+ /**
1456
+ * The set of alternatives,
1457
+ * See detailed description in {@link BaseParser.OR}
1458
+ */
1459
+ DEF: IOrAlt<T>[];
1460
+ /**
1461
+ * A description for the alternatives used in error messages
1462
+ * If none is provided, the error message will include the names of the expected
1463
+ * Tokens sequences which may start each alternative.
1464
+ */
1465
+ ERR_MSG?: string;
1466
+ /**
1467
+ * A Flag indicating that **all** ambiguities in this alternation should
1468
+ * be ignored.
1469
+ *
1470
+ * This flag should only be used in rare circumstances,
1471
+ * As normally alternation ambiguities should be resolved in other ways:
1472
+ * - Re-ordering the alternatives.
1473
+ * - Re-factoring the grammar to extract common prefixes before alternation.
1474
+ * - Using gates {@link IOrAlt.GATE} to implement custom lookahead logic.
1475
+ * - Using the more granular {@link IOrAlt.IGNORE_AMBIGUITIES} on a **specific** alternative.
1476
+ */
1477
+ IGNORE_AMBIGUITIES?: boolean;
1478
+ /**
1479
+ * Maximum number of "following tokens" which would be used to
1480
+ * Choose between the alternatives.
1481
+ *
1482
+ * By default this value is determined by the {@link IParserConfig.maxLookahead} value.
1483
+ * A Higher value may be used for a specific DSL method to resolve ambiguities
1484
+ * And a lower value may be used to resolve slow initialization times issues.
1485
+ *
1486
+ * TODO: create full docs and link
1487
+ */
1488
+ MAX_LOOKAHEAD?: number;
1489
+ }
1490
+ export interface ManySepMethodOpts<T> {
1491
+ /**
1492
+ * The grammar to process in each iteration.
1493
+ */
1494
+ DEF: GrammarAction<T>;
1495
+ /**
1496
+ * The separator between each iteration.
1497
+ */
1498
+ SEP: TokenType;
1499
+ /**
1500
+ * @see DSLMethodOpts.MAX_LOOKAHEAD
1501
+ */
1502
+ MAX_LOOKAHEAD?: number;
1503
+ }
1504
+ export interface AtLeastOneSepMethodOpts<T> extends ManySepMethodOpts<T> {
1505
+ /**
1506
+ * Short title/classification to what is being matched.
1507
+ * Will be used in the error message,.
1508
+ * If none is provided, the error message will include the names of the expected
1509
+ * Tokens sequences which start the method's inner grammar.
1510
+ */
1511
+ ERR_MSG?: string;
1512
+ }
1513
+ export interface ConsumeMethodOpts {
1514
+ /**
1515
+ * A custom Error message if the Token could not be consumed.
1516
+ * This will override any error message provided by the parser's "errorMessageProvider"
1517
+ */
1518
+ ERR_MSG?: string;
1519
+ /**
1520
+ * A label to be used instead of the TokenType name in the created CST.
1521
+ */
1522
+ LABEL?: string;
1523
+ }
1524
+ export interface SubruleMethodOpts<ARGS> {
1525
+ /**
1526
+ * The arguments to parameterized rules, see:
1527
+ * https://github.com/chevrotain/chevrotain/blob/master/examples/parser/parametrized_rules/parametrized.js
1528
+ */
1529
+ ARGS?: ARGS;
1530
+ /**
1531
+ * A label to be used instead of the subrule's name in the created CST.
1532
+ */
1533
+ LABEL?: string;
1534
+ }
1535
+ export declare type GrammarAction<OUT> = () => OUT;
1536
+ export interface IOrAlt<T> {
1537
+ GATE?: () => boolean;
1538
+ ALT: () => T;
1539
+ /**
1540
+ * A Flag indicating that any ambiguities involving this
1541
+ * specific alternative Should be ignored.
1542
+ *
1543
+ * This flag will be **implicitly** enabled if a GATE is used
1544
+ * as the assumption is that the GATE is used to resolve an ambiguity.
1545
+ */
1546
+ IGNORE_AMBIGUITIES?: boolean;
1547
+ }
1548
+ export interface IOrAltWithGate<T> extends IOrAlt<T> {
1549
+ }
1550
+ export interface ICstVisitor<IN, OUT> {
1551
+ visit(cstNode: CstNode | CstNode[], param?: IN): OUT;
1552
+ /**
1553
+ * Will throw an error if the visitor is missing any required methods
1554
+ * - `visitXYZ` for each `XYZ` grammar rule.
1555
+ */
1556
+ validateVisitor(): void;
1557
+ }
1558
+ /**
1559
+ * A [Concrete Syntax Tree](http://chevrotain.io/docs/guide/concrete_syntax_tree.html) Node.
1560
+ * This structure represents the whole parse tree of the grammar
1561
+ * This means that information on each and every Token is present.
1562
+ * This is unlike an AST (Abstract Syntax Tree) where some of the syntactic information is missing.
1563
+ *
1564
+ * For example given an ECMAScript grammar, an AST would normally not contain information on the location
1565
+ * of Commas, Semi colons, redundant parenthesis etc, however a CST would have that information.
1566
+ */
1567
+ export interface CstNode {
1568
+ readonly name: string;
1569
+ readonly children: CstChildrenDictionary;
1570
+ /**
1571
+ * A flag indicating the whole CSTNode has been recovered during **re-sync** error recovery.
1572
+ * This means that some of the node's children may be missing.
1573
+ * - Note that single token insertion/deletion recovery would not activate this flag.
1574
+ * This flag would only be activated in **re-sync** recovery when the rule's
1575
+ * grammar cannot be fully parsed.
1576
+ * - See: https://chevrotain.io/docs/tutorial/step4_fault_tolerance.html
1577
+ * for more info on error recovery and fault tolerance.
1578
+ */
1579
+ readonly recoveredNode?: boolean;
1580
+ /**
1581
+ * Will only be present if the {@link IParserConfig.nodeLocationTracking} is
1582
+ * **not** set to "none".
1583
+ * See: https://chevrotain.io/docs/guide/concrete_syntax_tree.html#cstnodes-location
1584
+ * For more details.
1585
+ */
1586
+ readonly location?: CstNodeLocation;
1587
+ }
1588
+ /**
1589
+ * The Column/Line properties will only be present when
1590
+ * The {@link IParserConfig.nodeLocationTracking} is set to "full".
1591
+ */
1592
+ export interface CstNodeLocation {
1593
+ startOffset: number;
1594
+ startLine?: number;
1595
+ startColumn?: number;
1596
+ endOffset?: number;
1597
+ endLine?: number;
1598
+ endColumn?: number;
1599
+ }
1600
+ export declare type CstChildrenDictionary = {
1601
+ [identifier: string]: CstElement[];
1602
+ };
1603
+ export declare type CstElement = IToken | CstNode;
1604
+ export declare type nodeLocationTrackingOptions = "full" | "onlyOffset" | "none";
1605
+ export interface IParserConfig {
1606
+ /**
1607
+ * Is the error recovery / fault tolerance of the Chevrotain Parser enabled.
1608
+ */
1609
+ recoveryEnabled?: boolean;
1610
+ /**
1611
+ * Maximum number of tokens the parser will use to choose between alternatives.
1612
+ * By default this value is `4`.
1613
+ * In the future it may be reduced to `3` due to performance considerations.
1614
+ */
1615
+ maxLookahead?: number;
1616
+ /**
1617
+ * Enable This Flag to to support Dynamically defined Tokens.
1618
+ * This will disable performance optimizations which cannot work if the whole Token vocabulary is not known
1619
+ * During Parser initialization.
1620
+ *
1621
+ * See [runnable example](https://github.com/chevrotain/chevrotain/tree/master/examples/parser/dynamic_tokens)
1622
+ */
1623
+ dynamicTokensEnabled?: boolean;
1624
+ /**
1625
+ * Enable computation of CST nodes location.
1626
+ * By default this is set to "none", meaning this feature is disabled.
1627
+ * See: http://chevrotain.io/docs/guide/concrete_syntax_tree.html#cstnode-location
1628
+ * For more details.
1629
+ */
1630
+ nodeLocationTracking?: nodeLocationTrackingOptions;
1631
+ /**
1632
+ * A custom error message provider.
1633
+ * Can be used to override the default error messages.
1634
+ * For example:
1635
+ * - Translating the error messages to a different languages.
1636
+ * - Changing the formatting.
1637
+ * - Providing special error messages under certain conditions, e.g: missing semicolons.
1638
+ */
1639
+ errorMessageProvider?: IParserErrorMessageProvider;
1640
+ /**
1641
+ * Enabling this flag will print performance tracing logs during parser
1642
+ * Initialization (constructor invocation), this is useful to narrow down the cause
1643
+ * of the initialization performance problem.
1644
+ *
1645
+ * You can also pass a numerical value which affects the verbosity
1646
+ * of the traces, this number is the maximum nesting level of the traces, e.g:
1647
+ * 0: Traces disabled === 'false'
1648
+ * 1: Top Level traces only.
1649
+ * 2: One level of nested inner traces.
1650
+ * ...
1651
+ *
1652
+ * Note that passing the boolean `true` is identical to passing the numerical value `infinity`
1653
+ */
1654
+ traceInitPerf?: boolean | number;
1655
+ /**
1656
+ * This flag will avoid running the grammar validations during Parser initialization.
1657
+ *
1658
+ * This can substantially improve the Parser's initialization (constructor) time.
1659
+ * @see IParserConfig.traceInitPerf to measure the grammar validations cost for your parser.
1660
+ *
1661
+ * Note that the grammar validations are **extremely useful** during development time,
1662
+ * e.g: detecting ambiguities / left recursion.
1663
+ * So they should not be skipped during development flows.
1664
+ * - For example: via a conditional that checks an env variable.
1665
+ */
1666
+ skipValidations?: boolean;
1667
+ /**
1668
+ * @experimental
1669
+ *
1670
+ * A custom lookahead strategy.
1671
+ * Can be used to override the default LL(*k*) lookahead behavior.
1672
+ *
1673
+ * Note that the default lookahead strategy is very well optimized and using a custom lookahead
1674
+ * strategy might lead to massively reduced performance.
1675
+ */
1676
+ lookaheadStrategy?: ILookaheadStrategy;
1677
+ }
1678
+ /**
1679
+ * A set of methods used to customize parsing error messages.
1680
+ * Call {@link defaultParserErrorProvider} to implement the default behavior
1681
+ */
1682
+ export interface IParserErrorMessageProvider {
1683
+ /**
1684
+ * Mismatched Token Error happens when the parser attempted to consume a terminal and failed.
1685
+ * It corresponds to a failed {@link BaseParser.CONSUME} in Chevrotain DSL terms.
1686
+ *
1687
+ * @param options.expected - The expected Token Type.
1688
+ *
1689
+ * @param options.actual - The actual Token "instance".
1690
+ *
1691
+ * @param options.previous - The previous Token "instance".
1692
+ * This is useful if options.actual[0] is of type chevrotain.EOF and you need to know the last token parsed.
1693
+ *
1694
+ * @param options.ruleName - The rule in which the error occurred.
1695
+ */
1696
+ buildMismatchTokenMessage(options: {
1697
+ expected: TokenType;
1698
+ actual: IToken;
1699
+ previous: IToken;
1700
+ ruleName: string;
1701
+ }): string;
1702
+ /**
1703
+ * A Redundant Input Error happens when the parser has completed parsing but there
1704
+ * is still unprocessed input remaining.
1705
+ *
1706
+ * @param options.firstRedundant - The first unprocessed token "instance".
1707
+ *
1708
+ * @param options.ruleName - The rule in which the error occurred.
1709
+ */
1710
+ buildNotAllInputParsedMessage(options: {
1711
+ firstRedundant: IToken;
1712
+ ruleName: string;
1713
+ }): string;
1714
+ /**
1715
+ * A No Viable Alternative Error happens when the parser cannot detect any valid alternative in an alternation.
1716
+ * It corresponds to a failed {@link BaseParser.OR} in Chevrotain DSL terms.
1717
+ *
1718
+ * @param options.expectedPathsPerAlt - First level of the array represents each alternative
1719
+ * The next two levels represent valid (expected) paths in each alternative.
1720
+ *
1721
+ * @param options.actual - The actual sequence of tokens encountered.
1722
+ *
1723
+ * @param options.previous - The previous Token "instance".
1724
+ * This is useful if options.actual[0] is of type chevrotain.EOF and you need to know the last token parsed.
1725
+ *
1726
+ * @param options.customUserDescription - A user may provide custom error message descriptor in the {@link BaseParser.AT_LEAST_ONE_SEP} DSL method
1727
+ * options parameter, this is that custom message.
1728
+ *
1729
+ * @param options.ruleName - The rule in which the error occurred.
1730
+ */
1731
+ buildNoViableAltMessage(options: {
1732
+ expectedPathsPerAlt: TokenType[][][];
1733
+ actual: IToken[];
1734
+ previous: IToken;
1735
+ customUserDescription?: string;
1736
+ ruleName: string;
1737
+ }): string;
1738
+ /**
1739
+ * An Early Exit Error happens when the parser cannot detect the first mandatory iteration of a repetition.
1740
+ * It corresponds to a failed {@link BaseParser.AT_LEAST_ONE_SEP} or {@link BaseParser.AT_LEAST_ONE_SEP} in Chevrotain DSL terms.
1741
+ *
1742
+ * @param options.expectedIterationPaths - The valid (expected) paths in the first iteration.
1743
+ *
1744
+ * @param options.actual - The actual sequence of tokens encountered.
1745
+ *
1746
+ * @param options.previous - The previous Token "instance".
1747
+ * This is useful if options.actual[0] is of type chevrotain.EOF and you need to know the last token parsed.
1748
+ *
1749
+ * @param options.customUserDescription - A user may provide custom error message descriptor in the {@link BaseParser.AT_LEAST_ONE_SEP} DSL method
1750
+ * options parameter, this is that custom message.
1751
+ *
1752
+ * @param options.ruleName - The rule in which the error occurred.
1753
+ */
1754
+ buildEarlyExitMessage(options: {
1755
+ expectedIterationPaths: TokenType[][];
1756
+ actual: IToken[];
1757
+ previous: IToken;
1758
+ customUserDescription?: string;
1759
+ ruleName: string;
1760
+ }): string;
1761
+ }
1762
+ /**
1763
+ * @experimental
1764
+ */
1765
+ export interface ILLkLookaheadValidator {
1766
+ validateNoLeftRecursion(rules: Rule[]): ILookaheadValidationError[];
1767
+ validateEmptyOrAlternatives(rules: Rule[]): ILookaheadValidationError[];
1768
+ validateAmbiguousAlternationAlternatives(rules: Rule[], maxLookahead: number): ILookaheadValidationError[];
1769
+ validateSomeNonEmptyLookaheadPath(rules: Rule[], maxLookahead: number): ILookaheadValidationError[];
1770
+ }
1771
+ /**
1772
+ * @experimental
1773
+ */
1774
+ export interface ILLkLookaheadStrategyConstructor {
1775
+ new (options?: {
1776
+ maxLookahead?: number;
1777
+ }): ILookaheadStrategy & ILLkLookaheadValidator;
1778
+ }
1779
+ /**
1780
+ * @experimental
1781
+ */
1782
+ export const LLkLookaheadStrategy: ILLkLookaheadStrategyConstructor;
1783
+ /**
1784
+ * @experimental
1785
+ */
1786
+ export interface ILookaheadStrategy {
1787
+ /**
1788
+ * Performs validations on the grammar specific to this lookahead strategy.
1789
+ * This method is not called if parser validations are disabled.
1790
+ *
1791
+ * @param options.rules All parser rules of the grammar.
1792
+ *
1793
+ * @param options.tokenTypes All token types of the grammar.
1794
+ *
1795
+ * @param options.grammarName The name of the grammar.
1796
+ */
1797
+ validate(options: {
1798
+ rules: Rule[];
1799
+ tokenTypes: TokenType[];
1800
+ grammarName: string;
1801
+ }): ILookaheadValidationError[];
1802
+ /**
1803
+ * Initializes the lookahead for a grammar.
1804
+ *
1805
+ * Note that this method does not build the lookahead functions.
1806
+ * It only initializes the internal state of the strategy based on all grammar rules.
1807
+ *
1808
+ * @param options.rules All parser rules of the grammar.
1809
+ */
1810
+ initialize?(options: {
1811
+ rules: Rule[];
1812
+ }): void;
1813
+ /**
1814
+ * Builds a lookahead function for alternations/`OR` parser methods.
1815
+ *
1816
+ * @param options.prodOccurrence The occurrence number of this `OR` within its rule.
1817
+ *
1818
+ * @param options.rule The rule that contains this `OR`.
1819
+ *
1820
+ * @param options.maxLookahead The maximum amount of lookahead for this `OR`.
1821
+ *
1822
+ * @param options.hasPredicates Whether any of the alternatives contain a predicate.
1823
+ *
1824
+ * @param options.dynamicTokensEnabled Whether dynamic tokens are enabled for this parser.
1825
+ *
1826
+ * @returns A function that is able to compute which of the alternatives to choose while parsing.
1827
+ */
1828
+ buildLookaheadForAlternation(options: {
1829
+ prodOccurrence: number;
1830
+ rule: Rule;
1831
+ maxLookahead: number;
1832
+ hasPredicates: boolean;
1833
+ dynamicTokensEnabled: boolean;
1834
+ }): (orAlts?: IOrAlt<any>[] | undefined) => number | undefined;
1835
+ /**
1836
+ * Builds a lookahead function for optional productions.
1837
+ *
1838
+ * @param options.prodOccurrence The occurrence number of this production within its rule.
1839
+ *
1840
+ * @param options.prodType The type of this production.
1841
+ *
1842
+ * @param options.rule The rule that contains this production.
1843
+ *
1844
+ * @param options.maxLookahead The maximum amount of lookahead for this production.
1845
+ *
1846
+ * @param options.dynamicTokensEnabled Whether dynamic tokens are enabled for this parser.
1847
+ *
1848
+ * @returns A function is able to compute whether to parse the production or to continue with the rest of the parser rule.
1849
+ */
1850
+ buildLookaheadForOptional(options: {
1851
+ prodOccurrence: number;
1852
+ prodType: OptionalProductionType;
1853
+ rule: Rule;
1854
+ maxLookahead: number;
1855
+ dynamicTokensEnabled: boolean;
1856
+ }): () => boolean;
1857
+ }
1858
+ export interface ILookaheadValidationError {
1859
+ message: string;
1860
+ ruleName?: string;
1861
+ }
1862
+ export type LookaheadSequence = TokenType[][];
1863
+ export type OptionalProductionType = "Option" | "RepetitionMandatory" | "RepetitionMandatoryWithSeparator" | "Repetition" | "RepetitionWithSeparator";
1864
+ export type LookaheadProductionType = OptionalProductionType | "Alternation";
1865
+ /**
1866
+ * Computes all lookahead paths for a given production.
1867
+ *
1868
+ * The result is a three-dimensional array of token types.
1869
+ * Accessing this array with the index of an alternative of the given production returns a two-dimensional array.
1870
+ * Each entry of this array represents a list of the token types which can occur in this alternative.
1871
+ *
1872
+ * @param options.occurrence The occurrence number of this production within its rule.
1873
+ *
1874
+ * @param options.rule The rule which contains this production.
1875
+ *
1876
+ * @param options.prodType The type of this production.
1877
+ *
1878
+ * @param options.maxLookahead The maximum amount of lookahead for this production.
1879
+ */
1880
+ export declare function getLookaheadPaths(options: {
1881
+ occurrence: number;
1882
+ rule: Rule;
1883
+ prodType: LookaheadProductionType;
1884
+ maxLookahead: number;
1885
+ }): LookaheadSequence[];
1886
+ export interface IRecognizerContext {
1887
+ /**
1888
+ * A copy of the parser's rule stack at the "time" the RecognitionException occurred.
1889
+ * This can be used to help debug parsing errors (How did we get here?).
1890
+ */
1891
+ ruleStack: string[];
1892
+ /**
1893
+ * A copy of the parser's rule occurrence stack at the "time" the RecognitionException occurred.
1894
+ * This can be used to help debug parsing errors (How did we get here?).
1895
+ */
1896
+ ruleOccurrenceStack: number[];
1897
+ }
1898
+ export declare type ISeparatedIterationResult<OUT> = {
1899
+ values: OUT[];
1900
+ separators: IToken[];
1901
+ };
1902
+ export interface ISerializedGast {
1903
+ type: ProductionType;
1904
+ definition?: ISerializedGast[];
1905
+ }
1906
+ export type ProductionType = LookaheadProductionType | "NonTerminal" | "Alternative" | "Terminal" | "Rule";
1907
+ /**
1908
+ * Structure for the path the parser "took" to reach a certain position
1909
+ * in the grammar.
1910
+ */
1911
+ export interface IGrammarPath {
1912
+ /**
1913
+ * The Grammar rules invoked and still unterminated to reach this Grammar Path.
1914
+ */
1915
+ ruleStack: string[];
1916
+ /**
1917
+ * The occurrence index (SUBRULE1/2/3/5/...) of each Grammar rule invoked and still unterminated.
1918
+ * Used to distinguish between **different** invocations of the same subrule at the same top level rule.
1919
+ */
1920
+ occurrenceStack: number[];
1921
+ }
1922
+ export interface ISyntacticContentAssistPath extends IGrammarPath {
1923
+ nextTokenType: TokenType;
1924
+ nextTokenOccurrence: number;
1925
+ }
1926
+ export interface ITokenGrammarPath extends IGrammarPath {
1927
+ lastTok: TokenType;
1928
+ lastTokOccurrence: number;
1929
+ }
1930
+ export declare enum LexerDefinitionErrorType {
1931
+ MISSING_PATTERN = 0,
1932
+ INVALID_PATTERN = 1,
1933
+ EOI_ANCHOR_FOUND = 2,
1934
+ UNSUPPORTED_FLAGS_FOUND = 3,
1935
+ DUPLICATE_PATTERNS_FOUND = 4,
1936
+ INVALID_GROUP_TYPE_FOUND = 5,
1937
+ PUSH_MODE_DOES_NOT_EXIST = 6,
1938
+ MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE = 7,
1939
+ MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY = 8,
1940
+ MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST = 9,
1941
+ LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED = 10,
1942
+ SOI_ANCHOR_FOUND = 11,
1943
+ EMPTY_MATCH_PATTERN = 12,
1944
+ NO_LINE_BREAKS_FLAGS = 13,
1945
+ UNREACHABLE_PATTERN = 14,
1946
+ IDENTIFY_TERMINATOR = 15,
1947
+ CUSTOM_LINE_BREAK = 16,
1948
+ MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE = 17
1949
+ }
1950
+ /**
1951
+ * Type of End Of File Token.
1952
+ */
1953
+ export declare const EOF: TokenType;
1954
+ /**
1955
+ * Convenience used to express an **empty** alternative in an OR (alternation).
1956
+ * can be used to more clearly describe the intent in a case of empty alternation.
1957
+ *
1958
+ * For example:
1959
+ *
1960
+ * 1. without using EMPTY_ALT:
1961
+ * ```
1962
+ * this.OR([
1963
+ * {ALT: () => {
1964
+ * this.CONSUME1(OneTok)
1965
+ * return "1"
1966
+ * }},
1967
+ * {ALT: () => {
1968
+ * this.CONSUME1(TwoTok)
1969
+ * return "2"
1970
+ * }},
1971
+ * // implicitly empty because there are no invoked grammar
1972
+ * // rules (OR/MANY/CONSUME...) inside this alternative.
1973
+ * {ALT: () => {
1974
+ * return "666"
1975
+ * }},
1976
+ * ])
1977
+ * ```
1978
+ *
1979
+ * 2. using EMPTY_ALT:
1980
+ * ```
1981
+ * this.OR([
1982
+ * {ALT: () => {
1983
+ * this.CONSUME1(OneTok)
1984
+ * return "1"
1985
+ * }},
1986
+ * {ALT: () => {
1987
+ * this.CONSUME1(TwoTok)
1988
+ * return "2"
1989
+ * }},
1990
+ * // explicitly empty, clearer intent
1991
+ * {ALT: EMPTY_ALT("666")},
1992
+ * ])
1993
+ * ```
1994
+ */
1995
+ export declare function EMPTY_ALT(): () => undefined;
1996
+ export declare function EMPTY_ALT<T>(value: T): () => T;
1997
+ /**
1998
+ * This is the default logic Chevrotain uses to construct error messages.
1999
+ * It can be used as a reference or as a starting point customize a parser's
2000
+ * error messages.
2001
+ *
2002
+ * - See: {@link IParserConfig.errorMessageProvider}
2003
+ */
2004
+ export declare const defaultParserErrorProvider: IParserErrorMessageProvider;
2005
+ /**
2006
+ * A Chevrotain Parser runtime exception.
2007
+ */
2008
+ export interface IRecognitionException extends Error {
2009
+ name: string;
2010
+ message: string;
2011
+ /**
2012
+ * The token which caused the parser error.
2013
+ */
2014
+ token: IToken;
2015
+ /**
2016
+ * Additional tokens which have been re-synced in error recovery due to the original error.
2017
+ * This information can be used the calculate the whole text area which has been skipped due to an error.
2018
+ * For example for displaying with a red underline in a text editor.
2019
+ */
2020
+ resyncedTokens: IToken[];
2021
+ context: IRecognizerContext;
2022
+ }
2023
+ /**
2024
+ * A utility to detect if an Error is a Chevrotain Parser's runtime exception.
2025
+ */
2026
+ export declare function isRecognitionException(error: Error): boolean;
2027
+ /**
2028
+ * An exception of this type will be saved in {@link BaseParser.errors} when {@link BaseParser.CONSUME}
2029
+ * was called but failed to match the expected Token Type.
2030
+ */
2031
+ export declare class MismatchedTokenException extends Error implements IRecognitionException {
2032
+ context: IRecognizerContext;
2033
+ resyncedTokens: IToken[];
2034
+ token: IToken;
2035
+ previousToken: IToken;
2036
+ constructor(message: string, token: IToken, previousToken: IToken);
2037
+ }
2038
+ /**
2039
+ * An exception of this type will be saved in {@link BaseParser.errors} when {@link BaseParser.OR}
2040
+ * was called yet none of the possible alternatives could be matched.
2041
+ */
2042
+ export declare class NoViableAltException extends Error implements IRecognitionException {
2043
+ context: IRecognizerContext;
2044
+ resyncedTokens: IToken[];
2045
+ token: IToken;
2046
+ previousToken: IToken;
2047
+ constructor(message: string, token: IToken, previousToken: IToken);
2048
+ }
2049
+ /**
2050
+ * An exception of this type will be saved in {@link BaseParser.errors} when
2051
+ * the parser has finished yet there exists remaining input (tokens) that has not processed.
2052
+ */
2053
+ export declare class NotAllInputParsedException extends Error implements IRecognitionException {
2054
+ context: IRecognizerContext;
2055
+ resyncedTokens: IToken[];
2056
+ token: IToken;
2057
+ constructor(message: string, token: IToken);
2058
+ }
2059
+ /**
2060
+ * An exception of this type will be saved in {@link BaseParser.errors} when {@link BaseParser.AT_LEAST_ONE_SEP}
2061
+ * or {@link BaseParser.AT_LEAST_ONE_SEP} was called but failed to match even a single iteration.
2062
+ */
2063
+ export declare class EarlyExitException extends Error implements IRecognitionException {
2064
+ context: IRecognizerContext;
2065
+ resyncedTokens: IToken[];
2066
+ token: IToken;
2067
+ previousToken: IToken;
2068
+ constructor(message: string, token: IToken, previousToken: IToken);
2069
+ }
2070
+ export interface IProduction {
2071
+ accept(visitor: IGASTVisitor): void;
2072
+ }
2073
+ export interface IProductionWithOccurrence extends IProduction {
2074
+ idx: number;
2075
+ }
2076
+ /**
2077
+ * A very basic implementation of a Visitor Pattern
2078
+ * For the Grammar AST structure.
2079
+ *
2080
+ * This may be useful for advanced users who create custom logic on the grammar AST.
2081
+ * For example, custom validations or introspection.
2082
+ */
2083
+ export abstract class GAstVisitor {
2084
+ visit(node: IProduction): any;
2085
+ abstract visitNonTerminal(node: NonTerminal): any;
2086
+ abstract visitAlternative(node: Alternative): any;
2087
+ abstract visitOption(node: Option$1): any;
2088
+ abstract visitRepetition(node: Repetition): any;
2089
+ abstract visitRepetitionMandatory(node: RepetitionMandatory): any;
2090
+ abstract visitRepetitionMandatoryWithSeparator(node: RepetitionMandatoryWithSeparator): any;
2091
+ abstract visitRepetitionWithSeparator(node: RepetitionWithSeparator): any;
2092
+ abstract visitAlternation(node: Alternation): any;
2093
+ abstract visitTerminal(node: Terminal): any;
2094
+ abstract visitRule(node: Rule): any;
2095
+ }
2096
+ /**
2097
+ * The Grammar AST class representing a top level {@link CstParser.RULE} or {@link EmbeddedActionsParser.RULE} call.
2098
+ */
2099
+ export declare class Rule {
2100
+ name: string;
2101
+ orgText: string;
2102
+ definition: IProduction[];
2103
+ constructor(options: {
2104
+ name: string;
2105
+ definition: IProduction[];
2106
+ orgText?: string;
2107
+ });
2108
+ accept(visitor: IGASTVisitor): void;
2109
+ }
2110
+ /**
2111
+ * The Grammar AST class representing a top level {@link CstParser.SUBRULE} or {@link EmbeddedActionsParser.SUBRULE} call.
2112
+ */
2113
+ export declare class NonTerminal implements IProductionWithOccurrence {
2114
+ nonTerminalName: string;
2115
+ label?: string;
2116
+ referencedRule: Rule;
2117
+ idx: number;
2118
+ constructor(options: {
2119
+ nonTerminalName: string;
2120
+ label?: string;
2121
+ referencedRule?: Rule;
2122
+ idx?: number;
2123
+ });
2124
+ definition: IProduction[];
2125
+ accept(visitor: IGASTVisitor): void;
2126
+ }
2127
+ /**
2128
+ * The Grammar AST class used to represent a single alternative in an {@link Alternation}.
2129
+ */
2130
+ export declare class Alternative {
2131
+ definition: IProduction[];
2132
+ ignoreAmbiguities: boolean;
2133
+ constructor(options: {
2134
+ definition: IProduction[];
2135
+ ignoreAmbiguities?: boolean;
2136
+ });
2137
+ accept(visitor: IGASTVisitor): void;
2138
+ }
2139
+ /**
2140
+ * The Grammar AST class representing a {@link BaseParser.OPTION} call.
2141
+ */
2142
+ declare class Option$1 implements IProductionWithOccurrence {
2143
+ idx: number;
2144
+ definition: IProduction[];
2145
+ constructor(options: {
2146
+ definition: IProduction[];
2147
+ idx?: number;
2148
+ name?: string;
2149
+ });
2150
+ accept(visitor: IGASTVisitor): void;
2151
+ }
2152
+ /**
2153
+ * The Grammar AST class representing a {@link BaseParser.AT_LEAST_ONE_SEP} call.
2154
+ */
2155
+ export declare class RepetitionMandatory implements IProductionWithOccurrence {
2156
+ idx: number;
2157
+ definition: IProduction[];
2158
+ constructor(options: {
2159
+ definition: IProduction[];
2160
+ idx?: number;
2161
+ name?: string;
2162
+ });
2163
+ accept(visitor: IGASTVisitor): void;
2164
+ }
2165
+ /**
2166
+ * The Grammar AST class representing a {@link BaseParser.AT_LEAST_ONE_SEP} call.
2167
+ */
2168
+ export declare class RepetitionMandatoryWithSeparator implements IProductionWithOccurrence {
2169
+ separator: TokenType;
2170
+ idx: number;
2171
+ definition: IProduction[];
2172
+ constructor(options: {
2173
+ definition: IProduction[];
2174
+ separator: TokenType;
2175
+ idx?: number;
2176
+ name?: string;
2177
+ });
2178
+ accept(visitor: IGASTVisitor): void;
2179
+ }
2180
+ /**
2181
+ * The Grammar AST class representing a {@link BaseParser.MANY} call.
2182
+ */
2183
+ export declare class Repetition implements IProductionWithOccurrence {
2184
+ separator: TokenType;
2185
+ idx: number;
2186
+ definition: IProduction[];
2187
+ constructor(options: {
2188
+ definition: IProduction[];
2189
+ idx?: number;
2190
+ name?: string;
2191
+ });
2192
+ accept(visitor: IGASTVisitor): void;
2193
+ }
2194
+ /**
2195
+ * The Grammar AST class representing a {@link BaseParser.MANY_SEP} call.
2196
+ */
2197
+ export declare class RepetitionWithSeparator implements IProductionWithOccurrence {
2198
+ separator: TokenType;
2199
+ idx: number;
2200
+ definition: IProduction[];
2201
+ constructor(options: {
2202
+ definition: IProduction[];
2203
+ separator: TokenType;
2204
+ idx?: number;
2205
+ name?: string;
2206
+ });
2207
+ accept(visitor: IGASTVisitor): void;
2208
+ }
2209
+ /**
2210
+ * The Grammar AST class representing a {@link BaseParser.OR} call.
2211
+ */
2212
+ export declare class Alternation implements IProductionWithOccurrence {
2213
+ idx: number;
2214
+ definition: IProduction[];
2215
+ constructor(options: {
2216
+ definition: IProduction[];
2217
+ idx?: number;
2218
+ });
2219
+ accept(visitor: IGASTVisitor): void;
2220
+ }
2221
+ /**
2222
+ * The Grammar AST class representing a {@link BaseParser.CONSUME} call.
2223
+ */
2224
+ export declare class Terminal implements IProductionWithOccurrence {
2225
+ terminalType: TokenType;
2226
+ label?: string;
2227
+ idx: number;
2228
+ constructor(options: {
2229
+ terminalType: TokenType;
2230
+ label?: string;
2231
+ idx?: number;
2232
+ });
2233
+ accept(visitor: IGASTVisitor): void;
2234
+ }
2235
+ export interface IGASTVisitor {
2236
+ visit(prod: IProduction): any;
2237
+ }
2238
+ /**
2239
+ * Serialize a Grammar to a JSON Object.
2240
+ *
2241
+ * This can be useful for scenarios requiring exporting the grammar structure
2242
+ * for example drawing syntax diagrams.
2243
+ */
2244
+ export declare function serializeGrammar(topRules: Rule[]): ISerializedGast[];
2245
+ /**
2246
+ * Like {@link serializeGrammar} but for a single GAST Production instead of a set of Rules.
2247
+ */
2248
+ export declare function serializeProduction(node: IProduction): ISerializedGast;
2249
+ /**
2250
+ * @deprecated
2251
+ * This function no longer does anything, Avoid using this function
2252
+ * As it will be removed in future versions.
2253
+ */
2254
+ export declare function clearCache(): void;
2255
+ /**
2256
+ * Structure of configuration object for {@link createSyntaxDiagramsCode}
2257
+ */
2258
+ export interface ICreateSyntaxDiagramsConfig {
2259
+ /**
2260
+ * Base Url to load the runtime resources for rendering the diagrams
2261
+ */
2262
+ resourceBase?: string;
2263
+ /**
2264
+ * Url to load the styleSheet, replace with your own for styling customization.
2265
+ */
2266
+ css?: string;
2267
+ }
2268
+ /**
2269
+ * Will generate an html source code (text).
2270
+ * This html text will render syntax diagrams for the provided grammar.
2271
+ *
2272
+ * - See detailed docs for [Syntax Diagrams](http://chevrotain.io/docs/guide/generating_syntax_diagrams.html).
2273
+ */
2274
+ export declare function createSyntaxDiagramsCode(grammar: ISerializedGast[], config?: ICreateSyntaxDiagramsConfig): string;
2275
+ /**
2276
+ * Will generate TypeScript definitions source code (text).
2277
+ * For a set of {@link Rule}.
2278
+ *
2279
+ * This set of Rules can be obtained from a Parser **instance** via the
2280
+ * {@link BaseParser.getGAstProductions} method.
2281
+ *
2282
+ * Note that this function produces a **string** the output.
2283
+ * It is the responsibility of the end-user to create the signatures files.
2284
+ * - e.g: via `fs.writeFileSync()`
2285
+ *
2286
+ * See: https://chevrotain.io/docs/guide/concrete_syntax_tree.html#cst-typescript-signatures
2287
+ */
2288
+ export declare function generateCstDts(productions: Record<string, Rule>, options?: GenerateDtsOptions): string;
2289
+ export declare type GenerateDtsOptions = {
2290
+ /**
2291
+ * `true` by default.
2292
+ * Disable this to prevent the generation of the CSTVisitor interface.
2293
+ * For example, if a different traversal method on the CST has been implemented
2294
+ * by the end-user and the Chevrotain CST Visitor apis are not used.
2295
+ */
2296
+ includeVisitorInterface?: boolean;
2297
+ /**
2298
+ * The generated visitor interface will be called `ICstNodeVisitor` by default
2299
+ * This parameter enables giving it a more specific name, for example: `MyCstVisitor` or `JohnDoe`
2300
+ */
2301
+ visitorInterfaceName?: string;
2302
+ };
2303
+
2304
+ export {
2305
+ Option$1 as Option,
2306
+ };
2307
+
2308
+ export {};