@@ -65,7 +65,7 @@ let counter = 0;
6565function checkParserStarts ( grammar , starts , modified , counts ) {
6666 for ( const start of starts ) {
6767 const startRule = start . startRule || undefined ; // NOT `??`
68- const peg$maxFailPos = start . peg$maxFailPos ?? 0 ;
68+ const peg$maxFailPos = start . peg$maxFailPos ?? undefined ;
6969 const options = start . options ?? { } ;
7070 const invalid = start . invalid ?? INVALID ;
7171 if ( ! modified && options . peg$startRuleFunction ) {
@@ -93,12 +93,19 @@ function checkParserStarts(grammar, starts, modified, counts) {
9393 peg$FAILED : { } ,
9494 peg$maxFailPos,
9595 } ;
96+ if ( peg$maxFailPos === undefined ) {
97+ delete expectedLib . peg$maxFailPos ;
98+ }
9699 let lib = grammar . parse ( start . validInput , {
97100 peg$library : true ,
98101 startRule,
99102 ...options ,
100103 } ) ;
101104 delete lib . peg$maxFailExpected ;
105+ if ( peg$maxFailPos === undefined ) {
106+ delete lib . peg$maxFailPos ;
107+ }
108+
102109 if ( typeof expected === "function" ) {
103110 // @ts -ignore
104111 lib . peg$result = expected ( lib . peg$result ) ;
@@ -112,6 +119,9 @@ function checkParserStarts(grammar, starts, modified, counts) {
112119 ...options ,
113120 } ) ;
114121 delete lib . peg$maxFailExpected ;
122+ if ( peg$maxFailPos === undefined ) {
123+ delete lib . peg$maxFailPos ;
124+ }
115125 if ( typeof expected === "function" ) {
116126 // @ts -ignore
117127 lib . peg$result = expected ( lib . peg$result ) ;
0 commit comments