File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,14 @@ function inferenceMatchResult(ast) {
59
59
// 6 == 3! -- permutations count for all transitions from one match
60
60
// state to another.
61
61
// After 6 iterations the cycle with guarantee begins
62
+ // For example, an input of `start = [] start` will generate the
63
+ // sequence: 0 -> -1 -> -1 (then stop)
64
+ //
65
+ // A more complex grammar theoretically would generate the
66
+ // sequence: 0 -> 1 -> 0 -> -1 -> 0 -> 1 -> ... (then cycle)
67
+ // but there are no examples of such grammars yet (possible, they
68
+ // do not exist at all)
69
+
62
70
// istanbul ignore next This is canary test, shouldn't trigger in real life
63
71
if ( ++ count > 6 ) {
64
72
throw new GrammarError (
Original file line number Diff line number Diff line change @@ -308,6 +308,21 @@ describe("peg.d.ts", () => {
308
308
"zero_or_more" ,
309
309
] ) ;
310
310
} ) ;
311
+
312
+ it ( "compiles" , ( ) => {
313
+ const ast = peggy . parser . parse ( "start = 'foo'" , {
314
+ grammarSource : "it compiles" ,
315
+ reservedWords : peggy . RESERVED_WORDS . slice ( ) ,
316
+ } ) ;
317
+ expectType < peggy . ast . Grammar > ( ast ) ;
318
+ const parser = peggy . compiler . compile (
319
+ ast ,
320
+ peggy . compiler . passes
321
+ ) ;
322
+ expectType < peggy . Parser > ( parser ) ;
323
+ expectType < peggy . ast . MatchResult | undefined > ( ast . rules [ 0 ] . match ) ;
324
+ expect ( ast . rules [ 0 ] . match ) . toBe ( 0 ) ;
325
+ } ) ;
311
326
} ) ;
312
327
313
328
describe ( "run tsd" , ( ) => {
You can’t perform that action at this time.
0 commit comments