2024-09-07 10:27:05 +08:00
var Gc = Object . defineProperty ; var Uc = ( n , e , t ) => e in n ? Gc ( n , e , { enumerable : ! 0 , configurable : ! 0 , writable : ! 0 , value : t } ) : n [ e ] = t ; var Je = ( n , e , t ) => Uc ( n , typeof e != "symbol" ? e + "" : e , t ) ; import { bs as Fc , bt as Bc , aT as ao , bu as Hc , aG as Mt , bn as Vc , aU as Kt , aW as Z , b4 as Wc , b5 as Kc , aB as zc , aD as Qi , aC as oo , bj as qc , bv as lo , bw as co , bx as Zi , bl as Yc , aX as Xc , by as Jc , bz as Qc , b0 as Zc , bA as eu , bo as Ie , aF as mt , aA as ze , aH as D , ah as te , aZ as es , bB as tu , bC as tn } from "./index-BpITZyw2.js" ; import { g as vi , m as b , f as Dt , e as _i , l as jt , d as nu } from "./min-uTkNmGja.js" ; import { c as Ei , g as ru , v as K , i as uo , j as iu , b as fo , a as S , h as x , r as oe , f as Ee , n as q } from "./_baseUniq-CRCEszl2.js" ; var su = Object . prototype , au = su . hasOwnProperty , _e = Fc ( function ( n , e ) { if ( Bc ( e ) || ao ( e ) ) { Hc ( e , Mt ( e ) , n ) ; return } for ( var t in e ) au . call ( e , t ) && Vc ( n , t , e [ t ] ) } ) ; function ho ( n , e , t ) { var r = - 1 , i = n . length ; e < 0 && ( e = - e > i ? 0 : i + e ) , t = t > i ? i : t , t < 0 && ( t += i ) , i = e > t ? 0 : t - e >>> 0 , e >>>= 0 ; for ( var s = Array ( i ) ; ++ r < i ; ) s [ r ] = n [ r + e ] ; return s } function hn ( n ) { for ( var e = - 1 , t = n == null ? 0 : n . length , r = 0 , i = [ ] ; ++ e < t ; ) { var s = n [ e ] ; s && ( i [ r ++ ] = s ) } return i } function ou ( n , e , t , r ) { for ( var i = - 1 , s = n == null ? 0 : n . length ; ++ i < s ; ) { var a = n [ i ] ; e ( r , a , t ( a ) , n ) } return r } function lu ( n , e , t , r ) { return Ei ( n , function ( i , s , a ) { e ( r , i , t ( i ) , a ) } ) , r } function cu ( n , e ) { return function ( t , r ) { var i = Z ( t ) ? ou : lu , s = e ? e ( ) : { } ; return i ( t , n , Kt ( r ) , s ) } } var uu = 200 ; function du ( n , e , t , r ) { var i = - 1 , s = ru , a = ! 0 , o = n . length , l = [ ] , c = e . length ; if ( ! o ) return l ; e . length >= uu && ( s = Kc , a = ! 1 , e = new Wc ( e ) ) ; e : for ( ; ++ i < o ; ) { var u = n [ i ] , d = u ; if ( u = u !== 0 ? u : 0 , a && d === d ) { for ( var f = c ; f -- ; ) if ( e [ f ] === d ) continue e ; l . push ( u ) } else s ( e , d , r ) || l . push ( u ) } return l } var nr = zc ( function ( n , e ) { return Qi ( n ) ? du ( n , oo ( e , 1 , Qi , ! 0 ) ) : [ ] } ) ; function J ( n , e , t ) { var r = n == null ? 0 : n . length ; return r ? ( e = e === void 0 ? 1 : vi ( e ) , ho ( n , e < 0 ? 0 : e , r ) ) : [ ] } function cn ( n , e , t ) { var r = n == null ? 0 : n . length ; return r ? ( e = e === void 0 ? 1 : vi ( e ) , e = r - e , ho ( n , 0 , e < 0 ? 0 : e ) ) : [ ] } function fu ( n , e ) { for ( var t = - 1 , r = n == null ? 0 : n . length ; ++ t < r ; ) if ( ! e ( n [ t ] , t , n ) ) return ! 1 ; return ! 0 } function hu ( n , e ) { var t = ! 0 ; return Ei ( n , function ( r , i , s ) { return t = ! ! e ( r , i , s ) , t } ) , t } function Oe ( n , e , t ) { var r = Z ( n ) ? fu : hu ; return r ( n , Kt ( e ) ) } function $e ( n ) { return n && n . length ? n [ 0 ] : void 0 } function ve ( n , e ) { return oo ( b ( n , e ) ) } var pu = Object . prototype , mu = pu . hasOwnProperty , gu = cu ( function ( n , e , t ) { mu . call ( n , t ) ? n [ t ] . push ( e ) : qc ( n , t , [ e ] ) } ) , yu = "[object String]" ; function fe ( n ) { return typeof n == "string" || ! Z ( n ) && lo ( n ) && co ( n ) == yu } var Tu = Math . max ; function ue ( n , e , t , r ) { n = ao ( n ) ? n : K ( n ) , t = t && ! r ? vi ( t ) : 0 ; var i = n . length ; return t < 0 && ( t = Tu ( i + t , 0 ) ) , fe ( n ) ? t <= i && n . indexOf ( e , t ) > - 1 : ! ! i && uo ( n , e , t ) > - 1 } function ts ( n , e , t ) { var r = n == null ? 0 : n . length ; if ( ! r ) return - 1 ; var i = 0 ; return uo ( n , e , i ) } var vu = "[object RegExp]" ; function _u ( n ) { return lo ( n ) && co ( n ) == vu } var ns = Zi && Zi . isRegExp , qe = ns ? Yc ( ns ) : _u , Eu = "Expected a function" ; function Ru ( n ) { if ( typeof n != "function" ) throw new TypeError ( Eu ) ; return function ( ) { var e = arguments ; switch ( e . length ) { case 0 : return ! n . call ( this ) ; case 1 : return ! n . call ( this , e [ 0 ] ) ; case 2 : return ! n . call ( this , e [ 0 ] , e [ 1 ] ) ; case 3 : return ! n . call ( this , e [ 0 ] , e [ 1 ] , e [ 2 ] ) } return ! n . apply ( this , e ) } } function Pe ( n , e ) { if ( n == null ) return { } ; var t = Xc ( Jc ( n ) , function ( r ) { return [ r ] } ) ; return e = Kt ( e ) , Qc ( n , t , function ( r , i ) { return e ( r , i [ 0 ] ) } ) } function rr ( n , e ) { var t = Z ( n ) ? Zc : iu ; return t ( n , Ru ( Kt ( e ) ) ) } function Au ( n , e ) { var t ; return Ei ( n , function ( r , i , s ) { return t = e ( r , i , s ) , ! t } ) , ! ! t } function po ( n , e , t ) { var r = Z ( n ) ? eu : Au ; return r ( n , Kt ( e ) ) } function Ri ( n ) { return n && n . length ? fo ( n ) : [ ] } function bu ( n , e ) { return n && n . length ? fo ( n , Kt ( e ) ) : [ ] } function ae ( n ) { return typeof n == "object" && n !== null && typeof n . $type == "string" } function Ge ( n ) { return typeof n == "object" && n !== null && typeof n . $refText == "string" } function Nu ( n ) { return typeof n == "object" && n !== null && typeof n . name == "string" && typeof n . type == "string" && typeof n . path == "string" } function kn ( n ) { return typeof n == "object" && n !== null && ae ( n . container ) && Ge ( n . reference ) && typeof n . message == "string" } class mo { constructor ( ) { this . subtypes = { } , this . allSubtypes = { } } isInstance ( e , t ) { return ae ( e ) && this . isSubtype ( e . $type , t ) } isSubtype ( e , t ) { if ( e === t ) return ! 0 ; let r = this . subtypes [ e ] ; r || ( r = this . subtypes [ e ] = { } ) ; const i = r [ t ] ; if ( i !== void 0 ) return i ; { const s = this . computeIsSubtype ( e , t ) ; return r [ t ] = s
2024-09-04 13:02:35 +08:00
` ),C(" \r "),C(" "),C(" \v "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" \u 2028"),C(" \u 2029"),C(" "),C(" "),C(" "),C(" \u FEFF")],dd=/[0-9a-fA-F]/,Rn=/[0-9]/,fd=/[1-9]/;class tl{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");const t=this.disjunction();this.consumeChar("/");const r={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":nn(r,"global");break;case"i":nn(r,"ignoreCase");break;case"m":nn(r,"multiLine");break;case"u":nn(r,"unicode");break;case"y":nn(r,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:r,value:t,loc:this.loc(0)}}disjunction(){const e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}}alternative(){const e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){const e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case" $ ":return{type:"EndAnchor",loc:this.loc(e)};case" \\ ":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let t;switch(this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead";break}vt(t);const r=this.disjunction();return this.consumeChar(")"),{type:t,value:r,loc:this.loc(e)}}return ud()}quantifier(e=!1){let t;const r=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":const i=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:i,atMost:i};break;case",":let s;this.isDigit()?(s=this.integerIncludingZero(),t={atLeast:i,atMost:s}):t={atLeast:i,atMost:1/0},this.consumeChar("}");break}if(e===!0&&t===void 0)return;vt(t);break}if(!(e===!0&&t===void 0)&&vt(t))return this.peekChar(0)==="?"?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(r),t}atom(){let e;const t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case" \\ ":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group();break}if(e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),vt(e))return e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[C( `
` ),C(" \r "),C(" \u 2028"),C(" \u 2029")]}}atomEscape(){switch(this.consumeChar(" \\ "),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case"d":e= $ n;break;case"D":e= $ n,t=!0;break;case"s":e=ls;break;case"S":e=ls,t=!0;break;case"w":e=Pn;break;case"W":e=Pn,t=!0;break}if(vt(e))return{type:"Set",value:e,complement:t}}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=C(" \f ");break;case"n":e=C( `
2024-08-27 22:31:52 +08:00
` );break;case"r":e=C(" \r ");break;case"t":e=C(" ");break;case"v":e=C(" \v ");break}if(vt(e))return{type:"Character",value:e}}controlLetterEscapeAtom(){this.consumeChar("c");const e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:C(" \0 ")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){const e=this.popChar();return{type:"Character",value:C(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case `
2024-09-04 13:02:35 +08:00
` :case" \r ":case" \u 2028":case" \u 2029":case" \\ ":case"]":throw Error("TBD");default:const e=this.popChar();return{type:"Character",value:C(e)}}}characterClass(){const e=[];let t=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),t=!0);this.isClassAtom();){const r=this.classAtom();if(r.type,os(r)&&this.isRangeDash()){this.consumeChar("-");const i=this.classAtom();if(i.type,os(i)){if(i.value<r.value)throw Error("Range out of order in character class");e.push({from:r.value,to:i.value})}else Rr(r.value,e),e.push(C("-")),Rr(i.value,e)}else Rr(r.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}}classAtom(){switch(this.peekChar()){case"]":case `
` :case" \r ":case" \u 2028":case" \u 2029":throw Error("TBD");case" \\ ":return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar(" \\ "),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:C(" \b ")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),e=!1;break;default:this.groupIdx++;break}const t=this.disjunction();this.consumeChar(")");const r={type:"Group",capturing:e,value:t};return e&&(r.idx=this.groupIdx),r}positiveInteger(){let e=this.popChar();if(fd.test(e)===!1)throw Error("Expecting a positive integer");for(;Rn.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(Rn.test(e)===!1)throw Error("Expecting an integer");for(;Rn.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){const e=this.popChar();switch(e){case `
` :case" \r ":case" \u 2028":case" \u 2029":case"^":case" $ ":case" \\ ":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:C(e)}}}isRegExpFlag(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}}isRangeDash(){return this.peekChar()==="-"&&this.isClassAtom(1)}isDigit(){return Rn.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case `
2024-08-27 22:31:52 +08:00
` :case" \r ":case" \u 2028":case" \u 2029":return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case" \\ ":case"[":case"(":return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case"^":case" $ ":return!0;case" \\ ":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return this.peekChar(1)==="?"&&(this.peekChar(2)==="="||this.peekChar(2)==="!");default:return!1}}isQuantifier(){const e=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case" $ ":case" \\ ":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case `
2024-09-04 13:02:35 +08:00
` :case" \r ":case" \u 2028":case" \u 2029":return!1;default:return!0}}parseHexDigits(e){let t="";for(let i=0;i<e;i++){const s=this.popChar();if(dd.test(s)===!1)throw Error("Expecting a HexDecimal digits");t+=s}return{type:"Character",value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){const e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(e!==void 0&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}}class or{visitChildren(e){for(const t in e){const r=e[t];e.hasOwnProperty(t)&&(r.type!==void 0?this.visit(r):Array.isArray(r)&&r.forEach(i=>{this.visit(i)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e);break}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}}const hd=/ \r ? \n /gm,pd=new tl;class md extends or{constructor(){super(...arguments),this.isStarting=!0,this.endRegexpStack=[],this.multiline=!1}get endRegex(){return this.endRegexpStack.join("")}reset(e){this.multiline=!1,this.regex=e,this.startRegexp="",this.isStarting=!0,this.endRegexpStack=[]}visitGroup(e){e.quantifier&&(this.isStarting=!1,this.endRegexpStack=[])}visitCharacter(e){const t=String.fromCharCode(e.value);if(!this.multiline&&t=== `
` &&(this.multiline=!0),e.quantifier)this.isStarting=!1,this.endRegexpStack=[];else{const r=lr(t);this.endRegexpStack.push(r),this.isStarting&&(this.startRegexp+=r)}}visitSet(e){if(!this.multiline){const t=this.regex.substring(e.loc.begin,e.loc.end),r=new RegExp(t);this.multiline=!! `
` .match(r)}if(e.quantifier)this.isStarting=!1,this.endRegexpStack=[];else{const t=this.regex.substring(e.loc.begin,e.loc.end);this.endRegexpStack.push(t),this.isStarting&&(this.startRegexp+=t)}}visitChildren(e){e.type==="Group"&&e.quantifier||super.visitChildren(e)}}const Ar=new md;function gd(n){try{return typeof n=="string"&&(n=new RegExp(n)),n=n.toString(),Ar.reset(n),Ar.visit(pd.pattern(n)),Ar.multiline}catch{return!1}}function cs(n){return(typeof n=="string"?new RegExp(n):n).test(" ")}function lr(n){return n.replace(/[.*+?^ ${ } ()|[ \] \\ ]/g," \\ $ &")}function yd(n){return Array.prototype.map.call(n,e=>/ \w /.test(e)? ` [ $ { e . toLowerCase ( ) } $ { e . toUpperCase ( ) } ] ` :lr(e)).join("")}function Td(n,e){const t=vd(n),r=e.match(t);return!!r&&r[0].length>0}function vd(n){typeof n=="string"&&(n=new RegExp(n));const e=n,t=n.source;let r=0;function i(){let s="",a;function o(c){s+=t.substr(r,c),r+=c}function l(c){s+="(?:"+t.substr(r,c)+"| $ )",r+=c}for(;r<t.length;)switch(t[r]){case" \\ ":switch(t[r+1]){case"c":l(3);break;case"x":l(4);break;case"u":e.unicode?t[r+2]==="{"?l(t.indexOf("}",r)-r+1):l(6):l(2);break;case"p":case"P":e.unicode?l(t.indexOf("}",r)-r+1):l(2);break;case"k":l(t.indexOf(">",r)-r+1);break;default:l(2);break}break;case"[":a=/ \[ (?: \\ .|.)*? \] /g,a.lastIndex=r,a=a.exec(t)||[],l(a[0].length);break;case"|":case"^":case" $ ":case"*":case"+":case"?":o(1);break;case"{":a=/ \{ \d +,? \d * \} /g,a.lastIndex=r,a=a.exec(t),a?o(a[0].length):l(1);break;case"(":if(t[r+1]==="?")switch(t[r+2]){case":":s+="(?:",r+=3,s+=i()+"| $ )";break;case"=":s+="(?=",r+=3,s+=i()+")";break;case"!":a=r,r+=3,i(),s+=t.substr(a,r-a);break;case"<":switch(t[r+3]){case"=":case"!":a=r,r+=4,i(),s+=t.substr(a,r-a);break;default:o(t.indexOf(">",r)-r+1),s+=i()+"| $ )";break}break}else o(1),s+=i()+"| $ )";break;case")":return++r,s;default:l(1);break}return s}return new RegExp(i(),n.flags)}function _d(n){return n.rules.find(e=>Se(e)&&e.entry)}function Ed(n){return n.rules.filter(e=>gt(e)&&e.hidden)}function nl(n,e){const t=new Set,r=_d(n);if(!r)return new Set(n.rules);const i=[r].concat(Ed(n));for(const a of i)rl(a,t,e);const s=new Set;for(const a of n.rules)(t.has(a.name)||gt(a)&&a.hidden)&&s.add(a);return s}function rl(n,e,t){e.add(n.name),pn(n).forEach(r=>{if(ft(r)||t){const i=r.rule.ref;i&&!e.has(i.name)&&rl(i,e,t)}})}function Rd(n){if(n.terminal)return n.terminal;if(n.type.ref){const e=sl(n.type.ref);return e==null?void 0:e.terminal}}function Ad(n){return n.hidden&&!xi(n).test(" ")}function bd(n,e){return!n||!e?[]:Ii(n,e,n.astNode,!0)}function il(n,e,t){if(!n||!e)return;const r=Ii(n,e,n.astNode,!0);if(r.length!==0)return t!==void 0?t=Math.max(0,Math.min(t,r.length-1)):t=0,r[t]}function Ii(n,e,t,r){if(!r){const i=ar(n.grammarSource,ut);if(i&&i.feature===e)return[n]}return Gt(n)&&n.astNode===t?n.content.flatMap(i=>Ii(i,e,t,!1)):[]}function Nd(n,e,t){if(!n)return;const r=kd(n,e,n==null?void 0:n.astNode);if(r.length!==0)return t!==void 0?t=Math.max(0,Math.min(t,r.length-1)):t=0,r[t]}function kd(n,e,t){if(n.astNode!==t)return[];if(dt(n.grammarSource)&&n.grammarSource.value===e)return[n];const r=Mr(n).iterator();let i;const s=[];do if(i=r.next(),!i.done){const a=i.value;a.astNode===t?dt(a.grammarSource)&&a.grammarSource.value===e&&s.push(a):r.prune()}while(!i.done);return s}function Id(n){var e;const t=n.astNode;for(;t===((e=n.container)===null||e===void 0?void 0:e.astNode);){const r=ar(n.grammarSource,ut);if(r)return r;n=n.container}}function sl(n){let e=n;return bo(e)&&(sr(e. $ container)?e=e. $ container. $ container:Se(e. $ container)?e=e. $ container:ir(e. $ container)),al(n,e,new Map)}function al(n,e,t){var r;function i(s,a){let o;return ar(s,ut)||(o=al(a,a,t)),t.set(n,o),o}if(t.has(n))return t.get(n);t.set(n,void 0);for(const s of pn(e)){if(ut(s)&&s.feature.toLowerCase()==="name")return t.set(n,s),s;if(ft(s)&&Se(s.rule.ref))return i(s,s.rule.ref);if(Yu(s)&&(!((r=s.typeRef)===null||r===void 0)&&r.ref))return i(s,s.typeRef.ref)}}function Si(n){return ol(n,new Set)}function ol(n,e){if(e.has(n))return!0;e.add(n);for(const t of pn(n))if(ft(t)){if(!t.rule.ref||Se(t.rule.ref)&&!ol(t.rule.ref,e))return!1
` ;function Yd(n,e=!1){try{const t=dr(n);return Ur(t.value,{},t.flags.ignoreCase)}catch(t){if(t.message===hl)e&&cl( ` $ { Dn } Unable to optimize : < $ { n . toString ( ) } >
2024-08-27 22:31:52 +08:00
Complement Sets cannot be automatically optimized .
This will disable the lexer ' s first char optimizations .
See : https : //chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let r="";e&&(r=`
This will disable the lexer ' s first char optimizations .
2024-09-04 13:02:35 +08:00
See : https : //chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),Gr(`${Dn}
2024-08-27 22:31:52 +08:00
Failed parsing : < $ { n . toString ( ) } >
Using the @ chevrotain / regexp - to - ast library
2024-09-04 13:02:35 +08:00
Please open an issue at : https : //github.com/chevrotain/chevrotain/issues`+r)}}return[]}function Ur(n,e,t){switch(n.type){case"Disjunction":for(let i=0;i<n.value.length;i++)Ur(n.value[i],e,t);break;case"Alternative":const r=n.value;for(let i=0;i<r.length;i++){const s=r[i];switch(s.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}const a=s;switch(a.type){case"Character":An(a.value,e,t);break;case"Set":if(a.complement===!0)throw Error(hl);S(a.value,l=>{if(typeof l=="number")An(l,e,t);else{const c=l;if(t===!0)for(let u=c.from;u<=c.to;u++)An(u,e,t);else{for(let u=c.from;u<=c.to&&u<on;u++)An(u,e,t);if(c.to>=on){const u=c.from>=on?c.from:on,d=c.to,f=et(u),h=et(d);for(let m=f;m<=h;m++)e[m]=m}}}});break;case"Group":Ur(a.value,e,t);break;default:throw Error("Non Exhaustive Match")}const o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type==="Group"&&Fr(a)===!1||a.type!=="Group"&&o===!1)break}break;default:throw Error("non exhaustive match!")}return K(e)}function An(n,e,t){const r=et(n);e[r]=r,t===!0&&Xd(n,e)}function Xd(n,e){const t=String.fromCharCode(n),r=t.toUpperCase();if(r!==t){const i=et(r.charCodeAt(0));e[i]=i}else{const i=t.toLowerCase();if(i!==t){const s=et(i.charCodeAt(0));e[s]=s}}}function ds(n,e){return Dt(n.value,t=>{if(typeof t=="number")return ue(e,t);{const r=t;return Dt(e,i=>r.from<=i&&i<=r.to)!==void 0}})}function Fr(n){const e=n.quantifier;return e&&e.atLeast===0?!0:n.value?Z(n.value)?Oe(n.value,Fr):Fr(n.value):!1}class Jd extends or{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case"Lookahead":this.visitLookahead(e);return;case"NegativeLookahead":this.visitNegativeLookahead(e);return}super.visitChildren(e)}}visitCharacter(e){ue(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?ds(e,this.targetCharCodes)===void 0&&(this.found=!0):ds(e,this.targetCharCodes)!==void 0&&(this.found=!0)}}function wi(n,e){if(e instanceof RegExp){const t=dr(e),r=new Jd(n);return r.visit(t),r.found}else return Dt(e,t=>ue(n,t.charCodeAt(0)))!==void 0}const ht="PATTERN",an="defaultMode",bn="modes";let pl=typeof new RegExp("(?:)").sticky=="boolean";function Qd(n,e){e=_i(e,{useSticky:pl,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
` ],tracer:(E,v)=>v()});const t=e.tracer;t("initCharCodeToOptimizedIndexMap",()=>{Rf()});let r;t("Reject Lexer.NA",()=>{r=rr(n,E=>E[ht]===de.NA)});let i=!1,s;t("Transform Patterns",()=>{i=!1,s=b(r,E=>{const v=E[ht];if(qe(v)){const I=v.source;return I.length===1&&I!=="^"&&I!==" $ "&&I!=="."&&!v.ignoreCase?I:I.length===2&&I[0]===" \\ "&&!ue(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],I[1])?I[1]:e.useSticky?hs(v):fs(v)}else{if(mt(v))return i=!0,{exec:v};if(typeof v=="object")return i=!0,v;if(typeof v=="string"){if(v.length===1)return v;{const I=v.replace(/[ \\ ^ $ .*+?()[ \] {}|]/g," \\ $ &"),j=new RegExp(I);return e.useSticky?hs(j):fs(j)}}else throw Error("non exhaustive match")}})});let a,o,l,c,u;t("misc mapping",()=>{a=b(r,E=>E.tokenTypeIdx),o=b(r,E=>{const v=E.GROUP;if(v!==de.SKIPPED){if(fe(v))return v;if(ze(v))return!1;throw Error("non exhaustive match")}}),l=b(r,E=>{const v=E.LONGER_ALT;if(v)return Z(v)?b(v,j=>ts(r,j)):[ts(r,v)]}),c=b(r,E=>E.PUSH_MODE),u=b(r,E=>x(E,"POP_MODE"))});let d;t("Line Terminator Handling",()=>{const E=yl(e.lineTerminatorCharacters);d=b(r,v=>!1),e.positionTracking!=="onlyOffset"&&(d=b(r,v=>x(v,"LINE_BREAKS")?!!v.LINE_BREAKS:gl(v,E)===!1&&wi(E,v.PATTERN)))});let f,h,m,g;t("Misc Mapping #2",()=>{f=b(r,ml),h=b(s,vf),m=oe(r,(E,v)=>{const I=v.GROUP;return fe(I)&&I!==de.SKIPPED&&(E[I]=[]),E},{}),g=b(s,(E,v)=>({pattern:s[v],longerAlt:l[v],canLineTerminator:d[v],isCustom:f[v],short:h[v],group:o[v],push:c[v],pop:u[v],tokenTypeIdx:a[v],tokenType:r[v]}))});let _=!0,y=[];return e.safeMode||t("First Char Optimization",()=>{y=oe(r,(E,v,I)=>{if(typeof v.PATTERN=="string"){const j=v.PATTERN.charCodeAt(0),ne=et(j);Nr(E,ne,g[I])}else if(Z(v.START_CHARS_HINT)){let j;S(v.START_CHARS_HINT,ne=>{const Ce=typeof ne=="string"?ne.charCodeAt(0):ne,ge=et(Ce);j!==ge&&(j=ge,Nr(E,ge,g[I]))})}else if(qe(v.PATTERN))if(v.PATTERN.unicode)_=!1,e.ensureOptimizations&&Gr( ` $ { Dn } Unable to analyze < $ { v . PATTERN . toString ( ) } > pattern .
2024-08-27 22:31:52 +08:00
The regexp unicode flag is not currently supported by the regexp - to - ast library .
This will disable the lexer ' s first char optimizations .
2024-09-04 13:02:35 +08:00
For details See : https : //chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{const j=Yd(v.PATTERN,e.ensureOptimizations);D(j)&&(_=!1),S(j,ne=>{Nr(E,ne,g[I])})}else e.ensureOptimizations&&Gr(`${Dn} TokenType: <${v.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
2024-08-27 22:31:52 +08:00
This will disable the lexer ' s first char optimizations .
2024-09-04 13:02:35 +08:00
For details See : https : //chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),_=!1;return E},[])}),{emptyGroups:m,patternIdxToConfig:g,charCodeToPatternIdxToConfig:y,hasCustom:i,canBeOptimized:_}}function Zd(n,e){let t=[];const r=tf(n);t=t.concat(r.errors);const i=nf(r.valid),s=i.valid;return t=t.concat(i.errors),t=t.concat(ef(s)),t=t.concat(df(s)),t=t.concat(ff(s,e)),t=t.concat(hf(s)),t}function ef(n){let e=[];const t=Ee(n,r=>qe(r[ht]));return e=e.concat(sf(t)),e=e.concat(lf(t)),e=e.concat(cf(t)),e=e.concat(uf(t)),e=e.concat(af(t)),e}function tf(n){const e=Ee(n,i=>!x(i,ht)),t=b(e,i=>({message:"Token Type: ->"+i.name+"<- missing static 'PATTERN' property",type:V.MISSING_PATTERN,tokenTypes:[i]})),r=nr(n,e);return{errors:t,valid:r}}function nf(n){const e=Ee(n,i=>{const s=i[ht];return!qe(s)&&!mt(s)&&!x(s,"exec")&&!fe(s)}),t=b(e,i=>({message:"Token Type: ->"+i.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:V.INVALID_PATTERN,tokenTypes:[i]})),r=nr(n,e);return{errors:t,valid:r}}const rf=/[^\\][$]/;function sf(n){class e extends or{constructor(){super(...arguments),this.found=!1}visitEndAnchor(s){this.found=!0}}const t=Ee(n,i=>{const s=i.PATTERN;try{const a=dr(s),o=new e;return o.visit(a),o.found}catch{return rf.test(s.source)}});return b(t,i=>({message:`Unexpected RegExp Anchor Error:
2024-08-27 22:31:52 +08:00
Token Type : - > ` +i.name+ ` < - static 'PATTERN' cannot contain end of input anchor '$'
2024-09-04 13:02:35 +08:00
See chevrotain . io / docs / guide / resolving _lexer _errors . html # ANCHORS for details . ` ,type:V.EOI_ANCHOR_FOUND,tokenTypes:[i]}))}function af(n){const e=Ee(n,r=>r.PATTERN.test(""));return b(e,r=>({message:"Token Type: ->"+r.name+"<- static 'PATTERN' must not match an empty string",type:V.EMPTY_MATCH_PATTERN,tokenTypes:[r]}))}const of=/[^ \\ [][ \^ ]|^ \^ /;function lf(n){class e extends or{constructor(){super(...arguments),this.found=!1}visitStartAnchor(s){this.found=!0}}const t=Ee(n,i=>{const s=i.PATTERN;try{const a=dr(s),o=new e;return o.visit(a),o.found}catch{return of.test(s.source)}});return b(t,i=>({message: ` Unexpected RegExp Anchor Error :
2024-08-27 22:31:52 +08:00
Token Type : - > ` +i.name+ ` < - static 'PATTERN' cannot contain start of input anchor '^'
2024-09-04 13:02:35 +08:00
See https : //chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:V.SOI_ANCHOR_FOUND,tokenTypes:[i]}))}function cf(n){const e=Ee(n,r=>{const i=r[ht];return i instanceof RegExp&&(i.multiline||i.global)});return b(e,r=>({message:"Token Type: ->"+r.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:V.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[r]}))}function uf(n){const e=[];let t=b(n,s=>oe(n,(a,o)=>(s.PATTERN.source===o.PATTERN.source&&!ue(e,o)&&o.PATTERN!==de.NA&&(e.push(o),a.push(o)),a),[]));t=hn(t);const r=Ee(t,s=>s.length>1);return b(r,s=>{const a=b(s,l=>l.name);return{message:`The same RegExp pattern ->${$e(s).PATTERN}<-has been used in all of the following Token Types: ${a.join(", ")} <-`,type:V.DUPLICATE_PATTERNS_FOUND,tokenTypes:s}})}function df(n){const e=Ee(n,r=>{if(!x(r,"GROUP"))return!1;const i=r.GROUP;return i!==de.SKIPPED&&i!==de.NA&&!fe(i)});return b(e,r=>({message:"Token Type: ->"+r.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:V.INVALID_GROUP_TYPE_FOUND,tokenTypes:[r]}))}function ff(n,e){const t=Ee(n,i=>i.PUSH_MODE!==void 0&&!ue(e,i.PUSH_MODE));return b(t,i=>({message:`Token Type: ->${i.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${i.PUSH_MODE}<-which does not exist`,type:V.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[i]}))}function hf(n){const e=[],t=oe(n,(r,i,s)=>{const a=i.PATTERN;return a===de.NA||(fe(a)?r.push({str:a,idx:s,tokenType:i}):qe(a)&&mf(a)&&r.push({str:a.source,idx:s,tokenType:i})),r},[]);return S(n,(r,i)=>{S(t,({str:s,idx:a,tokenType:o})=>{if(i<a&&pf(s,r.PATTERN)){const l=`Token: ->${o.name}<- can never be matched.
2024-08-27 22:31:52 +08:00
Because it appears AFTER the Token Type - > $ { r . name } < - in the lexer ' s definition .
2024-09-04 13:02:35 +08:00
See https : //chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;e.push({message:l,type:V.UNREACHABLE_PATTERN,tokenTypes:[r,o]})}})}),e}function pf(n,e){if(qe(e)){const t=e.exec(n);return t!==null&&t.index===0}else{if(mt(e))return e(n,0,[],{});if(x(e,"exec"))return e.exec(n,0,[],{});if(typeof e=="string")return e===n;throw Error("non exhaustive match")}}function mf(n){return Dt([".","\\","[","]","|","^","$","(",")","?","*","+","{"],t=>n.source.indexOf(t)!==-1)===void 0}function fs(n){const e=n.ignoreCase?"i":"";return new RegExp(`^(?:${n.source})`,e)}function hs(n){const e=n.ignoreCase?"iy":"y";return new RegExp(`${n.source}`,e)}function gf(n,e,t){const r=[];return x(n,an)||r.push({message:"A MultiMode Lexer cannot be initialized without a <"+an+`> property in its definition
` ,type:V.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),x(n,bn)||r.push({message:"A MultiMode Lexer cannot be initialized without a <"+bn+ ` > property in its definition
` ,type:V.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),x(n,bn)&&x(n,an)&&!x(n.modes,n.defaultMode)&&r.push({message: ` A MultiMode Lexer cannot be initialized with a $ { an } : < $ { n . defaultMode } > which does not exist
` ,type:V.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),x(n,bn)&&S(n.modes,(i,s)=>{S(i,(a,o)=>{if(ze(a))r.push({message: ` A Lexer cannot be initialized using an undefined Token Type . Mode : < $ { s } > at index : < $ { o } >
` ,type:V.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(x(a,"LONGER_ALT")){const l=Z(a.LONGER_ALT)?a.LONGER_ALT:[a.LONGER_ALT];S(l,c=>{!ze(c)&&!ue(i,c)&&r.push({message: ` A MultiMode Lexer cannot be initialized with a longer _alt < $ { c . name } > on token < $ { a . name } > outside of mode < $ { s } >
` ,type:V.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),r}function yf(n,e,t){const r=[];let i=!1;const s=hn(Ie(K(n.modes))),a=rr(s,l=>l[ht]===de.NA),o=yl(t);return e&&S(a,l=>{const c=gl(l,o);if(c!==!1){const d={message:Ef(l,c),type:c.issue,tokenType:l};r.push(d)}else x(l,"LINE_BREAKS")?l.LINE_BREAKS===!0&&(i=!0):wi(o,l.PATTERN)&&(i=!0)}),e&&!i&&r.push({message: ` Warning : No LINE _BREAKS Found .
2024-08-27 22:31:52 +08:00
This Lexer has been defined to track line and column information ,
But none of the Token Types can be identified as matching a line terminator .
See https : //chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
2024-09-04 13:02:35 +08:00
for details . ` ,type:V.NO_LINE_BREAKS_FLAGS}),r}function Tf(n){const e={},t=Mt(n);return S(t,r=>{const i=n[r];if(Z(i))e[r]=[];else throw Error("non exhaustive match")}),e}function ml(n){const e=n.PATTERN;if(qe(e))return!1;if(mt(e))return!0;if(x(e,"exec"))return!0;if(fe(e))return!1;throw Error("non exhaustive match")}function vf(n){return fe(n)&&n.length===1?n.charCodeAt(0):!1}const _f={test:function(n){const e=n.length;for(let t=this.lastIndex;t<e;t++){const r=n.charCodeAt(t);if(r===10)return this.lastIndex=t+1,!0;if(r===13)return n.charCodeAt(t+1)===10?this.lastIndex=t+2:this.lastIndex=t+1,!0}return!1},lastIndex:0};function gl(n,e){if(x(n,"LINE_BREAKS"))return!1;if(qe(n.PATTERN)){try{wi(e,n.PATTERN)}catch(t){return{issue:V.IDENTIFY_TERMINATOR,errMsg:t.message}}return!1}else{if(fe(n.PATTERN))return!1;if(ml(n))return{issue:V.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function Ef(n,e){if(e.issue===V.IDENTIFY_TERMINATOR)return ` Warning : unable to identify line terminator usage in pattern .
2024-08-27 22:31:52 +08:00
The problem is in the < $ { n . name } > Token Type
Root cause : $ { e . errMsg } .
2024-09-04 13:02:35 +08:00
For details See : https : //chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(e.issue===V.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
2024-08-27 22:31:52 +08:00
The problem is in the < $ { n . name } > Token Type
2024-09-04 13:02:35 +08:00
For details See : https : //chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function yl(n){return b(n,t=>fe(t)?t.charCodeAt(0):t)}function Nr(n,e,t){n[e]===void 0?n[e]=[t]:n[e].push(t)}const on=256;let xn=[];function et(n){return n<on?n:xn[n]}function Rf(){if(D(xn)){xn=new Array(65536);for(let n=0;n<65536;n++)xn[n]=n>255?255+~~(n/255):n}}function gn(n,e){const t=n.tokenTypeIdx;return t===e.tokenTypeIdx?!0:e.isParent===!0&&e.categoryMatchesMap[t]===!0}function jn(n,e){return n.tokenTypeIdx===e.tokenTypeIdx}let ps=1;const Tl={};function yn(n){const e=Af(n);bf(e),kf(e),Nf(e),S(e,t=>{t.isParent=t.categoryMatches.length>0})}function Af(n){let e=te(n),t=n,r=!0;for(;r;){t=hn(Ie(b(t,s=>s.CATEGORIES)));const i=nr(t,e);e=e.concat(i),D(i)?r=!1:t=i}return e}function bf(n){S(n,e=>{_l(e)||(Tl[ps]=e,e.tokenTypeIdx=ps++),ms(e)&&!Z(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),ms(e)||(e.CATEGORIES=[]),If(e)||(e.categoryMatches=[]),Sf(e)||(e.categoryMatchesMap={})})}function Nf(n){S(n,e=>{e.categoryMatches=[],S(e.categoryMatchesMap,(t,r)=>{e.categoryMatches.push(Tl[r].tokenTypeIdx)})})}function kf(n){S(n,e=>{vl([],e)})}function vl(n,e){S(n,t=>{e.categoryMatchesMap[t.tokenTypeIdx]=!0}),S(e.CATEGORIES,t=>{const r=n.concat(e);ue(r,t)||vl(r,t)})}function _l(n){return x(n,"tokenTypeIdx")}function ms(n){return x(n,"CATEGORIES")}function If(n){return x(n,"categoryMatches")}function Sf(n){return x(n,"categoryMatchesMap")}function xf(n){return x(n,"tokenTypeIdx")}const Cf={buildUnableToPopLexerModeMessage(n){return`Unable to pop Lexer Mode after encountering Token ->${n.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(n,e,t,r,i){return`unexpected character: ->${n.charAt(e)}<- at offset: ${e}, skipped ${t} characters.`}};var V;(function(n){n[n.MISSING_PATTERN=0]="MISSING_PATTERN",n[n.INVALID_PATTERN=1]="INVALID_PATTERN",n[n.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",n[n.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",n[n.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",n[n.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",n[n.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",n[n.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",n[n.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",n[n.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",n[n.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",n[n.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",n[n.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",n[n.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",n[n.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",n[n.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",n[n.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",n[n.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(V||(V={}));const ln={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
` ," \r "],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:Cf,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(ln);class de{constructor(e,t=ln){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(i,s)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;const a=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log( ` $ { a } -- > < $ { i } > ` );const{time:o,value:l}=ul(s),c=o>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&c( ` $ { a } < -- < $ { i } > time : $ { o } ms ` ),this.traceInitIndent--,l}else return s()},typeof t=="boolean")throw Error( ` The second argument to the Lexer constructor is now an ILexerConfig Object .
a boolean 2 nd argument is no longer supported ` );this.config=_e({},ln,t);const r=this.config.traceInitPerf;r===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof r=="number"&&(this.traceInitMaxIdent=r,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let i,s=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===ln.lineTerminatorsPattern)this.config.lineTerminatorsPattern=_f;else if(this.config.lineTerminatorCharacters===ln.lineTerminatorCharacters)throw Error( ` Error : Missing < lineTerminatorCharacters > property on the Lexer config .
For details See : https : //chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),Z(e)?i={modes:{defaultMode:te(e)},defaultMode:an}:(s=!1,i=te(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(gf(i,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(yf(i,this.trackStartLines,this.config.lineTerminatorCharacters))})),i.modes=i.modes?i.modes:{},S(i.modes,(o,l)=>{i.modes[l]=rr(o,c=>ze(c))});const a=Mt(i.modes);if(S(i.modes,(o,l)=>{this.TRACE_INIT(`Mode: <${l}> processing`,()=>{if(this.modes.push(l),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Zd(o,a))}),D(this.lexerDefinitionErrors)){yn(o);let c;this.TRACE_INIT("analyzeTokenTypes",()=>{c=Qd(o,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[l]=c.patternIdxToConfig,this.charCodeToPatternIdxToConfig[l]=c.charCodeToPatternIdxToConfig,this.emptyGroups=_e({},this.emptyGroups,c.emptyGroups),this.hasCustom=c.hasCustom||this.hasCustom,this.canModeBeOptimized[l]=c.canBeOptimized}})}),this.defaultMode=i.defaultMode,!D(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){const l=b(this.lexerDefinitionErrors,c=>c.message).join(`-----------------------
2024-08-27 22:31:52 +08:00
` );throw new Error( ` Errors detected in definition of Lexer :
2024-09-04 13:02:35 +08:00
` +l)}S(this.lexerDefinitionWarning,o=>{cl(o.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(pl?(this.chopInput=es,this.match=this.matchWithTest):(this.updateLastIndex=q,this.match=this.matchWithExec),s&&(this.handleModes=q),this.trackStartLines===!1&&(this.computeNewColumn=es),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=q),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error( ` Invalid < positionTracking > config option : "${this.config.positionTracking}" ` );this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{const o=oe(this.canModeBeOptimized,(l,c,u)=>(c===!1&&l.push(u),l),[]);if(t.ensureOptimizations&&!D(o))throw Error( ` Lexer Modes : < $ { o . join ( ", " ) } > cannot be optimized .
2024-08-27 22:31:52 +08:00
Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un - optimized mode .
2024-09-04 13:02:35 +08:00
Or inspect the console log for details on how to resolve these issues . ` )}),this.TRACE_INIT("clearRegExpParserCache",()=>{qd()}),this.TRACE_INIT("toFastProperties",()=>{dl(this)})})}tokenize(e,t=this.defaultMode){if(!D(this.lexerDefinitionErrors)){const i=b(this.lexerDefinitionErrors,s=>s.message).join( ` -- -- -- -- -- -- -- -- -- -- -- -
2024-08-27 22:31:52 +08:00
` );throw new Error( ` Unable to Tokenize because Errors detected in definition of Lexer :
2024-09-04 13:02:35 +08:00
` +i)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let r,i,s,a,o,l,c,u,d,f,h,m,g,_,y;const E=e,v=E.length;let I=0,j=0;const ne=this.hasCustom?0:Math.floor(e.length/10),Ce=new Array(ne),ge=[];let De=this.trackStartLines?1:void 0,be=this.trackStartLines?1:void 0;const A=Tf(this.emptyGroups),T=this.trackStartLines,R=this.config.lineTerminatorsPattern;let N=0,L=[],O=[];const w=[],ye=[];Object.freeze(ye);let z;function B(){return L}function at(re){const Ne=et(re),Tt=O[Ne];return Tt===void 0?ye:Tt}const jc=re=>{if(w.length===1&&re.tokenType.PUSH_MODE===void 0){const Ne=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(re);ge.push({offset:re.startOffset,line:re.startLine,column:re.startColumn,length:re.image.length,message:Ne})}else{w.pop();const Ne=jt(w);L=this.patternIdxToConfig[Ne],O=this.charCodeToPatternIdxToConfig[Ne],N=L.length;const Tt=this.canModeBeOptimized[Ne]&&this.config.safeMode===!1;O&&Tt?z=at:z=B}};function Yi(re){w.push(re),O=this.charCodeToPatternIdxToConfig[re],L=this.patternIdxToConfig[re],N=L.length,N=L.length;const Ne=this.canModeBeOptimized[re]&&this.config.safeMode===!1;O&&Ne?z=at:z=B}Yi.call(this,t);let we;const Xi=this.config.recoveryEnabled;for(;I<v;){l=null;const re=E.charCodeAt(I),Ne=z(re),Tt=Ne.length;for(r=0;r<Tt;r++){we=Ne[r];const Te=we.pattern;c=null;const Be=we.short;if(Be!==!1?re===Be&&(l=Te):we.isCustom===!0?(y=Te.exec(E,I,Ce,A),y!==null?(l=y[0],y.payload!==void 0&&(c=y.payload)):l=null):(this.updateLastIndex(Te,I),l=this.match(Te,e,I)),l!==null){if(o=we.longerAlt,o!==void 0){const Xe=o.length;for(s=0;s<Xe;s++){const He=L[o[s]],ot=He.pattern;if(u=null,He.isCustom===!0?(y=ot.exec(E,I,Ce,A),y!==null?(a=y[0],y.payload!==void 0&&(u=y.payload)):a=null):(this.updateLastIndex(ot,I),a=this.match(ot,e,I)),a&&a.length>l.length){l=a,c=u,we=He;break}}}break}}if(l!==null){if(d=l.length,f=we.group,f!==void 0&&(h=we.tokenTypeIdx,m=this.createTokenInstance(l,I,h,we.tokenType,De,be,d),this.handlePayload(m,c),f===!1?j=this.addToken(Ce,j,m):A[f].push(m)),e=this.chopInput(e,d),I=I+d,be=this.computeNewColumn(be,d),T===!0&&we.canLineTerminator===!0){let Te=0,Be,Xe;R.lastIndex=0;do Be=R.test(l),Be===!0&&(Xe=R.lastIndex-1,Te++);while(Be===!0);Te!==0&&(De=De+Te,be=d-Xe,this.updateTokenEndLineColumnLocation(m,f,Xe,Te,De,be,d))}this.handleModes(we,jc,Yi,m)}else{const Te=I,Be=De,Xe=be;let He=Xi===!1;for(;He===!1&&I<v;)for(e=this.chopInput(e,1),I++,i=0;i<N;i++){const ot=L[i],vr=ot.pattern,Ji=ot.short;if(Ji!==!1?E.charCodeAt(I)===Ji&&(He=!0):ot.isCustom===!0?He=vr.exec(E,I,Ce,A)!==null:(this.updateLastIndex(vr,I),He=vr.exec(e)!==null),He===!0)break}if(g=I-Te,be=this.computeNewColumn(be,g),_=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(E,Te,g,Be,Xe),ge.push({offset:Te,line:Be,column:Xe,length:g,message:_}),Xi===!1)break}}return this.hasCustom||(Ce.length=j),{tokens:Ce,groups:A,errors:ge}}handleModes(e,t,r,i){if(e.pop===!0){const s=e.push;t(i),s!==void 0&&r.call(this,s)}else e.push!==void 0&&r.call(this,e.push)}chopInput(e,t){return e.substring(t)}updateLastIndex(e,t){e.lastIndex=t}updateTokenEndLineColumnLocation(e,t,r,i,s,a,o){let l,c;t!==void 0&&(l=r===o-1,c=l?-1:0,i===1&&l===!0||(e.endLine=s+c,e.endColumn=a-1+-c))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,r,i){return{image:e,startOffset:t,tokenTypeIdx:r,tokenType:i}}createStartOnlyToken(e,t,r,i,s,a){return{image:e,startOffset:t,startLine:s,startColumn:a,tokenTypeIdx:r,tokenType:i}}createFullToken(e,t,r,i,s,a,o){return{image:e,startOffset:t,endOffset:t+o-1,startLine:s,endLine:s,startColumn:a,endColumn:a+o-1,tokenTypeIdx:r,tokenType:i}}addTokenUsingPush(e,t,r){return e.push(r),t}addTokenUsingMemberAccess(e,t,r){return e[t]=r,t++,t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){t!==null&&(e.payload=t)}matchWithTest(e,t,r){return e.test(t)===!0?t.substring(r,e.lastIndex):null}matchWithExec(e,t){const r=e.exec(t);return r!==null?r[0]:null}}de.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for examp
See : https : //github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return x(n,gs)&&(t.CATEGORIES=n[gs]),yn([t]),x(n,ys)&&(t.LABEL=n[ys]),x(n,Ts)&&(t.GROUP=n[Ts]),x(n,_s)&&(t.POP_MODE=n[_s]),x(n,vs)&&(t.PUSH_MODE=n[vs]),x(n,Es)&&(t.LONGER_ALT=n[Es]),x(n,Rs)&&(t.LINE_BREAKS=n[Rs]),x(n,As)&&(t.START_CHARS_HINT=n[As]),t}const tt=Rl({name:"EOF",pattern:de.NA});yn([tt]);function Oi(n,e,t,r,i,s,a,o){return{image:e,startOffset:t,endOffset:r,startLine:i,endLine:s,startColumn:a,endColumn:o,tokenTypeIdx:n.tokenTypeIdx,tokenType:n}}function Al(n,e){return gn(n,e)}const _t={buildMismatchTokenMessage({expected:n,actual:e,previous:t,ruleName:r}){return`Expecting ${El(n)?`--> ${Rt(n)} <--`:`token of type --> ${n.name} <--`} but found --> '${e.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:n,ruleName:e}){return"Redundant input, expecting EOF but found: "+n.image},buildNoViableAltMessage({expectedPathsPerAlt:n,actual:e,previous:t,customUserDescription:r,ruleName:i}){const s="Expecting: ",o=`
but found : '`+$e(e).image+"' ";if(r)return s+r+o;{const l=oe(n,(f,h)=>f.concat(h),[]),c=b(l,f=>`[${b(f,h=>Rt(h)).join(" , " ) } ] ` ),d= ` one of these possible Token sequences :
2024-08-27 22:31:52 +08:00
$ { b ( c , ( f , h ) => ` ${ h + 1 } . ${ f } ` ) . join ( `
` )} ` ; return s + d + o } } , buildEarlyExitMessage ( { expectedIterationPaths : n , actual : e , customUserDescription : t , ruleName : r } ) { const i = "Expecting: " , a = `
2024-09-04 13:02:35 +08:00
but found : '`+$e(e).image+"' " ; if ( t ) return i + t + a ; { const l = ` expecting at least one iteration which starts with one of these possible Token sequences::
< $ { b ( n , c => ` [ ${ b ( c , u => Rt ( u ) ) . join ( "," ) } ] ` ) . join ( " ," ) } > ` ;return i+l+a}}};Object.freeze(_t);const Lf={buildRuleNotFoundError(n,e){return"Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+ ` < -
inside top level rule : - > ` +n.name+"<-"}},ct={buildDuplicateFoundError(n,e){function t(u){return u instanceof G?u.terminalType.name:u instanceof le?u.nonTerminalName:""}const r=n.name,i= $ e(e),s=i.idx,a=je(i),o=t(i),l=s>0;let c= ` - > $ { a } $ { l ? s : "" } < - $ { o ? ` with argument: -> ${ o } <- ` : "" }
2024-08-27 22:31:52 +08:00
appears more than once ( $ { e . length } times ) in the top level rule : - > $ { r } < - .
For further details see : https : //chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
` ;return c=c.replace(/[ \t ]+/g," "),c=c.replace(/ \s \s +/g, `
` ),c},buildNamespaceConflictError(n){return ` Namespace conflict found in grammar .
The grammar has both a Terminal ( Token ) and a Non - Terminal ( Rule ) named : < $ { n . name } > .
To resolve this make sure each Terminal and Non - Terminal names are unique
This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
and Non - Terminal names start with a lower case letter . ` },buildAlternationPrefixAmbiguityError(n){const e=b(n.prefixPath,i=>Rt(i)).join(", "),t=n.alternation.idx===0?"":n.alternation.idx;return ` Ambiguous alternatives : < $ { n . ambiguityIndices . join ( " ," ) } > due to common lookahead prefix
in < OR$ { t } > inside < $ { n . topLevelRule . name } > Rule ,
< $ { e } > may appears as a prefix path in all these alternatives .
See : https : //chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
For Further details . ` },buildAlternationAmbiguityError(n){const e=b(n.prefixPath,i=>Rt(i)).join(", "),t=n.alternation.idx===0?"":n.alternation.idx;let r= ` Ambiguous Alternatives Detected : < $ { n . ambiguityIndices . join ( " ," ) } > in < OR$ { t } > inside < $ { n . topLevelRule . name } > Rule ,
< $ { e } > may appears as a prefix path in all these alternatives .
` ;return r=r+ ` See : https : //chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
2024-09-04 13:02:35 +08:00
For Further details . ` ,r},buildEmptyRepetitionError(n){let e=je(n.repetition);return n.repetition.idx!==0&&(e+=n.repetition.idx), ` The repetition < $ { e } > within Rule < $ { n . topLevelRule . name } > can never consume any tokens .
2024-08-27 22:31:52 +08:00
This could lead to an infinite loop . ` },buildTokenNameError(n){return"deprecated"},buildEmptyAlternationError(n){return ` Ambiguous empty alternative : < $ { n . emptyChoiceIdx + 1 } > in < OR$ { n . alternation . idx } > inside < $ { n . topLevelRule . name } > Rule .
Only the last alternative may be an empty alternative . ` },buildTooManyAlternativesError(n){return ` An Alternation cannot have more than 256 alternatives :
< OR$ { n . alternation . idx } > inside < $ { n . topLevelRule . name } > Rule .
has $ { n . alternation . definition . length + 1 } alternatives . ` },buildLeftRecursionError(n){const e=n.topLevelRule.name,t=b(n.leftRecursionPath,s=>s.name),r= ` $ { e } -- > $ { t . concat ( [ e ] ) . join ( " --> " ) } ` ;return ` Left Recursion found in grammar .
rule : < $ { e } > can be invoked from itself ( directly or indirectly )
without consuming any Tokens . The grammar path that causes this is :
$ { r }
To fix this refactor your grammar to remove the left recursion .
2024-09-04 13:02:35 +08:00
see : https : //en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(n){return"deprecated"},buildDuplicateRuleNameError(n){let e;return n.topLevelRule instanceof qt?e=n.topLevelRule.name:e=n.topLevelRule,`Duplicate definition, rule: ->${e}<- is already defined in the grammar: ->${n.grammarName}<-`}};function $f(n,e){const t=new Pf(n,e);return t.resolveRefs(),t.errors}class Pf extends Yt{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){S(K(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){const t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{const r=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:r,type:ce.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}}class Mf extends ur{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=te(this.path.ruleStack).reverse(),this.occurrenceStack=te(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,r){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){const i=t.concat(r);this.updateExpectedNext(),this.walk(e.referencedRule,i)}}updateExpectedNext(){D(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}}class Df extends Mf{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,r){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){const i=t.concat(r),s=new he({definition:i});this.possibleTokTypes=mn(s),this.found=!0}}}class fr extends ur{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class jf extends fr{walkMany(e,t,r){if(e.idx===this.occurrence){const i=$e(t.concat(r));this.result.isEndOfRule=i===void 0,i instanceof G&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkMany(e,t,r)}}class bs extends fr{walkManySep(e,t,r){if(e.idx===this.occurrence){const i=$e(t.concat(r));this.result.isEndOfRule=i===void 0,i instanceof G&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkManySep(e,t,r)}}class Gf extends fr{walkAtLeastOne(e,t,r){if(e.idx===this.occurrence){const i=$e(t.concat(r));this.result.isEndOfRule=i===void 0,i instanceof G&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOne(e,t,r)}}class Ns extends fr{walkAtLeastOneSep(e,t,r){if(e.idx===this.occurrence){const i=$e(t.concat(r));this.result.isEndOfRule=i===void 0,i instanceof G&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOneSep(e,t,r)}}function Br(n,e,t=[]){t=te(t);let r=[],i=0;function s(o){return o.concat(J(n,i+1))}function a(o){const l=Br(s(o),e,t);return r.concat(l)}for(;t.length<e&&i<n.length;){const o=n[i];if(o instanceof he)return a(o.definition);if(o instanceof le)return a(o.definition);if(o instanceof ee)r=a(o.definition);else if(o instanceof Re){const l=o.definition.concat([new H({definition:o.definition})]);return a(l)}else if(o instanceof Ae){const l=[new he({definition:o.definition}),new H({definition:[new G({terminalType:o.separator})].concat(o.definition)})];return a(l)}else if(o instanceof pe){const l=o.
2024-08-27 22:31:52 +08:00
$ { s . join ( `
` ).replace(/ \n /g, `
2024-09-04 13:02:35 +08:00
` )} ` ) } } } ; return t . prototype = r , t . prototype . constructor = t , t . _RULE _NAMES = e , t } function kh ( n , e , t ) { const r = function ( ) { } ; Gl ( r , n + "BaseSemanticsWithDefaults" ) ; const i = Object . create ( t . prototype ) ; return S ( e , s => { i [ s ] = bh } ) , r . prototype = i , r . prototype . constructor = r , r } var zr ; ( function ( n ) { n [ n . REDUNDANT _METHOD = 0 ] = "REDUNDANT_METHOD" , n [ n . MISSING _METHOD = 1 ] = "MISSING_METHOD" } ) ( zr || ( zr = { } ) ) ; function Ih ( n , e ) { return Sh ( n , e ) } function Sh ( n , e ) { const t = Ee ( e , i => mt ( n [ i ] ) === ! 1 ) , r = b ( t , i => ( { msg : ` Missing visitor method: < ${ i } > on ${ n . constructor . name } CST Visitor. ` , type : zr . MISSING _METHOD , methodName : i } ) ) ; return hn ( r ) } class xh { initTreeBuilder ( e ) { if ( this . CST _STACK = [ ] , this . outputCst = e . outputCst , this . nodeLocationTracking = x ( e , "nodeLocationTracking" ) ? e . nodeLocationTracking : Ye . nodeLocationTracking , ! this . outputCst ) this . cstInvocationStateUpdate = q , this . cstFinallyStateUpdate = q , this . cstPostTerminal = q , this . cstPostNonTerminal = q , this . cstPostRule = q ; else if ( /full/i . test ( this . nodeLocationTracking ) ) this . recoveryEnabled ? ( this . setNodeLocationFromToken = xs , this . setNodeLocationFromNode = xs , this . cstPostRule = q , this . setInitialNodeLocation = this . setInitialNodeLocationFullRecovery ) : ( this . setNodeLocationFromToken = q , this . setNodeLocationFromNode = q , this . cstPostRule = this . cstPostRuleFull , this . setInitialNodeLocation = this . setInitialNodeLocationFullRegular ) ; else if ( /onlyOffset/i . test ( this . nodeLocationTracking ) ) this . recoveryEnabled ? ( this . setNodeLocationFromToken = Ss , this . setNodeLocationFromNode = Ss , this . cstPostRule = q , this . setInitialNodeLocation = this . setInitialNodeLocationOnlyOffsetRecovery ) : ( this . setNodeLocationFromToken = q , this . setNodeLocationFromNode = q , this . cstPostRule = this . cstPostRuleOnlyOffset , this . setInitialNodeLocation = this . setInitialNodeLocationOnlyOffsetRegular ) ; else if ( /none/i . test ( this . nodeLocationTracking ) ) this . setNodeLocationFromToken = q , this . setNodeLocationFromNode = q , this . cstPostRule = q , this . setInitialNodeLocation = q ; else throw Error ( ` Invalid <nodeLocationTracking> config option: " ${ e . nodeLocationTracking } " ` ) } setInitialNodeLocationOnlyOffsetRecovery ( e ) { e . location = { startOffset : NaN , endOffset : NaN } } setInitialNodeLocationOnlyOffsetRegular ( e ) { e . location = { startOffset : this . LA ( 1 ) . startOffset , endOffset : NaN } } setInitialNodeLocationFullRecovery ( e ) { e . location = { startOffset : NaN , startLine : NaN , startColumn : NaN , endOffset : NaN , endLine : NaN , endColumn : NaN } } setInitialNodeLocationFullRegular ( e ) { const t = this . LA ( 1 ) ; e . location = { startOffset : t . startOffset , startLine : t . startLine , startColumn : t . startColumn , endOffset : NaN , endLine : NaN , endColumn : NaN } } cstInvocationStateUpdate ( e ) { const t = { name : e , children : Object . create ( null ) } ; this . setInitialNodeLocation ( t ) , this . CST _STACK . push ( t ) } cstFinallyStateUpdate ( ) { this . CST _STACK . pop ( ) } cstPostRuleFull ( e ) { const t = this . LA ( 0 ) , r = e . location ; r . startOffset <= t . startOffset ? ( r . endOffset = t . endOffset , r . endLine = t . endLine , r . endColumn = t . endColumn ) : ( r . startOffset = NaN , r . startLine = NaN , r . startColumn = NaN ) } cstPostRuleOnlyOffset ( e ) { const t = this . LA ( 0 ) , r = e . location ; r . startOffset <= t . startOffset ? r . endOffset = t . endOffset : r . startOffset = NaN } cstPostTerminal ( e , t ) { const r = this . CST _STACK [ this . CST _STACK . length - 1 ] ; Eh ( r , t , e ) , this . setNodeLocationFromToken ( r . location , t ) } cstPostNonTerminal ( e , t ) { const r = this . CST _STACK [ this . CST _STACK . length - 1 ] ; Rh ( r , t , e ) , this . setNodeLocationFromNode ( r . location , e . location ) } getBaseCstVisitorConstructor ( ) { if ( ze ( this . baseCstVisitorConstructor ) ) { const e = Nh ( this . className , Mt ( this . gastProductionsCache ) ) ; return this . baseCstVisitorConstructor = e , e } return this . baseCstVisitorConstructor } getBaseCstVisitorConstructorWithDefaults ( ) { if ( ze ( this . baseCstVisitorWithDefaultsConstructor ) ) { const e = kh ( this . className , Mt ( this . gastProductionsCache ) , this . getBaseCstVisitorConstructor ( ) ) ; return this . baseCstVisitorWithDefaultsConstructor = e , e } return this . baseCstVisitorWithDefaultsConstructor } getLastExplicitRuleShortName ( ) { const e = this . RULE _STACK ; return e [ e . length - 1 ] } getPreviousExplicitRuleShortName ( ) { const e = this . RULE _STACK ; return e [ e . length - 2 ] } getLastExplicitRuleOccurrenceIndex ( ) { const e = this . RULE _OCCURRENCE _STACK ; return e [ e . length - 1 ] } } class Ch { initLexerAdapter ( ) { this . tokVector = [ ] , this . tokVectorLength = 0 , this . currIdx = - 1 } set input ( e ) { i
2024-08-27 22:31:52 +08:00
See : https : //chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
For Further details . ` );if(Z(e)){if(D(e))throw Error( ` A Token Vocabulary cannot be empty .
Note that the first argument for the parser constructor
is no longer a Token vector ( since v4 . 0 ) . ` );if(typeof e[0].startOffset=="number")throw Error( ` The Parser constructor no longer accepts a token vector as the first argument .
See : https : //chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
2024-09-04 13:02:35 +08:00
For Further details . ` )}if(Z(e))this.tokensMap=oe(e,(s,a)=>(s[a.name]=a,s),{});else if(x(e,"modes")&&Oe(Ie(K(e.modes)),xf)){const s=Ie(K(e.modes)),a=Ri(s);this.tokensMap=oe(a,(o,l)=>(o[l.name]=l,o),{})}else if(tu(e))this.tokensMap=te(e);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=tt;const r=x(e,"modes")?Ie(K(e.modes)):K(e),i=Oe(r,s=>D(s.categoryMatches));this.tokenMatcher=i?jn:gn,yn(K(this.tokensMap))}defineRule(e,t,r){if(this.selfAnalysisDone)throw Error( ` Grammar rule < $ { e } > may not be defined after the 'performSelfAnalysis' method has been called '
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called . ` );const i=x(r,"resyncEnabled")?r.resyncEnabled:Bn.resyncEnabled,s=x(r,"recoveryValueFunc")?r.recoveryValueFunc:Bn.recoveryValueFunc,a=this.ruleShortNameIdx<<yh+it;this.ruleShortNameIdx++,this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a;let o;return this.outputCst===!0?o=function(...u){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,u);const d=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(d),d}catch(d){return this.invokeRuleCatch(d,i,s)}finally{this.ruleFinallyStateUpdate()}}:o=function(...u){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,u)}catch(d){return this.invokeRuleCatch(d,i,s)}finally{this.ruleFinallyStateUpdate()}},Object.assign(o,{ruleName:e,originalGrammarAction:t})}invokeRuleCatch(e,t,r){const i=this.RULE_STACK.length===1,s=t&&!this.isBackTracking()&&this.recoveryEnabled;if(Gn(e)){const a=e;if(s){const o=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(o))if(a.resyncedTokens=this.reSyncTo(o),this.outputCst){const l=this.CST_STACK[this.CST_STACK.length-1];return l.recoveredNode=!0,l}else return r(e);else{if(this.outputCst){const l=this.CST_STACK[this.CST_STACK.length-1];l.recoveredNode=!0,a.partialCstResult=l}throw a}}else{if(i)return this.moveToTerminatedState(),r(e);throw a}}else throw e}optionInternal(e,t){const r=this.getKeyForAutomaticLookahead(jl,t);return this.optionInternalLogic(e,t,r)}optionInternalLogic(e,t,r){let i=this.getLaFuncFromCache(r),s;if(typeof e!="function"){s=e.DEF;const a=e.GATE;if(a!==void 0){const o=i;i=()=>a.call(this)&&o.call(this)}}else s=e;if(i.call(this)===!0)return s.call(this)}atLeastOneInternal(e,t){const r=this.getKeyForAutomaticLookahead(Wr,e);return this.atLeastOneInternalLogic(e,t,r)}atLeastOneInternalLogic(e,t,r){let i=this.getLaFuncFromCache(r),s;if(typeof t!="function"){s=t.DEF;const a=t.GATE;if(a!==void 0){const o=i;i=()=>a.call(this)&&o.call(this)}}else s=t;if(i.call(this)===!0){let a=this.doSingleRepetition(s);for(;i.call(this)===!0&&a===!0;)a=this.doSingleRepetition(s)}else throw this.raiseEarlyExitException(e,F.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],i,Wr,e,Gf)}atLeastOneSepFirstInternal(e,t){const r=this.getKeyForAutomaticLookahead(wn,e);this.atLeastOneSepFirstInternalLogic(e,t,r)}atLeastOneSepFirstInternalLogic(e,t,r){const i=t.DEF,s=t.SEP;if(this.getLaFuncFromCache(r).call(this)===!0){i.call(this);const o=()=>this.tokenMatcher(this.LA(1),s);for(;this.tokenMatcher(this.LA(1),s)===!0;)this.CONSUME(s),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,s,o,i,Ns],o,wn,e,Ns)}else throw this.raiseEarlyExitException(e,F.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){const r=this.getKeyForAutomaticLookahead(Vr,e);return this.manyInternalLogic(e,t,r)}manyInternalLogic(e,t,r){let i=this.getLaFuncFromCache(r),s;if(typeof t!="function"){s=t.DEF;const o=t.GATE;if(o!==void 0){const l=i;i=()=>o.call(this)&&l.call(this)}}else s=t;let a=!0;for(;i.call(this)===!0&&a===!0;)a=this.doSingleRepetition(s);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],i,Vr,e,jf,a)}manySepFirstInternal(e,t){const r=this.getKeyForAutomaticLookahead(Kr,e);this.manySepFirstInternalLogic(e,t,r)}manySepFirstInternalLogic(e,t,r){const i=t.DEF,s=t.SEP;if(this.getLaFuncFromCache(r).call(this)===!0){i.call(this);const o=()=>this.tokenMatcher(this.LA(1),s);for(;this.tokenMatcher(this.LA(1),s)===!0;)this.CONSUME(s),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,s,o,i,bs],o,Kr,e,bs)}}repetitionSepSecondInternal(e,t,r,i,s){for(;r();)this.CONSUME(t),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,r,i,s],r,wn,e,s)}doSingleRepetition(e){const t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){const r=this.getKeyForAutomaticLookahead(Dl,t),i=Z(e)?e:e.DEF,a=this.getLaFuncFromCache(r).call(this,i);if(a!==void 0)return i[a].AL
See : https : //chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Fl);const Ph={name:`This CSTNode indicates the Parser is in Recording Phase
See : https : //chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};class Mh{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){const t=e>0?e:"";this[`CONSUME${t}`]=function(r,i){return this.consumeInternalRecord(r,e,i)},this[`SUBRULE${t}`]=function(r,i){return this.subruleInternalRecord(r,e,i)},this[`OPTION${t}`]=function(r){return this.optionInternalRecord(r,e)},this[`OR${t}`]=function(r){return this.orInternalRecord(r,e)},this[`MANY${t}`]=function(r){this.manyInternalRecord(e,r)},this[`MANY_SEP${t}`]=function(r){this.manySepFirstInternalRecord(e,r)},this[`AT_LEAST_ONE${t}`]=function(r){this.atLeastOneInternalRecord(e,r)},this[`AT_LEAST_ONE_SEP${t}`]=function(r){this.atLeastOneSepFirstInternalRecord(e,r)}}this.consume=function(e,t,r){return this.consumeInternalRecord(t,e,r)},this.subrule=function(e,t,r){return this.subruleInternalRecord(t,e,r)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{const e=this;for(let t=0;t<10;t++){const r=t>0?t:"";delete e[`CONSUME${r}`],delete e[`SUBRULE${r}`],delete e[`OPTION${r}`],delete e[`OR${r}`],delete e[`MANY${r}`],delete e[`MANY_SEP${r}`],delete e[`AT_LEAST_ONE${r}`],delete e[`AT_LEAST_ONE_SEP${r}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return Fn}topLevelRuleRecord(e,t){try{const r=new qt({definition:[],name:e});return r.name=e,this.recordingProdStack.push(r),t.call(this),this.recordingProdStack.pop(),r}catch(r){if(r.KNOWN_RECORDER_ERROR!==!0)try{r.message=r.message+`
2024-08-27 22:31:52 +08:00
This error was thrown during the "grammar recording phase" For more info see :
2024-09-04 13:02:35 +08:00
https : //chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw r}throw r}}optionInternalRecord(e,t){return rn.call(this,ee,e,t)}atLeastOneInternalRecord(e,t){rn.call(this,Re,t,e)}atLeastOneSepFirstInternalRecord(e,t){rn.call(this,Ae,t,e,Cs)}manyInternalRecord(e,t){rn.call(this,H,t,e)}manySepFirstInternalRecord(e,t){rn.call(this,pe,t,e,Cs)}orInternalRecord(e,t){return Dh.call(this,e,t)}subruleInternalRecord(e,t,r){if(Un(t),!e||x(e,"ruleName")===!1){const o=new Error(`<SUBRULE${Os(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
inside top level rule : < $ { this . recordingProdStack [ 0 ] . name } > ` );throw o.KNOWN_RECORDER_ERROR=!0,o}const i=jt(this.recordingProdStack),s=e.ruleName,a=new le({idx:t,nonTerminalName:s,label:r==null?void 0:r.LABEL,referencedRule:void 0});return i.definition.push(a),this.outputCst?Ph:gr}consumeInternalRecord(e,t,r){if(Un(t),!_l(e)){const a=new Error( ` < CONSUME$ { Os ( t ) } > argument is invalid expecting a TokenType reference but got : < $ { JSON . stringify ( e ) } >
inside top level rule : < $ { this . recordingProdStack [ 0 ] . name } > ` );throw a.KNOWN_RECORDER_ERROR=!0,a}const i=jt(this.recordingProdStack),s=new G({idx:t,terminalType:e,label:r==null?void 0:r.LABEL});return i.definition.push(s),Fl}}function rn(n,e,t,r=!1){Un(t);const i=jt(this.recordingProdStack),s=mt(e)?e:e.DEF,a=new n({definition:[],idx:t});return r&&(a.separator=e.SEP),x(e,"MAX_LOOKAHEAD")&&(a.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(a),s.call(this),i.definition.push(a),this.recordingProdStack.pop(),gr}function Dh(n,e){Un(e);const t=jt(this.recordingProdStack),r=Z(n)===!1,i=r===!1?n:n.DEF,s=new me({definition:[],idx:e,ignoreAmbiguities:r&&n.IGNORE_AMBIGUITIES===!0});x(n,"MAX_LOOKAHEAD")&&(s.maxLookahead=n.MAX_LOOKAHEAD);const a=po(i,o=>mt(o.GATE));return s.hasPredicates=a,t.definition.push(s),S(i,o=>{const l=new he({definition:[]});s.definition.push(l),x(o,"IGNORE_AMBIGUITIES")?l.ignoreAmbiguities=o.IGNORE_AMBIGUITIES:x(o,"GATE")&&(l.ignoreAmbiguities=!0),this.recordingProdStack.push(l),o.ALT.call(this),this.recordingProdStack.pop()}),gr}function Os(n){return n===0?"": ` $ { n } ` }function Un(n){if(n<0||n>ws){const e=new Error( ` Invalid DSL Method idx value : < $ { n } >
Idx value must be a none negative value smaller than $ { ws + 1 } ` );throw e.KNOWN_RECORDER_ERROR=!0,e}}class jh{initPerformanceTracer(e){if(x(e,"traceInitPerf")){const t=e.traceInitPerf,r=typeof t=="number";this.traceInitMaxIdent=r?t:1/0,this.traceInitPerf=r?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=Ye.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;const r=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log( ` $ { r } -- > < $ { e } > ` );const{time:i,value:s}=ul(t),a=i>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a( ` $ { r } < -- < $ { e } > time : $ { i } ms ` ),this.traceInitIndent--,s}else return t()}}function Gh(n,e){e.forEach(t=>{const r=t.prototype;Object.getOwnPropertyNames(r).forEach(i=>{if(i==="constructor")return;const s=Object.getOwnPropertyDescriptor(r,i);s&&(s.get||s.set)?Object.defineProperty(n.prototype,i,s):n.prototype[i]=t.prototype[i]})})}const Fn=Oi(tt,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Fn);const Ye=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:_t,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),Bn=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0});var ce;(function(n){n[n.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",n[n.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",n[n.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",n[n.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",n[n.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",n[n.LEFT_RECURSION=5]="LEFT_RECURSION",n[n.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",n[n.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",n[n.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",n[n.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",n[n.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",n[n.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",n[n.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",n[n.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(ce||(ce={}));function Ls(n=void 0){return function(){return n}}class Tn{static performSelfAnalysis(e){throw Error("The **static** ` performSelfAnalysis ` method has been deprecated. \n Use the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let e;this.selfAnalysisDone=!0;const t=this.className;this.TRACE_INIT("toFastProps",()=>{dl(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),S(this.definedRulesNames,i=>{const a=this[i].originalGrammarAction;let o;this.TRACE_INIT( ` $ { i } Rule ` ,()=>{o=this.topLevelRuleRecord(i,a)}),this.gastProductionsCache[i]=o})}finally{this.disableRecording()}});let r=[];if(this.TRACE_INIT("Grammar Resolving",()=>{r=ch({rules:K(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(r)}),this.TRACE_INIT("Grammar Validations",()=>{if(D(r)&&this.skipValidations===!1){const i=uh({rules:K(this.gastProductionsCache),tokenTypes:K(this.tokensMap),errMsgProvider:ct,grammarName:t}),s=qf({lookaheadStrategy:this.lookaheadStrategy,rules:K(this.gastProductionsCache),tokenTypes:K(this.tokensMap),grammarName:t});this.definitionErrors=this.definitionErrors.concat(i,s)}}),D(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{const i=Wd(K(this.gastProductionsCache));this.resyncFollows=i}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var i,s;(s=(i=this.lookaheadStrategy).initialize)===null||s===void 0||s.call(i,{rules:K(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(K(this.gastProductionsCache))})),!Tn.DEFER_DEFINITION_ERRORS_HANDLING&&!D(this.definitionErrors))throw e=b(this.definitionErrors,i=>i.message),new Error( ` Parser Definition Errors detected :
2024-08-27 22:31:52 +08:00
$ { e . join ( `
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
2024-09-04 13:02:35 +08:00
` )} ` ) } ) } constructor ( e , t ) { this . definitionErrors = [ ] , this . selfAnalysisDone = ! 1 ; const r = this ; if ( r . initErrorHandler ( t ) , r . initLexerAdapter ( ) , r . initLooksAhead ( t ) , r . initRecognizerEngine ( e , t ) , r . initRecoverable ( t ) , r . initTreeBuilder ( t ) , r . initContentAssist ( ) , r . initGastRecorder ( t ) , r . initPerformanceTracer ( t ) , x ( t , "ignoredIssues" ) ) throw new Error ( ` The <ignoredIssues> IParserConfig property has been deprecated.
2024-08-27 22:31:52 +08:00
Please use the < IGNORE _AMBIGUITIES > flag on the relevant DSL method instead .
See : https : //chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
2024-09-04 13:02:35 +08:00
For further details . ` );this.skipValidations=x(t,"skipValidations")?t.skipValidations:Ye.skipValidations}}Tn.DEFER_DEFINITION_ERRORS_HANDLING=!1;Gh(Tn,[mh,Th,xh,Ch,Oh,wh,Lh, $ h,Mh,jh]);class Uh extends Tn{constructor(e,t=Ye){const r=te(t);r.outputCst=!1,super(e,r)}}function Ut(n,e,t){return ` $ { n . name } _$ { e } _$ { t } ` }const nt=1,Fh=2,Bl=4,Hl=5,vn=7,Bh=8,Hh=9,Vh=10,Wh=11,Vl=12;class Mi{constructor(e){this.target=e}isEpsilon(){return!1}}class Di extends Mi{constructor(e,t){super(e),this.tokenType=t}}class Wl extends Mi{constructor(e){super(e)}isEpsilon(){return!0}}class ji extends Mi{constructor(e,t,r){super(e),this.rule=t,this.followState=r}isEpsilon(){return!0}}function Kh(n){const e={decisionMap:{},decisionStates:[],ruleToStartState:new Map,ruleToStopState:new Map,states:[]};zh(e,n);const t=n.length;for(let r=0;r<t;r++){const i=n[r],s=yt(e,i,i);s!==void 0&&ip(e,i,s)}return e}function zh(n,e){const t=e.length;for(let r=0;r<t;r++){const i=e[r],s=Y(n,i,void 0,{type:Fh}),a=Y(n,i,void 0,{type:vn});s.stop=a,n.ruleToStartState.set(i,s),n.ruleToStopState.set(i,a)}}function Kl(n,e,t){return t instanceof G?Gi(n,e,t.terminalType,t):t instanceof le?rp(n,e,t):t instanceof me?Qh(n,e,t):t instanceof ee?Zh(n,e,t):t instanceof H?qh(n,e,t):t instanceof pe?Yh(n,e,t):t instanceof Re?Xh(n,e,t):t instanceof Ae?Jh(n,e,t):yt(n,e,t)}function qh(n,e,t){const r=Y(n,e,t,{type:Hl});st(n,r);const i=Xt(n,e,r,t,yt(n,e,t));return ql(n,e,t,i)}function Yh(n,e,t){const r=Y(n,e,t,{type:Hl});st(n,r);const i=Xt(n,e,r,t,yt(n,e,t)),s=Gi(n,e,t.separator,t);return ql(n,e,t,i,s)}function Xh(n,e,t){const r=Y(n,e,t,{type:Bl});st(n,r);const i=Xt(n,e,r,t,yt(n,e,t));return zl(n,e,t,i)}function Jh(n,e,t){const r=Y(n,e,t,{type:Bl});st(n,r);const i=Xt(n,e,r,t,yt(n,e,t)),s=Gi(n,e,t.separator,t);return zl(n,e,t,i,s)}function Qh(n,e,t){const r=Y(n,e,t,{type:nt});st(n,r);const i=b(t.definition,a=>Kl(n,e,a));return Xt(n,e,r,t,...i)}function Zh(n,e,t){const r=Y(n,e,t,{type:nt});st(n,r);const i=Xt(n,e,r,t,yt(n,e,t));return ep(n,e,t,i)}function yt(n,e,t){const r=Ee(b(t.definition,i=>Kl(n,e,i)),i=>i!==void 0);return r.length===1?r[0]:r.length===0?void 0:np(n,r)}function zl(n,e,t,r,i){const s=r.left,a=r.right,o=Y(n,e,t,{type:Wh});st(n,o);const l=Y(n,e,t,{type:Vl});return s.loopback=o,l.loopback=o,n.decisionMap[Ut(e,i?"RepetitionMandatoryWithSeparator":"RepetitionMandatory",t.idx)]=o,W(a,o),i===void 0?(W(o,s),W(o,l)):(W(o,l),W(o,i.left),W(i.right,s)),{left:s,right:l}}function ql(n,e,t,r,i){const s=r.left,a=r.right,o=Y(n,e,t,{type:Vh});st(n,o);const l=Y(n,e,t,{type:Vl}),c=Y(n,e,t,{type:Hh});return o.loopback=c,l.loopback=c,W(o,s),W(o,l),W(a,c),i!==void 0?(W(c,l),W(c,i.left),W(i.right,s)):W(c,o),n.decisionMap[Ut(e,i?"RepetitionWithSeparator":"Repetition",t.idx)]=o,{left:o,right:l}}function ep(n,e,t,r){const i=r.left,s=r.right;return W(i,s),n.decisionMap[Ut(e,"Option",t.idx)]=i,r}function st(n,e){return n.decisionStates.push(e),e.decision=n.decisionStates.length-1,e.decision}function Xt(n,e,t,r,...i){const s=Y(n,e,r,{type:Bh,start:t});t.end=s;for(const o of i)o!==void 0?(W(t,o.left),W(o.right,s)):W(t,s);const a={left:t,right:s};return n.decisionMap[Ut(e,tp(r),r.idx)]=t,a}function tp(n){if(n instanceof me)return"Alternation";if(n instanceof ee)return"Option";if(n instanceof H)return"Repetition";if(n instanceof pe)return"RepetitionWithSeparator";if(n instanceof Re)return"RepetitionMandatory";if(n instanceof Ae)return"RepetitionMandatoryWithSeparator";throw new Error("Invalid production type encountered")}function np(n,e){const t=e.length;for(let s=0;s<t-1;s++){const a=e[s];let o;a.left.transitions.length===1&&(o=a.left.transitions[0]);const l=o instanceof ji,c=o,u=e[s+1].left;a.left.type===nt&&a.right.type===nt&&o!==void 0&&(l&&c.followState===a.right||o.target===a.right)?(l?c.followState=u:o.target=u,sp(n,a.right)):W(a.right,u)}const r=e[0],i=e[t-1];return{left:r.left,right:i.right}}function Gi(n,e,t,r){const i=Y(n,e,r,{type:nt}),s=Y(n,e,r,{type:nt});return Ui(i,new Di(s,t)),{left:i,right:s}}function rp(n,e,t){const r=t.referencedRule,i=n.ruleToStartState.get(r),s=Y(n,e,t,{type:nt}),a=Y(n,e,t
2024-08-27 22:31:52 +08:00
< $ { e } > may appears as a prefix path in all these alternatives .
` ;return r=r+ ` See : https : //chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
2024-09-04 13:02:35 +08:00
For Further details . ` ,r}function hp(n){if(n instanceof le)return"SUBRULE";if(n instanceof ee)return"OPTION";if(n instanceof me)return"OR";if(n instanceof Re)return"AT_LEAST_ONE";if(n instanceof Ae)return"AT_LEAST_ONE_SEP";if(n instanceof pe)return"MANY_SEP";if(n instanceof H)return"MANY";if(n instanceof G)return"CONSUME";throw Error("non exhaustive match")}function pp(n,e,t){const r=ve(e.configs.elements,s=>s.state.transitions),i=bu(r.filter(s=>s instanceof Di).map(s=>s.tokenType),s=>s.tokenTypeIdx);return{actualToken:t,possibleTokenTypes:i,tokenPath:n}}function mp(n,e){return n.edges[e.tokenTypeIdx]}function gp(n,e,t){const r=new qr,i=[];for(const a of n.elements){if(t.is(a.alt)===!1)continue;if(a.state.type===vn){i.push(a);continue}const o=a.state.transitions.length;for(let l=0;l<o;l++){const c=a.state.transitions[l],u=yp(c,e);u!==void 0&&r.add({state:u,alt:a.alt,stack:a.stack})}}let s;if(i.length===0&&r.size===1&&(s=r),s===void 0){s=new qr;for(const a of r.elements)Vn(a,s)}if(i.length>0&&!Ep(s))for(const a of i)s.add(a);return s}function yp(n,e){if(n instanceof Di&&Al(e,n.tokenType))return n.target}function Tp(n,e){let t;for(const r of n.elements)if(e.is(r.alt)===!0){if(t===void 0)t=r.alt;else if(t!==r.alt)return}return t}function Jl(n){return{configs:n,edges:{},isAcceptState:!1,prediction:-1}}function Ms(n,e,t,r){return r=Ql(n,r),e.edges[t.tokenTypeIdx]=r,r}function Ql(n,e){if(e===Hn)return e;const t=e.configs.key,r=n.states[t];return r!==void 0?r:(e.configs.finalize(),n.states[t]=e,e)}function vp(n){const e=new qr,t=n.transitions.length;for(let r=0;r<t;r++){const s={state:n.transitions[r].target,alt:r,stack:[]};Vn(s,e)}return e}function Vn(n,e){const t=n.state;if(t.type===vn){if(n.stack.length>0){const i=[...n.stack],a={state:i.pop(),alt:n.alt,stack:i};Vn(a,e)}else e.add(n);return}t.epsilonOnlyTransitions||e.add(n);const r=t.transitions.length;for(let i=0;i<r;i++){const s=t.transitions[i],a=_p(n,s);a!==void 0&&Vn(a,e)}}function _p(n,e){if(e instanceof Wl)return{state:e.target,alt:n.alt,stack:n.stack};if(e instanceof ji){const t=[...n.stack,e.followState];return{state:e.target,alt:n.alt,stack:t}}}function Ep(n){for(const e of n.elements)if(e.state.type===vn)return!0;return!1}function Rp(n){for(const e of n.elements)if(e.state.type!==vn)return!1;return!0}function Ap(n){if(Rp(n))return!0;const e=bp(n.elements);return Np(e)&&!kp(e)}function bp(n){const e=new Map;for(const t of n){const r=Yl(t,!1);let i=e.get(r);i===void 0&&(i={},e.set(r,i)),i[t.alt]=!0}return e}function Np(n){for(const e of Array.from(n.values()))if(Object.keys(e).length>1)return!0;return!1}function kp(n){for(const e of Array.from(n.values()))if(Object.keys(e).length===1)return!0;return!1}var Ds;(function(n){function e(t){return typeof t=="string"}n.is=e})(Ds||(Ds={}));var Yr;(function(n){function e(t){return typeof t=="string"}n.is=e})(Yr||(Yr={}));var js;(function(n){n.MIN_VALUE=-2147483648,n.MAX_VALUE=2147483647;function e(t){return typeof t=="number"&&n.MIN_VALUE<=t&&t<=n.MAX_VALUE}n.is=e})(js||(js={}));var Wn;(function(n){n.MIN_VALUE=0,n.MAX_VALUE=2147483647;function e(t){return typeof t=="number"&&n.MIN_VALUE<=t&&t<=n.MAX_VALUE}n.is=e})(Wn||(Wn={}));var P;(function(n){function e(r,i){return r===Number.MAX_VALUE&&(r=Wn.MAX_VALUE),i===Number.MAX_VALUE&&(i=Wn.MAX_VALUE),{line:r,character:i}}n.create=e;function t(r){let i=r;return p.objectLiteral(i)&&p.uinteger(i.line)&&p.uinteger(i.character)}n.is=t})(P||(P={}));var $ ;(function(n){function e(r,i,s,a){if(p.uinteger(r)&&p.uinteger(i)&&p.uinteger(s)&&p.uinteger(a))return{start:P.create(r,i),end:P.create(s,a)};if(P.is(r)&&P.is(i))return{start:r,end:i};throw new Error( ` Range # create called with invalid arguments [ $ { r } , $ { i } , $ { s } , $ { a } ] ` )}n.create=e;function t(r){let i=r;return p.objectLiteral(i)&&P.is(i.start)&&P.is(i.end)}n.is=t})( $ ||( $ ={}));var Kn;(function(n){function e(r,i){return{uri:r,range:i}}n.create=e;function t(r){let i=r;return p.objectLiteral(i)&& $ .is(i.range)&&(p.string(i.uri)||p.undefined(i.uri))}n.is=t})(Kn||(Kn={}));var Gs;(function(n){function e(r,i,s,a){return{targetUri:r,targetRange:i,t
2024-08-27 22:31:52 +08:00
` ,s===" \r "&&i+1<t.length&&t.charAt(i+1)=== `
2024-09-04 13:02:35 +08:00
` &&i++}r&&t.length>0&&e.push(t.length),this._lineOffsets=e}return this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let t=this.getLineOffsets(),r=0,i=t.length;if(i===0)return P.create(0,e);for(;r<i;){let a=Math.floor((r+i)/2);t[a]>e?i=a:r=a+1}let s=r-1;return P.create(s,e-t[s])}offsetAt(e){let t=this.getLineOffsets();if(e.line>=t.length)return this._content.length;if(e.line<0)return 0;let r=t[e.line],i=e.line+1<t.length?t[e.line+1]:this._content.length;return Math.max(Math.min(r+e.character,i),r)}get lineCount(){return this.getLineOffsets().length}};var p;(function(n){const e=Object.prototype.toString;function t(h){return typeof h<"u"}n.defined=t;function r(h){return typeof h>"u"}n.undefined=r;function i(h){return h===!0||h===!1}n.boolean=i;function s(h){return e.call(h)==="[object String]"}n.string=s;function a(h){return e.call(h)==="[object Number]"}n.number=a;function o(h,m,g){return e.call(h)==="[object Number]"&&m<=h&&h<=g}n.numberRange=o;function l(h){return e.call(h)==="[object Number]"&&-2147483648<=h&&h<=2147483647}n.integer=l;function c(h){return e.call(h)==="[object Number]"&&0<=h&&h<=2147483647}n.uinteger=c;function u(h){return e.call(h)==="[object Function]"}n.func=u;function d(h){return h!==null&&typeof h=="object"}n.objectLiteral=d;function f(h,m){return Array.isArray(h)&&h.every(m)}n.typedArray=f})(p||(p={}));class Sp{constructor(){this.nodeStack=[]}get current(){return this.nodeStack[this.nodeStack.length-1]}buildRootNode(e){return this.rootNode=new ec(e),this.rootNode.root=this.rootNode,this.nodeStack=[this.rootNode],this.rootNode}buildCompositeNode(e){const t=new Fi;return t.grammarSource=e,t.root=this.rootNode,this.current.content.push(t),this.nodeStack.push(t),t}buildLeafNode(e,t){const r=new li(e.startOffset,e.image.length,Dr(e),e.tokenType,!1);return r.grammarSource=t,r.root=this.rootNode,this.current.content.push(r),r}removeNode(e){const t=e.container;if(t){const r=t.content.indexOf(e);r>=0&&t.content.splice(r,1)}}construct(e){const t=this.current;typeof e. $ type=="string"&&(this.current.astNode=e),e. $ cstNode=t;const r=this.nodeStack.pop();(r==null?void 0:r.content.length)===0&&this.removeNode(r)}addHiddenTokens(e){for(const t of e){const r=new li(t.startOffset,t.image.length,Dr(t),t.tokenType,!0);r.root=this.rootNode,this.addHiddenToken(this.rootNode,r)}}addHiddenToken(e,t){const{offset:r,end:i}=t;for(let s=0;s<e.content.length;s++){const a=e.content[s],{offset:o,end:l}=a;if(Gt(a)&&r>o&&i<l){this.addHiddenToken(a,t);return}else if(i<=o){e.content.splice(s,0,t);return}}e.content.push(t)}}class Zl{get parent(){return this.container}get feature(){return this.grammarSource}get hidden(){return!1}get astNode(){var e,t;const r=typeof((e=this._astNode)===null||e===void 0?void 0:e. $ type)=="string"?this._astNode:(t=this.container)===null||t===void 0?void 0:t.astNode;if(!r)throw new Error("This node has no associated AST element");return r}set astNode(e){this._astNode=e}get element(){return this.astNode}get text(){return this.root.fullText.substring(this.offset,this.end)}}class li extends Zl{get offset(){return this._offset}get length(){return this._length}get end(){return this._offset+this._length}get hidden(){return this._hidden}get tokenType(){return this._tokenType}get range(){return this._range}constructor(e,t,r,i,s=!1){super(),this._hidden=s,this._offset=e,this._tokenType=i,this._length=t,this._range=r}}class Fi extends Zl{constructor(){super(...arguments),this.content=new Bi(this)}get children(){return this.content}get offset(){var e,t;return(t=(e=this.firstNonHiddenNode)===null||e===void 0?void 0:e.offset)!==null&&t!==void 0?t:0}get length(){return this.end-this.offset}get end(){var e,t;return(t=(e=this.lastNonHiddenNode)===null||e===void 0?void 0:e.end)!==null&&t!==void 0?t:0}get range(){const e=this.firstNonHiddenNode,t=this.lastNonHiddenNode;if(e&&t){if(this._rangeCache===void 0){const{range:r}=e,{range:i}=t;this._rangeCache={start:r.start,end:i.end.line<r.start.line?r.start:i.end}}return this._rangeCache}else return{start:P.create(0,0),end:P.create(0,0)}}get firstNon
2024-09-07 10:27:05 +08:00
` ;case"r":return" \r ";case"t":return" ";case"v":return" \v ";case"0":return" \0 ";default:return c}}function r(c){return c.charAt(0)==="^"?c.substring(1):c}n.convertID=r;function i(c){return parseInt(c)}n.convertInt=i;function s(c){return BigInt(c)}n.convertBigint=s;function a(c){return new Date(c)}n.convertDate=a;function o(c){return Number(c)}n.convertNumber=o;function l(c){return c.toLowerCase()==="true"}n.convertBoolean=l})(Ve||(Ve={}));var dn={},yr={};Object.defineProperty(yr,"__esModule",{value:!0});let di;function fi(){if(di===void 0)throw new Error("No runtime abstraction layer installed");return di}(function(n){function e(t){if(t===void 0)throw new Error("No runtime abstraction layer provided");di=t}n.install=e})(fi||(fi={}));yr.default=fi;var se={};Object.defineProperty(se,"__esModule",{value:!0});se.stringArray=se.array=se.func=se.error=se.number=se.string=se.boolean=void 0;function Kp(n){return n===!0||n===!1}se.boolean=Kp;function uc(n){return typeof n=="string"||n instanceof String}se.string=uc;function zp(n){return typeof n=="number"||n instanceof Number}se.number=zp;function qp(n){return n instanceof Error}se.error=qp;function Yp(n){return typeof n=="function"}se.func=Yp;function dc(n){return Array.isArray(n)}se.array=dc;function Xp(n){return dc(n)&&n.every(e=>uc(e))}se.stringArray=Xp;var Vt={};Object.defineProperty(Vt,"__esModule",{value:!0});Vt.Emitter=Vt.Event=void 0;const Jp=yr;var Ga;(function(n){const e={dispose(){}};n.None=function(){return e}})(Ga||(Vt.Event=Ga={}));class Qp{add(e,t=null,r){this._callbacks||(this._callbacks=[],this._contexts=[]),this._callbacks.push(e),this._contexts.push(t),Array.isArray(r)&&r.push({dispose:()=>this.remove(e,t)})}remove(e,t=null){if(!this._callbacks)return;let r=!1;for(let i=0,s=this._callbacks.length;i<s;i++)if(this._callbacks[i]===e)if(this._contexts[i]===t){this._callbacks.splice(i,1),this._contexts.splice(i,1);return}else r=!0;if(r)throw new Error("When adding a listener with a context, you should remove it with the same context")}invoke(...e){if(!this._callbacks)return[];const t=[],r=this._callbacks.slice(0),i=this._contexts.slice(0);for(let s=0,a=r.length;s<a;s++)try{t.push(r[s].apply(i[s],e))}catch(o){(0,Jp.default)().console.error(o)}return t}isEmpty(){return!this._callbacks||this._callbacks.length===0}dispose(){this._callbacks=void 0,this._contexts=void 0}}class Tr{constructor(e){this._options=e}get event(){return this._event||(this._event=(e,t,r)=>{this._callbacks||(this._callbacks=new Qp),this._options&&this._options.onFirstListenerAdd&&this._callbacks.isEmpty()&&this._options.onFirstListenerAdd(this),this._callbacks.add(e,t);const i={dispose:()=>{this._callbacks&&(this._callbacks.remove(e,t),i.dispose=Tr._noop,this._options&&this._options.onLastListenerRemove&&this._callbacks.isEmpty()&&this._options.onLastListenerRemove(this))}};return Array.isArray(r)&&r.push(i),i}),this._event}fire(e){this._callbacks&&this._callbacks.invoke.call(this._callbacks,e)}dispose(){this._callbacks&&(this._callbacks.dispose(),this._callbacks=void 0)}}Vt.Emitter=Tr;Tr._noop=function(){};var X;Object.defineProperty(dn,"__esModule",{value:!0});var hi=dn.CancellationTokenSource=X=dn.CancellationToken=void 0;const Zp=yr,em=se,pi=Vt;var Jn;(function(n){n.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:pi.Event.None}),n.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:pi.Event.None});function e(t){const r=t;return r&&(r===n.None||r===n.Cancelled||em.boolean(r.isCancellationRequested)&&!!r.onCancellationRequested)}n.is=e})(Jn||(X=dn.CancellationToken=Jn={}));const tm=Object.freeze(function(n,e){const t=(0,Zp.default)().timer.setTimeout(n.bind(e),0);return{dispose(){t.dispose()}}});class Ua{constructor(){this._isCancelled=!1}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?tm:(this._emitter||(this._emitter=new pi.Emitter),this._emitter.event)}dispose(){this._emitter&&(t
2024-09-04 13:02:35 +08:00
$ { t } ` ),this.inline? ` { $ { e } } ` :e}toMarkdown(e){var t,r;return(r=(t=e==null?void 0:e.renderTag)===null||t===void 0?void 0:t.call(e,this))!==null&&r!==void 0?r:this.toMarkdownDefault(e)}toMarkdownDefault(e){const t=this.content.toMarkdown(e);if(this.inline){const s=Wm(this.name,t,e??{});if(typeof s=="string")return s}let r="";(e==null?void 0:e.tag)==="italic"||(e==null?void 0:e.tag)===void 0?r="*":(e==null?void 0:e.tag)==="bold"?r="**":(e==null?void 0:e.tag)==="bold-italic"&&(r="***");let i= ` $ { r } @ $ { this . name } $ { r } ` ;return this.content.inlines.length===1?i= ` $ { i } — $ { t } ` :this.content.inlines.length>1&&(i= ` $ { i }
$ { t } ` ),this.inline? ` { $ { i } } ` :i}}function Wm(n,e,t){var r,i;if(n==="linkplain"||n==="linkcode"||n==="link"){const s=e.indexOf(" ");let a=e;if(s>0){const l=yi(e,s);a=e.substring(l),e=e.substring(0,s)}return(n==="linkcode"||n==="link"&&t.link==="code")&&(a= ` \ ` ${ a } \` ` ) , ( i = ( r = t . renderLink ) === null || r === void 0 ? void 0 : r . call ( t , e , a ) ) !== null && i !== void 0 ? i : Km ( e , a ) } } function Km ( n , e ) { try { return Wt . parse ( n , ! 0 ) , ` [ ${ e } ]( ${ n } ) ` } catch { return n } } class Ti { constructor ( e , t ) { this . inlines = e , this . range = t } toString ( ) { let e = "" ; for ( let t = 0 ; t < this . inlines . length ; t ++ ) { const r = this . inlines [ t ] , i = this . inlines [ t + 1 ] ; e += r . toString ( ) , i && i . range . start . line > r . range . start . line && ( e += `
2024-08-27 22:31:52 +08:00
` )}return e}toMarkdown(e){let t="";for(let r=0;r<this.inlines.length;r++){const i=this.inlines[r],s=this.inlines[r+1];t+=i.toMarkdown(e),s&&s.range.start.line>i.range.start.line&&(t+= `
2024-09-04 13:02:35 +08:00
` )}return t}}class Ec{constructor(e,t){this.text=e,this.range=t}toString(){return this.text}toMarkdown(){return this.text}}function Xa(n){return n.endsWith( `
2024-08-27 22:31:52 +08:00
` )? `
` : `
2024-09-04 13:02:35 +08:00
` }class zm{constructor(e){this.indexManager=e.shared.workspace.IndexManager,this.commentProvider=e.documentation.CommentProvider}getDocumentation(e){const t=this.commentProvider.getComment(e);if(t&& $ m(t))return Lm(t).toMarkdown({renderLink:(i,s)=>this.documentationLinkRenderer(e,i,s),renderTag:i=>this.documentationTagRenderer(e,i)})}documentationLinkRenderer(e,t,r){var i;const s=(i=this.findNameInPrecomputedScopes(e,t))!==null&&i!==void 0?i:this.findNameInGlobalScope(e,t);if(s&&s.nameSegment){const a=s.nameSegment.range.start.line+1,o=s.nameSegment.range.start.character+1,l=s.documentUri.with({fragment: ` L$ { a } , $ { o } ` });return ` [ $ { r } ] ( $ { l . toString ( ) } ) ` }else return}documentationTagRenderer(e,t){}findNameInPrecomputedScopes(e,t){const i=Ue(e).precomputedScopes;if(!i)return;let s=e;do{const o=i.get(s).find(l=>l.name===t);if(o)return o;s=s. $ container}while(s)}findNameInGlobalScope(e,t){return this.indexManager.allElements().find(i=>i.name===t)}}class qm{constructor(e){this.grammarConfig=()=>e.parser.GrammarConfig}getComment(e){var t;return Tm(e)?e. $ comment:(t=Ou(e. $ cstNode,this.grammarConfig().multilineCommentRules))===null||t===void 0?void 0:t.text}}class Ym{constructor(e){this.syncParser=e.parser.LangiumParser}parse(e){return Promise.resolve(this.syncParser.parse(e))}}class Xm{constructor(){this.previousTokenSource=new hi,this.writeQueue=[],this.readQueue=[],this.done=!0}write(e){this.cancelWrite();const t=new hi;return this.previousTokenSource=t,this.enqueue(this.writeQueue,e,t.token)}read(e){return this.enqueue(this.readQueue,e)}enqueue(e,t,r){const i=new Vi,s={action:t,deferred:i,cancellationToken:r??X.None};return e.push(s),this.performNextOperation(),i.promise}async performNextOperation(){if(!this.done)return;const e=[];if(this.writeQueue.length>0)e.push(this.writeQueue.shift());else if(this.readQueue.length>0)e.push(...this.readQueue.splice(0,this.readQueue.length));else return;this.done=!1,await Promise.all(e.map(async({action:t,deferred:r,cancellationToken:i})=>{try{const s=await Promise.resolve().then(()=>t(i));r.resolve(s)}catch(s){Hi(s)?r.resolve(void 0):r.reject(s)}})),this.done=!0,this.performNextOperation()}cancelWrite(){this.previousTokenSource.cancel()}}class Jm{constructor(e){this.grammarElementIdMap=new Ha,this.tokenTypeIdMap=new Ha,this.grammar=e.Grammar,this.lexer=e.parser.Lexer,this.linker=e.references.Linker}dehydrate(e){return{lexerErrors:e.lexerErrors.map(t=>Object.assign({},t)),parserErrors:e.parserErrors.map(t=>Object.assign({},t)),value:this.dehydrateAstNode(e.value,this.createDehyrationContext(e.value))}}createDehyrationContext(e){const t=new Map,r=new Map;for(const i of Et(e))t.set(i,{});if(e. $ cstNode)for(const i of Mr(e. $ cstNode))r.set(i,{});return{astNodes:t,cstNodes:r}}dehydrateAstNode(e,t){const r=t.astNodes.get(e);r. $ type=e. $ type,r. $ containerIndex=e. $ containerIndex,r. $ containerProperty=e. $ containerProperty,e. $ cstNode!==void 0&&(r. $ cstNode=this.dehydrateCstNode(e. $ cstNode,t));for(const[i,s]of Object.entries(e))if(!i.startsWith(" $ "))if(Array.isArray(s)){const a=[];r[i]=a;for(const o of s)ae(o)?a.push(this.dehydrateAstNode(o,t)):Ge(o)?a.push(this.dehydrateReference(o,t)):a.push(o)}else ae(s)?r[i]=this.dehydrateAstNode(s,t):Ge(s)?r[i]=this.dehydrateReference(s,t):s!==void 0&&(r[i]=s);return r}dehydrateReference(e,t){const r={};return r. $ refText=e. $ refText,e. $ refNode&&(r. $ refNode=t.cstNodes.get(e. $ refNode)),r}dehydrateCstNode(e,t){const r=t.cstNodes.get(e);return yo(e)?r.fullText=e.fullText:r.grammarSource=this.getGrammarElementId(e.grammarSource),r.hidden=e.hidden,r.astNode=t.astNodes.get(e.astNode),Gt(e)?r.content=e.content.map(i=>this.dehydrateCstNode(i,t)):go(e)&&(r.tokenType=e.tokenType.name,r.offset=e.offset,r.length=e.length,r.startLine=e.range.start.line,r.startColumn=e.range.start.character,r.endLine=e.range.end.line,r.endColumn=e.range.end.character),r}hydrate(e){const t=e.value,r=this.createHydrationContext(t);return" $ cstNode"in t&&this.hydrateCstNode(t. $ cstNode,r),{lexerErrors:e.lexerErrors,parserErrors:e.parserErrors,value:this.hydrateAstNode(t,r)}}createHydrationContext(e){const t=ne
` )}}},k(bt,"AbstractMermaidValueConverter"),bt),Nt,qi=(Nt=class extends zi{runCustomConverter(e,t,r){}},k(Nt,"CommonValueConverter"),Nt),kt,en=(kt=class extends lc{constructor(e){super(),this.keywords=new Set(e)}buildKeywordTokens(e,t,r){const i=super.buildKeywordTokens(e,t,r);return i.forEach(s=>{this.keywords.has(s.name)&&s.PATTERN!==void 0&&(s.PATTERN=new RegExp(s.PATTERN.toString()+"(?:(?=%%)|(?! \\ S))"))}),i}},k(kt,"AbstractMermaidTokenBuilder"),kt),It;It=class extends en{},k(It,"CommonTokenBuilder");var St,Vg=(St=class extends en{constructor(){super(["gitGraph"])}},k(St,"GitGraphTokenBuilder"),St),Sc={parser:{TokenBuilder:k(()=>new Vg,"TokenBuilder"),ValueConverter:k(()=>new qi,"ValueConverter")}};function xc(n=Zt){const e=xe(Qt(n),En),t=xe(Jt({shared:e}),Gg,Sc);return e.ServiceRegistry.register(t),{shared:e,GitGraph:t}}k(xc,"createGitGraphServices");var xt,Wg=(xt=class extends en{constructor(){super(["info","showInfo"])}},k(xt,"InfoTokenBuilder"),xt),Cc={parser:{TokenBuilder:k(()=>new Wg,"TokenBuilder"),ValueConverter:k(()=>new qi,"ValueConverter")}};function wc(n=Zt){const e=xe(Qt(n),En),t=xe(Jt({shared:e}),Pg,Cc);return e.ServiceRegistry.register(t),{shared:e,Info:t}}k(wc,"createInfoServices");var Ct,Kg=(Ct=class extends en{constructor(){super(["packet-beta"])}},k(Ct,"PacketTokenBuilder"),Ct),Oc={parser:{TokenBuilder:k(()=>new Kg,"TokenBuilder"),ValueConverter:k(()=>new qi,"ValueConverter")}};function Lc(n=Zt){const e=xe(Qt(n),En),t=xe(Jt({shared:e}),Mg,Oc);return e.ServiceRegistry.register(t),{shared:e,Packet:t}}k(Lc,"createPacketServices");var wt,zg=(wt=class extends en{constructor(){super(["pie","showData"])}},k(wt,"PieTokenBuilder"),wt),Ot,qg=(Ot=class extends zi{runCustomConverter(e,t,r){if(e.name==="PIE_SECTION_LABEL")return t.replace(/"/g,"").trim()}},k(Ot,"PieValueConverter"),Ot), $ c={parser:{TokenBuilder:k(()=>new zg,"TokenBuilder"),ValueConverter:k(()=>new qg,"ValueConverter")}};function Pc(n=Zt){const e=xe(Qt(n),En),t=xe(Jt({shared:e}),Dg, $ c);return e.ServiceRegistry.register(t),{shared:e,Pie:t}}k(Pc,"createPieServices");var Lt,Yg=(Lt=class extends en{constructor(){super(["architecture"])}},k(Lt,"ArchitectureTokenBuilder"),Lt), $ t,Xg=( $ t=class extends zi{runCustomConverter(e,t,r){if(e.name==="ARCH_ICON")return t.replace(/[()]/g,"").trim();if(e.name==="ARCH_TEXT_ICON")return t.replace(/["()]/g,"");if(e.name==="ARCH_TITLE")return t.replace(/[[ \] ]/g,"").trim()}},k( $ t,"ArchitectureValueConverter"), $ t),Mc={parser:{TokenBuilder:k(()=>new Yg,"TokenBuilder"),ValueConverter:k(()=>new Xg,"ValueConverter")}};function Dc(n=Zt){const e=xe(Qt(n),En),t=xe(Jt({shared:e}),jg,Mc);return e.ServiceRegistry.register(t),{shared:e,Architecture:t}}k(Dc,"createArchitectureServices");var lt={},Jg={info:k(async()=>{const{createInfoServices:n}=await tn(async()=>{const{createInfoServices:t}=await Promise.resolve().then(()=>ey);return{createInfoServices:t}},void 0),e=n().Info.parser.LangiumParser;lt.info=e},"info"),packet:k(async()=>{const{createPacketServices:n}=await tn(async()=>{const{createPacketServices:t}=await Promise.resolve().then(()=>ty);return{createPacketServices:t}},void 0),e=n().Packet.parser.LangiumParser;lt.packet=e},"packet"),pie:k(async()=>{const{createPieServices:n}=await tn(async()=>{const{createPieServices:t}=await Promise.resolve().then(()=>ny);return{createPieServices:t}},void 0),e=n().Pie.parser.LangiumParser;lt.pie=e},"pie"),architecture:k(async()=>{const{createArchitectureServices:n}=await tn(async()=>{const{createArchitectureServices:t}=await Promise.resolve().then(()=>ry);return{createArchitectureServices:t}},void 0),e=n().Architecture.parser.LangiumParser;lt.architecture=e},"architecture"),gitGraph:k(async()=>{const{createGitGraphServices:n}=await tn(async()=>{const{createGitGraphServices:t}=await Promise.resolve().then(()=>iy);return{createGitGraphServices:t}},void 0),e=n().GitGraph.parser.LangiumParser;lt.gitGraph=e},"gitGraph")};async function Qg(n,e){const t=Jg[n];if(!t)throw new Error( ` Unknown diagram type : $ { n } ` );lt[n]||await t();const i=lt[n].parse(e);if(i.lexerErrors.length>0||i.parserErrors.leng
2024-08-27 22:31:52 +08:00
` ),r=e.parserErrors.map(i=>i.message).join( `
2024-09-04 13:02:35 +08:00
` );super( ` Parsing failed : $ { t } $ { r } ` ),this.result=e}},k(Pt,"MermaidParseError"),Pt);const ey=Object.freeze(Object.defineProperty({__proto__:null,InfoModule:Cc,createInfoServices:wc},Symbol.toStringTag,{value:"Module"})),ty=Object.freeze(Object.defineProperty({__proto__:null,PacketModule:Oc,createPacketServices:Lc},Symbol.toStringTag,{value:"Module"})),ny=Object.freeze(Object.defineProperty({__proto__:null,PieModule: $ c,createPieServices:Pc},Symbol.toStringTag,{value:"Module"})),ry=Object.freeze(Object.defineProperty({__proto__:null,ArchitectureModule:Mc,createArchitectureServices:Dc},Symbol.toStringTag,{value:"Module"})),iy=Object.freeze(Object.defineProperty({__proto__:null,GitGraphModule:Sc,createGitGraphServices:xc},Symbol.toStringTag,{value:"Module"}));export{Qg as p};