@barishnamazov/gsql 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +61 -61
- package/dist/index.js +13 -13
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{readFileSync as Vu,writeFileSync as QT,existsSync as ZT}from"node:fs";import{resolve as zu,basename as JT,dirname as tS,join as eS}from"node:path";import{fileURLToPath as rS}from"node:url";var Qu=typeof global=="object"&&global&&global.Object===Object&&global,dn=Qu;var Zu=typeof self=="object"&&self&&self.Object===Object&&self,Ju=dn||Zu||Function("return this")(),J=Ju;var tf=J.Symbol,at=tf;var ws=Object.prototype,ef=ws.hasOwnProperty,rf=ws.toString,Rr=at?at.toStringTag:void 0;function nf(e){var t=ef.call(e,Rr),r=e[Rr];try{e[Rr]=void 0;var n=!0}catch{}var o=rf.call(e);return n&&(t?e[Rr]=r:delete e[Rr]),o}var Ds=nf;var of=Object.prototype,sf=of.toString;function af(e){return sf.call(e)}var Fs=af;var cf="[object Null]",lf="[object Undefined]",Bs=at?at.toStringTag:void 0;function uf(e){return e==null?e===void 0?lf:cf:Bs&&Bs in Object(e)?Ds(e):Fs(e)}var mt=uf;function ff(e){return e!=null&&typeof e=="object"}var Y=ff;var hf="[object Symbol]";function pf(e){return typeof e=="symbol"||Y(e)&&mt(e)==hf}var ue=pf;function mf(e,t){for(var r=-1,n=e==null?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}var Gt=mf;var df=Array.isArray,I=df;var gf=1/0,Gs=at?at.prototype:void 0,$s=Gs?Gs.toString:void 0;function js(e){if(typeof e=="string")return e;if(I(e))return Gt(e,js)+"";if(ue(e))return $s?$s.call(e):"";var t=e+"";return t=="0"&&1/e==-gf?"-0":t}var Ws=js;var Ef=/\s/;function xf(e){for(var t=e.length;t--&&Ef.test(e.charAt(t)););return t}var Ks=xf;var Tf=/^\s+/;function Sf(e){return e&&e.slice(0,Ks(e)+1).replace(Tf,"")}var Hs=Sf;function Af(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var W=Af;var qs=NaN,Nf=/^[-+]0x[0-9a-f]+$/i,If=/^0b[01]+$/i,Of=/^0o[0-7]+$/i,Cf=parseInt;function Rf(e){if(typeof e=="number")return e;if(ue(e))return qs;if(W(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=W(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Hs(e);var r=If.test(e);return r||Of.test(e)?Cf(e.slice(2),r?2:8):Nf.test(e)?qs:+e}var zs=Rf;var Vs=1/0,yf=17976931348623157e292;function Lf(e){if(!e)return e===0?e:0;if(e=zs(e),e===Vs||e===-Vs){var t=e<0?-1:1;return t*yf}return e===e?e:0}var Ys=Lf;function _f(e){var t=Ys(e),r=t%1;return t===t?r?t-r:t:0}var $t=_f;function vf(e){return e}var vt=vf;var Mf="[object AsyncFunction]",bf="[object Function]",kf="[object GeneratorFunction]",Pf="[object Proxy]";function Uf(e){if(!W(e))return!1;var t=mt(e);return t==bf||t==kf||t==Mf||t==Pf}var dt=Uf;var wf=J["__core-js_shared__"],gn=wf;var Xs=(function(){var e=/[^.]+$/.exec(gn&&gn.keys&&gn.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function Df(e){return!!Xs&&Xs in e}var Qs=Df;var Ff=Function.prototype,Bf=Ff.toString;function Gf(e){if(e!=null){try{return Bf.call(e)}catch{}try{return e+""}catch{}}return""}var te=Gf;var $f=/[\\^$.*+?()[\]{}|]/g,jf=/^\[object .+?Constructor\]$/,Wf=Function.prototype,Kf=Object.prototype,Hf=Wf.toString,qf=Kf.hasOwnProperty,zf=RegExp("^"+Hf.call(qf).replace($f,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Vf(e){if(!W(e)||Qs(e))return!1;var t=dt(e)?zf:jf;return t.test(te(e))}var Zs=Vf;function Yf(e,t){return e?.[t]}var Js=Yf;function Xf(e,t){var r=Js(e,t);return Zs(r)?r:void 0}var St=Xf;var Qf=St(J,"WeakMap"),En=Qf;var ta=Object.create,Zf=(function(){function e(){}return function(t){if(!W(t))return{};if(ta)return ta(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}})(),ea=Zf;function Jf(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var ra=Jf;function th(){}var K=th;function eh(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}var na=eh;var rh=800,nh=16,oh=Date.now;function ih(e){var t=0,r=0;return function(){var n=oh(),o=nh-(n-r);if(r=n,o>0){if(++t>=rh)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var oa=ih;function sh(e){return function(){return e}}var ia=sh;var ah=(function(){try{var e=St(Object,"defineProperty");return e({},"",{}),e}catch{}})(),Be=ah;var ch=Be?function(e,t){return Be(e,"toString",{configurable:!0,enumerable:!1,value:ia(t),writable:!0})}:vt,sa=ch;var lh=oa(sa),aa=lh;function uh(e,t){for(var r=-1,n=e==null?0:e.length;++r<n&&t(e[r],r,e)!==!1;);return e}var xn=uh;function fh(e,t,r,n){for(var o=e.length,i=r+(n?1:-1);n?i--:++i<o;)if(t(e[i],i,e))return i;return-1}var Tn=fh;function hh(e){return e!==e}var ca=hh;function ph(e,t,r){for(var n=r-1,o=e.length;++n<o;)if(e[n]===t)return n;return-1}var la=ph;function mh(e,t,r){return t===t?la(e,t,r):Tn(e,ca,r)}var Ge=mh;function dh(e,t){var r=e==null?0:e.length;return!!r&&Ge(e,t,0)>-1}var Sn=dh;var gh=9007199254740991,Eh=/^(?:0|[1-9]\d*)$/;function xh(e,t){var r=typeof e;return t=t??gh,!!t&&(r=="number"||r!="symbol"&&Eh.test(e))&&e>-1&&e%1==0&&e<t}var fe=xh;function Th(e,t,r){t=="__proto__"&&Be?Be(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var $e=Th;function Sh(e,t){return e===t||e!==e&&t!==t}var jt=Sh;var Ah=Object.prototype,Nh=Ah.hasOwnProperty;function Ih(e,t,r){var n=e[t];(!(Nh.call(e,t)&&jt(n,r))||r===void 0&&!(t in e))&&$e(e,t,r)}var he=Ih;function Oh(e,t,r,n){var o=!r;r||(r={});for(var i=-1,s=t.length;++i<s;){var a=t[i],c=n?n(r[a],e[a],a,r,e):void 0;c===void 0&&(c=e[a]),o?$e(r,a,c):he(r,a,c)}return r}var Wt=Oh;var ua=Math.max;function Ch(e,t,r){return t=ua(t===void 0?e.length-1:t,0),function(){for(var n=arguments,o=-1,i=ua(n.length-t,0),s=Array(i);++o<i;)s[o]=n[t+o];o=-1;for(var a=Array(t+1);++o<t;)a[o]=n[o];return a[t]=r(s),ra(e,this,a)}}var fa=Ch;function Rh(e,t){return aa(fa(e,t,vt),e+"")}var je=Rh;var yh=9007199254740991;function Lh(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=yh}var We=Lh;function _h(e){return e!=null&&We(e.length)&&!dt(e)}var tt=_h;function vh(e,t,r){if(!W(r))return!1;var n=typeof t;return(n=="number"?tt(r)&&fe(t,r.length):n=="string"&&t in r)?jt(r[t],e):!1}var pe=vh;function Mh(e){return je(function(t,r){var n=-1,o=r.length,i=o>1?r[o-1]:void 0,s=o>2?r[2]:void 0;for(i=e.length>3&&typeof i=="function"?(o--,i):void 0,s&&pe(r[0],r[1],s)&&(i=o<3?void 0:i,o=1),t=Object(t);++n<o;){var a=r[n];a&&e(t,a,n,i)}return t})}var ha=Mh;var bh=Object.prototype;function kh(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||bh;return e===r}var Kt=kh;function Ph(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var pa=Ph;var Uh="[object Arguments]";function wh(e){return Y(e)&&mt(e)==Uh}var wi=wh;var ma=Object.prototype,Dh=ma.hasOwnProperty,Fh=ma.propertyIsEnumerable,Bh=wi((function(){return arguments})())?wi:function(e){return Y(e)&&Dh.call(e,"callee")&&!Fh.call(e,"callee")},me=Bh;function Gh(){return!1}var da=Gh;var xa=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ga=xa&&typeof module=="object"&&module&&!module.nodeType&&module,$h=ga&&ga.exports===xa,Ea=$h?J.Buffer:void 0,jh=Ea?Ea.isBuffer:void 0,Wh=jh||da,ee=Wh;var Kh="[object Arguments]",Hh="[object Array]",qh="[object Boolean]",zh="[object Date]",Vh="[object Error]",Yh="[object Function]",Xh="[object Map]",Qh="[object Number]",Zh="[object Object]",Jh="[object RegExp]",tp="[object Set]",ep="[object String]",rp="[object WeakMap]",np="[object ArrayBuffer]",op="[object DataView]",ip="[object Float32Array]",sp="[object Float64Array]",ap="[object Int8Array]",cp="[object Int16Array]",lp="[object Int32Array]",up="[object Uint8Array]",fp="[object Uint8ClampedArray]",hp="[object Uint16Array]",pp="[object Uint32Array]",B={};B[ip]=B[sp]=B[ap]=B[cp]=B[lp]=B[up]=B[fp]=B[hp]=B[pp]=!0;B[Kh]=B[Hh]=B[np]=B[qh]=B[op]=B[zh]=B[Vh]=B[Yh]=B[Xh]=B[Qh]=B[Zh]=B[Jh]=B[tp]=B[ep]=B[rp]=!1;function mp(e){return Y(e)&&We(e.length)&&!!B[mt(e)]}var Ta=mp;function dp(e){return function(t){return e(t)}}var Ht=dp;var Sa=typeof exports=="object"&&exports&&!exports.nodeType&&exports,yr=Sa&&typeof module=="object"&&module&&!module.nodeType&&module,gp=yr&&yr.exports===Sa,Di=gp&&dn.process,Ep=(function(){try{var e=yr&&yr.require&&yr.require("util").types;return e||Di&&Di.binding&&Di.binding("util")}catch{}})(),Mt=Ep;var Aa=Mt&&Mt.isTypedArray,xp=Aa?Ht(Aa):Ta,Ke=xp;var Tp=Object.prototype,Sp=Tp.hasOwnProperty;function Ap(e,t){var r=I(e),n=!r&&me(e),o=!r&&!n&&ee(e),i=!r&&!n&&!o&&Ke(e),s=r||n||o||i,a=s?pa(e.length,String):[],c=a.length;for(var l in e)(t||Sp.call(e,l))&&!(s&&(l=="length"||o&&(l=="offset"||l=="parent")||i&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||fe(l,c)))&&a.push(l);return a}var An=Ap;function Np(e,t){return function(r){return e(t(r))}}var Nn=Np;var Ip=Nn(Object.keys,Object),Na=Ip;var Op=Object.prototype,Cp=Op.hasOwnProperty;function Rp(e){if(!Kt(e))return Na(e);var t=[];for(var r in Object(e))Cp.call(e,r)&&r!="constructor"&&t.push(r);return t}var In=Rp;function yp(e){return tt(e)?An(e):In(e)}var P=yp;var Lp=Object.prototype,_p=Lp.hasOwnProperty,vp=ha(function(e,t){if(Kt(t)||tt(t)){Wt(t,P(t),e);return}for(var r in t)_p.call(t,r)&&he(e,r,t[r])}),lt=vp;function Mp(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}var Ia=Mp;var bp=Object.prototype,kp=bp.hasOwnProperty;function Pp(e){if(!W(e))return Ia(e);var t=Kt(e),r=[];for(var n in e)n=="constructor"&&(t||!kp.call(e,n))||r.push(n);return r}var Oa=Pp;function Up(e){return tt(e)?An(e,!0):Oa(e)}var de=Up;var wp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Dp=/^\w*$/;function Fp(e,t){if(I(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||ue(e)?!0:Dp.test(e)||!wp.test(e)||t!=null&&e in Object(t)}var He=Fp;var Bp=St(Object,"create"),re=Bp;function Gp(){this.__data__=re?re(null):{},this.size=0}var Ca=Gp;function $p(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ra=$p;var jp="__lodash_hash_undefined__",Wp=Object.prototype,Kp=Wp.hasOwnProperty;function Hp(e){var t=this.__data__;if(re){var r=t[e];return r===jp?void 0:r}return Kp.call(t,e)?t[e]:void 0}var ya=Hp;var qp=Object.prototype,zp=qp.hasOwnProperty;function Vp(e){var t=this.__data__;return re?t[e]!==void 0:zp.call(t,e)}var La=Vp;var Yp="__lodash_hash_undefined__";function Xp(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=re&&t===void 0?Yp:t,this}var _a=Xp;function qe(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}qe.prototype.clear=Ca;qe.prototype.delete=Ra;qe.prototype.get=ya;qe.prototype.has=La;qe.prototype.set=_a;var Fi=qe;function Qp(){this.__data__=[],this.size=0}var va=Qp;function Zp(e,t){for(var r=e.length;r--;)if(jt(e[r][0],t))return r;return-1}var ge=Zp;var Jp=Array.prototype,tm=Jp.splice;function em(e){var t=this.__data__,r=ge(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():tm.call(t,r,1),--this.size,!0}var Ma=em;function rm(e){var t=this.__data__,r=ge(t,e);return r<0?void 0:t[r][1]}var ba=rm;function nm(e){return ge(this.__data__,e)>-1}var ka=nm;function om(e,t){var r=this.__data__,n=ge(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var Pa=om;function ze(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}ze.prototype.clear=va;ze.prototype.delete=Ma;ze.prototype.get=ba;ze.prototype.has=ka;ze.prototype.set=Pa;var Ee=ze;var im=St(J,"Map"),xe=im;function sm(){this.size=0,this.__data__={hash:new Fi,map:new(xe||Ee),string:new Fi}}var Ua=sm;function am(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var wa=am;function cm(e,t){var r=e.__data__;return wa(t)?r[typeof t=="string"?"string":"hash"]:r.map}var Te=cm;function lm(e){var t=Te(this,e).delete(e);return this.size-=t?1:0,t}var Da=lm;function um(e){return Te(this,e).get(e)}var Fa=um;function fm(e){return Te(this,e).has(e)}var Ba=fm;function hm(e,t){var r=Te(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var Ga=hm;function Ve(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Ve.prototype.clear=Ua;Ve.prototype.delete=Da;Ve.prototype.get=Fa;Ve.prototype.has=Ba;Ve.prototype.set=Ga;var Le=Ve;var pm="Expected a function";function Bi(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(pm);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var s=e.apply(this,n);return r.cache=i.set(o,s)||i,s};return r.cache=new(Bi.Cache||Le),r}Bi.Cache=Le;var $a=Bi;var mm=500;function dm(e){var t=$a(e,function(n){return r.size===mm&&r.clear(),n}),r=t.cache;return t}var ja=dm;var gm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Em=/\\(\\)?/g,xm=ja(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(gm,function(r,n,o,i){t.push(o?i.replace(Em,"$1"):n||r)}),t}),Wa=xm;function Tm(e){return e==null?"":Ws(e)}var Ka=Tm;function Sm(e,t){return I(e)?e:He(e,t)?[e]:Wa(Ka(e))}var Se=Sm;var Am=1/0;function Nm(e){if(typeof e=="string"||ue(e))return e;var t=e+"";return t=="0"&&1/e==-Am?"-0":t}var qt=Nm;function Im(e,t){t=Se(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[qt(t[r++])];return r&&r==n?e:void 0}var Ye=Im;function Om(e,t,r){var n=e==null?void 0:Ye(e,t);return n===void 0?r:n}var Ha=Om;function Cm(e,t){for(var r=-1,n=t.length,o=e.length;++r<n;)e[o+r]=t[r];return e}var Xe=Cm;var qa=at?at.isConcatSpreadable:void 0;function Rm(e){return I(e)||me(e)||!!(qa&&e&&e[qa])}var za=Rm;function Va(e,t,r,n,o){var i=-1,s=e.length;for(r||(r=za),o||(o=[]);++i<s;){var a=e[i];t>0&&r(a)?t>1?Va(a,t-1,r,n,o):Xe(o,a):n||(o[o.length]=a)}return o}var Qe=Va;function ym(e){var t=e==null?0:e.length;return t?Qe(e,1):[]}var ot=ym;var Lm=Nn(Object.getPrototypeOf,Object),On=Lm;function _m(e,t,r){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),r=r>o?o:r,r<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+t];return i}var Cn=_m;function vm(e,t,r,n){var o=-1,i=e==null?0:e.length;for(n&&i&&(r=e[++o]);++o<i;)r=t(r,e[o],o,e);return r}var Ya=vm;function Mm(){this.__data__=new Ee,this.size=0}var Xa=Mm;function bm(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var Qa=bm;function km(e){return this.__data__.get(e)}var Za=km;function Pm(e){return this.__data__.has(e)}var Ja=Pm;var Um=200;function wm(e,t){var r=this.__data__;if(r instanceof Ee){var n=r.__data__;if(!xe||n.length<Um-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Le(n)}return r.set(e,t),this.size=r.size,this}var tc=wm;function Ze(e){var t=this.__data__=new Ee(e);this.size=t.size}Ze.prototype.clear=Xa;Ze.prototype.delete=Qa;Ze.prototype.get=Za;Ze.prototype.has=Ja;Ze.prototype.set=tc;var Ae=Ze;function Dm(e,t){return e&&Wt(t,P(t),e)}var ec=Dm;function Fm(e,t){return e&&Wt(t,de(t),e)}var rc=Fm;var sc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,nc=sc&&typeof module=="object"&&module&&!module.nodeType&&module,Bm=nc&&nc.exports===sc,oc=Bm?J.Buffer:void 0,ic=oc?oc.allocUnsafe:void 0;function Gm(e,t){if(t)return e.slice();var r=e.length,n=ic?ic(r):new e.constructor(r);return e.copy(n),n}var ac=Gm;function $m(e,t){for(var r=-1,n=e==null?0:e.length,o=0,i=[];++r<n;){var s=e[r];t(s,r,e)&&(i[o++]=s)}return i}var Je=$m;function jm(){return[]}var Rn=jm;var Wm=Object.prototype,Km=Wm.propertyIsEnumerable,cc=Object.getOwnPropertySymbols,Hm=cc?function(e){return e==null?[]:(e=Object(e),Je(cc(e),function(t){return Km.call(e,t)}))}:Rn,tr=Hm;function qm(e,t){return Wt(e,tr(e),t)}var lc=qm;var zm=Object.getOwnPropertySymbols,Vm=zm?function(e){for(var t=[];e;)Xe(t,tr(e)),e=On(e);return t}:Rn,yn=Vm;function Ym(e,t){return Wt(e,yn(e),t)}var uc=Ym;function Xm(e,t,r){var n=t(e);return I(e)?n:Xe(n,r(e))}var Ln=Xm;function Qm(e){return Ln(e,P,tr)}var Lr=Qm;function Zm(e){return Ln(e,de,yn)}var _n=Zm;var Jm=St(J,"DataView"),vn=Jm;var td=St(J,"Promise"),Mn=td;var ed=St(J,"Set"),Ne=ed;var fc="[object Map]",rd="[object Object]",hc="[object Promise]",pc="[object Set]",mc="[object WeakMap]",dc="[object DataView]",nd=te(vn),od=te(xe),id=te(Mn),sd=te(Ne),ad=te(En),_e=mt;(vn&&_e(new vn(new ArrayBuffer(1)))!=dc||xe&&_e(new xe)!=fc||Mn&&_e(Mn.resolve())!=hc||Ne&&_e(new Ne)!=pc||En&&_e(new En)!=mc)&&(_e=function(e){var t=mt(e),r=t==rd?e.constructor:void 0,n=r?te(r):"";if(n)switch(n){case nd:return dc;case od:return fc;case id:return hc;case sd:return pc;case ad:return mc}return t});var Ut=_e;var cd=Object.prototype,ld=cd.hasOwnProperty;function ud(e){var t=e.length,r=new e.constructor(t);return t&&typeof e[0]=="string"&&ld.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var gc=ud;var fd=J.Uint8Array,er=fd;function hd(e){var t=new e.constructor(e.byteLength);return new er(t).set(new er(e)),t}var rr=hd;function pd(e,t){var r=t?rr(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var Ec=pd;var md=/\w*$/;function dd(e){var t=new e.constructor(e.source,md.exec(e));return t.lastIndex=e.lastIndex,t}var xc=dd;var Tc=at?at.prototype:void 0,Sc=Tc?Tc.valueOf:void 0;function gd(e){return Sc?Object(Sc.call(e)):{}}var Ac=gd;function Ed(e,t){var r=t?rr(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var Nc=Ed;var xd="[object Boolean]",Td="[object Date]",Sd="[object Map]",Ad="[object Number]",Nd="[object RegExp]",Id="[object Set]",Od="[object String]",Cd="[object Symbol]",Rd="[object ArrayBuffer]",yd="[object DataView]",Ld="[object Float32Array]",_d="[object Float64Array]",vd="[object Int8Array]",Md="[object Int16Array]",bd="[object Int32Array]",kd="[object Uint8Array]",Pd="[object Uint8ClampedArray]",Ud="[object Uint16Array]",wd="[object Uint32Array]";function Dd(e,t,r){var n=e.constructor;switch(t){case Rd:return rr(e);case xd:case Td:return new n(+e);case yd:return Ec(e,r);case Ld:case _d:case vd:case Md:case bd:case kd:case Pd:case Ud:case wd:return Nc(e,r);case Sd:return new n;case Ad:case Od:return new n(e);case Nd:return xc(e);case Id:return new n;case Cd:return Ac(e)}}var Ic=Dd;function Fd(e){return typeof e.constructor=="function"&&!Kt(e)?ea(On(e)):{}}var Oc=Fd;var Bd="[object Map]";function Gd(e){return Y(e)&&Ut(e)==Bd}var Cc=Gd;var Rc=Mt&&Mt.isMap,$d=Rc?Ht(Rc):Cc,yc=$d;var jd="[object Set]";function Wd(e){return Y(e)&&Ut(e)==jd}var Lc=Wd;var _c=Mt&&Mt.isSet,Kd=_c?Ht(_c):Lc,vc=Kd;var Hd=1,qd=2,zd=4,Mc="[object Arguments]",Vd="[object Array]",Yd="[object Boolean]",Xd="[object Date]",Qd="[object Error]",bc="[object Function]",Zd="[object GeneratorFunction]",Jd="[object Map]",tg="[object Number]",kc="[object Object]",eg="[object RegExp]",rg="[object Set]",ng="[object String]",og="[object Symbol]",ig="[object WeakMap]",sg="[object ArrayBuffer]",ag="[object DataView]",cg="[object Float32Array]",lg="[object Float64Array]",ug="[object Int8Array]",fg="[object Int16Array]",hg="[object Int32Array]",pg="[object Uint8Array]",mg="[object Uint8ClampedArray]",dg="[object Uint16Array]",gg="[object Uint32Array]",U={};U[Mc]=U[Vd]=U[sg]=U[ag]=U[Yd]=U[Xd]=U[cg]=U[lg]=U[ug]=U[fg]=U[hg]=U[Jd]=U[tg]=U[kc]=U[eg]=U[rg]=U[ng]=U[og]=U[pg]=U[mg]=U[dg]=U[gg]=!0;U[Qd]=U[bc]=U[ig]=!1;function bn(e,t,r,n,o,i){var s,a=t&Hd,c=t&qd,l=t&zd;if(r&&(s=o?r(e,n,o,i):r(e)),s!==void 0)return s;if(!W(e))return e;var u=I(e);if(u){if(s=gc(e),!a)return na(e,s)}else{var f=Ut(e),h=f==bc||f==Zd;if(ee(e))return ac(e,a);if(f==kc||f==Mc||h&&!o){if(s=c||h?{}:Oc(e),!a)return c?uc(e,rc(s,e)):lc(e,ec(s,e))}else{if(!U[f])return o?e:{};s=Ic(e,f,a)}}i||(i=new Ae);var x=i.get(e);if(x)return x;i.set(e,s),vc(e)?e.forEach(function(R){s.add(bn(R,t,r,R,e,i))}):yc(e)&&e.forEach(function(R,N){s.set(N,bn(R,t,r,N,e,i))});var T=l?c?_n:Lr:c?de:P,O=u?void 0:T(e);return xn(O||e,function(R,N){O&&(N=R,R=e[N]),he(s,N,bn(R,t,r,N,e,i))}),s}var Pc=bn;var Eg=4;function xg(e){return Pc(e,Eg)}var w=xg;function Tg(e){for(var t=-1,r=e==null?0:e.length,n=0,o=[];++t<r;){var i=e[t];i&&(o[n++]=i)}return o}var zt=Tg;var Sg="__lodash_hash_undefined__";function Ag(e){return this.__data__.set(e,Sg),this}var Uc=Ag;function Ng(e){return this.__data__.has(e)}var wc=Ng;function kn(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new Le;++t<r;)this.add(e[t])}kn.prototype.add=kn.prototype.push=Uc;kn.prototype.has=wc;var nr=kn;function Ig(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}var Pn=Ig;function Og(e,t){return e.has(t)}var or=Og;var Cg=1,Rg=2;function yg(e,t,r,n,o,i){var s=r&Cg,a=e.length,c=t.length;if(a!=c&&!(s&&c>a))return!1;var l=i.get(e),u=i.get(t);if(l&&u)return l==t&&u==e;var f=-1,h=!0,x=r&Rg?new nr:void 0;for(i.set(e,t),i.set(t,e);++f<a;){var T=e[f],O=t[f];if(n)var R=s?n(O,T,f,t,e,i):n(T,O,f,e,t,i);if(R!==void 0){if(R)continue;h=!1;break}if(x){if(!Pn(t,function(N,E){if(!or(x,E)&&(T===N||o(T,N,r,n,i)))return x.push(E)})){h=!1;break}}else if(!(T===O||o(T,O,r,n,i))){h=!1;break}}return i.delete(e),i.delete(t),h}var Un=yg;function Lg(e){var t=-1,r=Array(e.size);return e.forEach(function(n,o){r[++t]=[o,n]}),r}var Dc=Lg;function _g(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var ir=_g;var vg=1,Mg=2,bg="[object Boolean]",kg="[object Date]",Pg="[object Error]",Ug="[object Map]",wg="[object Number]",Dg="[object RegExp]",Fg="[object Set]",Bg="[object String]",Gg="[object Symbol]",$g="[object ArrayBuffer]",jg="[object DataView]",Fc=at?at.prototype:void 0,Gi=Fc?Fc.valueOf:void 0;function Wg(e,t,r,n,o,i,s){switch(r){case jg:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case $g:return!(e.byteLength!=t.byteLength||!i(new er(e),new er(t)));case bg:case kg:case wg:return jt(+e,+t);case Pg:return e.name==t.name&&e.message==t.message;case Dg:case Bg:return e==t+"";case Ug:var a=Dc;case Fg:var c=n&vg;if(a||(a=ir),e.size!=t.size&&!c)return!1;var l=s.get(e);if(l)return l==t;n|=Mg,s.set(e,t);var u=Un(a(e),a(t),n,o,i,s);return s.delete(e),u;case Gg:if(Gi)return Gi.call(e)==Gi.call(t)}return!1}var Bc=Wg;var Kg=1,Hg=Object.prototype,qg=Hg.hasOwnProperty;function zg(e,t,r,n,o,i){var s=r&Kg,a=Lr(e),c=a.length,l=Lr(t),u=l.length;if(c!=u&&!s)return!1;for(var f=c;f--;){var h=a[f];if(!(s?h in t:qg.call(t,h)))return!1}var x=i.get(e),T=i.get(t);if(x&&T)return x==t&&T==e;var O=!0;i.set(e,t),i.set(t,e);for(var R=s;++f<c;){h=a[f];var N=e[h],E=t[h];if(n)var d=s?n(E,N,h,t,e,i):n(N,E,h,e,t,i);if(!(d===void 0?N===E||o(N,E,r,n,i):d)){O=!1;break}R||(R=h=="constructor")}if(O&&!R){var y=e.constructor,L=t.constructor;y!=L&&"constructor"in e&&"constructor"in t&&!(typeof y=="function"&&y instanceof y&&typeof L=="function"&&L instanceof L)&&(O=!1)}return i.delete(e),i.delete(t),O}var Gc=zg;var Vg=1,$c="[object Arguments]",jc="[object Array]",wn="[object Object]",Yg=Object.prototype,Wc=Yg.hasOwnProperty;function Xg(e,t,r,n,o,i){var s=I(e),a=I(t),c=s?jc:Ut(e),l=a?jc:Ut(t);c=c==$c?wn:c,l=l==$c?wn:l;var u=c==wn,f=l==wn,h=c==l;if(h&&ee(e)){if(!ee(t))return!1;s=!0,u=!1}if(h&&!u)return i||(i=new Ae),s||Ke(e)?Un(e,t,r,n,o,i):Bc(e,t,c,r,n,o,i);if(!(r&Vg)){var x=u&&Wc.call(e,"__wrapped__"),T=f&&Wc.call(t,"__wrapped__");if(x||T){var O=x?e.value():e,R=T?t.value():t;return i||(i=new Ae),o(O,R,r,n,i)}}return h?(i||(i=new Ae),Gc(e,t,r,n,o,i)):!1}var Kc=Xg;function Hc(e,t,r,n,o){return e===t?!0:e==null||t==null||!Y(e)&&!Y(t)?e!==e&&t!==t:Kc(e,t,r,n,Hc,o)}var Dn=Hc;var Qg=1,Zg=2;function Jg(e,t,r,n){var o=r.length,i=o,s=!n;if(e==null)return!i;for(e=Object(e);o--;){var a=r[o];if(s&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++o<i;){a=r[o];var c=a[0],l=e[c],u=a[1];if(s&&a[2]){if(l===void 0&&!(c in e))return!1}else{var f=new Ae;if(n)var h=n(l,u,c,e,t,f);if(!(h===void 0?Dn(u,l,Qg|Zg,n,f):h))return!1}}return!0}var qc=Jg;function tE(e){return e===e&&!W(e)}var Fn=tE;function eE(e){for(var t=P(e),r=t.length;r--;){var n=t[r],o=e[n];t[r]=[n,o,Fn(o)]}return t}var zc=eE;function rE(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==void 0||e in Object(r))}}var Bn=rE;function nE(e){var t=zc(e);return t.length==1&&t[0][2]?Bn(t[0][0],t[0][1]):function(r){return r===e||qc(r,e,t)}}var Vc=nE;function oE(e,t){return e!=null&&t in Object(e)}var Yc=oE;function iE(e,t,r){t=Se(t,e);for(var n=-1,o=t.length,i=!1;++n<o;){var s=qt(t[n]);if(!(i=e!=null&&r(e,s)))break;e=e[s]}return i||++n!=o?i:(o=e==null?0:e.length,!!o&&We(o)&&fe(s,o)&&(I(e)||me(e)))}var Gn=iE;function sE(e,t){return e!=null&&Gn(e,t,Yc)}var Xc=sE;var aE=1,cE=2;function lE(e,t){return He(e)&&Fn(t)?Bn(qt(e),t):function(r){var n=Ha(r,e);return n===void 0&&n===t?Xc(r,e):Dn(t,n,aE|cE)}}var Qc=lE;function uE(e){return function(t){return t?.[e]}}var Zc=uE;function fE(e){return function(t){return Ye(t,e)}}var Jc=fE;function hE(e){return He(e)?Zc(qt(e)):Jc(e)}var tl=hE;function pE(e){return typeof e=="function"?e:e==null?vt:typeof e=="object"?I(e)?Qc(e[0],e[1]):Vc(e):tl(e)}var et=pE;function mE(e,t,r,n){for(var o=-1,i=e==null?0:e.length;++o<i;){var s=e[o];t(n,s,r(s),e)}return n}var el=mE;function dE(e){return function(t,r,n){for(var o=-1,i=Object(t),s=n(t),a=s.length;a--;){var c=s[e?a:++o];if(r(i[c],c,i)===!1)break}return t}}var rl=dE;var gE=rl(),nl=gE;function EE(e,t){return e&&nl(e,t,P)}var ol=EE;function xE(e,t){return function(r,n){if(r==null)return r;if(!tt(r))return e(r,n);for(var o=r.length,i=t?o:-1,s=Object(r);(t?i--:++i<o)&&n(s[i],i,s)!==!1;);return r}}var il=xE;var TE=il(ol),At=TE;function SE(e,t,r,n){return At(e,function(o,i,s){t(n,o,r(o),s)}),n}var sl=SE;function AE(e,t){return function(r,n){var o=I(r)?el:sl,i=t?t():{};return o(r,e,et(n,2),i)}}var al=AE;var cl=Object.prototype,NE=cl.hasOwnProperty,IE=je(function(e,t){e=Object(e);var r=-1,n=t.length,o=n>2?t[2]:void 0;for(o&&pe(t[0],t[1],o)&&(n=1);++r<n;)for(var i=t[r],s=de(i),a=-1,c=s.length;++a<c;){var l=s[a],u=e[l];(u===void 0||jt(u,cl[l])&&!NE.call(e,l))&&(e[l]=i[l])}return e}),sr=IE;function OE(e){return Y(e)&&tt(e)}var $i=OE;function CE(e,t,r){for(var n=-1,o=e==null?0:e.length;++n<o;)if(r(t,e[n]))return!0;return!1}var $n=CE;var RE=200;function yE(e,t,r,n){var o=-1,i=Sn,s=!0,a=e.length,c=[],l=t.length;if(!a)return c;r&&(t=Gt(t,Ht(r))),n?(i=$n,s=!1):t.length>=RE&&(i=or,s=!1,t=new nr(t));t:for(;++o<a;){var u=e[o],f=r==null?u:r(u);if(u=n||u!==0?u:0,s&&f===f){for(var h=l;h--;)if(t[h]===f)continue t;c.push(u)}else i(t,f,n)||c.push(u)}return c}var ll=yE;var LE=je(function(e,t){return $i(e)?ll(e,Qe(t,1,$i,!0)):[]}),Ie=LE;function _E(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var Vt=_E;function vE(e,t,r){var n=e==null?0:e.length;return n?(t=r||t===void 0?1:$t(t),Cn(e,t<0?0:t,n)):[]}var X=vE;function ME(e,t,r){var n=e==null?0:e.length;return n?(t=r||t===void 0?1:$t(t),t=n-t,Cn(e,0,t<0?0:t)):[]}var ne=ME;function bE(e){return typeof e=="function"?e:vt}var ul=bE;function kE(e,t){var r=I(e)?xn:At;return r(e,ul(t))}var S=kE;function PE(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(!t(e[r],r,e))return!1;return!0}var fl=PE;function UE(e,t){var r=!0;return At(e,function(n,o,i){return r=!!t(n,o,i),r}),r}var hl=UE;function wE(e,t,r){var n=I(e)?fl:hl;return r&&pe(e,t,r)&&(t=void 0),n(e,et(t,3))}var ft=wE;function DE(e,t){var r=[];return At(e,function(n,o,i){t(n,o,i)&&r.push(n)}),r}var jn=DE;function FE(e,t){var r=I(e)?Je:jn;return r(e,et(t,3))}var ht=FE;function BE(e){return function(t,r,n){var o=Object(t);if(!tt(t)){var i=et(r,3);t=P(t),r=function(a){return i(o[a],a,o)}}var s=e(t,r,n);return s>-1?o[i?t[s]:s]:void 0}}var pl=BE;var GE=Math.max;function $E(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var o=r==null?0:$t(r);return o<0&&(o=GE(n+o,0)),Tn(e,et(t,3),o)}var ml=$E;var jE=pl(ml),Yt=jE;function WE(e){return e&&e.length?e[0]:void 0}var ct=WE;function KE(e,t){var r=-1,n=tt(e)?Array(e.length):[];return At(e,function(o,i,s){n[++r]=t(o,i,s)}),n}var dl=KE;function HE(e,t){var r=I(e)?Gt:dl;return r(e,et(t,3))}var g=HE;function qE(e,t){return Qe(g(e,t),1)}var gt=qE;var zE=Object.prototype,VE=zE.hasOwnProperty,YE=al(function(e,t,r){VE.call(e,r)?e[r].push(t):$e(e,r,[t])}),ji=YE;var XE=Object.prototype,QE=XE.hasOwnProperty;function ZE(e,t){return e!=null&&QE.call(e,t)}var gl=ZE;function JE(e,t){return e!=null&&Gn(e,t,gl)}var A=JE;var tx="[object String]";function ex(e){return typeof e=="string"||!I(e)&&Y(e)&&mt(e)==tx}var it=ex;function rx(e,t){return Gt(t,function(r){return e[r]})}var El=rx;function nx(e){return e==null?[]:El(e,P(e))}var k=nx;var ox=Math.max;function ix(e,t,r,n){e=tt(e)?e:k(e),r=r&&!n?$t(r):0;var o=e.length;return r<0&&(r=ox(o+r,0)),it(e)?r<=o&&e.indexOf(t,r)>-1:!!o&&Ge(e,t,r)>-1}var $=ix;var sx=Math.max;function ax(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var o=r==null?0:$t(r);return o<0&&(o=sx(n+o,0)),Ge(e,t,o)}var Wn=ax;var cx="[object Map]",lx="[object Set]",ux=Object.prototype,fx=ux.hasOwnProperty;function hx(e){if(e==null)return!0;if(tt(e)&&(I(e)||typeof e=="string"||typeof e.splice=="function"||ee(e)||Ke(e)||me(e)))return!e.length;var t=Ut(e);if(t==cx||t==lx)return!e.size;if(Kt(e))return!In(e).length;for(var r in e)if(fx.call(e,r))return!1;return!0}var _=hx;var px="[object RegExp]";function mx(e){return Y(e)&&mt(e)==px}var xl=mx;var Tl=Mt&&Mt.isRegExp,dx=Tl?Ht(Tl):xl,bt=dx;function gx(e){return e===void 0}var pt=gx;var Ex="Expected a function";function xx(e){if(typeof e!="function")throw new TypeError(Ex);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}var Sl=xx;function Tx(e,t,r,n){if(!W(e))return e;t=Se(t,e);for(var o=-1,i=t.length,s=i-1,a=e;a!=null&&++o<i;){var c=qt(t[o]),l=r;if(c==="__proto__"||c==="constructor"||c==="prototype")return e;if(o!=s){var u=a[c];l=n?n(u,c,a):void 0,l===void 0&&(l=W(u)?u:fe(t[o+1])?[]:{})}he(a,c,l),a=a[c]}return e}var Al=Tx;function Sx(e,t,r){for(var n=-1,o=t.length,i={};++n<o;){var s=t[n],a=Ye(e,s);r(a,s)&&Al(i,Se(s,e),a)}return i}var Nl=Sx;function Ax(e,t){if(e==null)return{};var r=Gt(_n(e),function(n){return[n]});return t=et(t),Nl(e,r,function(n,o){return t(n,o[0])})}var Nt=Ax;function Nx(e,t,r,n,o){return o(e,function(i,s,a){r=n?(n=!1,i):t(r,i,s,a)}),r}var Il=Nx;function Ix(e,t,r){var n=I(e)?Ya:Il,o=arguments.length<3;return n(e,et(t,4),r,o,At)}var rt=Ix;function Ox(e,t){var r=I(e)?Je:jn;return r(e,Sl(et(t,3)))}var Oe=Ox;function Cx(e,t){var r;return At(e,function(n,o,i){return r=t(n,o,i),!r}),!!r}var Ol=Cx;function Rx(e,t,r){var n=I(e)?Pn:Ol;return r&&pe(e,t,r)&&(t=void 0),n(e,et(t,3))}var _r=Rx;var yx=1/0,Lx=Ne&&1/ir(new Ne([,-0]))[1]==yx?function(e){return new Ne(e)}:K,Cl=Lx;var _x=200;function vx(e,t,r){var n=-1,o=Sn,i=e.length,s=!0,a=[],c=a;if(r)s=!1,o=$n;else if(i>=_x){var l=t?null:Cl(e);if(l)return ir(l);s=!1,o=or,c=new nr}else c=t?[]:a;t:for(;++n<i;){var u=e[n],f=t?t(u):u;if(u=r||u!==0?u:0,s&&f===f){for(var h=c.length;h--;)if(c[h]===f)continue t;t&&c.push(f),a.push(u)}else o(c,f,r)||(c!==a&&c.push(f),a.push(u))}return a}var Rl=vx;function Mx(e){return e&&e.length?Rl(e):[]}var ar=Mx;function cr(e){console&&console.error&&console.error(`Error: ${e}`)}function vr(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function Mr(e){let t=new Date().getTime(),r=e();return{time:new Date().getTime()-t,value:r}}function br(e){function t(){}t.prototype=e;let r=new t;function n(){return typeof r.bar}return n(),n(),e;(0,eval)(e)}function bx(e){return kx(e)?e.LABEL:e.name}function kx(e){return it(e.LABEL)&&e.LABEL!==""}var Lt=class{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){this._definition=t}accept(t){t.visit(this),S(this.definition,r=>{r.accept(t)})}},D=class extends Lt{constructor(t){super([]),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}set definition(t){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(t){t.visit(this)}},Et=class extends Lt{constructor(t){super(t.definition),this.orgText="",lt(this,Nt(t,r=>r!==void 0))}},F=class extends Lt{constructor(t){super(t.definition),this.ignoreAmbiguities=!1,lt(this,Nt(t,r=>r!==void 0))}},G=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}},Q=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}},Z=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}},b=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}},z=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}},V=class extends Lt{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){super(t.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,lt(this,Nt(t,r=>r!==void 0))}},v=class{constructor(t){this.idx=1,lt(this,Nt(t,r=>r!==void 0))}accept(t){t.visit(this)}};function Kn(e){return g(e,lr)}function lr(e){function t(r){return g(r,lr)}if(e instanceof D){let r={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};return it(e.label)&&(r.label=e.label),r}else{if(e instanceof F)return{type:"Alternative",definition:t(e.definition)};if(e instanceof G)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof Q)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof Z)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:lr(new v({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof z)return{type:"RepetitionWithSeparator",idx:e.idx,separator:lr(new v({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof b)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof V)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof v){let r={type:"Terminal",name:e.terminalType.name,label:bx(e.terminalType),idx:e.idx};it(e.label)&&(r.terminalLabel=e.label);let n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(r.pattern=bt(n)?n.source:n),r}else{if(e instanceof Et)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match")}}}var xt=class{visit(t){let r=t;switch(r.constructor){case D:return this.visitNonTerminal(r);case F:return this.visitAlternative(r);case G:return this.visitOption(r);case Q:return this.visitRepetitionMandatory(r);case Z:return this.visitRepetitionMandatoryWithSeparator(r);case z:return this.visitRepetitionWithSeparator(r);case b:return this.visitRepetition(r);case V:return this.visitAlternation(r);case v:return this.visitTerminal(r);case Et:return this.visitRule(r);default:throw Error("non exhaustive match")}}visitNonTerminal(t){}visitAlternative(t){}visitOption(t){}visitRepetition(t){}visitRepetitionMandatory(t){}visitRepetitionMandatoryWithSeparator(t){}visitRepetitionWithSeparator(t){}visitAlternation(t){}visitTerminal(t){}visitRule(t){}};function Wi(e){return e instanceof F||e instanceof G||e instanceof b||e instanceof Q||e instanceof Z||e instanceof z||e instanceof v||e instanceof Et}function ve(e,t=[]){return e instanceof G||e instanceof b||e instanceof z?!0:e instanceof V?_r(e.definition,n=>ve(n,t)):e instanceof D&&$(t,e)?!1:e instanceof Lt?(e instanceof D&&t.push(e),ft(e.definition,n=>ve(n,t))):!1}function Ki(e){return e instanceof V}function It(e){if(e instanceof D)return"SUBRULE";if(e instanceof G)return"OPTION";if(e instanceof V)return"OR";if(e instanceof Q)return"AT_LEAST_ONE";if(e instanceof Z)return"AT_LEAST_ONE_SEP";if(e instanceof z)return"MANY_SEP";if(e instanceof b)return"MANY";if(e instanceof v)return"CONSUME";throw Error("non exhaustive match")}var oe=class{walk(t,r=[]){S(t.definition,(n,o)=>{let i=X(t.definition,o+1);if(n instanceof D)this.walkProdRef(n,i,r);else if(n instanceof v)this.walkTerminal(n,i,r);else if(n instanceof F)this.walkFlat(n,i,r);else if(n instanceof G)this.walkOption(n,i,r);else if(n instanceof Q)this.walkAtLeastOne(n,i,r);else if(n instanceof Z)this.walkAtLeastOneSep(n,i,r);else if(n instanceof z)this.walkManySep(n,i,r);else if(n instanceof b)this.walkMany(n,i,r);else if(n instanceof V)this.walkOr(n,i,r);else throw Error("non exhaustive match")})}walkTerminal(t,r,n){}walkProdRef(t,r,n){}walkFlat(t,r,n){let o=r.concat(n);this.walk(t,o)}walkOption(t,r,n){let o=r.concat(n);this.walk(t,o)}walkAtLeastOne(t,r,n){let o=[new G({definition:t.definition})].concat(r,n);this.walk(t,o)}walkAtLeastOneSep(t,r,n){let o=yl(t,r,n);this.walk(t,o)}walkMany(t,r,n){let o=[new G({definition:t.definition})].concat(r,n);this.walk(t,o)}walkManySep(t,r,n){let o=yl(t,r,n);this.walk(t,o)}walkOr(t,r,n){let o=r.concat(n);S(t.definition,i=>{let s=new F({definition:[i]});this.walk(s,o)})}};function yl(e,t,r){return[new G({definition:[new v({terminalType:e.separator})].concat(e.definition)})].concat(t,r)}function Me(e){if(e instanceof D)return Me(e.referencedRule);if(e instanceof v)return wx(e);if(Wi(e))return Px(e);if(Ki(e))return Ux(e);throw Error("non exhaustive match")}function Px(e){let t=[],r=e.definition,n=0,o=r.length>n,i,s=!0;for(;o&&s;)i=r[n],s=ve(i),t=t.concat(Me(i)),n=n+1,o=r.length>n;return ar(t)}function Ux(e){let t=g(e.definition,r=>Me(r));return ar(ot(t))}function wx(e){return[e.terminalType]}var Hn="_~IN~_";var Hi=class extends oe{constructor(t){super(),this.topProd=t,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(t,r,n){}walkProdRef(t,r,n){let o=Dx(t.referencedRule,t.idx)+this.topProd.name,i=r.concat(n),s=new F({definition:i}),a=Me(s);this.follows[o]=a}};function Ll(e){let t={};return S(e,r=>{let n=new Hi(r).startWalking();lt(t,n)}),t}function Dx(e,t){return e.name+t+Hn}function C(e){return e.charCodeAt(0)}function qn(e,t){Array.isArray(e)?e.forEach(function(r){t.push(r)}):t.push(e)}function ur(e,t){if(e[t]===!0)throw"duplicate flag "+t;let r=e[t];e[t]=!0}function be(e){if(e===void 0)throw Error("Internal Error - Should never get here!");return!0}function kr(){throw Error("Internal Error - Should never get here!")}function qi(e){return e.type==="Character"}var Pr=[];for(let e=C("0");e<=C("9");e++)Pr.push(e);var Ur=[C("_")].concat(Pr);for(let e=C("a");e<=C("z");e++)Ur.push(e);for(let e=C("A");e<=C("Z");e++)Ur.push(e);var zi=[C(" "),C("\f"),C(`
|
|
3
|
-
`),C("\r"),C(" "),C("\v"),C(" "),C("\xA0"),C("\u1680"),C("\u2000"),C("\u2001"),C("\u2002"),C("\u2003"),C("\u2004"),C("\u2005"),C("\u2006"),C("\u2007"),C("\u2008"),C("\u2009"),C("\u200A"),C("\u2028"),C("\u2029"),C("\u202F"),C("\u205F"),C("\u3000"),C("\uFEFF")];var
|
|
4
|
-
`),C("\r"),C("\u2028"),C("\u2029")]}}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 t,r=!1;switch(this.popChar()){case"d":t=Pr;break;case"D":t=Pr,r=!0;break;case"s":t=
|
|
2
|
+
import{readFileSync as Xu,writeFileSync as JT,existsSync as tS}from"node:fs";import{resolve as Yu,basename as eS,dirname as rS,join as nS}from"node:path";import{fileURLToPath as iS}from"node:url";var Ju=typeof global=="object"&&global&&global.Object===Object&&global,dn=Ju;var tf=typeof self=="object"&&self&&self.Object===Object&&self,ef=dn||tf||Function("return this")(),J=ef;var rf=J.Symbol,at=rf;var Us=Object.prototype,nf=Us.hasOwnProperty,of=Us.toString,Rr=at?at.toStringTag:void 0;function sf(e){var t=nf.call(e,Rr),r=e[Rr];try{e[Rr]=void 0;var n=!0}catch{}var i=of.call(e);return n&&(t?e[Rr]=r:delete e[Rr]),i}var ws=sf;var af=Object.prototype,cf=af.toString;function lf(e){return cf.call(e)}var Ds=lf;var uf="[object Null]",ff="[object Undefined]",Fs=at?at.toStringTag:void 0;function hf(e){return e==null?e===void 0?ff:uf:Fs&&Fs in Object(e)?ws(e):Ds(e)}var mt=hf;function pf(e){return e!=null&&typeof e=="object"}var Y=pf;var mf="[object Symbol]";function df(e){return typeof e=="symbol"||Y(e)&&mt(e)==mf}var ue=df;function gf(e,t){for(var r=-1,n=e==null?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}var Gt=gf;var Ef=Array.isArray,O=Ef;var xf=1/0,Bs=at?at.prototype:void 0,Gs=Bs?Bs.toString:void 0;function $s(e){if(typeof e=="string")return e;if(O(e))return Gt(e,$s)+"";if(ue(e))return Gs?Gs.call(e):"";var t=e+"";return t=="0"&&1/e==-xf?"-0":t}var js=$s;var Tf=/\s/;function Sf(e){for(var t=e.length;t--&&Tf.test(e.charAt(t)););return t}var Ws=Sf;var Af=/^\s+/;function Nf(e){return e&&e.slice(0,Ws(e)+1).replace(Af,"")}var Ks=Nf;function Of(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var W=Of;var Hs=NaN,If=/^[-+]0x[0-9a-f]+$/i,Cf=/^0b[01]+$/i,Rf=/^0o[0-7]+$/i,yf=parseInt;function Lf(e){if(typeof e=="number")return e;if(ue(e))return Hs;if(W(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=W(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Ks(e);var r=Cf.test(e);return r||Rf.test(e)?yf(e.slice(2),r?2:8):If.test(e)?Hs:+e}var qs=Lf;var zs=1/0,_f=17976931348623157e292;function vf(e){if(!e)return e===0?e:0;if(e=qs(e),e===zs||e===-zs){var t=e<0?-1:1;return t*_f}return e===e?e:0}var Vs=vf;function Mf(e){var t=Vs(e),r=t%1;return t===t?r?t-r:t:0}var $t=Mf;function bf(e){return e}var vt=bf;var kf="[object AsyncFunction]",Pf="[object Function]",Uf="[object GeneratorFunction]",wf="[object Proxy]";function Df(e){if(!W(e))return!1;var t=mt(e);return t==Pf||t==Uf||t==kf||t==wf}var dt=Df;var Ff=J["__core-js_shared__"],gn=Ff;var Ys=(function(){var e=/[^.]+$/.exec(gn&&gn.keys&&gn.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function Bf(e){return!!Ys&&Ys in e}var Xs=Bf;var Gf=Function.prototype,$f=Gf.toString;function jf(e){if(e!=null){try{return $f.call(e)}catch{}try{return e+""}catch{}}return""}var te=jf;var Wf=/[\\^$.*+?()[\]{}|]/g,Kf=/^\[object .+?Constructor\]$/,Hf=Function.prototype,qf=Object.prototype,zf=Hf.toString,Vf=qf.hasOwnProperty,Yf=RegExp("^"+zf.call(Vf).replace(Wf,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Xf(e){if(!W(e)||Xs(e))return!1;var t=dt(e)?Yf:Kf;return t.test(te(e))}var Qs=Xf;function Qf(e,t){return e?.[t]}var Zs=Qf;function Zf(e,t){var r=Zs(e,t);return Qs(r)?r:void 0}var St=Zf;var Jf=St(J,"WeakMap"),En=Jf;var Js=Object.create,th=(function(){function e(){}return function(t){if(!W(t))return{};if(Js)return Js(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}})(),ta=th;function eh(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var ea=eh;function rh(){}var K=rh;function nh(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}var ra=nh;var ih=800,oh=16,sh=Date.now;function ah(e){var t=0,r=0;return function(){var n=sh(),i=oh-(n-r);if(r=n,i>0){if(++t>=ih)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var na=ah;function ch(e){return function(){return e}}var ia=ch;var lh=(function(){try{var e=St(Object,"defineProperty");return e({},"",{}),e}catch{}})(),Be=lh;var uh=Be?function(e,t){return Be(e,"toString",{configurable:!0,enumerable:!1,value:ia(t),writable:!0})}:vt,oa=uh;var fh=na(oa),sa=fh;function hh(e,t){for(var r=-1,n=e==null?0:e.length;++r<n&&t(e[r],r,e)!==!1;);return e}var xn=hh;function ph(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o<i;)if(t(e[o],o,e))return o;return-1}var Tn=ph;function mh(e){return e!==e}var aa=mh;function dh(e,t,r){for(var n=r-1,i=e.length;++n<i;)if(e[n]===t)return n;return-1}var ca=dh;function gh(e,t,r){return t===t?ca(e,t,r):Tn(e,aa,r)}var Ge=gh;function Eh(e,t){var r=e==null?0:e.length;return!!r&&Ge(e,t,0)>-1}var Sn=Eh;var xh=9007199254740991,Th=/^(?:0|[1-9]\d*)$/;function Sh(e,t){var r=typeof e;return t=t??xh,!!t&&(r=="number"||r!="symbol"&&Th.test(e))&&e>-1&&e%1==0&&e<t}var fe=Sh;function Ah(e,t,r){t=="__proto__"&&Be?Be(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var $e=Ah;function Nh(e,t){return e===t||e!==e&&t!==t}var jt=Nh;var Oh=Object.prototype,Ih=Oh.hasOwnProperty;function Ch(e,t,r){var n=e[t];(!(Ih.call(e,t)&&jt(n,r))||r===void 0&&!(t in e))&&$e(e,t,r)}var he=Ch;function Rh(e,t,r,n){var i=!r;r||(r={});for(var o=-1,s=t.length;++o<s;){var a=t[o],c=n?n(r[a],e[a],a,r,e):void 0;c===void 0&&(c=e[a]),i?$e(r,a,c):he(r,a,c)}return r}var Wt=Rh;var la=Math.max;function yh(e,t,r){return t=la(t===void 0?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=la(n.length-t,0),s=Array(o);++i<o;)s[i]=n[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=n[i];return a[t]=r(s),ea(e,this,a)}}var ua=yh;function Lh(e,t){return sa(ua(e,t,vt),e+"")}var je=Lh;var _h=9007199254740991;function vh(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=_h}var We=vh;function Mh(e){return e!=null&&We(e.length)&&!dt(e)}var tt=Mh;function bh(e,t,r){if(!W(r))return!1;var n=typeof t;return(n=="number"?tt(r)&&fe(t,r.length):n=="string"&&t in r)?jt(r[t],e):!1}var pe=bh;function kh(e){return je(function(t,r){var n=-1,i=r.length,o=i>1?r[i-1]:void 0,s=i>2?r[2]:void 0;for(o=e.length>3&&typeof o=="function"?(i--,o):void 0,s&&pe(r[0],r[1],s)&&(o=i<3?void 0:o,i=1),t=Object(t);++n<i;){var a=r[n];a&&e(t,a,n,o)}return t})}var fa=kh;var Ph=Object.prototype;function Uh(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||Ph;return e===r}var Kt=Uh;function wh(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var ha=wh;var Dh="[object Arguments]";function Fh(e){return Y(e)&&mt(e)==Dh}var wo=Fh;var pa=Object.prototype,Bh=pa.hasOwnProperty,Gh=pa.propertyIsEnumerable,$h=wo((function(){return arguments})())?wo:function(e){return Y(e)&&Bh.call(e,"callee")&&!Gh.call(e,"callee")},me=$h;function jh(){return!1}var ma=jh;var Ea=typeof exports=="object"&&exports&&!exports.nodeType&&exports,da=Ea&&typeof module=="object"&&module&&!module.nodeType&&module,Wh=da&&da.exports===Ea,ga=Wh?J.Buffer:void 0,Kh=ga?ga.isBuffer:void 0,Hh=Kh||ma,ee=Hh;var qh="[object Arguments]",zh="[object Array]",Vh="[object Boolean]",Yh="[object Date]",Xh="[object Error]",Qh="[object Function]",Zh="[object Map]",Jh="[object Number]",tp="[object Object]",ep="[object RegExp]",rp="[object Set]",np="[object String]",ip="[object WeakMap]",op="[object ArrayBuffer]",sp="[object DataView]",ap="[object Float32Array]",cp="[object Float64Array]",lp="[object Int8Array]",up="[object Int16Array]",fp="[object Int32Array]",hp="[object Uint8Array]",pp="[object Uint8ClampedArray]",mp="[object Uint16Array]",dp="[object Uint32Array]",B={};B[ap]=B[cp]=B[lp]=B[up]=B[fp]=B[hp]=B[pp]=B[mp]=B[dp]=!0;B[qh]=B[zh]=B[op]=B[Vh]=B[sp]=B[Yh]=B[Xh]=B[Qh]=B[Zh]=B[Jh]=B[tp]=B[ep]=B[rp]=B[np]=B[ip]=!1;function gp(e){return Y(e)&&We(e.length)&&!!B[mt(e)]}var xa=gp;function Ep(e){return function(t){return e(t)}}var Ht=Ep;var Ta=typeof exports=="object"&&exports&&!exports.nodeType&&exports,yr=Ta&&typeof module=="object"&&module&&!module.nodeType&&module,xp=yr&&yr.exports===Ta,Do=xp&&dn.process,Tp=(function(){try{var e=yr&&yr.require&&yr.require("util").types;return e||Do&&Do.binding&&Do.binding("util")}catch{}})(),Mt=Tp;var Sa=Mt&&Mt.isTypedArray,Sp=Sa?Ht(Sa):xa,Ke=Sp;var Ap=Object.prototype,Np=Ap.hasOwnProperty;function Op(e,t){var r=O(e),n=!r&&me(e),i=!r&&!n&&ee(e),o=!r&&!n&&!i&&Ke(e),s=r||n||i||o,a=s?ha(e.length,String):[],c=a.length;for(var l in e)(t||Np.call(e,l))&&!(s&&(l=="length"||i&&(l=="offset"||l=="parent")||o&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||fe(l,c)))&&a.push(l);return a}var An=Op;function Ip(e,t){return function(r){return e(t(r))}}var Nn=Ip;var Cp=Nn(Object.keys,Object),Aa=Cp;var Rp=Object.prototype,yp=Rp.hasOwnProperty;function Lp(e){if(!Kt(e))return Aa(e);var t=[];for(var r in Object(e))yp.call(e,r)&&r!="constructor"&&t.push(r);return t}var On=Lp;function _p(e){return tt(e)?An(e):On(e)}var P=_p;var vp=Object.prototype,Mp=vp.hasOwnProperty,bp=fa(function(e,t){if(Kt(t)||tt(t)){Wt(t,P(t),e);return}for(var r in t)Mp.call(t,r)&&he(e,r,t[r])}),lt=bp;function kp(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}var Na=kp;var Pp=Object.prototype,Up=Pp.hasOwnProperty;function wp(e){if(!W(e))return Na(e);var t=Kt(e),r=[];for(var n in e)n=="constructor"&&(t||!Up.call(e,n))||r.push(n);return r}var Oa=wp;function Dp(e){return tt(e)?An(e,!0):Oa(e)}var de=Dp;var Fp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Bp=/^\w*$/;function Gp(e,t){if(O(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||ue(e)?!0:Bp.test(e)||!Fp.test(e)||t!=null&&e in Object(t)}var He=Gp;var $p=St(Object,"create"),re=$p;function jp(){this.__data__=re?re(null):{},this.size=0}var Ia=jp;function Wp(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ca=Wp;var Kp="__lodash_hash_undefined__",Hp=Object.prototype,qp=Hp.hasOwnProperty;function zp(e){var t=this.__data__;if(re){var r=t[e];return r===Kp?void 0:r}return qp.call(t,e)?t[e]:void 0}var Ra=zp;var Vp=Object.prototype,Yp=Vp.hasOwnProperty;function Xp(e){var t=this.__data__;return re?t[e]!==void 0:Yp.call(t,e)}var ya=Xp;var Qp="__lodash_hash_undefined__";function Zp(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=re&&t===void 0?Qp:t,this}var La=Zp;function qe(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}qe.prototype.clear=Ia;qe.prototype.delete=Ca;qe.prototype.get=Ra;qe.prototype.has=ya;qe.prototype.set=La;var Fo=qe;function Jp(){this.__data__=[],this.size=0}var _a=Jp;function tm(e,t){for(var r=e.length;r--;)if(jt(e[r][0],t))return r;return-1}var ge=tm;var em=Array.prototype,rm=em.splice;function nm(e){var t=this.__data__,r=ge(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():rm.call(t,r,1),--this.size,!0}var va=nm;function im(e){var t=this.__data__,r=ge(t,e);return r<0?void 0:t[r][1]}var Ma=im;function om(e){return ge(this.__data__,e)>-1}var ba=om;function sm(e,t){var r=this.__data__,n=ge(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var ka=sm;function ze(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}ze.prototype.clear=_a;ze.prototype.delete=va;ze.prototype.get=Ma;ze.prototype.has=ba;ze.prototype.set=ka;var Ee=ze;var am=St(J,"Map"),xe=am;function cm(){this.size=0,this.__data__={hash:new Fo,map:new(xe||Ee),string:new Fo}}var Pa=cm;function lm(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Ua=lm;function um(e,t){var r=e.__data__;return Ua(t)?r[typeof t=="string"?"string":"hash"]:r.map}var Te=um;function fm(e){var t=Te(this,e).delete(e);return this.size-=t?1:0,t}var wa=fm;function hm(e){return Te(this,e).get(e)}var Da=hm;function pm(e){return Te(this,e).has(e)}var Fa=pm;function mm(e,t){var r=Te(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var Ba=mm;function Ve(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Ve.prototype.clear=Pa;Ve.prototype.delete=wa;Ve.prototype.get=Da;Ve.prototype.has=Fa;Ve.prototype.set=Ba;var Le=Ve;var dm="Expected a function";function Bo(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(dm);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(Bo.Cache||Le),r}Bo.Cache=Le;var Ga=Bo;var gm=500;function Em(e){var t=Ga(e,function(n){return r.size===gm&&r.clear(),n}),r=t.cache;return t}var $a=Em;var xm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Tm=/\\(\\)?/g,Sm=$a(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(xm,function(r,n,i,o){t.push(i?o.replace(Tm,"$1"):n||r)}),t}),ja=Sm;function Am(e){return e==null?"":js(e)}var Wa=Am;function Nm(e,t){return O(e)?e:He(e,t)?[e]:ja(Wa(e))}var Se=Nm;var Om=1/0;function Im(e){if(typeof e=="string"||ue(e))return e;var t=e+"";return t=="0"&&1/e==-Om?"-0":t}var qt=Im;function Cm(e,t){t=Se(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[qt(t[r++])];return r&&r==n?e:void 0}var Ye=Cm;function Rm(e,t,r){var n=e==null?void 0:Ye(e,t);return n===void 0?r:n}var Ka=Rm;function ym(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}var Xe=ym;var Ha=at?at.isConcatSpreadable:void 0;function Lm(e){return O(e)||me(e)||!!(Ha&&e&&e[Ha])}var qa=Lm;function za(e,t,r,n,i){var o=-1,s=e.length;for(r||(r=qa),i||(i=[]);++o<s;){var a=e[o];t>0&&r(a)?t>1?za(a,t-1,r,n,i):Xe(i,a):n||(i[i.length]=a)}return i}var Qe=za;function _m(e){var t=e==null?0:e.length;return t?Qe(e,1):[]}var it=_m;var vm=Nn(Object.getPrototypeOf,Object),In=vm;function Mm(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),r=r>i?i:r,r<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n<i;)o[n]=e[n+t];return o}var Cn=Mm;function bm(e,t,r,n){var i=-1,o=e==null?0:e.length;for(n&&o&&(r=e[++i]);++i<o;)r=t(r,e[i],i,e);return r}var Va=bm;function km(){this.__data__=new Ee,this.size=0}var Ya=km;function Pm(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var Xa=Pm;function Um(e){return this.__data__.get(e)}var Qa=Um;function wm(e){return this.__data__.has(e)}var Za=wm;var Dm=200;function Fm(e,t){var r=this.__data__;if(r instanceof Ee){var n=r.__data__;if(!xe||n.length<Dm-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Le(n)}return r.set(e,t),this.size=r.size,this}var Ja=Fm;function Ze(e){var t=this.__data__=new Ee(e);this.size=t.size}Ze.prototype.clear=Ya;Ze.prototype.delete=Xa;Ze.prototype.get=Qa;Ze.prototype.has=Za;Ze.prototype.set=Ja;var Ae=Ze;function Bm(e,t){return e&&Wt(t,P(t),e)}var tc=Bm;function Gm(e,t){return e&&Wt(t,de(t),e)}var ec=Gm;var oc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,rc=oc&&typeof module=="object"&&module&&!module.nodeType&&module,$m=rc&&rc.exports===oc,nc=$m?J.Buffer:void 0,ic=nc?nc.allocUnsafe:void 0;function jm(e,t){if(t)return e.slice();var r=e.length,n=ic?ic(r):new e.constructor(r);return e.copy(n),n}var sc=jm;function Wm(e,t){for(var r=-1,n=e==null?0:e.length,i=0,o=[];++r<n;){var s=e[r];t(s,r,e)&&(o[i++]=s)}return o}var Je=Wm;function Km(){return[]}var Rn=Km;var Hm=Object.prototype,qm=Hm.propertyIsEnumerable,ac=Object.getOwnPropertySymbols,zm=ac?function(e){return e==null?[]:(e=Object(e),Je(ac(e),function(t){return qm.call(e,t)}))}:Rn,tr=zm;function Vm(e,t){return Wt(e,tr(e),t)}var cc=Vm;var Ym=Object.getOwnPropertySymbols,Xm=Ym?function(e){for(var t=[];e;)Xe(t,tr(e)),e=In(e);return t}:Rn,yn=Xm;function Qm(e,t){return Wt(e,yn(e),t)}var lc=Qm;function Zm(e,t,r){var n=t(e);return O(e)?n:Xe(n,r(e))}var Ln=Zm;function Jm(e){return Ln(e,P,tr)}var Lr=Jm;function td(e){return Ln(e,de,yn)}var _n=td;var ed=St(J,"DataView"),vn=ed;var rd=St(J,"Promise"),Mn=rd;var nd=St(J,"Set"),Ne=nd;var uc="[object Map]",id="[object Object]",fc="[object Promise]",hc="[object Set]",pc="[object WeakMap]",mc="[object DataView]",od=te(vn),sd=te(xe),ad=te(Mn),cd=te(Ne),ld=te(En),_e=mt;(vn&&_e(new vn(new ArrayBuffer(1)))!=mc||xe&&_e(new xe)!=uc||Mn&&_e(Mn.resolve())!=fc||Ne&&_e(new Ne)!=hc||En&&_e(new En)!=pc)&&(_e=function(e){var t=mt(e),r=t==id?e.constructor:void 0,n=r?te(r):"";if(n)switch(n){case od:return mc;case sd:return uc;case ad:return fc;case cd:return hc;case ld:return pc}return t});var Ut=_e;var ud=Object.prototype,fd=ud.hasOwnProperty;function hd(e){var t=e.length,r=new e.constructor(t);return t&&typeof e[0]=="string"&&fd.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var dc=hd;var pd=J.Uint8Array,er=pd;function md(e){var t=new e.constructor(e.byteLength);return new er(t).set(new er(e)),t}var rr=md;function dd(e,t){var r=t?rr(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var gc=dd;var gd=/\w*$/;function Ed(e){var t=new e.constructor(e.source,gd.exec(e));return t.lastIndex=e.lastIndex,t}var Ec=Ed;var xc=at?at.prototype:void 0,Tc=xc?xc.valueOf:void 0;function xd(e){return Tc?Object(Tc.call(e)):{}}var Sc=xd;function Td(e,t){var r=t?rr(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var Ac=Td;var Sd="[object Boolean]",Ad="[object Date]",Nd="[object Map]",Od="[object Number]",Id="[object RegExp]",Cd="[object Set]",Rd="[object String]",yd="[object Symbol]",Ld="[object ArrayBuffer]",_d="[object DataView]",vd="[object Float32Array]",Md="[object Float64Array]",bd="[object Int8Array]",kd="[object Int16Array]",Pd="[object Int32Array]",Ud="[object Uint8Array]",wd="[object Uint8ClampedArray]",Dd="[object Uint16Array]",Fd="[object Uint32Array]";function Bd(e,t,r){var n=e.constructor;switch(t){case Ld:return rr(e);case Sd:case Ad:return new n(+e);case _d:return gc(e,r);case vd:case Md:case bd:case kd:case Pd:case Ud:case wd:case Dd:case Fd:return Ac(e,r);case Nd:return new n;case Od:case Rd:return new n(e);case Id:return Ec(e);case Cd:return new n;case yd:return Sc(e)}}var Nc=Bd;function Gd(e){return typeof e.constructor=="function"&&!Kt(e)?ta(In(e)):{}}var Oc=Gd;var $d="[object Map]";function jd(e){return Y(e)&&Ut(e)==$d}var Ic=jd;var Cc=Mt&&Mt.isMap,Wd=Cc?Ht(Cc):Ic,Rc=Wd;var Kd="[object Set]";function Hd(e){return Y(e)&&Ut(e)==Kd}var yc=Hd;var Lc=Mt&&Mt.isSet,qd=Lc?Ht(Lc):yc,_c=qd;var zd=1,Vd=2,Yd=4,vc="[object Arguments]",Xd="[object Array]",Qd="[object Boolean]",Zd="[object Date]",Jd="[object Error]",Mc="[object Function]",tg="[object GeneratorFunction]",eg="[object Map]",rg="[object Number]",bc="[object Object]",ng="[object RegExp]",ig="[object Set]",og="[object String]",sg="[object Symbol]",ag="[object WeakMap]",cg="[object ArrayBuffer]",lg="[object DataView]",ug="[object Float32Array]",fg="[object Float64Array]",hg="[object Int8Array]",pg="[object Int16Array]",mg="[object Int32Array]",dg="[object Uint8Array]",gg="[object Uint8ClampedArray]",Eg="[object Uint16Array]",xg="[object Uint32Array]",U={};U[vc]=U[Xd]=U[cg]=U[lg]=U[Qd]=U[Zd]=U[ug]=U[fg]=U[hg]=U[pg]=U[mg]=U[eg]=U[rg]=U[bc]=U[ng]=U[ig]=U[og]=U[sg]=U[dg]=U[gg]=U[Eg]=U[xg]=!0;U[Jd]=U[Mc]=U[ag]=!1;function bn(e,t,r,n,i,o){var s,a=t&zd,c=t&Vd,l=t&Yd;if(r&&(s=i?r(e,n,i,o):r(e)),s!==void 0)return s;if(!W(e))return e;var u=O(e);if(u){if(s=dc(e),!a)return ra(e,s)}else{var f=Ut(e),h=f==Mc||f==tg;if(ee(e))return sc(e,a);if(f==bc||f==vc||h&&!i){if(s=c||h?{}:Oc(e),!a)return c?lc(e,ec(s,e)):cc(e,tc(s,e))}else{if(!U[f])return i?e:{};s=Nc(e,f,a)}}o||(o=new Ae);var g=o.get(e);if(g)return g;o.set(e,s),_c(e)?e.forEach(function(R){s.add(bn(R,t,r,R,e,o))}):Rc(e)&&e.forEach(function(R,N){s.set(N,bn(R,t,r,N,e,o))});var T=l?c?_n:Lr:c?de:P,I=u?void 0:T(e);return xn(I||e,function(R,N){I&&(N=R,R=e[N]),he(s,N,bn(R,t,r,N,e,o))}),s}var kc=bn;var Tg=4;function Sg(e){return kc(e,Tg)}var w=Sg;function Ag(e){for(var t=-1,r=e==null?0:e.length,n=0,i=[];++t<r;){var o=e[t];o&&(i[n++]=o)}return i}var zt=Ag;var Ng="__lodash_hash_undefined__";function Og(e){return this.__data__.set(e,Ng),this}var Pc=Og;function Ig(e){return this.__data__.has(e)}var Uc=Ig;function kn(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new Le;++t<r;)this.add(e[t])}kn.prototype.add=kn.prototype.push=Pc;kn.prototype.has=Uc;var nr=kn;function Cg(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}var Pn=Cg;function Rg(e,t){return e.has(t)}var ir=Rg;var yg=1,Lg=2;function _g(e,t,r,n,i,o){var s=r&yg,a=e.length,c=t.length;if(a!=c&&!(s&&c>a))return!1;var l=o.get(e),u=o.get(t);if(l&&u)return l==t&&u==e;var f=-1,h=!0,g=r&Lg?new nr:void 0;for(o.set(e,t),o.set(t,e);++f<a;){var T=e[f],I=t[f];if(n)var R=s?n(I,T,f,t,e,o):n(T,I,f,e,t,o);if(R!==void 0){if(R)continue;h=!1;break}if(g){if(!Pn(t,function(N,x){if(!ir(g,x)&&(T===N||i(T,N,r,n,o)))return g.push(x)})){h=!1;break}}else if(!(T===I||i(T,I,r,n,o))){h=!1;break}}return o.delete(e),o.delete(t),h}var Un=_g;function vg(e){var t=-1,r=Array(e.size);return e.forEach(function(n,i){r[++t]=[i,n]}),r}var wc=vg;function Mg(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var or=Mg;var bg=1,kg=2,Pg="[object Boolean]",Ug="[object Date]",wg="[object Error]",Dg="[object Map]",Fg="[object Number]",Bg="[object RegExp]",Gg="[object Set]",$g="[object String]",jg="[object Symbol]",Wg="[object ArrayBuffer]",Kg="[object DataView]",Dc=at?at.prototype:void 0,Go=Dc?Dc.valueOf:void 0;function Hg(e,t,r,n,i,o,s){switch(r){case Kg:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Wg:return!(e.byteLength!=t.byteLength||!o(new er(e),new er(t)));case Pg:case Ug:case Fg:return jt(+e,+t);case wg:return e.name==t.name&&e.message==t.message;case Bg:case $g:return e==t+"";case Dg:var a=wc;case Gg:var c=n&bg;if(a||(a=or),e.size!=t.size&&!c)return!1;var l=s.get(e);if(l)return l==t;n|=kg,s.set(e,t);var u=Un(a(e),a(t),n,i,o,s);return s.delete(e),u;case jg:if(Go)return Go.call(e)==Go.call(t)}return!1}var Fc=Hg;var qg=1,zg=Object.prototype,Vg=zg.hasOwnProperty;function Yg(e,t,r,n,i,o){var s=r&qg,a=Lr(e),c=a.length,l=Lr(t),u=l.length;if(c!=u&&!s)return!1;for(var f=c;f--;){var h=a[f];if(!(s?h in t:Vg.call(t,h)))return!1}var g=o.get(e),T=o.get(t);if(g&&T)return g==t&&T==e;var I=!0;o.set(e,t),o.set(t,e);for(var R=s;++f<c;){h=a[f];var N=e[h],x=t[h];if(n)var d=s?n(x,N,h,t,e,o):n(N,x,h,e,t,o);if(!(d===void 0?N===x||i(N,x,r,n,o):d)){I=!1;break}R||(R=h=="constructor")}if(I&&!R){var y=e.constructor,L=t.constructor;y!=L&&"constructor"in e&&"constructor"in t&&!(typeof y=="function"&&y instanceof y&&typeof L=="function"&&L instanceof L)&&(I=!1)}return o.delete(e),o.delete(t),I}var Bc=Yg;var Xg=1,Gc="[object Arguments]",$c="[object Array]",wn="[object Object]",Qg=Object.prototype,jc=Qg.hasOwnProperty;function Zg(e,t,r,n,i,o){var s=O(e),a=O(t),c=s?$c:Ut(e),l=a?$c:Ut(t);c=c==Gc?wn:c,l=l==Gc?wn:l;var u=c==wn,f=l==wn,h=c==l;if(h&&ee(e)){if(!ee(t))return!1;s=!0,u=!1}if(h&&!u)return o||(o=new Ae),s||Ke(e)?Un(e,t,r,n,i,o):Fc(e,t,c,r,n,i,o);if(!(r&Xg)){var g=u&&jc.call(e,"__wrapped__"),T=f&&jc.call(t,"__wrapped__");if(g||T){var I=g?e.value():e,R=T?t.value():t;return o||(o=new Ae),i(I,R,r,n,o)}}return h?(o||(o=new Ae),Bc(e,t,r,n,i,o)):!1}var Wc=Zg;function Kc(e,t,r,n,i){return e===t?!0:e==null||t==null||!Y(e)&&!Y(t)?e!==e&&t!==t:Wc(e,t,r,n,Kc,i)}var Dn=Kc;var Jg=1,tE=2;function eE(e,t,r,n){var i=r.length,o=i,s=!n;if(e==null)return!o;for(e=Object(e);i--;){var a=r[i];if(s&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++i<o;){a=r[i];var c=a[0],l=e[c],u=a[1];if(s&&a[2]){if(l===void 0&&!(c in e))return!1}else{var f=new Ae;if(n)var h=n(l,u,c,e,t,f);if(!(h===void 0?Dn(u,l,Jg|tE,n,f):h))return!1}}return!0}var Hc=eE;function rE(e){return e===e&&!W(e)}var Fn=rE;function nE(e){for(var t=P(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,Fn(i)]}return t}var qc=nE;function iE(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==void 0||e in Object(r))}}var Bn=iE;function oE(e){var t=qc(e);return t.length==1&&t[0][2]?Bn(t[0][0],t[0][1]):function(r){return r===e||Hc(r,e,t)}}var zc=oE;function sE(e,t){return e!=null&&t in Object(e)}var Vc=sE;function aE(e,t,r){t=Se(t,e);for(var n=-1,i=t.length,o=!1;++n<i;){var s=qt(t[n]);if(!(o=e!=null&&r(e,s)))break;e=e[s]}return o||++n!=i?o:(i=e==null?0:e.length,!!i&&We(i)&&fe(s,i)&&(O(e)||me(e)))}var Gn=aE;function cE(e,t){return e!=null&&Gn(e,t,Vc)}var Yc=cE;var lE=1,uE=2;function fE(e,t){return He(e)&&Fn(t)?Bn(qt(e),t):function(r){var n=Ka(r,e);return n===void 0&&n===t?Yc(r,e):Dn(t,n,lE|uE)}}var Xc=fE;function hE(e){return function(t){return t?.[e]}}var Qc=hE;function pE(e){return function(t){return Ye(t,e)}}var Zc=pE;function mE(e){return He(e)?Qc(qt(e)):Zc(e)}var Jc=mE;function dE(e){return typeof e=="function"?e:e==null?vt:typeof e=="object"?O(e)?Xc(e[0],e[1]):zc(e):Jc(e)}var et=dE;function gE(e,t,r,n){for(var i=-1,o=e==null?0:e.length;++i<o;){var s=e[i];t(n,s,r(s),e)}return n}var tl=gE;function EE(e){return function(t,r,n){for(var i=-1,o=Object(t),s=n(t),a=s.length;a--;){var c=s[e?a:++i];if(r(o[c],c,o)===!1)break}return t}}var el=EE;var xE=el(),rl=xE;function TE(e,t){return e&&rl(e,t,P)}var nl=TE;function SE(e,t){return function(r,n){if(r==null)return r;if(!tt(r))return e(r,n);for(var i=r.length,o=t?i:-1,s=Object(r);(t?o--:++o<i)&&n(s[o],o,s)!==!1;);return r}}var il=SE;var AE=il(nl),At=AE;function NE(e,t,r,n){return At(e,function(i,o,s){t(n,i,r(i),s)}),n}var ol=NE;function OE(e,t){return function(r,n){var i=O(r)?tl:ol,o=t?t():{};return i(r,e,et(n,2),o)}}var sl=OE;var al=Object.prototype,IE=al.hasOwnProperty,CE=je(function(e,t){e=Object(e);var r=-1,n=t.length,i=n>2?t[2]:void 0;for(i&&pe(t[0],t[1],i)&&(n=1);++r<n;)for(var o=t[r],s=de(o),a=-1,c=s.length;++a<c;){var l=s[a],u=e[l];(u===void 0||jt(u,al[l])&&!IE.call(e,l))&&(e[l]=o[l])}return e}),sr=CE;function RE(e){return Y(e)&&tt(e)}var $o=RE;function yE(e,t,r){for(var n=-1,i=e==null?0:e.length;++n<i;)if(r(t,e[n]))return!0;return!1}var $n=yE;var LE=200;function _E(e,t,r,n){var i=-1,o=Sn,s=!0,a=e.length,c=[],l=t.length;if(!a)return c;r&&(t=Gt(t,Ht(r))),n?(o=$n,s=!1):t.length>=LE&&(o=ir,s=!1,t=new nr(t));t:for(;++i<a;){var u=e[i],f=r==null?u:r(u);if(u=n||u!==0?u:0,s&&f===f){for(var h=l;h--;)if(t[h]===f)continue t;c.push(u)}else o(t,f,n)||c.push(u)}return c}var cl=_E;var vE=je(function(e,t){return $o(e)?cl(e,Qe(t,1,$o,!0)):[]}),Oe=vE;function ME(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var Vt=ME;function bE(e,t,r){var n=e==null?0:e.length;return n?(t=r||t===void 0?1:$t(t),Cn(e,t<0?0:t,n)):[]}var X=bE;function kE(e,t,r){var n=e==null?0:e.length;return n?(t=r||t===void 0?1:$t(t),t=n-t,Cn(e,0,t<0?0:t)):[]}var ne=kE;function PE(e){return typeof e=="function"?e:vt}var ll=PE;function UE(e,t){var r=O(e)?xn:At;return r(e,ll(t))}var S=UE;function wE(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(!t(e[r],r,e))return!1;return!0}var ul=wE;function DE(e,t){var r=!0;return At(e,function(n,i,o){return r=!!t(n,i,o),r}),r}var fl=DE;function FE(e,t,r){var n=O(e)?ul:fl;return r&&pe(e,t,r)&&(t=void 0),n(e,et(t,3))}var ft=FE;function BE(e,t){var r=[];return At(e,function(n,i,o){t(n,i,o)&&r.push(n)}),r}var jn=BE;function GE(e,t){var r=O(e)?Je:jn;return r(e,et(t,3))}var ht=GE;function $E(e){return function(t,r,n){var i=Object(t);if(!tt(t)){var o=et(r,3);t=P(t),r=function(a){return o(i[a],a,i)}}var s=e(t,r,n);return s>-1?i[o?t[s]:s]:void 0}}var hl=$E;var jE=Math.max;function WE(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var i=r==null?0:$t(r);return i<0&&(i=jE(n+i,0)),Tn(e,et(t,3),i)}var pl=WE;var KE=hl(pl),Yt=KE;function HE(e){return e&&e.length?e[0]:void 0}var ct=HE;function qE(e,t){var r=-1,n=tt(e)?Array(e.length):[];return At(e,function(i,o,s){n[++r]=t(i,o,s)}),n}var ml=qE;function zE(e,t){var r=O(e)?Gt:ml;return r(e,et(t,3))}var E=zE;function VE(e,t){return Qe(E(e,t),1)}var gt=VE;var YE=Object.prototype,XE=YE.hasOwnProperty,QE=sl(function(e,t,r){XE.call(e,r)?e[r].push(t):$e(e,r,[t])}),jo=QE;var ZE=Object.prototype,JE=ZE.hasOwnProperty;function tx(e,t){return e!=null&&JE.call(e,t)}var dl=tx;function ex(e,t){return e!=null&&Gn(e,t,dl)}var A=ex;var rx="[object String]";function nx(e){return typeof e=="string"||!O(e)&&Y(e)&&mt(e)==rx}var ot=nx;function ix(e,t){return Gt(t,function(r){return e[r]})}var gl=ix;function ox(e){return e==null?[]:gl(e,P(e))}var k=ox;var sx=Math.max;function ax(e,t,r,n){e=tt(e)?e:k(e),r=r&&!n?$t(r):0;var i=e.length;return r<0&&(r=sx(i+r,0)),ot(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&Ge(e,t,r)>-1}var $=ax;var cx=Math.max;function lx(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var i=r==null?0:$t(r);return i<0&&(i=cx(n+i,0)),Ge(e,t,i)}var Wn=lx;var ux="[object Map]",fx="[object Set]",hx=Object.prototype,px=hx.hasOwnProperty;function mx(e){if(e==null)return!0;if(tt(e)&&(O(e)||typeof e=="string"||typeof e.splice=="function"||ee(e)||Ke(e)||me(e)))return!e.length;var t=Ut(e);if(t==ux||t==fx)return!e.size;if(Kt(e))return!On(e).length;for(var r in e)if(px.call(e,r))return!1;return!0}var _=mx;var dx="[object RegExp]";function gx(e){return Y(e)&&mt(e)==dx}var El=gx;var xl=Mt&&Mt.isRegExp,Ex=xl?Ht(xl):El,bt=Ex;function xx(e){return e===void 0}var pt=xx;var Tx="Expected a function";function Sx(e){if(typeof e!="function")throw new TypeError(Tx);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}var Tl=Sx;function Ax(e,t,r,n){if(!W(e))return e;t=Se(t,e);for(var i=-1,o=t.length,s=o-1,a=e;a!=null&&++i<o;){var c=qt(t[i]),l=r;if(c==="__proto__"||c==="constructor"||c==="prototype")return e;if(i!=s){var u=a[c];l=n?n(u,c,a):void 0,l===void 0&&(l=W(u)?u:fe(t[i+1])?[]:{})}he(a,c,l),a=a[c]}return e}var Sl=Ax;function Nx(e,t,r){for(var n=-1,i=t.length,o={};++n<i;){var s=t[n],a=Ye(e,s);r(a,s)&&Sl(o,Se(s,e),a)}return o}var Al=Nx;function Ox(e,t){if(e==null)return{};var r=Gt(_n(e),function(n){return[n]});return t=et(t),Al(e,r,function(n,i){return t(n,i[0])})}var Nt=Ox;function Ix(e,t,r,n,i){return i(e,function(o,s,a){r=n?(n=!1,o):t(r,o,s,a)}),r}var Nl=Ix;function Cx(e,t,r){var n=O(e)?Va:Nl,i=arguments.length<3;return n(e,et(t,4),r,i,At)}var rt=Cx;function Rx(e,t){var r=O(e)?Je:jn;return r(e,Tl(et(t,3)))}var Ie=Rx;function yx(e,t){var r;return At(e,function(n,i,o){return r=t(n,i,o),!r}),!!r}var Ol=yx;function Lx(e,t,r){var n=O(e)?Pn:Ol;return r&&pe(e,t,r)&&(t=void 0),n(e,et(t,3))}var _r=Lx;var _x=1/0,vx=Ne&&1/or(new Ne([,-0]))[1]==_x?function(e){return new Ne(e)}:K,Il=vx;var Mx=200;function bx(e,t,r){var n=-1,i=Sn,o=e.length,s=!0,a=[],c=a;if(r)s=!1,i=$n;else if(o>=Mx){var l=t?null:Il(e);if(l)return or(l);s=!1,i=ir,c=new nr}else c=t?[]:a;t:for(;++n<o;){var u=e[n],f=t?t(u):u;if(u=r||u!==0?u:0,s&&f===f){for(var h=c.length;h--;)if(c[h]===f)continue t;t&&c.push(f),a.push(u)}else i(c,f,r)||(c!==a&&c.push(f),a.push(u))}return a}var Cl=bx;function kx(e){return e&&e.length?Cl(e):[]}var ar=kx;function cr(e){console&&console.error&&console.error(`Error: ${e}`)}function vr(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function Mr(e){let t=new Date().getTime(),r=e();return{time:new Date().getTime()-t,value:r}}function br(e){function t(){}t.prototype=e;let r=new t;function n(){return typeof r.bar}return n(),n(),e;(0,eval)(e)}function Px(e){return Ux(e)?e.LABEL:e.name}function Ux(e){return ot(e.LABEL)&&e.LABEL!==""}var Lt=class{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){this._definition=t}accept(t){t.visit(this),S(this.definition,r=>{r.accept(t)})}},D=class extends Lt{constructor(t){super([]),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}set definition(t){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(t){t.visit(this)}},Et=class extends Lt{constructor(t){super(t.definition),this.orgText="",lt(this,Nt(t,r=>r!==void 0))}},F=class extends Lt{constructor(t){super(t.definition),this.ignoreAmbiguities=!1,lt(this,Nt(t,r=>r!==void 0))}},G=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}},Q=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}},Z=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}},b=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}},z=class extends Lt{constructor(t){super(t.definition),this.idx=1,lt(this,Nt(t,r=>r!==void 0))}},V=class extends Lt{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){super(t.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,lt(this,Nt(t,r=>r!==void 0))}},v=class{constructor(t){this.idx=1,lt(this,Nt(t,r=>r!==void 0))}accept(t){t.visit(this)}};function Kn(e){return E(e,lr)}function lr(e){function t(r){return E(r,lr)}if(e instanceof D){let r={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};return ot(e.label)&&(r.label=e.label),r}else{if(e instanceof F)return{type:"Alternative",definition:t(e.definition)};if(e instanceof G)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof Q)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof Z)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:lr(new v({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof z)return{type:"RepetitionWithSeparator",idx:e.idx,separator:lr(new v({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof b)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof V)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof v){let r={type:"Terminal",name:e.terminalType.name,label:Px(e.terminalType),idx:e.idx};ot(e.label)&&(r.terminalLabel=e.label);let n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(r.pattern=bt(n)?n.source:n),r}else{if(e instanceof Et)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match")}}}var xt=class{visit(t){let r=t;switch(r.constructor){case D:return this.visitNonTerminal(r);case F:return this.visitAlternative(r);case G:return this.visitOption(r);case Q:return this.visitRepetitionMandatory(r);case Z:return this.visitRepetitionMandatoryWithSeparator(r);case z:return this.visitRepetitionWithSeparator(r);case b:return this.visitRepetition(r);case V:return this.visitAlternation(r);case v:return this.visitTerminal(r);case Et:return this.visitRule(r);default:throw Error("non exhaustive match")}}visitNonTerminal(t){}visitAlternative(t){}visitOption(t){}visitRepetition(t){}visitRepetitionMandatory(t){}visitRepetitionMandatoryWithSeparator(t){}visitRepetitionWithSeparator(t){}visitAlternation(t){}visitTerminal(t){}visitRule(t){}};function Wo(e){return e instanceof F||e instanceof G||e instanceof b||e instanceof Q||e instanceof Z||e instanceof z||e instanceof v||e instanceof Et}function ve(e,t=[]){return e instanceof G||e instanceof b||e instanceof z?!0:e instanceof V?_r(e.definition,n=>ve(n,t)):e instanceof D&&$(t,e)?!1:e instanceof Lt?(e instanceof D&&t.push(e),ft(e.definition,n=>ve(n,t))):!1}function Ko(e){return e instanceof V}function Ot(e){if(e instanceof D)return"SUBRULE";if(e instanceof G)return"OPTION";if(e instanceof V)return"OR";if(e instanceof Q)return"AT_LEAST_ONE";if(e instanceof Z)return"AT_LEAST_ONE_SEP";if(e instanceof z)return"MANY_SEP";if(e instanceof b)return"MANY";if(e instanceof v)return"CONSUME";throw Error("non exhaustive match")}var ie=class{walk(t,r=[]){S(t.definition,(n,i)=>{let o=X(t.definition,i+1);if(n instanceof D)this.walkProdRef(n,o,r);else if(n instanceof v)this.walkTerminal(n,o,r);else if(n instanceof F)this.walkFlat(n,o,r);else if(n instanceof G)this.walkOption(n,o,r);else if(n instanceof Q)this.walkAtLeastOne(n,o,r);else if(n instanceof Z)this.walkAtLeastOneSep(n,o,r);else if(n instanceof z)this.walkManySep(n,o,r);else if(n instanceof b)this.walkMany(n,o,r);else if(n instanceof V)this.walkOr(n,o,r);else throw Error("non exhaustive match")})}walkTerminal(t,r,n){}walkProdRef(t,r,n){}walkFlat(t,r,n){let i=r.concat(n);this.walk(t,i)}walkOption(t,r,n){let i=r.concat(n);this.walk(t,i)}walkAtLeastOne(t,r,n){let i=[new G({definition:t.definition})].concat(r,n);this.walk(t,i)}walkAtLeastOneSep(t,r,n){let i=Rl(t,r,n);this.walk(t,i)}walkMany(t,r,n){let i=[new G({definition:t.definition})].concat(r,n);this.walk(t,i)}walkManySep(t,r,n){let i=Rl(t,r,n);this.walk(t,i)}walkOr(t,r,n){let i=r.concat(n);S(t.definition,o=>{let s=new F({definition:[o]});this.walk(s,i)})}};function Rl(e,t,r){return[new G({definition:[new v({terminalType:e.separator})].concat(e.definition)})].concat(t,r)}function Me(e){if(e instanceof D)return Me(e.referencedRule);if(e instanceof v)return Fx(e);if(Wo(e))return wx(e);if(Ko(e))return Dx(e);throw Error("non exhaustive match")}function wx(e){let t=[],r=e.definition,n=0,i=r.length>n,o,s=!0;for(;i&&s;)o=r[n],s=ve(o),t=t.concat(Me(o)),n=n+1,i=r.length>n;return ar(t)}function Dx(e){let t=E(e.definition,r=>Me(r));return ar(it(t))}function Fx(e){return[e.terminalType]}var Hn="_~IN~_";var Ho=class extends ie{constructor(t){super(),this.topProd=t,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(t,r,n){}walkProdRef(t,r,n){let i=Bx(t.referencedRule,t.idx)+this.topProd.name,o=r.concat(n),s=new F({definition:o}),a=Me(s);this.follows[i]=a}};function yl(e){let t={};return S(e,r=>{let n=new Ho(r).startWalking();lt(t,n)}),t}function Bx(e,t){return e.name+t+Hn}function C(e){return e.charCodeAt(0)}function qn(e,t){Array.isArray(e)?e.forEach(function(r){t.push(r)}):t.push(e)}function ur(e,t){if(e[t]===!0)throw"duplicate flag "+t;let r=e[t];e[t]=!0}function be(e){if(e===void 0)throw Error("Internal Error - Should never get here!");return!0}function kr(){throw Error("Internal Error - Should never get here!")}function qo(e){return e.type==="Character"}var Pr=[];for(let e=C("0");e<=C("9");e++)Pr.push(e);var Ur=[C("_")].concat(Pr);for(let e=C("a");e<=C("z");e++)Ur.push(e);for(let e=C("A");e<=C("Z");e++)Ur.push(e);var zo=[C(" "),C("\f"),C(`
|
|
3
|
+
`),C("\r"),C(" "),C("\v"),C(" "),C("\xA0"),C("\u1680"),C("\u2000"),C("\u2001"),C("\u2002"),C("\u2003"),C("\u2004"),C("\u2005"),C("\u2006"),C("\u2007"),C("\u2008"),C("\u2009"),C("\u200A"),C("\u2028"),C("\u2029"),C("\u202F"),C("\u205F"),C("\u3000"),C("\uFEFF")];var Gx=/[0-9a-fA-F]/,zn=/[0-9]/,$x=/[1-9]/,wr=class{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(t){this.idx=t.idx,this.input=t.input,this.groupIdx=t.groupIdx}pattern(t){this.idx=0,this.input=t,this.groupIdx=0,this.consumeChar("/");let r=this.disjunction();this.consumeChar("/");let n={type:"Flags",loc:{begin:this.idx,end:t.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":ur(n,"global");break;case"i":ur(n,"ignoreCase");break;case"m":ur(n,"multiLine");break;case"u":ur(n,"unicode");break;case"y":ur(n,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:r,loc:this.loc(0)}}disjunction(){let t=[],r=this.idx;for(t.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),t.push(this.alternative());return{type:"Disjunction",value:t,loc:this.loc(r)}}alternative(){let t=[],r=this.idx;for(;this.isTerm();)t.push(this.term());return{type:"Alternative",value:t,loc:this.loc(r)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let t=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(t)};case"$":return{type:"EndAnchor",loc:this.loc(t)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(t)};case"B":return{type:"NonWordBoundary",loc:this.loc(t)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let r;switch(this.popChar()){case"=":r="Lookahead";break;case"!":r="NegativeLookahead";break}be(r);let n=this.disjunction();return this.consumeChar(")"),{type:r,value:n,loc:this.loc(t)}}return kr()}quantifier(t=!1){let r,n=this.idx;switch(this.popChar()){case"*":r={atLeast:0,atMost:1/0};break;case"+":r={atLeast:1,atMost:1/0};break;case"?":r={atLeast:0,atMost:1};break;case"{":let i=this.integerIncludingZero();switch(this.popChar()){case"}":r={atLeast:i,atMost:i};break;case",":let o;this.isDigit()?(o=this.integerIncludingZero(),r={atLeast:i,atMost:o}):r={atLeast:i,atMost:1/0},this.consumeChar("}");break}if(t===!0&&r===void 0)return;be(r);break}if(!(t===!0&&r===void 0)&&be(r))return this.peekChar(0)==="?"?(this.consumeChar("?"),r.greedy=!1):r.greedy=!0,r.type="Quantifier",r.loc=this.loc(n),r}atom(){let t,r=this.idx;switch(this.peekChar()){case".":t=this.dotAll();break;case"\\":t=this.atomEscape();break;case"[":t=this.characterClass();break;case"(":t=this.group();break}return t===void 0&&this.isPatternCharacter()&&(t=this.patternCharacter()),be(t)?(t.loc=this.loc(r),this.isQuantifier()&&(t.quantifier=this.quantifier()),t):kr()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[C(`
|
|
4
|
+
`),C("\r"),C("\u2028"),C("\u2029")]}}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 t,r=!1;switch(this.popChar()){case"d":t=Pr;break;case"D":t=Pr,r=!0;break;case"s":t=zo;break;case"S":t=zo,r=!0;break;case"w":t=Ur;break;case"W":t=Ur,r=!0;break}return be(t)?{type:"Set",value:t,complement:r}:kr()}controlEscapeAtom(){let t;switch(this.popChar()){case"f":t=C("\f");break;case"n":t=C(`
|
|
5
5
|
`);break;case"r":t=C("\r");break;case"t":t=C(" ");break;case"v":t=C("\v");break}return be(t)?{type:"Character",value:t}:kr()}controlLetterEscapeAtom(){this.consumeChar("c");let t=this.popChar();if(/[a-zA-Z]/.test(t)===!1)throw Error("Invalid ");return{type:"Character",value:t.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(){let t=this.popChar();return{type:"Character",value:C(t)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
|
|
6
|
-
`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let t=this.popChar();return{type:"Character",value:C(t)}}}characterClass(){let t=[],r=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),r=!0);this.isClassAtom();){let n=this.classAtom(),
|
|
7
|
-
`:case"\r":case"\u2028":case"\u2029":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 t=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),t=!1;break;default:this.groupIdx++;break}let r=this.disjunction();this.consumeChar(")");let n={type:"Group",capturing:t,value:r};return t&&(n.idx=this.groupIdx),n}positiveInteger(){let t=this.popChar();if(
|
|
6
|
+
`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let t=this.popChar();return{type:"Character",value:C(t)}}}characterClass(){let t=[],r=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),r=!0);this.isClassAtom();){let n=this.classAtom(),i=n.type==="Character";if(qo(n)&&this.isRangeDash()){this.consumeChar("-");let o=this.classAtom(),s=o.type==="Character";if(qo(o)){if(o.value<n.value)throw Error("Range out of order in character class");t.push({from:n.value,to:o.value})}else qn(n.value,t),t.push(C("-")),qn(o.value,t)}else qn(n.value,t)}return this.consumeChar("]"),{type:"Set",complement:r,value:t}}classAtom(){switch(this.peekChar()){case"]":case`
|
|
7
|
+
`:case"\r":case"\u2028":case"\u2029":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 t=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),t=!1;break;default:this.groupIdx++;break}let r=this.disjunction();this.consumeChar(")");let n={type:"Group",capturing:t,value:r};return t&&(n.idx=this.groupIdx),n}positiveInteger(){let t=this.popChar();if($x.test(t)===!1)throw Error("Expecting a positive integer");for(;zn.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)}integerIncludingZero(){let t=this.popChar();if(zn.test(t)===!1)throw Error("Expecting an integer");for(;zn.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)}patternCharacter(){let t=this.popChar();switch(t){case`
|
|
8
8
|
`:case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:C(t)}}}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 zn.test(this.peekChar(0))}isClassAtom(t=0){switch(this.peekChar(t)){case"]":case`
|
|
9
9
|
`:case"\r":case"\u2028":case"\u2029":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(){let t=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(t)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
|
|
10
|
-
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(t){let r="";for(let
|
|
11
|
-
`;function
|
|
10
|
+
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(t){let r="";for(let i=0;i<t;i++){let o=this.popChar();if(Gx.test(o)===!1)throw Error("Expecting a HexDecimal digits");r+=o}return{type:"Character",value:parseInt(r,16)}}peekChar(t=0){return this.input[this.idx+t]}popChar(){let t=this.peekChar(0);return this.consumeChar(void 0),t}consumeChar(t){if(t!==void 0&&this.input[this.idx]!==t)throw Error("Expected: '"+t+"' 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(t){return{begin:t,end:this.idx}}};var Ce=class{visitChildren(t){for(let r in t){let n=t[r];t.hasOwnProperty(r)&&(n.type!==void 0?this.visit(n):Array.isArray(n)&&n.forEach(i=>{this.visit(i)},this))}}visit(t){switch(t.type){case"Pattern":this.visitPattern(t);break;case"Flags":this.visitFlags(t);break;case"Disjunction":this.visitDisjunction(t);break;case"Alternative":this.visitAlternative(t);break;case"StartAnchor":this.visitStartAnchor(t);break;case"EndAnchor":this.visitEndAnchor(t);break;case"WordBoundary":this.visitWordBoundary(t);break;case"NonWordBoundary":this.visitNonWordBoundary(t);break;case"Lookahead":this.visitLookahead(t);break;case"NegativeLookahead":this.visitNegativeLookahead(t);break;case"Character":this.visitCharacter(t);break;case"Set":this.visitSet(t);break;case"Group":this.visitGroup(t);break;case"GroupBackReference":this.visitGroupBackReference(t);break;case"Quantifier":this.visitQuantifier(t);break}this.visitChildren(t)}visitPattern(t){}visitFlags(t){}visitDisjunction(t){}visitAlternative(t){}visitStartAnchor(t){}visitEndAnchor(t){}visitWordBoundary(t){}visitNonWordBoundary(t){}visitLookahead(t){}visitNegativeLookahead(t){}visitCharacter(t){}visitSet(t){}visitGroup(t){}visitGroupBackReference(t){}visitQuantifier(t){}};var Vn={},jx=new wr;function fr(e){let t=e.toString();if(Vn.hasOwnProperty(t))return Vn[t];{let r=jx.pattern(t);return Vn[t]=r,r}}function Ll(){Vn={}}var vl="Complement Sets are not supported for first char optimization",Dr=`Unable to use "first char" lexer optimizations:
|
|
11
|
+
`;function Ml(e,t=!1){try{let r=fr(e);return Vo(r.value,{},r.flags.ignoreCase)}catch(r){if(r.message===vl)t&&vr(`${Dr} Unable to optimize: < ${e.toString()} >
|
|
12
12
|
Complement Sets cannot be automatically optimized.
|
|
13
13
|
This will disable the lexer's first char optimizations.
|
|
14
14
|
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n="";t&&(n=`
|
|
@@ -16,49 +16,49 @@ import{readFileSync as Vu,writeFileSync as QT,existsSync as ZT}from"node:fs";imp
|
|
|
16
16
|
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),cr(`${Dr}
|
|
17
17
|
Failed parsing: < ${e.toString()} >
|
|
18
18
|
Using the @chevrotain/regexp-to-ast library
|
|
19
|
-
Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function
|
|
20
|
-
`],tracer:(
|
|
19
|
+
Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function Vo(e,t,r){switch(e.type){case"Disjunction":for(let i=0;i<e.value.length;i++)Vo(e.value[i],t,r);break;case"Alternative":let n=e.value;for(let i=0;i<n.length;i++){let o=n[i];switch(o.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}let s=o;switch(s.type){case"Character":Yn(s.value,t,r);break;case"Set":if(s.complement===!0)throw Error(vl);S(s.value,c=>{if(typeof c=="number")Yn(c,t,r);else{let l=c;if(r===!0)for(let u=l.from;u<=l.to;u++)Yn(u,t,r);else{for(let u=l.from;u<=l.to&&u<hr;u++)Yn(u,t,r);if(l.to>=hr){let u=l.from>=hr?l.from:hr,f=l.to,h=Xt(u),g=Xt(f);for(let T=h;T<=g;T++)t[T]=T}}}});break;case"Group":Vo(s.value,t,r);break;default:throw Error("Non Exhaustive Match")}let a=s.quantifier!==void 0&&s.quantifier.atLeast===0;if(s.type==="Group"&&Yo(s)===!1||s.type!=="Group"&&a===!1)break}break;default:throw Error("non exhaustive match!")}return k(t)}function Yn(e,t,r){let n=Xt(e);t[n]=n,r===!0&&Wx(e,t)}function Wx(e,t){let r=String.fromCharCode(e),n=r.toUpperCase();if(n!==r){let i=Xt(n.charCodeAt(0));t[i]=i}else{let i=r.toLowerCase();if(i!==r){let o=Xt(i.charCodeAt(0));t[o]=o}}}function _l(e,t){return Yt(e.value,r=>{if(typeof r=="number")return $(t,r);{let n=r;return Yt(t,i=>n.from<=i&&i<=n.to)!==void 0}})}function Yo(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?O(e.value)?ft(e.value,Yo):Yo(e.value):!1}var Xo=class extends Ce{constructor(t){super(),this.targetCharCodes=t,this.found=!1}visitChildren(t){if(this.found!==!0){switch(t.type){case"Lookahead":this.visitLookahead(t);return;case"NegativeLookahead":this.visitNegativeLookahead(t);return}super.visitChildren(t)}}visitCharacter(t){$(this.targetCharCodes,t.value)&&(this.found=!0)}visitSet(t){t.complement?_l(t,this.targetCharCodes)===void 0&&(this.found=!0):_l(t,this.targetCharCodes)!==void 0&&(this.found=!0)}};function Xn(e,t){if(t instanceof RegExp){let r=fr(t),n=new Xo(e);return n.visit(r),n.found}else return Yt(t,r=>$(e,r.charCodeAt(0)))!==void 0}var ke="PATTERN",pr="defaultMode",Qn="modes",Zo=typeof new RegExp("(?:)").sticky=="boolean";function Pl(e,t){t=sr(t,{useSticky:Zo,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
|
|
20
|
+
`],tracer:(x,d)=>d()});let r=t.tracer;r("initCharCodeToOptimizedIndexMap",()=>{aT()});let n;r("Reject Lexer.NA",()=>{n=Ie(e,x=>x[ke]===H.NA)});let i=!1,o;r("Transform Patterns",()=>{i=!1,o=E(n,x=>{let d=x[ke];if(bt(d)){let y=d.source;return y.length===1&&y!=="^"&&y!=="$"&&y!=="."&&!d.ignoreCase?y:y.length===2&&y[0]==="\\"&&!$(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],y[1])?y[1]:t.useSticky?kl(d):bl(d)}else{if(dt(d))return i=!0,{exec:d};if(typeof d=="object")return i=!0,d;if(typeof d=="string"){if(d.length===1)return d;{let y=d.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),L=new RegExp(y);return t.useSticky?kl(L):bl(L)}}else throw Error("non exhaustive match")}})});let s,a,c,l,u;r("misc mapping",()=>{s=E(n,x=>x.tokenTypeIdx),a=E(n,x=>{let d=x.GROUP;if(d!==H.SKIPPED){if(ot(d))return d;if(pt(d))return!1;throw Error("non exhaustive match")}}),c=E(n,x=>{let d=x.LONGER_ALT;if(d)return O(d)?E(d,L=>Wn(n,L)):[Wn(n,d)]}),l=E(n,x=>x.PUSH_MODE),u=E(n,x=>A(x,"POP_MODE"))});let f;r("Line Terminator Handling",()=>{let x=jl(t.lineTerminatorCharacters);f=E(n,d=>!1),t.positionTracking!=="onlyOffset"&&(f=E(n,d=>A(d,"LINE_BREAKS")?!!d.LINE_BREAKS:$l(d,x)===!1&&Xn(x,d.PATTERN)))});let h,g,T,I;r("Misc Mapping #2",()=>{h=E(n,Bl),g=E(o,oT),T=rt(n,(x,d)=>{let y=d.GROUP;return ot(y)&&y!==H.SKIPPED&&(x[y]=[]),x},{}),I=E(o,(x,d)=>({pattern:o[d],longerAlt:c[d],canLineTerminator:f[d],isCustom:h[d],short:g[d],group:a[d],push:l[d],pop:u[d],tokenTypeIdx:s[d],tokenType:n[d]}))});let R=!0,N=[];return t.safeMode||r("First Char Optimization",()=>{N=rt(n,(x,d,y)=>{if(typeof d.PATTERN=="string"){let L=d.PATTERN.charCodeAt(0),Rt=Xt(L);Qo(x,Rt,I[y])}else if(O(d.START_CHARS_HINT)){let L;S(d.START_CHARS_HINT,Rt=>{let bo=typeof Rt=="string"?Rt.charCodeAt(0):Rt,Bt=Xt(bo);L!==Bt&&(L=Bt,Qo(x,Bt,I[y]))})}else if(bt(d.PATTERN))if(d.PATTERN.unicode)R=!1,t.ensureOptimizations&&cr(`${Dr} Unable to analyze < ${d.PATTERN.toString()} > pattern.
|
|
21
21
|
The regexp unicode flag is not currently supported by the regexp-to-ast library.
|
|
22
22
|
This will disable the lexer's first char optimizations.
|
|
23
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let L=
|
|
23
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let L=Ml(d.PATTERN,t.ensureOptimizations);_(L)&&(R=!1),S(L,Rt=>{Qo(x,Rt,I[y])})}else t.ensureOptimizations&&cr(`${Dr} TokenType: <${d.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
|
|
24
24
|
This will disable the lexer's first char optimizations.
|
|
25
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),R=!1;return
|
|
26
|
-
Token Type: ->`+
|
|
27
|
-
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:j.EOI_ANCHOR_FOUND,tokenTypes:[
|
|
28
|
-
Token Type: ->`+
|
|
29
|
-
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:j.SOI_ANCHOR_FOUND,tokenTypes:[
|
|
25
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),R=!1;return x},[])}),{emptyGroups:T,patternIdxToConfig:I,charCodeToPatternIdxToConfig:N,hasCustom:i,canBeOptimized:R}}function Ul(e,t){let r=[],n=Hx(e);r=r.concat(n.errors);let i=qx(n.valid),o=i.valid;return r=r.concat(i.errors),r=r.concat(Kx(o)),r=r.concat(tT(o)),r=r.concat(eT(o,t)),r=r.concat(rT(o)),r}function Kx(e){let t=[],r=ht(e,n=>bt(n[ke]));return t=t.concat(Vx(r)),t=t.concat(Qx(r)),t=t.concat(Zx(r)),t=t.concat(Jx(r)),t=t.concat(Yx(r)),t}function Hx(e){let t=ht(e,i=>!A(i,ke)),r=E(t,i=>({message:"Token Type: ->"+i.name+"<- missing static 'PATTERN' property",type:j.MISSING_PATTERN,tokenTypes:[i]})),n=Oe(e,t);return{errors:r,valid:n}}function qx(e){let t=ht(e,i=>{let o=i[ke];return!bt(o)&&!dt(o)&&!A(o,"exec")&&!ot(o)}),r=E(t,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:j.INVALID_PATTERN,tokenTypes:[i]})),n=Oe(e,t);return{errors:r,valid:n}}var zx=/[^\\][$]/;function Vx(e){class t extends Ce{constructor(){super(...arguments),this.found=!1}visitEndAnchor(o){this.found=!0}}let r=ht(e,i=>{let o=i.PATTERN;try{let s=fr(o),a=new t;return a.visit(s),a.found}catch{return zx.test(o.source)}});return E(r,i=>({message:`Unexpected RegExp Anchor Error:
|
|
26
|
+
Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
|
|
27
|
+
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:j.EOI_ANCHOR_FOUND,tokenTypes:[i]}))}function Yx(e){let t=ht(e,n=>n.PATTERN.test(""));return E(t,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' must not match an empty string",type:j.EMPTY_MATCH_PATTERN,tokenTypes:[n]}))}var Xx=/[^\\[][\^]|^\^/;function Qx(e){class t extends Ce{constructor(){super(...arguments),this.found=!1}visitStartAnchor(o){this.found=!0}}let r=ht(e,i=>{let o=i.PATTERN;try{let s=fr(o),a=new t;return a.visit(s),a.found}catch{return Xx.test(o.source)}});return E(r,i=>({message:`Unexpected RegExp Anchor Error:
|
|
28
|
+
Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
|
|
29
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:j.SOI_ANCHOR_FOUND,tokenTypes:[i]}))}function Zx(e){let t=ht(e,n=>{let i=n[ke];return i instanceof RegExp&&(i.multiline||i.global)});return E(t,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:j.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[n]}))}function Jx(e){let t=[],r=E(e,o=>rt(e,(s,a)=>(o.PATTERN.source===a.PATTERN.source&&!$(t,a)&&a.PATTERN!==H.NA&&(t.push(a),s.push(a)),s),[]));r=zt(r);let n=ht(r,o=>o.length>1);return E(n,o=>{let s=E(o,c=>c.name);return{message:`The same RegExp pattern ->${ct(o).PATTERN}<-has been used in all of the following Token Types: ${s.join(", ")} <-`,type:j.DUPLICATE_PATTERNS_FOUND,tokenTypes:o}})}function tT(e){let t=ht(e,n=>{if(!A(n,"GROUP"))return!1;let i=n.GROUP;return i!==H.SKIPPED&&i!==H.NA&&!ot(i)});return E(t,n=>({message:"Token Type: ->"+n.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:j.INVALID_GROUP_TYPE_FOUND,tokenTypes:[n]}))}function eT(e,t){let r=ht(e,i=>i.PUSH_MODE!==void 0&&!$(t,i.PUSH_MODE));return E(r,i=>({message:`Token Type: ->${i.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${i.PUSH_MODE}<-which does not exist`,type:j.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[i]}))}function rT(e){let t=[],r=rt(e,(n,i,o)=>{let s=i.PATTERN;return s===H.NA||(ot(s)?n.push({str:s,idx:o,tokenType:i}):bt(s)&&iT(s)&&n.push({str:s.source,idx:o,tokenType:i})),n},[]);return S(e,(n,i)=>{S(r,({str:o,idx:s,tokenType:a})=>{if(i<s&&nT(o,n.PATTERN)){let c=`Token: ->${a.name}<- can never be matched.
|
|
30
30
|
Because it appears AFTER the Token Type ->${n.name}<-in the lexer's definition.
|
|
31
|
-
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:c,type:j.UNREACHABLE_PATTERN,tokenTypes:[n,a]})}})}),t}function
|
|
31
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:c,type:j.UNREACHABLE_PATTERN,tokenTypes:[n,a]})}})}),t}function nT(e,t){if(bt(t)){let r=t.exec(e);return r!==null&&r.index===0}else{if(dt(t))return t(e,0,[],{});if(A(t,"exec"))return t.exec(e,0,[],{});if(typeof t=="string")return t===e;throw Error("non exhaustive match")}}function iT(e){return Yt([".","\\","[","]","|","^","$","(",")","?","*","+","{"],r=>e.source.indexOf(r)!==-1)===void 0}function bl(e){let t=e.ignoreCase?"i":"";return new RegExp(`^(?:${e.source})`,t)}function kl(e){let t=e.ignoreCase?"iy":"y";return new RegExp(`${e.source}`,t)}function wl(e,t,r){let n=[];return A(e,pr)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+pr+`> property in its definition
|
|
32
32
|
`,type:j.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),A(e,Qn)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+Qn+`> property in its definition
|
|
33
33
|
`,type:j.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),A(e,Qn)&&A(e,pr)&&!A(e.modes,e.defaultMode)&&n.push({message:`A MultiMode Lexer cannot be initialized with a ${pr}: <${e.defaultMode}>which does not exist
|
|
34
|
-
`,type:j.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),A(e,Qn)&&S(e.modes,(o
|
|
35
|
-
`,type:j.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(A(s,"LONGER_ALT")){let c=
|
|
36
|
-
`,type:j.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),n}function
|
|
34
|
+
`,type:j.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),A(e,Qn)&&S(e.modes,(i,o)=>{S(i,(s,a)=>{if(pt(s))n.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${o}> at index: <${a}>
|
|
35
|
+
`,type:j.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(A(s,"LONGER_ALT")){let c=O(s.LONGER_ALT)?s.LONGER_ALT:[s.LONGER_ALT];S(c,l=>{!pt(l)&&!$(i,l)&&n.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${l.name}> on token <${s.name}> outside of mode <${o}>
|
|
36
|
+
`,type:j.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),n}function Dl(e,t,r){let n=[],i=!1,o=zt(it(k(e.modes))),s=Ie(o,c=>c[ke]===H.NA),a=jl(r);return t&&S(s,c=>{let l=$l(c,a);if(l!==!1){let f={message:sT(c,l),type:l.issue,tokenType:c};n.push(f)}else A(c,"LINE_BREAKS")?c.LINE_BREAKS===!0&&(i=!0):Xn(a,c.PATTERN)&&(i=!0)}),t&&!i&&n.push({message:`Warning: No LINE_BREAKS Found.
|
|
37
37
|
This Lexer has been defined to track line and column information,
|
|
38
38
|
But none of the Token Types can be identified as matching a line terminator.
|
|
39
39
|
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
|
|
40
|
-
for details.`,type:j.NO_LINE_BREAKS_FLAGS}),n}function
|
|
40
|
+
for details.`,type:j.NO_LINE_BREAKS_FLAGS}),n}function Fl(e){let t={},r=P(e);return S(r,n=>{let i=e[n];if(O(i))t[n]=[];else throw Error("non exhaustive match")}),t}function Bl(e){let t=e.PATTERN;if(bt(t))return!1;if(dt(t))return!0;if(A(t,"exec"))return!0;if(ot(t))return!1;throw Error("non exhaustive match")}function oT(e){return ot(e)&&e.length===1?e.charCodeAt(0):!1}var Gl={test:function(e){let t=e.length;for(let r=this.lastIndex;r<t;r++){let n=e.charCodeAt(r);if(n===10)return this.lastIndex=r+1,!0;if(n===13)return e.charCodeAt(r+1)===10?this.lastIndex=r+2:this.lastIndex=r+1,!0}return!1},lastIndex:0};function $l(e,t){if(A(e,"LINE_BREAKS"))return!1;if(bt(e.PATTERN)){try{Xn(t,e.PATTERN)}catch(r){return{issue:j.IDENTIFY_TERMINATOR,errMsg:r.message}}return!1}else{if(ot(e.PATTERN))return!1;if(Bl(e))return{issue:j.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function sT(e,t){if(t.issue===j.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
|
|
41
41
|
The problem is in the <${e.name}> Token Type
|
|
42
42
|
Root cause: ${t.errMsg}.
|
|
43
43
|
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===j.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
|
|
44
44
|
The problem is in the <${e.name}> Token Type
|
|
45
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function
|
|
46
|
-
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:ts,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Fr);var H=class{constructor(t,r=Fr){if(this.lexerDefinition=t,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=(o
|
|
47
|
-
a boolean 2nd argument is no longer supported`);this.config=lt({},Fr,r);let n=this.config.traceInitPerf;n===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof n=="number"&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let o
|
|
48
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(r.safeMode&&r.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),
|
|
45
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function jl(e){return E(e,r=>ot(r)?r.charCodeAt(0):r)}function Qo(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}var hr=256,Zn=[];function Xt(e){return e<hr?e:Zn[e]}function aT(){if(_(Zn)){Zn=new Array(65536);for(let e=0;e<65536;e++)Zn[e]=e>255?255+~~(e/255):e}}function oe(e,t){let r=e.tokenTypeIdx;return r===t.tokenTypeIdx?!0:t.isParent===!0&&t.categoryMatchesMap[r]===!0}function mr(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}var Wl=1,Hl={};function se(e){let t=cT(e);lT(t),fT(t),uT(t),S(t,r=>{r.isParent=r.categoryMatches.length>0})}function cT(e){let t=w(e),r=e,n=!0;for(;n;){r=zt(it(E(r,o=>o.CATEGORIES)));let i=Oe(r,t);t=t.concat(i),_(i)?n=!1:r=i}return t}function lT(e){S(e,t=>{Jo(t)||(Hl[Wl]=t,t.tokenTypeIdx=Wl++),Kl(t)&&!O(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),Kl(t)||(t.CATEGORIES=[]),hT(t)||(t.categoryMatches=[]),pT(t)||(t.categoryMatchesMap={})})}function uT(e){S(e,t=>{t.categoryMatches=[],S(t.categoryMatchesMap,(r,n)=>{t.categoryMatches.push(Hl[n].tokenTypeIdx)})})}function fT(e){S(e,t=>{ql([],t)})}function ql(e,t){S(e,r=>{t.categoryMatchesMap[r.tokenTypeIdx]=!0}),S(t.CATEGORIES,r=>{let n=e.concat(t);$(n,r)||ql(n,r)})}function Jo(e){return A(e,"tokenTypeIdx")}function Kl(e){return A(e,"CATEGORIES")}function hT(e){return A(e,"categoryMatches")}function pT(e){return A(e,"categoryMatchesMap")}function zl(e){return A(e,"tokenTypeIdx")}var ts={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,r,n,i){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${r} characters.`}};var j;(function(e){e[e.MISSING_PATTERN=0]="MISSING_PATTERN",e[e.INVALID_PATTERN=1]="INVALID_PATTERN",e[e.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",e[e.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",e[e.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",e[e.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",e[e.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",e[e.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",e[e.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",e[e.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",e[e.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",e[e.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",e[e.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(j||(j={}));var Fr={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
|
|
46
|
+
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:ts,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Fr);var H=class{constructor(t,r=Fr){if(this.lexerDefinition=t,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,o)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let s=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${s}--> <${i}>`);let{time:a,value:c}=Mr(o),l=a>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&l(`${s}<-- <${i}> time: ${a}ms`),this.traceInitIndent--,c}else return o()},typeof r=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
|
|
47
|
+
a boolean 2nd argument is no longer supported`);this.config=lt({},Fr,r);let n=this.config.traceInitPerf;n===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof n=="number"&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let i,o=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===Fr.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Gl;else if(this.config.lineTerminatorCharacters===Fr.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
|
|
48
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(r.safeMode&&r.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),O(t)?i={modes:{defaultMode:w(t)},defaultMode:pr}:(o=!1,i=w(t))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(wl(i,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Dl(i,this.trackStartLines,this.config.lineTerminatorCharacters))})),i.modes=i.modes?i.modes:{},S(i.modes,(a,c)=>{i.modes[c]=Ie(a,l=>pt(l))});let s=P(i.modes);if(S(i.modes,(a,c)=>{this.TRACE_INIT(`Mode: <${c}> processing`,()=>{if(this.modes.push(c),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Ul(a,s))}),_(this.lexerDefinitionErrors)){se(a);let l;this.TRACE_INIT("analyzeTokenTypes",()=>{l=Pl(a,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:r.positionTracking,ensureOptimizations:r.ensureOptimizations,safeMode:r.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[c]=l.patternIdxToConfig,this.charCodeToPatternIdxToConfig[c]=l.charCodeToPatternIdxToConfig,this.emptyGroups=lt({},this.emptyGroups,l.emptyGroups),this.hasCustom=l.hasCustom||this.hasCustom,this.canModeBeOptimized[c]=l.canBeOptimized}})}),this.defaultMode=i.defaultMode,!_(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let c=E(this.lexerDefinitionErrors,l=>l.message).join(`-----------------------
|
|
49
49
|
`);throw new Error(`Errors detected in definition of Lexer:
|
|
50
|
-
`+c)}S(this.lexerDefinitionWarning,a=>{vr(a.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(
|
|
50
|
+
`+c)}S(this.lexerDefinitionWarning,a=>{vr(a.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(Zo?(this.chopInput=vt,this.match=this.matchWithTest):(this.updateLastIndex=K,this.match=this.matchWithExec),o&&(this.handleModes=K),this.trackStartLines===!1&&(this.computeNewColumn=vt),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=K),/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",()=>{let a=rt(this.canModeBeOptimized,(c,l,u)=>(l===!1&&c.push(u),c),[]);if(r.ensureOptimizations&&!_(a))throw Error(`Lexer Modes: < ${a.join(", ")} > cannot be optimized.
|
|
51
51
|
Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
|
|
52
|
-
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{
|
|
52
|
+
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{Ll()}),this.TRACE_INIT("toFastProperties",()=>{br(this)})})}tokenize(t,r=this.defaultMode){if(!_(this.lexerDefinitionErrors)){let i=E(this.lexerDefinitionErrors,o=>o.message).join(`-----------------------
|
|
53
53
|
`);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
|
|
54
|
-
`+
|
|
55
|
-
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return A(e,
|
|
56
|
-
but found: '`+ct(t).image+"'";if(n)return
|
|
57
|
-
${
|
|
58
|
-
`)}`;return
|
|
59
|
-
but found: '`+ct(t).image+"'";if(r)return
|
|
60
|
-
<${
|
|
61
|
-
inside top level rule: ->`+e.name+"<-"}},Dt={buildDuplicateFoundError(e,t){function r(u){return u instanceof v?u.terminalType.name:u instanceof D?u.nonTerminalName:""}let n=e.name,
|
|
54
|
+
`+i)}return this.tokenizeInternal(t,r)}tokenizeInternal(t,r){let n,i,o,s,a,c,l,u,f,h,g,T,I,R,N,x,d=t,y=d.length,L=0,Rt=0,bo=this.hasCustom?0:Math.floor(t.length/10),Bt=new Array(bo),ko=[],Nr=this.trackStartLines?1:void 0,ae=this.trackStartLines?1:void 0,Or=Fl(this.emptyGroups),Qu=this.trackStartLines,Po=this.config.lineTerminatorsPattern,pn=0,ce=[],Ir=[],mn=[],_s=[];Object.freeze(_s);let Cr;function vs(){return ce}function Ms(ut){let _t=Xt(ut),Fe=Ir[_t];return Fe===void 0?_s:Fe}let Zu=ut=>{if(mn.length===1&&ut.tokenType.PUSH_MODE===void 0){let _t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(ut);ko.push({offset:ut.startOffset,line:ut.startLine,column:ut.startColumn,length:ut.image.length,message:_t})}else{mn.pop();let _t=Vt(mn);ce=this.patternIdxToConfig[_t],Ir=this.charCodeToPatternIdxToConfig[_t],pn=ce.length;let Fe=this.canModeBeOptimized[_t]&&this.config.safeMode===!1;Ir&&Fe?Cr=Ms:Cr=vs}};function bs(ut){mn.push(ut),Ir=this.charCodeToPatternIdxToConfig[ut],ce=this.patternIdxToConfig[ut],pn=ce.length,pn=ce.length;let _t=this.canModeBeOptimized[ut]&&this.config.safeMode===!1;Ir&&_t?Cr=Ms:Cr=vs}bs.call(this,r);let Pt,ks=this.config.recoveryEnabled;for(;L<y;){c=null;let ut=d.charCodeAt(L),_t=Cr(ut),Fe=_t.length;for(n=0;n<Fe;n++){Pt=_t[n];let yt=Pt.pattern;l=null;let Zt=Pt.short;if(Zt!==!1?ut===Zt&&(c=yt):Pt.isCustom===!0?(x=yt.exec(d,L,Bt,Or),x!==null?(c=x[0],x.payload!==void 0&&(l=x.payload)):c=null):(this.updateLastIndex(yt,L),c=this.match(yt,t,L)),c!==null){if(a=Pt.longerAlt,a!==void 0){let le=a.length;for(o=0;o<le;o++){let Jt=ce[a[o]],ye=Jt.pattern;if(u=null,Jt.isCustom===!0?(x=ye.exec(d,L,Bt,Or),x!==null?(s=x[0],x.payload!==void 0&&(u=x.payload)):s=null):(this.updateLastIndex(ye,L),s=this.match(ye,t,L)),s&&s.length>c.length){c=s,l=u,Pt=Jt;break}}}break}}if(c!==null){if(f=c.length,h=Pt.group,h!==void 0&&(g=Pt.tokenTypeIdx,T=this.createTokenInstance(c,L,g,Pt.tokenType,Nr,ae,f),this.handlePayload(T,l),h===!1?Rt=this.addToken(Bt,Rt,T):Or[h].push(T)),t=this.chopInput(t,f),L=L+f,ae=this.computeNewColumn(ae,f),Qu===!0&&Pt.canLineTerminator===!0){let yt=0,Zt,le;Po.lastIndex=0;do Zt=Po.test(c),Zt===!0&&(le=Po.lastIndex-1,yt++);while(Zt===!0);yt!==0&&(Nr=Nr+yt,ae=f-le,this.updateTokenEndLineColumnLocation(T,h,le,yt,Nr,ae,f))}this.handleModes(Pt,Zu,bs,T)}else{let yt=L,Zt=Nr,le=ae,Jt=ks===!1;for(;Jt===!1&&L<y;)for(t=this.chopInput(t,1),L++,i=0;i<pn;i++){let ye=ce[i],Uo=ye.pattern,Ps=ye.short;if(Ps!==!1?d.charCodeAt(L)===Ps&&(Jt=!0):ye.isCustom===!0?Jt=Uo.exec(d,L,Bt,Or)!==null:(this.updateLastIndex(Uo,L),Jt=Uo.exec(t)!==null),Jt===!0)break}if(I=L-yt,ae=this.computeNewColumn(ae,I),N=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(d,yt,I,Zt,le),ko.push({offset:yt,line:Zt,column:le,length:I,message:N}),ks===!1)break}}return this.hasCustom||(Bt.length=Rt),{tokens:Bt,groups:Or,errors:ko}}handleModes(t,r,n,i){if(t.pop===!0){let o=t.push;r(i),o!==void 0&&n.call(this,o)}else t.push!==void 0&&n.call(this,t.push)}chopInput(t,r){return t.substring(r)}updateLastIndex(t,r){t.lastIndex=r}updateTokenEndLineColumnLocation(t,r,n,i,o,s,a){let c,l;r!==void 0&&(c=n===a-1,l=c?-1:0,i===1&&c===!0||(t.endLine=o+l,t.endColumn=s-1+-l))}computeNewColumn(t,r){return t+r}createOffsetOnlyToken(t,r,n,i){return{image:t,startOffset:r,tokenTypeIdx:n,tokenType:i}}createStartOnlyToken(t,r,n,i,o,s){return{image:t,startOffset:r,startLine:o,startColumn:s,tokenTypeIdx:n,tokenType:i}}createFullToken(t,r,n,i,o,s,a){return{image:t,startOffset:r,endOffset:r+a-1,startLine:o,endLine:o,startColumn:s,endColumn:s+a-1,tokenTypeIdx:n,tokenType:i}}addTokenUsingPush(t,r,n){return t.push(n),r}addTokenUsingMemberAccess(t,r,n){return t[r]=n,r++,r}handlePayloadNoCustom(t,r){}handlePayloadWithCustom(t,r){r!==null&&(t.payload=r)}matchWithTest(t,r,n){return t.test(r)===!0?r.substring(n,t.lastIndex):null}matchWithExec(t,r){let n=t.exec(r);return n!==null?n[0]:null}};H.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 example to completely ignore whitespace.";H.NA=/NOT_APPLICABLE/;function Pe(e){return es(e)?e.LABEL:e.name}function es(e){return ot(e.LABEL)&&e.LABEL!==""}var mT="parent",Vl="categories",Yl="label",Xl="group",Ql="push_mode",Zl="pop_mode",Jl="longer_alt",tu="line_breaks",eu="start_chars_hint";function m(e){return dT(e)}function dT(e){let t=e.pattern,r={};if(r.name=e.name,pt(t)||(r.PATTERN=t),A(e,mT))throw`The parent property is no longer supported.
|
|
55
|
+
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return A(e,Vl)&&(r.CATEGORIES=e[Vl]),se([r]),A(e,Yl)&&(r.LABEL=e[Yl]),A(e,Xl)&&(r.GROUP=e[Xl]),A(e,Zl)&&(r.POP_MODE=e[Zl]),A(e,Ql)&&(r.PUSH_MODE=e[Ql]),A(e,Jl)&&(r.LONGER_ALT=e[Jl]),A(e,tu)&&(r.LINE_BREAKS=e[tu]),A(e,eu)&&(r.START_CHARS_HINT=e[eu]),r}var wt=m({name:"EOF",pattern:H.NA});se([wt]);function Ue(e,t,r,n,i,o,s,a){return{image:t,startOffset:r,endOffset:n,startLine:i,endLine:o,startColumn:s,endColumn:a,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function rs(e,t){return oe(e,t)}var Jn={buildMismatchTokenMessage({expected:e,actual:t,previous:r,ruleName:n}){return`Expecting ${es(e)?`--> ${Pe(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:t}){return"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:r,customUserDescription:n,ruleName:i}){let o="Expecting: ",a=`
|
|
56
|
+
but found: '`+ct(t).image+"'";if(n)return o+n+a;{let c=rt(e,(h,g)=>h.concat(g),[]),l=E(c,h=>`[${E(h,g=>Pe(g)).join(", ")}]`),f=`one of these possible Token sequences:
|
|
57
|
+
${E(l,(h,g)=>` ${g+1}. ${h}`).join(`
|
|
58
|
+
`)}`;return o+f+a}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:r,ruleName:n}){let i="Expecting: ",s=`
|
|
59
|
+
but found: '`+ct(t).image+"'";if(r)return i+r+s;{let c=`expecting at least one iteration which starts with one of these possible Token sequences::
|
|
60
|
+
<${E(e,l=>`[${E(l,u=>Pe(u)).join(",")}]`).join(" ,")}>`;return i+c+s}}};Object.freeze(Jn);var ru={buildRuleNotFoundError(e,t){return"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+`<-
|
|
61
|
+
inside top level rule: ->`+e.name+"<-"}},Dt={buildDuplicateFoundError(e,t){function r(u){return u instanceof v?u.terminalType.name:u instanceof D?u.nonTerminalName:""}let n=e.name,i=ct(t),o=i.idx,s=Ot(i),a=r(i),c=o>0,l=`->${s}${c?o:""}<- ${a?`with argument: ->${a}<-`:""}
|
|
62
62
|
appears more than once (${t.length} times) in the top level rule: ->${n}<-.
|
|
63
63
|
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
|
|
64
64
|
`;return l=l.replace(/[ \t]+/g," "),l=l.replace(/\s\s+/g,`
|
|
@@ -66,68 +66,68 @@ inside top level rule: ->`+e.name+"<-"}},Dt={buildDuplicateFoundError(e,t){funct
|
|
|
66
66
|
The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.
|
|
67
67
|
To resolve this make sure each Terminal and Non-Terminal names are unique
|
|
68
68
|
This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
|
|
69
|
-
and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=
|
|
69
|
+
and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=E(e.prefixPath,i=>Pe(i)).join(", "),r=e.alternation.idx===0?"":e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix
|
|
70
70
|
in <OR${r}> inside <${e.topLevelRule.name}> Rule,
|
|
71
71
|
<${t}> may appears as a prefix path in all these alternatives.
|
|
72
72
|
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
|
|
73
|
-
For Further details.`},buildAlternationAmbiguityError(e){let t=
|
|
73
|
+
For Further details.`},buildAlternationAmbiguityError(e){let t=E(e.prefixPath,i=>Pe(i)).join(", "),r=e.alternation.idx===0?"":e.alternation.idx,n=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(" ,")}> in <OR${r}> inside <${e.topLevelRule.name}> Rule,
|
|
74
74
|
<${t}> may appears as a prefix path in all these alternatives.
|
|
75
75
|
`;return n=n+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
|
|
76
|
-
For Further details.`,n},buildEmptyRepetitionError(e){let t=
|
|
76
|
+
For Further details.`,n},buildEmptyRepetitionError(e){let t=Ot(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.
|
|
77
77
|
This could lead to an infinite loop.`},buildTokenNameError(e){return"deprecated"},buildEmptyAlternationError(e){return`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.
|
|
78
78
|
Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(e){return`An Alternation cannot have more than 256 alternatives:
|
|
79
79
|
<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.
|
|
80
|
-
has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name,r=
|
|
80
|
+
has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name,r=E(e.leftRecursionPath,o=>o.name),n=`${t} --> ${r.concat([t]).join(" --> ")}`;return`Left Recursion found in grammar.
|
|
81
81
|
rule: <${t}> can be invoked from itself (directly or indirectly)
|
|
82
82
|
without consuming any Tokens. The grammar path that causes this is:
|
|
83
83
|
${n}
|
|
84
84
|
To fix this refactor your grammar to remove the left recursion.
|
|
85
|
-
see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return"deprecated"},buildDuplicateRuleNameError(e){let t;return e.topLevelRule instanceof Et?t=e.topLevelRule.name:t=e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function ou(e,t){let r=new ns(e,t);return r.resolveRefs(),r.errors}var ns=class extends xt{constructor(t,r){super(),this.nameToTopRule=t,this.errMsgProvider=r,this.errors=[]}resolveRefs(){S(k(this.nameToTopRule),t=>{this.currTopLevel=t,t.accept(this)})}visitNonTerminal(t){let r=this.nameToTopRule[t.nonTerminalName];if(r)t.referencedRule=r;else{let n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,t);this.errors.push({message:n,type:st.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:t.nonTerminalName})}}};var os=class extends oe{constructor(t,r){super(),this.topProd=t,this.path=r,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=w(this.path.ruleStack).reverse(),this.occurrenceStack=w(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(t,r=[]){this.found||super.walk(t,r)}walkProdRef(t,r,n){if(t.referencedRule.name===this.nextProductionName&&t.idx===this.nextProductionOccurrence){let o=r.concat(n);this.updateExpectedNext(),this.walk(t.referencedRule,o)}}updateExpectedNext(){_(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},to=class extends os{constructor(t,r){super(t,r),this.path=r,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(t,r,n){if(this.isAtEndOfPath&&t.terminalType.name===this.nextTerminalName&&t.idx===this.nextTerminalOccurrence&&!this.found){let o=r.concat(n),i=new F({definition:o});this.possibleTokTypes=Me(i),this.found=!0}}},dr=class extends oe{constructor(t,r){super(),this.topRule=t,this.occurrence=r,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},eo=class extends dr{walkMany(t,r,n){if(t.idx===this.occurrence){let o=ct(r.concat(n));this.result.isEndOfRule=o===void 0,o instanceof v&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else super.walkMany(t,r,n)}},Br=class extends dr{walkManySep(t,r,n){if(t.idx===this.occurrence){let o=ct(r.concat(n));this.result.isEndOfRule=o===void 0,o instanceof v&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else super.walkManySep(t,r,n)}},ro=class extends dr{walkAtLeastOne(t,r,n){if(t.idx===this.occurrence){let o=ct(r.concat(n));this.result.isEndOfRule=o===void 0,o instanceof v&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else super.walkAtLeastOne(t,r,n)}},Gr=class extends dr{walkAtLeastOneSep(t,r,n){if(t.idx===this.occurrence){let o=ct(r.concat(n));this.result.isEndOfRule=o===void 0,o instanceof v&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else super.walkAtLeastOneSep(t,r,n)}};function no(e,t,r=[]){r=w(r);let n=[],o=0;function i(a){return a.concat(X(e,o+1))}function s(a){let c=no(i(a),t,r);return n.concat(c)}for(;r.length<t&&o<e.length;){let a=e[o];if(a instanceof F)return s(a.definition);if(a instanceof D)return s(a.definition);if(a instanceof G)n=s(a.definition);else if(a instanceof Q){let c=a.definition.concat([new b({definition:a.definition})]);return s(c)}else if(a instanceof Z){let c=[new F({definition:a.definition}),new b({definition:[new v({terminalType:a.separator})].concat(a.definition)})];return s(c)}else if(a instanceof z){let c=a.definition.concat([new b({definition:[new v({terminalType:a.separator})].concat(a.definition)})]);n=s(c)}else if(a instanceof b){let c=a.definition.concat([new b({definition:a.definition})]);n=s(c)}else{if(a instanceof V)return S(a.definition,c=>{_(c.definition)===!1&&(n=s(c.definition))}),n;if(a instanceof v)r.push(a.terminalType);else throw Error("non exhaustive match")}o++}return n.push({partialPath:r,suffixDef:X(e,o)}),n}function oo(e,t,r,n){let o="EXIT_NONE_TERMINAL",i=[o],s="EXIT_ALTERNATIVE",a=!1,c=t.length,l=c-n-1,u=[],f=[];for(f.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!_(f);){let h=f.pop();if(h===s){a&&Vt(f).idx<=l&&f.pop();continue}let x=h.def,T=h.idx,O=h.ruleStack,R=h.occurrenceStack;if(_(x))continue;let N=x[0];if(N===o){let E={idx:T,def:X(x),ruleStack:ne(O),occurrenceStack:ne(R)};f.push(E)}else if(N instanceof v)if(T<c-1){let E=T+1,d=t[E];if(r(d,N.terminalType)){let y={idx:E,def:X(x),ruleStack:O,occurrenceStack:R};f.push(y)}}else if(T===c-1)u.push({nextTokenType:N.terminalType,nextTokenOccurrence:N.idx,ruleStack:O,occurrenceStack:R}),a=!0;else throw Error("non exhaustive match");else if(N instanceof D){let E=w(O);E.push(N.nonTerminalName);let d=w(R);d.push(N.idx);let y={idx:T,def:N.definition.concat(i,X(x)),ruleStack:E,occurrenceStack:d};f.push(y)}else if(N instanceof G){let E={idx:T,def:X(x),ruleStack:O,occurrenceStack:R};f.push(E),f.push(s);let d={idx:T,def:N.definition.concat(X(x)),ruleStack:O,occurrenceStack:R};f.push(d)}else if(N instanceof Q){let E=new b({definition:N.definition,idx:N.idx}),d=N.definition.concat([E],X(x)),y={idx:T,def:d,ruleStack:O,occurrenceStack:R};f.push(y)}else if(N instanceof Z){let E=new v({terminalType:N.separator}),d=new b({definition:[E].concat(N.definition),idx:N.idx}),y=N.definition.concat([d],X(x)),L={idx:T,def:y,ruleStack:O,occurrenceStack:R};f.push(L)}else if(N instanceof z){let E={idx:T,def:X(x),ruleStack:O,occurrenceStack:R};f.push(E),f.push(s);let d=new v({terminalType:N.separator}),y=new b({definition:[d].concat(N.definition),idx:N.idx}),L=N.definition.concat([y],X(x)),Rt={idx:T,def:L,ruleStack:O,occurrenceStack:R};f.push(Rt)}else if(N instanceof b){let E={idx:T,def:X(x),ruleStack:O,occurrenceStack:R};f.push(E),f.push(s);let d=new b({definition:N.definition,idx:N.idx}),y=N.definition.concat([d],X(x)),L={idx:T,def:y,ruleStack:O,occurrenceStack:R};f.push(L)}else if(N instanceof V)for(let E=N.definition.length-1;E>=0;E--){let d=N.definition[E],y={idx:T,def:d.definition.concat(X(x)),ruleStack:O,occurrenceStack:R};f.push(y),f.push(s)}else if(N instanceof F)f.push({idx:T,def:N.definition.concat(X(x)),ruleStack:O,occurrenceStack:R});else if(N instanceof Et)f.push(mT(N,T,O,R));else throw Error("non exhaustive match")}return u}function mT(e,t,r,n){let o=w(r);o.push(e.name);let i=w(n);return i.push(1),{idx:t,def:e.definition,ruleStack:o,occurrenceStack:i}}var q;(function(e){e[e.OPTION=0]="OPTION",e[e.REPETITION=1]="REPETITION",e[e.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",e[e.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",e[e.ALTERNATION=5]="ALTERNATION"})(q||(q={}));function so(e){if(e instanceof G||e==="Option")return q.OPTION;if(e instanceof b||e==="Repetition")return q.REPETITION;if(e instanceof Q||e==="RepetitionMandatory")return q.REPETITION_MANDATORY;if(e instanceof Z||e==="RepetitionMandatoryWithSeparator")return q.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof z||e==="RepetitionWithSeparator")return q.REPETITION_WITH_SEPARATOR;if(e instanceof V||e==="Alternation")return q.ALTERNATION;throw Error("non exhaustive match")}function su(e,t,r,n,o,i){let s=$r(e,t,r),a=hu(s)?mr:ie;return i(s,n,a,o)}function au(e,t,r,n,o,i){let s=jr(e,t,o,r),a=hu(s)?mr:ie;return i(s[0],a,n)}function cu(e,t,r,n){let o=e.length,i=ft(e,s=>ft(s,a=>a.length===1));if(t)return function(s){let a=g(s,c=>c.GATE);for(let c=0;c<o;c++){let l=e[c],u=l.length,f=a[c];if(!(f!==void 0&&f.call(this)===!1))t:for(let h=0;h<u;h++){let x=l[h],T=x.length;for(let O=0;O<T;O++){let R=this.LA(O+1);if(r(R,x[O])===!1)continue t}return c}}};if(i&&!n){let s=g(e,c=>ot(c)),a=rt(s,(c,l,u)=>(S(l,f=>{A(c,f.tokenTypeIdx)||(c[f.tokenTypeIdx]=u),S(f.categoryMatches,h=>{A(c,h)||(c[h]=u)})}),c),{});return function(){let c=this.LA(1);return a[c.tokenTypeIdx]}}else return function(){for(let s=0;s<o;s++){let a=e[s],c=a.length;t:for(let l=0;l<c;l++){let u=a[l],f=u.length;for(let h=0;h<f;h++){let x=this.LA(h+1);if(r(x,u[h])===!1)continue t}return s}}}}function lu(e,t,r){let n=ft(e,i=>i.length===1),o=e.length;if(n&&!r){let i=ot(e);if(i.length===1&&_(i[0].categoryMatches)){let a=i[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===a}}else{let s=rt(i,(a,c,l)=>(a[c.tokenTypeIdx]=!0,S(c.categoryMatches,u=>{a[u]=!0}),a),[]);return function(){let a=this.LA(1);return s[a.tokenTypeIdx]===!0}}}else return function(){t:for(let i=0;i<o;i++){let s=e[i],a=s.length;for(let c=0;c<a;c++){let l=this.LA(c+1);if(t(l,s[c])===!1)continue t}return!0}return!1}}var ss=class extends oe{constructor(t,r,n){super(),this.topProd=t,this.targetOccurrence=r,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(t,r,n,o){return t.idx===this.targetOccurrence&&this.targetProdType===r?(this.restDef=n.concat(o),!0):!1}walkOption(t,r,n){this.checkIsTarget(t,q.OPTION,r,n)||super.walkOption(t,r,n)}walkAtLeastOne(t,r,n){this.checkIsTarget(t,q.REPETITION_MANDATORY,r,n)||super.walkOption(t,r,n)}walkAtLeastOneSep(t,r,n){this.checkIsTarget(t,q.REPETITION_MANDATORY_WITH_SEPARATOR,r,n)||super.walkOption(t,r,n)}walkMany(t,r,n){this.checkIsTarget(t,q.REPETITION,r,n)||super.walkOption(t,r,n)}walkManySep(t,r,n){this.checkIsTarget(t,q.REPETITION_WITH_SEPARATOR,r,n)||super.walkOption(t,r,n)}},io=class extends xt{constructor(t,r,n){super(),this.targetOccurrence=t,this.targetProdType=r,this.targetRef=n,this.result=[]}checkIsTarget(t,r){t.idx===this.targetOccurrence&&this.targetProdType===r&&(this.targetRef===void 0||t===this.targetRef)&&(this.result=t.definition)}visitOption(t){this.checkIsTarget(t,q.OPTION)}visitRepetition(t){this.checkIsTarget(t,q.REPETITION)}visitRepetitionMandatory(t){this.checkIsTarget(t,q.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(t){this.checkIsTarget(t,q.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(t){this.checkIsTarget(t,q.REPETITION_WITH_SEPARATOR)}visitAlternation(t){this.checkIsTarget(t,q.ALTERNATION)}};function iu(e){let t=new Array(e);for(let r=0;r<e;r++)t[r]=[];return t}function is(e){let t=[""];for(let r=0;r<e.length;r++){let n=e[r],o=[];for(let i=0;i<t.length;i++){let s=t[i];o.push(s+"_"+n.tokenTypeIdx);for(let a=0;a<n.categoryMatches.length;a++){let c="_"+n.categoryMatches[a];o.push(s+c)}}t=o}return t}function dT(e,t,r){for(let n=0;n<e.length;n++){if(n===r)continue;let o=e[n];for(let i=0;i<t.length;i++){let s=t[i];if(o[s]===!0)return!1}}return!0}function uu(e,t){let r=g(e,s=>no([s],1)),n=iu(r.length),o=g(r,s=>{let a={};return S(s,c=>{let l=is(c.partialPath);S(l,u=>{a[u]=!0})}),a}),i=r;for(let s=1;s<=t;s++){let a=i;i=iu(a.length);for(let c=0;c<a.length;c++){let l=a[c];for(let u=0;u<l.length;u++){let f=l[u].partialPath,h=l[u].suffixDef,x=is(f);if(dT(o,x,c)||_(h)||f.length===t){let O=n[c];if(ao(O,f)===!1){O.push(f);for(let R=0;R<x.length;R++){let N=x[R];o[c][N]=!0}}}else{let O=no(h,s+1,f);i[c]=i[c].concat(O),S(O,R=>{let N=is(R.partialPath);S(N,E=>{o[c][E]=!0})})}}}}return n}function $r(e,t,r,n){let o=new io(e,q.ALTERNATION,n);return t.accept(o),uu(o.result,r)}function jr(e,t,r,n){let o=new io(e,r);t.accept(o);let i=o.result,a=new ss(t,e,r).startWalking(),c=new F({definition:i}),l=new F({definition:a});return uu([c,l],n)}function ao(e,t){t:for(let r=0;r<e.length;r++){let n=e[r];if(n.length===t.length){for(let o=0;o<n.length;o++){let i=t[o],s=n[o];if((i===s||s.categoryMatchesMap[i.tokenTypeIdx]!==void 0)===!1)continue t}return!0}}return!1}function fu(e,t){return e.length<t.length&&ft(e,(r,n)=>{let o=t[n];return r===o||o.categoryMatchesMap[r.tokenTypeIdx]})}function hu(e){return ft(e,t=>ft(t,r=>ft(r,n=>_(n.categoryMatches))))}function pu(e){let t=e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName});return g(t,r=>Object.assign({type:st.CUSTOM_LOOKAHEAD_VALIDATION},r))}function mu(e,t,r,n){let o=gt(e,c=>gT(c,r)),i=NT(e,t,r),s=gt(e,c=>TT(c,r)),a=gt(e,c=>xT(c,e,n,r));return o.concat(i,s,a)}function gT(e,t){let r=new as;e.accept(r);let n=r.allProductions,o=ji(n,ET),i=Nt(o,a=>a.length>1);return g(k(i),a=>{let c=ct(a),l=t.buildDuplicateFoundError(e,a),u=It(c),f={message:l,type:st.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:u,occurrence:c.idx},h=du(c);return h&&(f.parameter=h),f})}function ET(e){return`${It(e)}_#_${e.idx}_#_${du(e)}`}function du(e){return e instanceof v?e.terminalType.name:e instanceof D?e.nonTerminalName:""}var as=class extends xt{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(t){this.allProductions.push(t)}visitOption(t){this.allProductions.push(t)}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}visitAlternation(t){this.allProductions.push(t)}visitTerminal(t){this.allProductions.push(t)}};function xT(e,t,r,n){let o=[];if(rt(t,(s,a)=>a.name===e.name?s+1:s,0)>1){let s=n.buildDuplicateRuleNameError({topLevelRule:e,grammarName:r});o.push({message:s,type:st.DUPLICATE_RULE_NAME,ruleName:e.name})}return o}function gu(e,t,r){let n=[],o;return $(t,e)||(o=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${r}<-as it is not defined in any of the super grammars `,n.push({message:o,type:st.INVALID_RULE_OVERRIDE,ruleName:e})),n}function ls(e,t,r,n=[]){let o=[],i=co(t.definition);if(_(i))return[];{let s=e.name;$(i,e)&&o.push({message:r.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:n}),type:st.LEFT_RECURSION,ruleName:s});let c=Ie(i,n.concat([e])),l=gt(c,u=>{let f=w(n);return f.push(u),ls(e,u,r,f)});return o.concat(l)}}function co(e){let t=[];if(_(e))return t;let r=ct(e);if(r instanceof D)t.push(r.referencedRule);else if(r instanceof F||r instanceof G||r instanceof Q||r instanceof Z||r instanceof z||r instanceof b)t=t.concat(co(r.definition));else if(r instanceof V)t=ot(g(r.definition,i=>co(i.definition)));else if(!(r instanceof v))throw Error("non exhaustive match");let n=ve(r),o=e.length>1;if(n&&o){let i=X(e);return t.concat(co(i))}else return t}var Wr=class extends xt{constructor(){super(...arguments),this.alternations=[]}visitAlternation(t){this.alternations.push(t)}};function Eu(e,t){let r=new Wr;e.accept(r);let n=r.alternations;return gt(n,i=>{let s=ne(i.definition);return gt(s,(a,c)=>{let l=oo([a],[],ie,1);return _(l)?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:i,emptyChoiceIdx:c}),type:st.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:i.idx,alternative:c+1}]:[]})})}function xu(e,t,r){let n=new Wr;e.accept(n);let o=n.alternations;return o=Oe(o,s=>s.ignoreAmbiguities===!0),gt(o,s=>{let a=s.idx,c=s.maxLookahead||t,l=$r(a,e,c,s),u=ST(l,s,e,r),f=AT(l,s,e,r);return u.concat(f)})}var cs=class extends xt{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}};function TT(e,t){let r=new Wr;e.accept(r);let n=r.alternations;return gt(n,i=>i.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:i}),type:st.TOO_MANY_ALTS,ruleName:e.name,occurrence:i.idx}]:[])}function Tu(e,t,r){let n=[];return S(e,o=>{let i=new cs;o.accept(i);let s=i.allProductions;S(s,a=>{let c=so(a),l=a.maxLookahead||t,u=a.idx,h=jr(u,o,c,l)[0];if(_(ot(h))){let x=r.buildEmptyRepetitionError({topLevelRule:o,repetition:a});n.push({message:x,type:st.NO_NON_EMPTY_LOOKAHEAD,ruleName:o.name})}})}),n}function ST(e,t,r,n){let o=[],i=rt(e,(a,c,l)=>(t.definition[l].ignoreAmbiguities===!0||S(c,u=>{let f=[l];S(e,(h,x)=>{l!==x&&ao(h,u)&&t.definition[x].ignoreAmbiguities!==!0&&f.push(x)}),f.length>1&&!ao(o,u)&&(o.push(u),a.push({alts:f,path:u}))}),a),[]);return g(i,a=>{let c=g(a.alts,u=>u+1);return{message:n.buildAlternationAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:c,prefixPath:a.path}),type:st.AMBIGUOUS_ALTS,ruleName:r.name,occurrence:t.idx,alternatives:a.alts}})}function AT(e,t,r,n){let o=rt(e,(s,a,c)=>{let l=g(a,u=>({idx:c,path:u}));return s.concat(l)},[]);return zt(gt(o,s=>{if(t.definition[s.idx].ignoreAmbiguities===!0)return[];let c=s.idx,l=s.path,u=ht(o,h=>t.definition[h.idx].ignoreAmbiguities!==!0&&h.idx<c&&fu(h.path,l));return g(u,h=>{let x=[h.idx+1,c+1],T=t.idx===0?"":t.idx;return{message:n.buildAlternationPrefixAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:x,prefixPath:h.path}),type:st.AMBIGUOUS_PREFIX_ALTS,ruleName:r.name,occurrence:T,alternatives:x}})}))}function NT(e,t,r){let n=[],o=g(t,i=>i.name);return S(e,i=>{let s=i.name;if($(o,s)){let a=r.buildNamespaceConflictError(i);n.push({message:a,type:st.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:s})}}),n}function Su(e){let t=sr(e,{errMsgProvider:nu}),r={};return S(e.rules,n=>{r[n.name]=n}),ou(r,t.errMsgProvider)}function Au(e){return e=sr(e,{errMsgProvider:Dt}),mu(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}var Nu="MismatchedTokenException",Iu="NoViableAltException",Ou="EarlyExitException",Cu="NotAllInputParsedException",Ru=[Nu,Iu,Ou,Cu];Object.freeze(Ru);function Re(e){return $(Ru,e.name)}var gr=class extends Error{constructor(t,r){super(t),this.token=r,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},we=class extends gr{constructor(t,r,n){super(t,r),this.previousToken=n,this.name=Nu}},Kr=class extends gr{constructor(t,r,n){super(t,r),this.previousToken=n,this.name=Iu}},Hr=class extends gr{constructor(t,r){super(t,r),this.name=Cu}},qr=class extends gr{constructor(t,r,n){super(t,r),this.previousToken=n,this.name=Ou}};var us={},hs="InRuleRecoveryException",fs=class extends Error{constructor(t){super(t),this.name=hs}},lo=class{initRecoverable(t){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=A(t,"recoveryEnabled")?t.recoveryEnabled:Tt.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=IT)}getTokenToInsert(t){let r=Ue(t,"",NaN,NaN,NaN,NaN,NaN,NaN);return r.isInsertedInRecovery=!0,r}canTokenTypeBeInsertedInRecovery(t){return!0}canTokenTypeBeDeletedInRecovery(t){return!0}tryInRepetitionRecovery(t,r,n,o){let i=this.findReSyncTokenType(),s=this.exportLexerState(),a=[],c=!1,l=this.LA(1),u=this.LA(1),f=()=>{let h=this.LA(0),x=this.errorMessageProvider.buildMismatchTokenMessage({expected:o,actual:l,previous:h,ruleName:this.getCurrRuleFullName()}),T=new we(x,l,this.LA(0));T.resyncedTokens=ne(a),this.SAVE_ERROR(T)};for(;!c;)if(this.tokenMatcher(u,o)){f();return}else if(n.call(this)){f(),t.apply(this,r);return}else this.tokenMatcher(u,i)?c=!0:(u=this.SKIP_TOKEN(),this.addToResyncTokens(u,a));this.importLexerState(s)}shouldInRepetitionRecoveryBeTried(t,r,n){return!(n===!1||this.tokenMatcher(this.LA(1),t)||this.isBackTracking()||this.canPerformInRuleRecovery(t,this.getFollowsForInRuleRecovery(t,r)))}getFollowsForInRuleRecovery(t,r){let n=this.getCurrentGrammarPath(t,r);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(t,r){if(this.canRecoverWithSingleTokenInsertion(t,r))return this.getTokenToInsert(t);if(this.canRecoverWithSingleTokenDeletion(t)){let n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new fs("sad sad panda")}canPerformInRuleRecovery(t,r){return this.canRecoverWithSingleTokenInsertion(t,r)||this.canRecoverWithSingleTokenDeletion(t)}canRecoverWithSingleTokenInsertion(t,r){if(!this.canTokenTypeBeInsertedInRecovery(t)||_(r))return!1;let n=this.LA(1);return Yt(r,i=>this.tokenMatcher(n,i))!==void 0}canRecoverWithSingleTokenDeletion(t){return this.canTokenTypeBeDeletedInRecovery(t)?this.tokenMatcher(this.LA(2),t):!1}isInCurrentRuleReSyncSet(t){let r=this.getCurrFollowKey(),n=this.getFollowSetFromFollowKey(r);return $(n,t)}findReSyncTokenType(){let t=this.flattenFollowSet(),r=this.LA(1),n=2;for(;;){let o=Yt(t,i=>rs(r,i));if(o!==void 0)return o;r=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return us;let t=this.getLastExplicitRuleShortName(),r=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(t),idxInCallingRule:r,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let t=this.RULE_STACK,r=this.RULE_OCCURRENCE_STACK;return g(t,(n,o)=>o===0?us:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:r[o],inRule:this.shortRuleNameToFullName(t[o-1])})}flattenFollowSet(){let t=g(this.buildFullFollowKeyStack(),r=>this.getFollowSetFromFollowKey(r));return ot(t)}getFollowSetFromFollowKey(t){if(t===us)return[wt];let r=t.ruleName+t.idxInCallingRule+Hn+t.inRule;return this.resyncFollows[r]}addToResyncTokens(t,r){return this.tokenMatcher(t,wt)||r.push(t),r}reSyncTo(t){let r=[],n=this.LA(1);for(;this.tokenMatcher(n,t)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,r);return ne(r)}attemptInRepetitionRecovery(t,r,n,o,i,s,a){}getCurrentGrammarPath(t,r){let n=this.getHumanReadableRuleStack(),o=w(this.RULE_OCCURRENCE_STACK);return{ruleStack:n,occurrenceStack:o,lastTok:t,lastTokOccurrence:r}}getHumanReadableRuleStack(){return g(this.RULE_STACK,t=>this.shortRuleNameToFullName(t))}};function IT(e,t,r,n,o,i,s){let a=this.getKeyForAutomaticLookahead(n,o),c=this.firstAfterRepMap[a];if(c===void 0){let h=this.getCurrRuleFullName(),x=this.getGAstProductions()[h];c=new i(x,o).startWalking(),this.firstAfterRepMap[a]=c}let l=c.token,u=c.occurrence,f=c.isEndOfRule;this.RULE_STACK.length===1&&f&&l===void 0&&(l=wt,u=1),!(l===void 0||u===void 0)&&this.shouldInRepetitionRecoveryBeTried(l,u,s)&&this.tryInRepetitionRecovery(e,t,r,l)}function uo(e,t,r){return r|t|e}var zr=class{constructor(t){var r;this.maxLookahead=(r=t?.maxLookahead)!==null&&r!==void 0?r:Tt.maxLookahead}validate(t){let r=this.validateNoLeftRecursion(t.rules);if(_(r)){let n=this.validateEmptyOrAlternatives(t.rules),o=this.validateAmbiguousAlternationAlternatives(t.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(t.rules,this.maxLookahead);return[...r,...n,...o,...i]}return r}validateNoLeftRecursion(t){return gt(t,r=>ls(r,r,Dt))}validateEmptyOrAlternatives(t){return gt(t,r=>Eu(r,Dt))}validateAmbiguousAlternationAlternatives(t,r){return gt(t,n=>xu(n,r,Dt))}validateSomeNonEmptyLookaheadPath(t,r){return Tu(t,r,Dt)}buildLookaheadForAlternation(t){return su(t.prodOccurrence,t.rule,t.maxLookahead,t.hasPredicates,t.dynamicTokensEnabled,cu)}buildLookaheadForOptional(t){return au(t.prodOccurrence,t.rule,t.maxLookahead,t.dynamicTokensEnabled,so(t.prodType),lu)}};var ho=class{initLooksAhead(t){this.dynamicTokensEnabled=A(t,"dynamicTokensEnabled")?t.dynamicTokensEnabled:Tt.dynamicTokensEnabled,this.maxLookahead=A(t,"maxLookahead")?t.maxLookahead:Tt.maxLookahead,this.lookaheadStrategy=A(t,"lookaheadStrategy")?t.lookaheadStrategy:new zr({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(t){S(t,r=>{this.TRACE_INIT(`${r.name} Rule Lookahead`,()=>{let{alternation:n,repetition:o,option:i,repetitionMandatory:s,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:c}=OT(r);S(n,l=>{let u=l.idx===0?"":l.idx;this.TRACE_INIT(`${It(l)}${u}`,()=>{let f=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:l.idx,rule:r,maxLookahead:l.maxLookahead||this.maxLookahead,hasPredicates:l.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),h=uo(this.fullRuleNameToShort[r.name],256,l.idx);this.setLaFuncCache(h,f)})}),S(o,l=>{this.computeLookaheadFunc(r,l.idx,768,"Repetition",l.maxLookahead,It(l))}),S(i,l=>{this.computeLookaheadFunc(r,l.idx,512,"Option",l.maxLookahead,It(l))}),S(s,l=>{this.computeLookaheadFunc(r,l.idx,1024,"RepetitionMandatory",l.maxLookahead,It(l))}),S(a,l=>{this.computeLookaheadFunc(r,l.idx,1536,"RepetitionMandatoryWithSeparator",l.maxLookahead,It(l))}),S(c,l=>{this.computeLookaheadFunc(r,l.idx,1280,"RepetitionWithSeparator",l.maxLookahead,It(l))})})})}computeLookaheadFunc(t,r,n,o,i,s){this.TRACE_INIT(`${s}${r===0?"":r}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:r,rule:t,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:o}),c=uo(this.fullRuleNameToShort[t.name],n,r);this.setLaFuncCache(c,a)})}getKeyForAutomaticLookahead(t,r){let n=this.getLastExplicitRuleShortName();return uo(n,t,r)}getLaFuncFromCache(t){return this.lookAheadFuncsCache.get(t)}setLaFuncCache(t,r){this.lookAheadFuncsCache.set(t,r)}},ps=class extends xt{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(t){this.dslMethods.option.push(t)}visitRepetitionWithSeparator(t){this.dslMethods.repetitionWithSeparator.push(t)}visitRepetitionMandatory(t){this.dslMethods.repetitionMandatory.push(t)}visitRepetitionMandatoryWithSeparator(t){this.dslMethods.repetitionMandatoryWithSeparator.push(t)}visitRepetition(t){this.dslMethods.repetition.push(t)}visitAlternation(t){this.dslMethods.alternation.push(t)}},fo=new ps;function OT(e){fo.reset(),e.accept(fo);let t=fo.dslMethods;return fo.reset(),t}function gs(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function Es(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function yu(e,t,r){e.children[r]===void 0?e.children[r]=[t]:e.children[r].push(t)}function Lu(e,t,r){e.children[t]===void 0?e.children[t]=[r]:e.children[t].push(r)}var CT="name";function xs(e,t){Object.defineProperty(e,CT,{enumerable:!1,configurable:!0,writable:!1,value:t})}function RT(e,t){let r=P(e),n=r.length;for(let o=0;o<n;o++){let i=r[o],s=e[i],a=s.length;for(let c=0;c<a;c++){let l=s[c];l.tokenTypeIdx===void 0&&this[l.name](l.children,t)}}}function _u(e,t){let r=function(){};xs(r,e+"BaseSemantics");let n={visit:function(o,i){if(I(o)&&(o=o[0]),!pt(o))return this[o.name](o.children,i)},validateVisitor:function(){let o=yT(this,t);if(!_(o)){let i=g(o,s=>s.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
|
|
86
|
-
${
|
|
85
|
+
see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return"deprecated"},buildDuplicateRuleNameError(e){let t;return e.topLevelRule instanceof Et?t=e.topLevelRule.name:t=e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function nu(e,t){let r=new ns(e,t);return r.resolveRefs(),r.errors}var ns=class extends xt{constructor(t,r){super(),this.nameToTopRule=t,this.errMsgProvider=r,this.errors=[]}resolveRefs(){S(k(this.nameToTopRule),t=>{this.currTopLevel=t,t.accept(this)})}visitNonTerminal(t){let r=this.nameToTopRule[t.nonTerminalName];if(r)t.referencedRule=r;else{let n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,t);this.errors.push({message:n,type:st.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:t.nonTerminalName})}}};var is=class extends ie{constructor(t,r){super(),this.topProd=t,this.path=r,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=w(this.path.ruleStack).reverse(),this.occurrenceStack=w(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(t,r=[]){this.found||super.walk(t,r)}walkProdRef(t,r,n){if(t.referencedRule.name===this.nextProductionName&&t.idx===this.nextProductionOccurrence){let i=r.concat(n);this.updateExpectedNext(),this.walk(t.referencedRule,i)}}updateExpectedNext(){_(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},ti=class extends is{constructor(t,r){super(t,r),this.path=r,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(t,r,n){if(this.isAtEndOfPath&&t.terminalType.name===this.nextTerminalName&&t.idx===this.nextTerminalOccurrence&&!this.found){let i=r.concat(n),o=new F({definition:i});this.possibleTokTypes=Me(o),this.found=!0}}},dr=class extends ie{constructor(t,r){super(),this.topRule=t,this.occurrence=r,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},ei=class extends dr{walkMany(t,r,n){if(t.idx===this.occurrence){let i=ct(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof v&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkMany(t,r,n)}},Br=class extends dr{walkManySep(t,r,n){if(t.idx===this.occurrence){let i=ct(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof v&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkManySep(t,r,n)}},ri=class extends dr{walkAtLeastOne(t,r,n){if(t.idx===this.occurrence){let i=ct(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof v&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOne(t,r,n)}},Gr=class extends dr{walkAtLeastOneSep(t,r,n){if(t.idx===this.occurrence){let i=ct(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof v&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOneSep(t,r,n)}};function ni(e,t,r=[]){r=w(r);let n=[],i=0;function o(a){return a.concat(X(e,i+1))}function s(a){let c=ni(o(a),t,r);return n.concat(c)}for(;r.length<t&&i<e.length;){let a=e[i];if(a instanceof F)return s(a.definition);if(a instanceof D)return s(a.definition);if(a instanceof G)n=s(a.definition);else if(a instanceof Q){let c=a.definition.concat([new b({definition:a.definition})]);return s(c)}else if(a instanceof Z){let c=[new F({definition:a.definition}),new b({definition:[new v({terminalType:a.separator})].concat(a.definition)})];return s(c)}else if(a instanceof z){let c=a.definition.concat([new b({definition:[new v({terminalType:a.separator})].concat(a.definition)})]);n=s(c)}else if(a instanceof b){let c=a.definition.concat([new b({definition:a.definition})]);n=s(c)}else{if(a instanceof V)return S(a.definition,c=>{_(c.definition)===!1&&(n=s(c.definition))}),n;if(a instanceof v)r.push(a.terminalType);else throw Error("non exhaustive match")}i++}return n.push({partialPath:r,suffixDef:X(e,i)}),n}function ii(e,t,r,n){let i="EXIT_NONE_TERMINAL",o=[i],s="EXIT_ALTERNATIVE",a=!1,c=t.length,l=c-n-1,u=[],f=[];for(f.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!_(f);){let h=f.pop();if(h===s){a&&Vt(f).idx<=l&&f.pop();continue}let g=h.def,T=h.idx,I=h.ruleStack,R=h.occurrenceStack;if(_(g))continue;let N=g[0];if(N===i){let x={idx:T,def:X(g),ruleStack:ne(I),occurrenceStack:ne(R)};f.push(x)}else if(N instanceof v)if(T<c-1){let x=T+1,d=t[x];if(r(d,N.terminalType)){let y={idx:x,def:X(g),ruleStack:I,occurrenceStack:R};f.push(y)}}else if(T===c-1)u.push({nextTokenType:N.terminalType,nextTokenOccurrence:N.idx,ruleStack:I,occurrenceStack:R}),a=!0;else throw Error("non exhaustive match");else if(N instanceof D){let x=w(I);x.push(N.nonTerminalName);let d=w(R);d.push(N.idx);let y={idx:T,def:N.definition.concat(o,X(g)),ruleStack:x,occurrenceStack:d};f.push(y)}else if(N instanceof G){let x={idx:T,def:X(g),ruleStack:I,occurrenceStack:R};f.push(x),f.push(s);let d={idx:T,def:N.definition.concat(X(g)),ruleStack:I,occurrenceStack:R};f.push(d)}else if(N instanceof Q){let x=new b({definition:N.definition,idx:N.idx}),d=N.definition.concat([x],X(g)),y={idx:T,def:d,ruleStack:I,occurrenceStack:R};f.push(y)}else if(N instanceof Z){let x=new v({terminalType:N.separator}),d=new b({definition:[x].concat(N.definition),idx:N.idx}),y=N.definition.concat([d],X(g)),L={idx:T,def:y,ruleStack:I,occurrenceStack:R};f.push(L)}else if(N instanceof z){let x={idx:T,def:X(g),ruleStack:I,occurrenceStack:R};f.push(x),f.push(s);let d=new v({terminalType:N.separator}),y=new b({definition:[d].concat(N.definition),idx:N.idx}),L=N.definition.concat([y],X(g)),Rt={idx:T,def:L,ruleStack:I,occurrenceStack:R};f.push(Rt)}else if(N instanceof b){let x={idx:T,def:X(g),ruleStack:I,occurrenceStack:R};f.push(x),f.push(s);let d=new b({definition:N.definition,idx:N.idx}),y=N.definition.concat([d],X(g)),L={idx:T,def:y,ruleStack:I,occurrenceStack:R};f.push(L)}else if(N instanceof V)for(let x=N.definition.length-1;x>=0;x--){let d=N.definition[x],y={idx:T,def:d.definition.concat(X(g)),ruleStack:I,occurrenceStack:R};f.push(y),f.push(s)}else if(N instanceof F)f.push({idx:T,def:N.definition.concat(X(g)),ruleStack:I,occurrenceStack:R});else if(N instanceof Et)f.push(gT(N,T,I,R));else throw Error("non exhaustive match")}return u}function gT(e,t,r,n){let i=w(r);i.push(e.name);let o=w(n);return o.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:o}}var q;(function(e){e[e.OPTION=0]="OPTION",e[e.REPETITION=1]="REPETITION",e[e.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",e[e.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",e[e.ALTERNATION=5]="ALTERNATION"})(q||(q={}));function si(e){if(e instanceof G||e==="Option")return q.OPTION;if(e instanceof b||e==="Repetition")return q.REPETITION;if(e instanceof Q||e==="RepetitionMandatory")return q.REPETITION_MANDATORY;if(e instanceof Z||e==="RepetitionMandatoryWithSeparator")return q.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof z||e==="RepetitionWithSeparator")return q.REPETITION_WITH_SEPARATOR;if(e instanceof V||e==="Alternation")return q.ALTERNATION;throw Error("non exhaustive match")}function ou(e,t,r,n,i,o){let s=$r(e,t,r),a=fu(s)?mr:oe;return o(s,n,a,i)}function su(e,t,r,n,i,o){let s=jr(e,t,i,r),a=fu(s)?mr:oe;return o(s[0],a,n)}function au(e,t,r,n){let i=e.length,o=ft(e,s=>ft(s,a=>a.length===1));if(t)return function(s){let a=E(s,c=>c.GATE);for(let c=0;c<i;c++){let l=e[c],u=l.length,f=a[c];if(!(f!==void 0&&f.call(this)===!1))t:for(let h=0;h<u;h++){let g=l[h],T=g.length;for(let I=0;I<T;I++){let R=this.LA(I+1);if(r(R,g[I])===!1)continue t}return c}}};if(o&&!n){let s=E(e,c=>it(c)),a=rt(s,(c,l,u)=>(S(l,f=>{A(c,f.tokenTypeIdx)||(c[f.tokenTypeIdx]=u),S(f.categoryMatches,h=>{A(c,h)||(c[h]=u)})}),c),{});return function(){let c=this.LA(1);return a[c.tokenTypeIdx]}}else return function(){for(let s=0;s<i;s++){let a=e[s],c=a.length;t:for(let l=0;l<c;l++){let u=a[l],f=u.length;for(let h=0;h<f;h++){let g=this.LA(h+1);if(r(g,u[h])===!1)continue t}return s}}}}function cu(e,t,r){let n=ft(e,o=>o.length===1),i=e.length;if(n&&!r){let o=it(e);if(o.length===1&&_(o[0].categoryMatches)){let a=o[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===a}}else{let s=rt(o,(a,c,l)=>(a[c.tokenTypeIdx]=!0,S(c.categoryMatches,u=>{a[u]=!0}),a),[]);return function(){let a=this.LA(1);return s[a.tokenTypeIdx]===!0}}}else return function(){t:for(let o=0;o<i;o++){let s=e[o],a=s.length;for(let c=0;c<a;c++){let l=this.LA(c+1);if(t(l,s[c])===!1)continue t}return!0}return!1}}var ss=class extends ie{constructor(t,r,n){super(),this.topProd=t,this.targetOccurrence=r,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(t,r,n,i){return t.idx===this.targetOccurrence&&this.targetProdType===r?(this.restDef=n.concat(i),!0):!1}walkOption(t,r,n){this.checkIsTarget(t,q.OPTION,r,n)||super.walkOption(t,r,n)}walkAtLeastOne(t,r,n){this.checkIsTarget(t,q.REPETITION_MANDATORY,r,n)||super.walkOption(t,r,n)}walkAtLeastOneSep(t,r,n){this.checkIsTarget(t,q.REPETITION_MANDATORY_WITH_SEPARATOR,r,n)||super.walkOption(t,r,n)}walkMany(t,r,n){this.checkIsTarget(t,q.REPETITION,r,n)||super.walkOption(t,r,n)}walkManySep(t,r,n){this.checkIsTarget(t,q.REPETITION_WITH_SEPARATOR,r,n)||super.walkOption(t,r,n)}},oi=class extends xt{constructor(t,r,n){super(),this.targetOccurrence=t,this.targetProdType=r,this.targetRef=n,this.result=[]}checkIsTarget(t,r){t.idx===this.targetOccurrence&&this.targetProdType===r&&(this.targetRef===void 0||t===this.targetRef)&&(this.result=t.definition)}visitOption(t){this.checkIsTarget(t,q.OPTION)}visitRepetition(t){this.checkIsTarget(t,q.REPETITION)}visitRepetitionMandatory(t){this.checkIsTarget(t,q.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(t){this.checkIsTarget(t,q.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(t){this.checkIsTarget(t,q.REPETITION_WITH_SEPARATOR)}visitAlternation(t){this.checkIsTarget(t,q.ALTERNATION)}};function iu(e){let t=new Array(e);for(let r=0;r<e;r++)t[r]=[];return t}function os(e){let t=[""];for(let r=0;r<e.length;r++){let n=e[r],i=[];for(let o=0;o<t.length;o++){let s=t[o];i.push(s+"_"+n.tokenTypeIdx);for(let a=0;a<n.categoryMatches.length;a++){let c="_"+n.categoryMatches[a];i.push(s+c)}}t=i}return t}function ET(e,t,r){for(let n=0;n<e.length;n++){if(n===r)continue;let i=e[n];for(let o=0;o<t.length;o++){let s=t[o];if(i[s]===!0)return!1}}return!0}function lu(e,t){let r=E(e,s=>ni([s],1)),n=iu(r.length),i=E(r,s=>{let a={};return S(s,c=>{let l=os(c.partialPath);S(l,u=>{a[u]=!0})}),a}),o=r;for(let s=1;s<=t;s++){let a=o;o=iu(a.length);for(let c=0;c<a.length;c++){let l=a[c];for(let u=0;u<l.length;u++){let f=l[u].partialPath,h=l[u].suffixDef,g=os(f);if(ET(i,g,c)||_(h)||f.length===t){let I=n[c];if(ai(I,f)===!1){I.push(f);for(let R=0;R<g.length;R++){let N=g[R];i[c][N]=!0}}}else{let I=ni(h,s+1,f);o[c]=o[c].concat(I),S(I,R=>{let N=os(R.partialPath);S(N,x=>{i[c][x]=!0})})}}}}return n}function $r(e,t,r,n){let i=new oi(e,q.ALTERNATION,n);return t.accept(i),lu(i.result,r)}function jr(e,t,r,n){let i=new oi(e,r);t.accept(i);let o=i.result,a=new ss(t,e,r).startWalking(),c=new F({definition:o}),l=new F({definition:a});return lu([c,l],n)}function ai(e,t){t:for(let r=0;r<e.length;r++){let n=e[r];if(n.length===t.length){for(let i=0;i<n.length;i++){let o=t[i],s=n[i];if((o===s||s.categoryMatchesMap[o.tokenTypeIdx]!==void 0)===!1)continue t}return!0}}return!1}function uu(e,t){return e.length<t.length&&ft(e,(r,n)=>{let i=t[n];return r===i||i.categoryMatchesMap[r.tokenTypeIdx]})}function fu(e){return ft(e,t=>ft(t,r=>ft(r,n=>_(n.categoryMatches))))}function hu(e){let t=e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName});return E(t,r=>Object.assign({type:st.CUSTOM_LOOKAHEAD_VALIDATION},r))}function pu(e,t,r,n){let i=gt(e,c=>xT(c,r)),o=IT(e,t,r),s=gt(e,c=>AT(c,r)),a=gt(e,c=>ST(c,e,n,r));return i.concat(o,s,a)}function xT(e,t){let r=new as;e.accept(r);let n=r.allProductions,i=jo(n,TT),o=Nt(i,a=>a.length>1);return E(k(o),a=>{let c=ct(a),l=t.buildDuplicateFoundError(e,a),u=Ot(c),f={message:l,type:st.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:u,occurrence:c.idx},h=mu(c);return h&&(f.parameter=h),f})}function TT(e){return`${Ot(e)}_#_${e.idx}_#_${mu(e)}`}function mu(e){return e instanceof v?e.terminalType.name:e instanceof D?e.nonTerminalName:""}var as=class extends xt{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(t){this.allProductions.push(t)}visitOption(t){this.allProductions.push(t)}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}visitAlternation(t){this.allProductions.push(t)}visitTerminal(t){this.allProductions.push(t)}};function ST(e,t,r,n){let i=[];if(rt(t,(s,a)=>a.name===e.name?s+1:s,0)>1){let s=n.buildDuplicateRuleNameError({topLevelRule:e,grammarName:r});i.push({message:s,type:st.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function du(e,t,r){let n=[],i;return $(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${r}<-as it is not defined in any of the super grammars `,n.push({message:i,type:st.INVALID_RULE_OVERRIDE,ruleName:e})),n}function ls(e,t,r,n=[]){let i=[],o=ci(t.definition);if(_(o))return[];{let s=e.name;$(o,e)&&i.push({message:r.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:n}),type:st.LEFT_RECURSION,ruleName:s});let c=Oe(o,n.concat([e])),l=gt(c,u=>{let f=w(n);return f.push(u),ls(e,u,r,f)});return i.concat(l)}}function ci(e){let t=[];if(_(e))return t;let r=ct(e);if(r instanceof D)t.push(r.referencedRule);else if(r instanceof F||r instanceof G||r instanceof Q||r instanceof Z||r instanceof z||r instanceof b)t=t.concat(ci(r.definition));else if(r instanceof V)t=it(E(r.definition,o=>ci(o.definition)));else if(!(r instanceof v))throw Error("non exhaustive match");let n=ve(r),i=e.length>1;if(n&&i){let o=X(e);return t.concat(ci(o))}else return t}var Wr=class extends xt{constructor(){super(...arguments),this.alternations=[]}visitAlternation(t){this.alternations.push(t)}};function gu(e,t){let r=new Wr;e.accept(r);let n=r.alternations;return gt(n,o=>{let s=ne(o.definition);return gt(s,(a,c)=>{let l=ii([a],[],oe,1);return _(l)?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:o,emptyChoiceIdx:c}),type:st.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:o.idx,alternative:c+1}]:[]})})}function Eu(e,t,r){let n=new Wr;e.accept(n);let i=n.alternations;return i=Ie(i,s=>s.ignoreAmbiguities===!0),gt(i,s=>{let a=s.idx,c=s.maxLookahead||t,l=$r(a,e,c,s),u=NT(l,s,e,r),f=OT(l,s,e,r);return u.concat(f)})}var cs=class extends xt{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}};function AT(e,t){let r=new Wr;e.accept(r);let n=r.alternations;return gt(n,o=>o.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:o}),type:st.TOO_MANY_ALTS,ruleName:e.name,occurrence:o.idx}]:[])}function xu(e,t,r){let n=[];return S(e,i=>{let o=new cs;i.accept(o);let s=o.allProductions;S(s,a=>{let c=si(a),l=a.maxLookahead||t,u=a.idx,h=jr(u,i,c,l)[0];if(_(it(h))){let g=r.buildEmptyRepetitionError({topLevelRule:i,repetition:a});n.push({message:g,type:st.NO_NON_EMPTY_LOOKAHEAD,ruleName:i.name})}})}),n}function NT(e,t,r,n){let i=[],o=rt(e,(a,c,l)=>(t.definition[l].ignoreAmbiguities===!0||S(c,u=>{let f=[l];S(e,(h,g)=>{l!==g&&ai(h,u)&&t.definition[g].ignoreAmbiguities!==!0&&f.push(g)}),f.length>1&&!ai(i,u)&&(i.push(u),a.push({alts:f,path:u}))}),a),[]);return E(o,a=>{let c=E(a.alts,u=>u+1);return{message:n.buildAlternationAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:c,prefixPath:a.path}),type:st.AMBIGUOUS_ALTS,ruleName:r.name,occurrence:t.idx,alternatives:a.alts}})}function OT(e,t,r,n){let i=rt(e,(s,a,c)=>{let l=E(a,u=>({idx:c,path:u}));return s.concat(l)},[]);return zt(gt(i,s=>{if(t.definition[s.idx].ignoreAmbiguities===!0)return[];let c=s.idx,l=s.path,u=ht(i,h=>t.definition[h.idx].ignoreAmbiguities!==!0&&h.idx<c&&uu(h.path,l));return E(u,h=>{let g=[h.idx+1,c+1],T=t.idx===0?"":t.idx;return{message:n.buildAlternationPrefixAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:g,prefixPath:h.path}),type:st.AMBIGUOUS_PREFIX_ALTS,ruleName:r.name,occurrence:T,alternatives:g}})}))}function IT(e,t,r){let n=[],i=E(t,o=>o.name);return S(e,o=>{let s=o.name;if($(i,s)){let a=r.buildNamespaceConflictError(o);n.push({message:a,type:st.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:s})}}),n}function Tu(e){let t=sr(e,{errMsgProvider:ru}),r={};return S(e.rules,n=>{r[n.name]=n}),nu(r,t.errMsgProvider)}function Su(e){return e=sr(e,{errMsgProvider:Dt}),pu(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}var Au="MismatchedTokenException",Nu="NoViableAltException",Ou="EarlyExitException",Iu="NotAllInputParsedException",Cu=[Au,Nu,Ou,Iu];Object.freeze(Cu);function Re(e){return $(Cu,e.name)}var gr=class extends Error{constructor(t,r){super(t),this.token=r,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},we=class extends gr{constructor(t,r,n){super(t,r),this.previousToken=n,this.name=Au}},Kr=class extends gr{constructor(t,r,n){super(t,r),this.previousToken=n,this.name=Nu}},Hr=class extends gr{constructor(t,r){super(t,r),this.name=Iu}},qr=class extends gr{constructor(t,r,n){super(t,r),this.previousToken=n,this.name=Ou}};var us={},hs="InRuleRecoveryException",fs=class extends Error{constructor(t){super(t),this.name=hs}},li=class{initRecoverable(t){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=A(t,"recoveryEnabled")?t.recoveryEnabled:Tt.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=CT)}getTokenToInsert(t){let r=Ue(t,"",NaN,NaN,NaN,NaN,NaN,NaN);return r.isInsertedInRecovery=!0,r}canTokenTypeBeInsertedInRecovery(t){return!0}canTokenTypeBeDeletedInRecovery(t){return!0}tryInRepetitionRecovery(t,r,n,i){let o=this.findReSyncTokenType(),s=this.exportLexerState(),a=[],c=!1,l=this.LA(1),u=this.LA(1),f=()=>{let h=this.LA(0),g=this.errorMessageProvider.buildMismatchTokenMessage({expected:i,actual:l,previous:h,ruleName:this.getCurrRuleFullName()}),T=new we(g,l,this.LA(0));T.resyncedTokens=ne(a),this.SAVE_ERROR(T)};for(;!c;)if(this.tokenMatcher(u,i)){f();return}else if(n.call(this)){f(),t.apply(this,r);return}else this.tokenMatcher(u,o)?c=!0:(u=this.SKIP_TOKEN(),this.addToResyncTokens(u,a));this.importLexerState(s)}shouldInRepetitionRecoveryBeTried(t,r,n){return!(n===!1||this.tokenMatcher(this.LA(1),t)||this.isBackTracking()||this.canPerformInRuleRecovery(t,this.getFollowsForInRuleRecovery(t,r)))}getFollowsForInRuleRecovery(t,r){let n=this.getCurrentGrammarPath(t,r);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(t,r){if(this.canRecoverWithSingleTokenInsertion(t,r))return this.getTokenToInsert(t);if(this.canRecoverWithSingleTokenDeletion(t)){let n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new fs("sad sad panda")}canPerformInRuleRecovery(t,r){return this.canRecoverWithSingleTokenInsertion(t,r)||this.canRecoverWithSingleTokenDeletion(t)}canRecoverWithSingleTokenInsertion(t,r){if(!this.canTokenTypeBeInsertedInRecovery(t)||_(r))return!1;let n=this.LA(1);return Yt(r,o=>this.tokenMatcher(n,o))!==void 0}canRecoverWithSingleTokenDeletion(t){return this.canTokenTypeBeDeletedInRecovery(t)?this.tokenMatcher(this.LA(2),t):!1}isInCurrentRuleReSyncSet(t){let r=this.getCurrFollowKey(),n=this.getFollowSetFromFollowKey(r);return $(n,t)}findReSyncTokenType(){let t=this.flattenFollowSet(),r=this.LA(1),n=2;for(;;){let i=Yt(t,o=>rs(r,o));if(i!==void 0)return i;r=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return us;let t=this.getLastExplicitRuleShortName(),r=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(t),idxInCallingRule:r,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let t=this.RULE_STACK,r=this.RULE_OCCURRENCE_STACK;return E(t,(n,i)=>i===0?us:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:r[i],inRule:this.shortRuleNameToFullName(t[i-1])})}flattenFollowSet(){let t=E(this.buildFullFollowKeyStack(),r=>this.getFollowSetFromFollowKey(r));return it(t)}getFollowSetFromFollowKey(t){if(t===us)return[wt];let r=t.ruleName+t.idxInCallingRule+Hn+t.inRule;return this.resyncFollows[r]}addToResyncTokens(t,r){return this.tokenMatcher(t,wt)||r.push(t),r}reSyncTo(t){let r=[],n=this.LA(1);for(;this.tokenMatcher(n,t)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,r);return ne(r)}attemptInRepetitionRecovery(t,r,n,i,o,s,a){}getCurrentGrammarPath(t,r){let n=this.getHumanReadableRuleStack(),i=w(this.RULE_OCCURRENCE_STACK);return{ruleStack:n,occurrenceStack:i,lastTok:t,lastTokOccurrence:r}}getHumanReadableRuleStack(){return E(this.RULE_STACK,t=>this.shortRuleNameToFullName(t))}};function CT(e,t,r,n,i,o,s){let a=this.getKeyForAutomaticLookahead(n,i),c=this.firstAfterRepMap[a];if(c===void 0){let h=this.getCurrRuleFullName(),g=this.getGAstProductions()[h];c=new o(g,i).startWalking(),this.firstAfterRepMap[a]=c}let l=c.token,u=c.occurrence,f=c.isEndOfRule;this.RULE_STACK.length===1&&f&&l===void 0&&(l=wt,u=1),!(l===void 0||u===void 0)&&this.shouldInRepetitionRecoveryBeTried(l,u,s)&&this.tryInRepetitionRecovery(e,t,r,l)}function ui(e,t,r){return r|t|e}var zr=class{constructor(t){var r;this.maxLookahead=(r=t?.maxLookahead)!==null&&r!==void 0?r:Tt.maxLookahead}validate(t){let r=this.validateNoLeftRecursion(t.rules);if(_(r)){let n=this.validateEmptyOrAlternatives(t.rules),i=this.validateAmbiguousAlternationAlternatives(t.rules,this.maxLookahead),o=this.validateSomeNonEmptyLookaheadPath(t.rules,this.maxLookahead);return[...r,...n,...i,...o]}return r}validateNoLeftRecursion(t){return gt(t,r=>ls(r,r,Dt))}validateEmptyOrAlternatives(t){return gt(t,r=>gu(r,Dt))}validateAmbiguousAlternationAlternatives(t,r){return gt(t,n=>Eu(n,r,Dt))}validateSomeNonEmptyLookaheadPath(t,r){return xu(t,r,Dt)}buildLookaheadForAlternation(t){return ou(t.prodOccurrence,t.rule,t.maxLookahead,t.hasPredicates,t.dynamicTokensEnabled,au)}buildLookaheadForOptional(t){return su(t.prodOccurrence,t.rule,t.maxLookahead,t.dynamicTokensEnabled,si(t.prodType),cu)}};var hi=class{initLooksAhead(t){this.dynamicTokensEnabled=A(t,"dynamicTokensEnabled")?t.dynamicTokensEnabled:Tt.dynamicTokensEnabled,this.maxLookahead=A(t,"maxLookahead")?t.maxLookahead:Tt.maxLookahead,this.lookaheadStrategy=A(t,"lookaheadStrategy")?t.lookaheadStrategy:new zr({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(t){S(t,r=>{this.TRACE_INIT(`${r.name} Rule Lookahead`,()=>{let{alternation:n,repetition:i,option:o,repetitionMandatory:s,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:c}=RT(r);S(n,l=>{let u=l.idx===0?"":l.idx;this.TRACE_INIT(`${Ot(l)}${u}`,()=>{let f=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:l.idx,rule:r,maxLookahead:l.maxLookahead||this.maxLookahead,hasPredicates:l.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),h=ui(this.fullRuleNameToShort[r.name],256,l.idx);this.setLaFuncCache(h,f)})}),S(i,l=>{this.computeLookaheadFunc(r,l.idx,768,"Repetition",l.maxLookahead,Ot(l))}),S(o,l=>{this.computeLookaheadFunc(r,l.idx,512,"Option",l.maxLookahead,Ot(l))}),S(s,l=>{this.computeLookaheadFunc(r,l.idx,1024,"RepetitionMandatory",l.maxLookahead,Ot(l))}),S(a,l=>{this.computeLookaheadFunc(r,l.idx,1536,"RepetitionMandatoryWithSeparator",l.maxLookahead,Ot(l))}),S(c,l=>{this.computeLookaheadFunc(r,l.idx,1280,"RepetitionWithSeparator",l.maxLookahead,Ot(l))})})})}computeLookaheadFunc(t,r,n,i,o,s){this.TRACE_INIT(`${s}${r===0?"":r}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:r,rule:t,maxLookahead:o||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:i}),c=ui(this.fullRuleNameToShort[t.name],n,r);this.setLaFuncCache(c,a)})}getKeyForAutomaticLookahead(t,r){let n=this.getLastExplicitRuleShortName();return ui(n,t,r)}getLaFuncFromCache(t){return this.lookAheadFuncsCache.get(t)}setLaFuncCache(t,r){this.lookAheadFuncsCache.set(t,r)}},ps=class extends xt{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(t){this.dslMethods.option.push(t)}visitRepetitionWithSeparator(t){this.dslMethods.repetitionWithSeparator.push(t)}visitRepetitionMandatory(t){this.dslMethods.repetitionMandatory.push(t)}visitRepetitionMandatoryWithSeparator(t){this.dslMethods.repetitionMandatoryWithSeparator.push(t)}visitRepetition(t){this.dslMethods.repetition.push(t)}visitAlternation(t){this.dslMethods.alternation.push(t)}},fi=new ps;function RT(e){fi.reset(),e.accept(fi);let t=fi.dslMethods;return fi.reset(),t}function gs(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function Es(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function Ru(e,t,r){e.children[r]===void 0?e.children[r]=[t]:e.children[r].push(t)}function yu(e,t,r){e.children[t]===void 0?e.children[t]=[r]:e.children[t].push(r)}var yT="name";function xs(e,t){Object.defineProperty(e,yT,{enumerable:!1,configurable:!0,writable:!1,value:t})}function LT(e,t){let r=P(e),n=r.length;for(let i=0;i<n;i++){let o=r[i],s=e[o],a=s.length;for(let c=0;c<a;c++){let l=s[c];l.tokenTypeIdx===void 0&&this[l.name](l.children,t)}}}function Lu(e,t){let r=function(){};xs(r,e+"BaseSemantics");let n={visit:function(i,o){if(O(i)&&(i=i[0]),!pt(i))return this[i.name](i.children,o)},validateVisitor:function(){let i=_T(this,t);if(!_(i)){let o=E(i,s=>s.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
|
|
86
|
+
${o.join(`
|
|
87
87
|
|
|
88
88
|
`).replace(/\n/g,`
|
|
89
|
-
`)}`)}}};return r.prototype=n,r.prototype.constructor=r,r._RULE_NAMES=t,r}function
|
|
89
|
+
`)}`)}}};return r.prototype=n,r.prototype.constructor=r,r._RULE_NAMES=t,r}function _u(e,t,r){let n=function(){};xs(n,e+"BaseSemanticsWithDefaults");let i=Object.create(r.prototype);return S(t,o=>{i[o]=LT}),n.prototype=i,n.prototype.constructor=n,n}var Ts;(function(e){e[e.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",e[e.MISSING_METHOD=1]="MISSING_METHOD"})(Ts||(Ts={}));function _T(e,t){return vT(e,t)}function vT(e,t){let r=ht(t,i=>dt(e[i])===!1),n=E(r,i=>({msg:`Missing visitor method: <${i}> on ${e.constructor.name} CST Visitor.`,type:Ts.MISSING_METHOD,methodName:i}));return zt(n)}var gi=class{initTreeBuilder(t){if(this.CST_STACK=[],this.outputCst=t.outputCst,this.nodeLocationTracking=A(t,"nodeLocationTracking")?t.nodeLocationTracking:Tt.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=K,this.cstFinallyStateUpdate=K,this.cstPostTerminal=K,this.cstPostNonTerminal=K,this.cstPostRule=K;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Es,this.setNodeLocationFromNode=Es,this.cstPostRule=K,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=K,this.setNodeLocationFromNode=K,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=gs,this.setNodeLocationFromNode=gs,this.cstPostRule=K,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=K,this.setNodeLocationFromNode=K,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=K,this.setNodeLocationFromNode=K,this.cstPostRule=K,this.setInitialNodeLocation=K;else throw Error(`Invalid <nodeLocationTracking> config option: "${t.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(t){t.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(t){t.location={startOffset:this.LA(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(t){t.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(t){let r=this.LA(1);t.location={startOffset:r.startOffset,startLine:r.startLine,startColumn:r.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(t){let r={name:t,children:Object.create(null)};this.setInitialNodeLocation(r),this.CST_STACK.push(r)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(t){let r=this.LA(0),n=t.location;n.startOffset<=r.startOffset?(n.endOffset=r.endOffset,n.endLine=r.endLine,n.endColumn=r.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)}cstPostRuleOnlyOffset(t){let r=this.LA(0),n=t.location;n.startOffset<=r.startOffset?n.endOffset=r.endOffset:n.startOffset=NaN}cstPostTerminal(t,r){let n=this.CST_STACK[this.CST_STACK.length-1];Ru(n,r,t),this.setNodeLocationFromToken(n.location,r)}cstPostNonTerminal(t,r){let n=this.CST_STACK[this.CST_STACK.length-1];yu(n,r,t),this.setNodeLocationFromNode(n.location,t.location)}getBaseCstVisitorConstructor(){if(pt(this.baseCstVisitorConstructor)){let t=Lu(this.className,P(this.gastProductionsCache));return this.baseCstVisitorConstructor=t,t}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(pt(this.baseCstVisitorWithDefaultsConstructor)){let t=_u(this.className,P(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=t,t}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){let t=this.RULE_STACK;return t[t.length-1]}getPreviousExplicitRuleShortName(){let t=this.RULE_STACK;return t[t.length-2]}getLastExplicitRuleOccurrenceIndex(){let t=this.RULE_OCCURRENCE_STACK;return t[t.length-1]}};var Ei=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(t){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=t,this.tokVectorLength=t.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):Er}LA(t){let r=this.currIdx+t;return r<0||this.tokVectorLength<=r?Er:this.tokVector[r]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(t){this.currIdx=t}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}};var xi=class{ACTION(t){return t.call(this)}consume(t,r,n){return this.consumeInternal(r,t,n)}subrule(t,r,n){return this.subruleInternal(r,t,n)}option(t,r){return this.optionInternal(r,t)}or(t,r){return this.orInternal(r,t)}many(t,r){return this.manyInternal(t,r)}atLeastOne(t,r){return this.atLeastOneInternal(t,r)}CONSUME(t,r){return this.consumeInternal(t,0,r)}CONSUME1(t,r){return this.consumeInternal(t,1,r)}CONSUME2(t,r){return this.consumeInternal(t,2,r)}CONSUME3(t,r){return this.consumeInternal(t,3,r)}CONSUME4(t,r){return this.consumeInternal(t,4,r)}CONSUME5(t,r){return this.consumeInternal(t,5,r)}CONSUME6(t,r){return this.consumeInternal(t,6,r)}CONSUME7(t,r){return this.consumeInternal(t,7,r)}CONSUME8(t,r){return this.consumeInternal(t,8,r)}CONSUME9(t,r){return this.consumeInternal(t,9,r)}SUBRULE(t,r){return this.subruleInternal(t,0,r)}SUBRULE1(t,r){return this.subruleInternal(t,1,r)}SUBRULE2(t,r){return this.subruleInternal(t,2,r)}SUBRULE3(t,r){return this.subruleInternal(t,3,r)}SUBRULE4(t,r){return this.subruleInternal(t,4,r)}SUBRULE5(t,r){return this.subruleInternal(t,5,r)}SUBRULE6(t,r){return this.subruleInternal(t,6,r)}SUBRULE7(t,r){return this.subruleInternal(t,7,r)}SUBRULE8(t,r){return this.subruleInternal(t,8,r)}SUBRULE9(t,r){return this.subruleInternal(t,9,r)}OPTION(t){return this.optionInternal(t,0)}OPTION1(t){return this.optionInternal(t,1)}OPTION2(t){return this.optionInternal(t,2)}OPTION3(t){return this.optionInternal(t,3)}OPTION4(t){return this.optionInternal(t,4)}OPTION5(t){return this.optionInternal(t,5)}OPTION6(t){return this.optionInternal(t,6)}OPTION7(t){return this.optionInternal(t,7)}OPTION8(t){return this.optionInternal(t,8)}OPTION9(t){return this.optionInternal(t,9)}OR(t){return this.orInternal(t,0)}OR1(t){return this.orInternal(t,1)}OR2(t){return this.orInternal(t,2)}OR3(t){return this.orInternal(t,3)}OR4(t){return this.orInternal(t,4)}OR5(t){return this.orInternal(t,5)}OR6(t){return this.orInternal(t,6)}OR7(t){return this.orInternal(t,7)}OR8(t){return this.orInternal(t,8)}OR9(t){return this.orInternal(t,9)}MANY(t){this.manyInternal(0,t)}MANY1(t){this.manyInternal(1,t)}MANY2(t){this.manyInternal(2,t)}MANY3(t){this.manyInternal(3,t)}MANY4(t){this.manyInternal(4,t)}MANY5(t){this.manyInternal(5,t)}MANY6(t){this.manyInternal(6,t)}MANY7(t){this.manyInternal(7,t)}MANY8(t){this.manyInternal(8,t)}MANY9(t){this.manyInternal(9,t)}MANY_SEP(t){this.manySepFirstInternal(0,t)}MANY_SEP1(t){this.manySepFirstInternal(1,t)}MANY_SEP2(t){this.manySepFirstInternal(2,t)}MANY_SEP3(t){this.manySepFirstInternal(3,t)}MANY_SEP4(t){this.manySepFirstInternal(4,t)}MANY_SEP5(t){this.manySepFirstInternal(5,t)}MANY_SEP6(t){this.manySepFirstInternal(6,t)}MANY_SEP7(t){this.manySepFirstInternal(7,t)}MANY_SEP8(t){this.manySepFirstInternal(8,t)}MANY_SEP9(t){this.manySepFirstInternal(9,t)}AT_LEAST_ONE(t){this.atLeastOneInternal(0,t)}AT_LEAST_ONE1(t){return this.atLeastOneInternal(1,t)}AT_LEAST_ONE2(t){this.atLeastOneInternal(2,t)}AT_LEAST_ONE3(t){this.atLeastOneInternal(3,t)}AT_LEAST_ONE4(t){this.atLeastOneInternal(4,t)}AT_LEAST_ONE5(t){this.atLeastOneInternal(5,t)}AT_LEAST_ONE6(t){this.atLeastOneInternal(6,t)}AT_LEAST_ONE7(t){this.atLeastOneInternal(7,t)}AT_LEAST_ONE8(t){this.atLeastOneInternal(8,t)}AT_LEAST_ONE9(t){this.atLeastOneInternal(9,t)}AT_LEAST_ONE_SEP(t){this.atLeastOneSepFirstInternal(0,t)}AT_LEAST_ONE_SEP1(t){this.atLeastOneSepFirstInternal(1,t)}AT_LEAST_ONE_SEP2(t){this.atLeastOneSepFirstInternal(2,t)}AT_LEAST_ONE_SEP3(t){this.atLeastOneSepFirstInternal(3,t)}AT_LEAST_ONE_SEP4(t){this.atLeastOneSepFirstInternal(4,t)}AT_LEAST_ONE_SEP5(t){this.atLeastOneSepFirstInternal(5,t)}AT_LEAST_ONE_SEP6(t){this.atLeastOneSepFirstInternal(6,t)}AT_LEAST_ONE_SEP7(t){this.atLeastOneSepFirstInternal(7,t)}AT_LEAST_ONE_SEP8(t){this.atLeastOneSepFirstInternal(8,t)}AT_LEAST_ONE_SEP9(t){this.atLeastOneSepFirstInternal(9,t)}RULE(t,r,n=xr){if($(this.definedRulesNames,t)){let s={message:Dt.buildDuplicateRuleNameError({topLevelRule:t,grammarName:this.className}),type:st.DUPLICATE_RULE_NAME,ruleName:t};this.definitionErrors.push(s)}this.definedRulesNames.push(t);let i=this.defineRule(t,r,n);return this[t]=i,i}OVERRIDE_RULE(t,r,n=xr){let i=du(t,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(i);let o=this.defineRule(t,r,n);return this[t]=o,o}BACKTRACK(t,r){return function(){this.isBackTrackingStack.push(1);let n=this.saveRecogState();try{return t.apply(this,r),!0}catch(i){if(Re(i))return!1;throw i}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Kn(k(this.gastProductionsCache))}};var Ti=class{initRecognizerEngine(t,r){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=mr,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},A(r,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
|
|
90
90
|
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
|
|
91
|
-
For Further details.`);if(
|
|
91
|
+
For Further details.`);if(O(t)){if(_(t))throw Error(`A Token Vocabulary cannot be empty.
|
|
92
92
|
Note that the first argument for the parser constructor
|
|
93
93
|
is no longer a Token vector (since v4.0).`);if(typeof t[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
|
|
94
94
|
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
|
|
95
|
-
For Further details.`)}if(
|
|
96
|
-
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let
|
|
97
|
-
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(
|
|
98
|
-
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},
|
|
95
|
+
For Further details.`)}if(O(t))this.tokensMap=rt(t,(o,s)=>(o[s.name]=s,o),{});else if(A(t,"modes")&&ft(it(k(t.modes)),zl)){let o=it(k(t.modes)),s=ar(o);this.tokensMap=rt(s,(a,c)=>(a[c.name]=c,a),{})}else if(W(t))this.tokensMap=w(t);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=wt;let n=A(t,"modes")?it(k(t.modes)):k(t),i=ft(n,o=>_(o.categoryMatches));this.tokenMatcher=i?mr:oe,se(k(this.tokensMap))}defineRule(t,r,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${t}> may not be defined after the 'performSelfAnalysis' method has been called'
|
|
96
|
+
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let i=A(n,"resyncEnabled")?n.resyncEnabled:xr.resyncEnabled,o=A(n,"recoveryValueFunc")?n.recoveryValueFunc:xr.recoveryValueFunc,s=this.ruleShortNameIdx<<12;this.ruleShortNameIdx++,this.shortRuleNameToFull[s]=t,this.fullRuleNameToShort[t]=s;let a;return this.outputCst===!0?a=function(...u){try{this.ruleInvocationStateUpdate(s,t,this.subruleIdx),r.apply(this,u);let f=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(f),f}catch(f){return this.invokeRuleCatch(f,i,o)}finally{this.ruleFinallyStateUpdate()}}:a=function(...u){try{return this.ruleInvocationStateUpdate(s,t,this.subruleIdx),r.apply(this,u)}catch(f){return this.invokeRuleCatch(f,i,o)}finally{this.ruleFinallyStateUpdate()}},Object.assign(a,{ruleName:t,originalGrammarAction:r})}invokeRuleCatch(t,r,n){let i=this.RULE_STACK.length===1,o=r&&!this.isBackTracking()&&this.recoveryEnabled;if(Re(t)){let s=t;if(o){let a=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(a))if(s.resyncedTokens=this.reSyncTo(a),this.outputCst){let c=this.CST_STACK[this.CST_STACK.length-1];return c.recoveredNode=!0,c}else return n(t);else{if(this.outputCst){let c=this.CST_STACK[this.CST_STACK.length-1];c.recoveredNode=!0,s.partialCstResult=c}throw s}}else{if(i)return this.moveToTerminatedState(),n(t);throw s}}else throw t}optionInternal(t,r){let n=this.getKeyForAutomaticLookahead(512,r);return this.optionInternalLogic(t,r,n)}optionInternalLogic(t,r,n){let i=this.getLaFuncFromCache(n),o;if(typeof t!="function"){o=t.DEF;let s=t.GATE;if(s!==void 0){let a=i;i=()=>s.call(this)&&a.call(this)}}else o=t;if(i.call(this)===!0)return o.call(this)}atLeastOneInternal(t,r){let n=this.getKeyForAutomaticLookahead(1024,t);return this.atLeastOneInternalLogic(t,r,n)}atLeastOneInternalLogic(t,r,n){let i=this.getLaFuncFromCache(n),o;if(typeof r!="function"){o=r.DEF;let s=r.GATE;if(s!==void 0){let a=i;i=()=>s.call(this)&&a.call(this)}}else o=r;if(i.call(this)===!0){let s=this.doSingleRepetition(o);for(;i.call(this)===!0&&s===!0;)s=this.doSingleRepetition(o)}else throw this.raiseEarlyExitException(t,q.REPETITION_MANDATORY,r.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[t,r],i,1024,t,ri)}atLeastOneSepFirstInternal(t,r){let n=this.getKeyForAutomaticLookahead(1536,t);this.atLeastOneSepFirstInternalLogic(t,r,n)}atLeastOneSepFirstInternalLogic(t,r,n){let i=r.DEF,o=r.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){i.call(this);let a=()=>this.tokenMatcher(this.LA(1),o);for(;this.tokenMatcher(this.LA(1),o)===!0;)this.CONSUME(o),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,o,a,i,Gr],a,1536,t,Gr)}else throw this.raiseEarlyExitException(t,q.REPETITION_MANDATORY_WITH_SEPARATOR,r.ERR_MSG)}manyInternal(t,r){let n=this.getKeyForAutomaticLookahead(768,t);return this.manyInternalLogic(t,r,n)}manyInternalLogic(t,r,n){let i=this.getLaFuncFromCache(n),o;if(typeof r!="function"){o=r.DEF;let a=r.GATE;if(a!==void 0){let c=i;i=()=>a.call(this)&&c.call(this)}}else o=r;let s=!0;for(;i.call(this)===!0&&s===!0;)s=this.doSingleRepetition(o);this.attemptInRepetitionRecovery(this.manyInternal,[t,r],i,768,t,ei,s)}manySepFirstInternal(t,r){let n=this.getKeyForAutomaticLookahead(1280,t);this.manySepFirstInternalLogic(t,r,n)}manySepFirstInternalLogic(t,r,n){let i=r.DEF,o=r.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){i.call(this);let a=()=>this.tokenMatcher(this.LA(1),o);for(;this.tokenMatcher(this.LA(1),o)===!0;)this.CONSUME(o),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,o,a,i,Br],a,1280,t,Br)}}repetitionSepSecondInternal(t,r,n,i,o){for(;n();)this.CONSUME(r),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,r,n,i,o],n,1536,t,o)}doSingleRepetition(t){let r=this.getLexerPosition();return t.call(this),this.getLexerPosition()>r}orInternal(t,r){let n=this.getKeyForAutomaticLookahead(256,r),i=O(t)?t:t.DEF,s=this.getLaFuncFromCache(n).call(this,i);if(s!==void 0)return i[s].ALT.call(this);this.raiseNoAltException(r,t.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){let t=this.LA(1),r=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:t,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Hr(r,t))}}subruleInternal(t,r,n){let i;try{let o=n!==void 0?n.ARGS:void 0;return this.subruleIdx=r,i=t.apply(this,o),this.cstPostNonTerminal(i,n!==void 0&&n.LABEL!==void 0?n.LABEL:t.ruleName),i}catch(o){throw this.subruleInternalError(o,n,t.ruleName)}}subruleInternalError(t,r,n){throw Re(t)&&t.partialCstResult!==void 0&&(this.cstPostNonTerminal(t.partialCstResult,r!==void 0&&r.LABEL!==void 0?r.LABEL:n),delete t.partialCstResult),t}consumeInternal(t,r,n){let i;try{let o=this.LA(1);this.tokenMatcher(o,t)===!0?(this.consumeToken(),i=o):this.consumeInternalError(t,o,n)}catch(o){i=this.consumeInternalRecovery(t,r,o)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:t.name,i),i}consumeInternalError(t,r,n){let i,o=this.LA(0);throw n!==void 0&&n.ERR_MSG?i=n.ERR_MSG:i=this.errorMessageProvider.buildMismatchTokenMessage({expected:t,actual:r,previous:o,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new we(i,r,o))}consumeInternalRecovery(t,r,n){if(this.recoveryEnabled&&n.name==="MismatchedTokenException"&&!this.isBackTracking()){let i=this.getFollowsForInRuleRecovery(t,r);try{return this.tryInRuleRecovery(t,i)}catch(o){throw o.name===hs?n:o}}else throw n}saveRecogState(){let t=this.errors,r=w(this.RULE_STACK);return{errors:t,lexerState:this.exportLexerState(),RULE_STACK:r,CST_STACK:this.CST_STACK}}reloadRecogState(t){this.errors=t.errors,this.importLexerState(t.lexerState),this.RULE_STACK=t.RULE_STACK}ruleInvocationStateUpdate(t,r,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(t),this.cstInvocationStateUpdate(r)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let t=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[t]}shortRuleNameToFullName(t){return this.shortRuleNameToFull[t]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),wt)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}};var Si=class{initErrorHandler(t){this._errors=[],this.errorMessageProvider=A(t,"errorMessageProvider")?t.errorMessageProvider:Tt.errorMessageProvider}SAVE_ERROR(t){if(Re(t))return t.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:w(this.RULE_OCCURRENCE_STACK)},this._errors.push(t),t;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return w(this._errors)}set errors(t){this._errors=t}raiseEarlyExitException(t,r,n){let i=this.getCurrRuleFullName(),o=this.getGAstProductions()[i],a=jr(t,o,r,this.maxLookahead)[0],c=[];for(let u=1;u<=this.maxLookahead;u++)c.push(this.LA(u));let l=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:a,actual:c,previous:this.LA(0),customUserDescription:n,ruleName:i});throw this.SAVE_ERROR(new qr(l,this.LA(1),this.LA(0)))}raiseNoAltException(t,r){let n=this.getCurrRuleFullName(),i=this.getGAstProductions()[n],o=$r(t,i,this.maxLookahead),s=[];for(let l=1;l<=this.maxLookahead;l++)s.push(this.LA(l));let a=this.LA(0),c=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:o,actual:s,previous:a,customUserDescription:r,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new Kr(c,this.LA(1),a))}};var Ai=class{initContentAssist(){}computeContentAssist(t,r){let n=this.gastProductionsCache[t];if(pt(n))throw Error(`Rule ->${t}<- does not exist in this grammar.`);return ii([n],r,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(t){let r=ct(t.ruleStack),i=this.getGAstProductions()[r];return new ti(i,t).startWalking()}};var Ii={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Ii);var vu=!0,Mu=Math.pow(2,8)-1,ku=m({name:"RECORDING_PHASE_TOKEN",pattern:H.NA});se([ku]);var Pu=Ue(ku,`This IToken indicates the Parser is in Recording Phase
|
|
97
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Pu);var bT={name:`This CSTNode indicates the Parser is in Recording Phase
|
|
98
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},Ni=class{initGastRecorder(t){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let t=0;t<10;t++){let r=t>0?t:"";this[`CONSUME${r}`]=function(n,i){return this.consumeInternalRecord(n,t,i)},this[`SUBRULE${r}`]=function(n,i){return this.subruleInternalRecord(n,t,i)},this[`OPTION${r}`]=function(n){return this.optionInternalRecord(n,t)},this[`OR${r}`]=function(n){return this.orInternalRecord(n,t)},this[`MANY${r}`]=function(n){this.manyInternalRecord(t,n)},this[`MANY_SEP${r}`]=function(n){this.manySepFirstInternalRecord(t,n)},this[`AT_LEAST_ONE${r}`]=function(n){this.atLeastOneInternalRecord(t,n)},this[`AT_LEAST_ONE_SEP${r}`]=function(n){this.atLeastOneSepFirstInternalRecord(t,n)}}this.consume=function(t,r,n){return this.consumeInternalRecord(r,t,n)},this.subrule=function(t,r,n){return this.subruleInternalRecord(r,t,n)},this.option=function(t,r){return this.optionInternalRecord(r,t)},this.or=function(t,r){return this.orInternalRecord(r,t)},this.many=function(t,r){this.manyInternalRecord(t,r)},this.atLeastOne=function(t,r){this.atLeastOneInternalRecord(t,r)},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",()=>{let t=this;for(let r=0;r<10;r++){let n=r>0?r:"";delete t[`CONSUME${n}`],delete t[`SUBRULE${n}`],delete t[`OPTION${n}`],delete t[`OR${n}`],delete t[`MANY${n}`],delete t[`MANY_SEP${n}`],delete t[`AT_LEAST_ONE${n}`],delete t[`AT_LEAST_ONE_SEP${n}`]}delete t.consume,delete t.subrule,delete t.option,delete t.or,delete t.many,delete t.atLeastOne,delete t.ACTION,delete t.BACKTRACK,delete t.LA})}ACTION_RECORD(t){}BACKTRACK_RECORD(t,r){return()=>!0}LA_RECORD(t){return Er}topLevelRuleRecord(t,r){try{let n=new Et({definition:[],name:t});return n.name=t,this.recordingProdStack.push(n),r.call(this),this.recordingProdStack.pop(),n}catch(n){if(n.KNOWN_RECORDER_ERROR!==!0)try{n.message=n.message+`
|
|
99
99
|
This error was thrown during the "grammar recording phase" For more info see:
|
|
100
|
-
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw n}throw n}}optionInternalRecord(t,r){return Yr.call(this,G,t,r)}atLeastOneInternalRecord(t,r){Yr.call(this,Q,r,t)}atLeastOneSepFirstInternalRecord(t,r){Yr.call(this,Z,r,t,
|
|
101
|
-
inside top level rule: <${this.recordingProdStack[0].name}>`);throw a.KNOWN_RECORDER_ERROR=!0,a}let
|
|
102
|
-
inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let
|
|
103
|
-
Idx value must be a none negative value smaller than ${
|
|
100
|
+
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw n}throw n}}optionInternalRecord(t,r){return Yr.call(this,G,t,r)}atLeastOneInternalRecord(t,r){Yr.call(this,Q,r,t)}atLeastOneSepFirstInternalRecord(t,r){Yr.call(this,Z,r,t,vu)}manyInternalRecord(t,r){Yr.call(this,b,r,t)}manySepFirstInternalRecord(t,r){Yr.call(this,z,r,t,vu)}orInternalRecord(t,r){return kT.call(this,t,r)}subruleInternalRecord(t,r,n){if(Oi(r),!t||A(t,"ruleName")===!1){let a=new Error(`<SUBRULE${bu(r)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(t)}>
|
|
101
|
+
inside top level rule: <${this.recordingProdStack[0].name}>`);throw a.KNOWN_RECORDER_ERROR=!0,a}let i=Vt(this.recordingProdStack),o=t.ruleName,s=new D({idx:r,nonTerminalName:o,label:n?.LABEL,referencedRule:void 0});return i.definition.push(s),this.outputCst?bT:Ii}consumeInternalRecord(t,r,n){if(Oi(r),!Jo(t)){let s=new Error(`<CONSUME${bu(r)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(t)}>
|
|
102
|
+
inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let i=Vt(this.recordingProdStack),o=new v({idx:r,terminalType:t,label:n?.LABEL});return i.definition.push(o),Pu}};function Yr(e,t,r,n=!1){Oi(r);let i=Vt(this.recordingProdStack),o=dt(t)?t:t.DEF,s=new e({definition:[],idx:r});return n&&(s.separator=t.SEP),A(t,"MAX_LOOKAHEAD")&&(s.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(s),o.call(this),i.definition.push(s),this.recordingProdStack.pop(),Ii}function kT(e,t){Oi(t);let r=Vt(this.recordingProdStack),n=O(e)===!1,i=n===!1?e:e.DEF,o=new V({definition:[],idx:t,ignoreAmbiguities:n&&e.IGNORE_AMBIGUITIES===!0});A(e,"MAX_LOOKAHEAD")&&(o.maxLookahead=e.MAX_LOOKAHEAD);let s=_r(i,a=>dt(a.GATE));return o.hasPredicates=s,r.definition.push(o),S(i,a=>{let c=new F({definition:[]});o.definition.push(c),A(a,"IGNORE_AMBIGUITIES")?c.ignoreAmbiguities=a.IGNORE_AMBIGUITIES:A(a,"GATE")&&(c.ignoreAmbiguities=!0),this.recordingProdStack.push(c),a.ALT.call(this),this.recordingProdStack.pop()}),Ii}function bu(e){return e===0?"":`${e}`}function Oi(e){if(e<0||e>Mu){let t=new Error(`Invalid DSL Method idx value: <${e}>
|
|
103
|
+
Idx value must be a none negative value smaller than ${Mu+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var Ci=class{initPerformanceTracer(t){if(A(t,"traceInitPerf")){let r=t.traceInitPerf,n=typeof r=="number";this.traceInitMaxIdent=n?r:1/0,this.traceInitPerf=n?r>0:r}else this.traceInitMaxIdent=0,this.traceInitPerf=Tt.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(t,r){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${t}>`);let{time:i,value:o}=Mr(r),s=i>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&s(`${n}<-- <${t}> time: ${i}ms`),this.traceInitIndent--,o}else return r()}};function Uu(e,t){t.forEach(r=>{let n=r.prototype;Object.getOwnPropertyNames(n).forEach(i=>{if(i==="constructor")return;let o=Object.getOwnPropertyDescriptor(n,i);o&&(o.get||o.set)?Object.defineProperty(e.prototype,i,o):e.prototype[i]=r.prototype[i]})})}var Er=Ue(wt,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Er);var Tt=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:Jn,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),xr=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0}),st;(function(e){e[e.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",e[e.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",e[e.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",e[e.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",e[e.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",e[e.LEFT_RECURSION=5]="LEFT_RECURSION",e[e.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",e[e.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",e[e.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",e[e.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",e[e.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",e[e.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(st||(st={}));var Xr=class e{static performSelfAnalysis(t){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let t;this.selfAnalysisDone=!0;let r=this.className;this.TRACE_INIT("toFastProps",()=>{br(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),S(this.definedRulesNames,i=>{let s=this[i].originalGrammarAction,a;this.TRACE_INIT(`${i} Rule`,()=>{a=this.topLevelRuleRecord(i,s)}),this.gastProductionsCache[i]=a})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=Tu({rules:k(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(_(n)&&this.skipValidations===!1){let i=Su({rules:k(this.gastProductionsCache),tokenTypes:k(this.tokensMap),errMsgProvider:Dt,grammarName:r}),o=hu({lookaheadStrategy:this.lookaheadStrategy,rules:k(this.gastProductionsCache),tokenTypes:k(this.tokensMap),grammarName:r});this.definitionErrors=this.definitionErrors.concat(i,o)}}),_(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{let i=yl(k(this.gastProductionsCache));this.resyncFollows=i}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var i,o;(o=(i=this.lookaheadStrategy).initialize)===null||o===void 0||o.call(i,{rules:k(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(k(this.gastProductionsCache))})),!e.DEFER_DEFINITION_ERRORS_HANDLING&&!_(this.definitionErrors))throw t=E(this.definitionErrors,i=>i.message),new Error(`Parser Definition Errors detected:
|
|
104
104
|
${t.join(`
|
|
105
105
|
-------------------------------
|
|
106
106
|
`)}`)})}constructor(t,r){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(r),n.initLexerAdapter(),n.initLooksAhead(r),n.initRecognizerEngine(t,r),n.initRecoverable(r),n.initTreeBuilder(r),n.initContentAssist(),n.initGastRecorder(r),n.initPerformanceTracer(r),A(r,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
|
|
107
107
|
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
|
|
108
108
|
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
|
|
109
|
-
For further details.`);this.skipValidations=A(r,"skipValidations")?r.skipValidations:Tt.skipValidations}};Xr.DEFER_DEFINITION_ERRORS_HANDLING=!1;wu(Xr,[lo,ho,Eo,xo,So,To,Ao,No,Io,Ro]);var Qr=class extends Xr{constructor(t,r=Tt){let n=w(r);n.outputCst=!0,super(t,n)}};var kT=m({name:"WhiteSpace",pattern:/\s+/,group:H.SKIPPED}),PT=m({name:"LineComment",pattern:/\/\/[^\n]*/,group:H.SKIPPED}),UT=m({name:"BlockComment",pattern:/\/\*[\s\S]*?\*\//,group:H.SKIPPED}),p=m({name:"Identifier",pattern:/[a-zA-Z_][a-zA-Z0-9_]*/}),Zr=m({name:"TemplateIdentifier",pattern:/\{[a-zA-Z_][a-zA-Z0-9_]*\}/}),yo=m({name:"Concept",pattern:/concept/,longer_alt:p}),Lo=m({name:"Schema",pattern:/schema/,longer_alt:p}),_o=m({name:"Mixin",pattern:/mixin/,longer_alt:p}),vo=m({name:"Enum",pattern:/enum/,longer_alt:p}),Mo=m({name:"Extension",pattern:/extension/,longer_alt:p}),bo=m({name:"Function",pattern:/function/,longer_alt:p}),ko=m({name:"Func",pattern:/func/,longer_alt:p}),Po=m({name:"Trigger",pattern:/trigger/,longer_alt:p}),Jr=m({name:"Index",pattern:/index/,longer_alt:p}),tn=m({name:"Check",pattern:/check/,longer_alt:p}),Uo=m({name:"Before",pattern:/before/,longer_alt:p}),wo=m({name:"After",pattern:/after/,longer_alt:p}),Do=m({name:"Ondelete",pattern:/ondelete/,longer_alt:p}),Fo=m({name:"On",pattern:/on/,longer_alt:p}),Bo=m({name:"Each",pattern:/each/,longer_alt:p}),Go=m({name:"Row",pattern:/row/,longer_alt:p}),$o=m({name:"Statement",pattern:/statement/,longer_alt:p}),jo=m({name:"Execute",pattern:/execute/,longer_alt:p}),Tr=m({name:"Unique",pattern:/unique/,longer_alt:p}),en=m({name:"Gin",pattern:/gin/,longer_alt:p}),rn=m({name:"Gist",pattern:/gist/,longer_alt:p}),nn=m({name:"Btree",pattern:/btree/,longer_alt:p}),on=m({name:"Hash",pattern:/hash/,longer_alt:p}),Wo=m({name:"Pkey",pattern:/pkey/,longer_alt:p}),Ko=m({name:"Nonull",pattern:/nonull/,longer_alt:p}),Ho=m({name:"Default",pattern:/default/,longer_alt:p}),qo=m({name:"Ref",pattern:/ref/,longer_alt:p}),zo=m({name:"Cascade",pattern:/cascade/,longer_alt:p}),Vo=m({name:"Restrict",pattern:/restrict/,longer_alt:p}),Yo=m({name:"SetNull",pattern:/setnull/,longer_alt:p}),Xo=m({name:"SetDefault",pattern:/setdefault/,longer_alt:p}),Qo=m({name:"NoAction",pattern:/noaction/,longer_alt:p}),Zo=m({name:"Update",pattern:/update/,longer_alt:p}),Jo=m({name:"Insert",pattern:/insert/,longer_alt:p}),ti=m({name:"Delete",pattern:/delete/,longer_alt:p}),ei=m({name:"Return",pattern:/return/,longer_alt:p}),sn=m({name:"New",pattern:/NEW/,longer_alt:p}),an=m({name:"Old",pattern:/OLD/,longer_alt:p}),ri=m({name:"Serial",pattern:/serial/i,longer_alt:p}),ni=m({name:"BigSerial",pattern:/bigserial/i,longer_alt:p}),oi=m({name:"Integer",pattern:/integer/i,longer_alt:p}),ii=m({name:"Bigint",pattern:/bigint/i,longer_alt:p}),si=m({name:"SmallInt",pattern:/smallint/i,longer_alt:p}),ai=m({name:"Text",pattern:/text/i,longer_alt:p}),ci=m({name:"Varchar",pattern:/varchar/i,longer_alt:p}),li=m({name:"Char",pattern:/char/i,longer_alt:p}),ui=m({name:"Boolean",pattern:/boolean/i,longer_alt:p}),fi=m({name:"Timestamptz",pattern:/timestamptz/i,longer_alt:p}),hi=m({name:"Timestamp",pattern:/timestamp/i,longer_alt:p}),pi=m({name:"Date",pattern:/date/i,longer_alt:p}),mi=m({name:"Time",pattern:/time/i,longer_alt:p}),di=m({name:"Jsonb",pattern:/jsonb/i,longer_alt:p}),gi=m({name:"Json",pattern:/json/i,longer_alt:p}),Ei=m({name:"Uuid",pattern:/uuid/i,longer_alt:p}),xi=m({name:"Inet",pattern:/inet/i,longer_alt:p}),Ti=m({name:"Citext",pattern:/citext/i,longer_alt:p}),Si=m({name:"Decimal",pattern:/decimal/i,longer_alt:p}),Ai=m({name:"Numeric",pattern:/numeric/i,longer_alt:p}),Ni=m({name:"Real",pattern:/real/i,longer_alt:p}),Ii=m({name:"DoublePrecision",pattern:/double\s+precision/i,longer_alt:p}),Oi=m({name:"Bytea",pattern:/bytea/i,longer_alt:p}),Ci=m({name:"StringLiteral",pattern:/'(?:[^'\\]|\\.)*'/}),cn=m({name:"NumberLiteral",pattern:/-?\d+(?:\.\d+)?/}),Ri=m({name:"BooleanLiteral",pattern:/true|false/,longer_alt:p}),yi=m({name:"NullLiteral",pattern:/null/i,longer_alt:p}),As=m({name:"Arrow",pattern:/->/}),Li=m({name:"DoubleColon",pattern:/::/}),Sr=m({name:"LBrace",pattern:/\{/}),Ar=m({name:"RBrace",pattern:/\}/}),Ot=m({name:"LParen",pattern:/\(/}),Ct=m({name:"RParen",pattern:/\)/}),_i=m({name:"LBracket",pattern:/\[/}),vi=m({name:"RBracket",pattern:/\]/}),ln=m({name:"LAngle",pattern:/</}),un=m({name:"RAngle",pattern:/>/}),kt=m({name:"Semicolon",pattern:/;/}),Qt=m({name:"Comma",pattern:/,/}),fn=m({name:"Dot",pattern:/\./}),hn=m({name:"Equals",pattern:/=/}),Ns=[kT,PT,UT,As,Li,yo,Lo,_o,vo,Mo,bo,ko,Po,Jr,tn,Uo,wo,Do,Fo,Bo,Go,$o,jo,Tr,en,rn,nn,on,Wo,Ko,Ho,qo,Xo,Yo,zo,Vo,Qo,Zo,Jo,ti,ei,sn,an,Ii,fi,hi,ni,ri,si,ii,oi,ci,li,ai,ui,pi,mi,di,gi,Ei,xi,Ti,Si,Ai,Ni,Oi,Ci,cn,Ri,yi,Zr,p,Sr,Ar,Ot,Ct,_i,vi,ln,un,kt,Qt,fn,hn],wT=new H(Ns,{ensureOptimizations:!0});function Du(e){return wT.tokenize(e)}var Cs=class extends Qr{constructor(){super(Ns,{recoveryEnabled:!0,maxLookahead:3}),this.performSelfAnalysis()}anyIdentifier=this.RULE("anyIdentifier",()=>{this.OR([{ALT:()=>this.CONSUME(p)},{ALT:()=>this.CONSUME(yo)},{ALT:()=>this.CONSUME(Lo)},{ALT:()=>this.CONSUME(_o)},{ALT:()=>this.CONSUME(vo)},{ALT:()=>this.CONSUME(Mo)},{ALT:()=>this.CONSUME(ko)},{ALT:()=>this.CONSUME(Po)},{ALT:()=>this.CONSUME(Jr)},{ALT:()=>this.CONSUME(tn)},{ALT:()=>this.CONSUME(Uo)},{ALT:()=>this.CONSUME(wo)},{ALT:()=>this.CONSUME(Fo)},{ALT:()=>this.CONSUME(Bo)},{ALT:()=>this.CONSUME(Go)},{ALT:()=>this.CONSUME($o)},{ALT:()=>this.CONSUME(jo)},{ALT:()=>this.CONSUME(bo)},{ALT:()=>this.CONSUME(ei)},{ALT:()=>this.CONSUME(sn)},{ALT:()=>this.CONSUME(an)},{ALT:()=>this.CONSUME(Zo)},{ALT:()=>this.CONSUME(Jo)},{ALT:()=>this.CONSUME(ti)},{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.CONSUME(Wo)},{ALT:()=>this.CONSUME(Ko)},{ALT:()=>this.CONSUME(Ho)},{ALT:()=>this.CONSUME(qo)},{ALT:()=>this.CONSUME(Do)},{ALT:()=>this.CONSUME(zo)},{ALT:()=>this.CONSUME(Vo)},{ALT:()=>this.CONSUME(Yo)},{ALT:()=>this.CONSUME(Xo)},{ALT:()=>this.CONSUME(Qo)},{ALT:()=>this.CONSUME(en)},{ALT:()=>this.CONSUME(rn)},{ALT:()=>this.CONSUME(nn)},{ALT:()=>this.CONSUME(on)},{ALT:()=>this.CONSUME(ri)},{ALT:()=>this.CONSUME(ni)},{ALT:()=>this.CONSUME(oi)},{ALT:()=>this.CONSUME(ii)},{ALT:()=>this.CONSUME(si)},{ALT:()=>this.CONSUME(ai)},{ALT:()=>this.CONSUME(ci)},{ALT:()=>this.CONSUME(li)},{ALT:()=>this.CONSUME(ui)},{ALT:()=>this.CONSUME(fi)},{ALT:()=>this.CONSUME(hi)},{ALT:()=>this.CONSUME(pi)},{ALT:()=>this.CONSUME(mi)},{ALT:()=>this.CONSUME(di)},{ALT:()=>this.CONSUME(gi)},{ALT:()=>this.CONSUME(Ei)},{ALT:()=>this.CONSUME(xi)},{ALT:()=>this.CONSUME(Ti)},{ALT:()=>this.CONSUME(Si)},{ALT:()=>this.CONSUME(Ai)},{ALT:()=>this.CONSUME(Ni)},{ALT:()=>this.CONSUME(Ii)},{ALT:()=>this.CONSUME(Oi)}])});program=this.RULE("program",()=>{this.MANY(()=>{this.SUBRULE(this.topLevelDeclaration)})});topLevelDeclaration=this.RULE("topLevelDeclaration",()=>{this.OR([{ALT:()=>this.SUBRULE(this.extensionDecl)},{ALT:()=>this.SUBRULE(this.functionDecl)},{ALT:()=>this.SUBRULE(this.conceptDecl)},{ALT:()=>this.SUBRULE(this.enumDecl)},{ALT:()=>this.SUBRULE(this.schemaDecl)},{ALT:()=>this.SUBRULE(this.instantiation)},{ALT:()=>this.SUBRULE(this.perInstanceIndex)}])});extensionDecl=this.RULE("extensionDecl",()=>{this.CONSUME(Mo),this.SUBRULE(this.anyIdentifier),this.CONSUME(kt)});functionDecl=this.RULE("functionDecl",()=>{this.CONSUME(ko),this.SUBRULE(this.anyIdentifier),this.CONSUME(Ot),this.CONSUME(Ct),this.CONSUME(As),this.SUBRULE2(this.anyIdentifier),this.SUBRULE(this.functionBody)});functionBody=this.RULE("functionBody",()=>{this.CONSUME(Sr),this.MANY(()=>{this.SUBRULE(this.functionStatement)}),this.CONSUME(Ar)});functionStatement=this.RULE("functionStatement",()=>{this.OR([{ALT:()=>this.SUBRULE(this.returnStatement)},{ALT:()=>this.SUBRULE(this.assignmentStatement)}])});returnStatement=this.RULE("returnStatement",()=>{this.CONSUME(ei),this.OR([{ALT:()=>this.CONSUME(sn)},{ALT:()=>this.CONSUME(an)},{ALT:()=>this.CONSUME(p)}]),this.CONSUME(kt)});assignmentStatement=this.RULE("assignmentStatement",()=>{this.OR([{ALT:()=>this.CONSUME(sn)},{ALT:()=>this.CONSUME(an)},{ALT:()=>this.CONSUME(p)}]),this.CONSUME(fn),this.SUBRULE(this.anyIdentifier),this.CONSUME(hn),this.SUBRULE(this.functionCallExpr),this.CONSUME(kt)});functionCallExpr=this.RULE("functionCallExpr",()=>{this.CONSUME(p),this.CONSUME(Ot),this.CONSUME(Ct)});conceptDecl=this.RULE("conceptDecl",()=>{this.CONSUME(yo),this.CONSUME(p),this.OPTION(()=>{this.SUBRULE(this.typeParamList)}),this.CONSUME(Sr),this.MANY(()=>{this.OR([{ALT:()=>this.SUBRULE(this.enumDecl)},{ALT:()=>this.SUBRULE(this.schemaDecl)}])}),this.CONSUME(Ar)});typeParamList=this.RULE("typeParamList",()=>{this.CONSUME(ln),this.CONSUME(p),this.MANY(()=>{this.CONSUME(Qt),this.CONSUME2(p)}),this.CONSUME(un)});enumDecl=this.RULE("enumDecl",()=>{this.CONSUME(vo),this.SUBRULE(this.anyIdentifier),this.CONSUME(Sr),this.MANY(()=>{this.SUBRULE2(this.anyIdentifier),this.CONSUME(kt)}),this.CONSUME(Ar)});schemaDecl=this.RULE("schemaDecl",()=>{this.CONSUME(Lo),this.CONSUME(p),this.OPTION(()=>{this.SUBRULE(this.mixinList)}),this.CONSUME(Sr),this.MANY(()=>{this.SUBRULE(this.schemaBodyItem)}),this.CONSUME(Ar)});mixinList=this.RULE("mixinList",()=>{this.CONSUME(_o),this.CONSUME(p),this.MANY(()=>{this.CONSUME(Qt),this.CONSUME2(p)})});schemaBodyItem=this.RULE("schemaBodyItem",()=>{this.OR([{ALT:()=>this.SUBRULE(this.indexDef)},{ALT:()=>this.SUBRULE(this.checkDef)},{ALT:()=>this.SUBRULE(this.triggerDef)},{ALT:()=>this.SUBRULE(this.columnDef)}])});columnDef=this.RULE("columnDef",()=>{this.SUBRULE(this.columnName),this.SUBRULE(this.dataType),this.MANY(()=>{this.SUBRULE(this.columnConstraint)}),this.CONSUME(kt)});columnName=this.RULE("columnName",()=>{this.OR([{ALT:()=>{this.CONSUME(Zr),this.OPTION(()=>{this.CONSUME(p)})}},{ALT:()=>this.CONSUME2(p)}])});dataType=this.RULE("dataType",()=>{this.OR([{ALT:()=>this.CONSUME(ri)},{ALT:()=>this.CONSUME(ni)},{ALT:()=>this.CONSUME(oi)},{ALT:()=>this.CONSUME(ii)},{ALT:()=>this.CONSUME(si)},{ALT:()=>this.CONSUME(ai)},{ALT:()=>this.CONSUME(ci)},{ALT:()=>this.CONSUME(li)},{ALT:()=>this.CONSUME(ui)},{ALT:()=>this.CONSUME(fi)},{ALT:()=>this.CONSUME(hi)},{ALT:()=>this.CONSUME(pi)},{ALT:()=>this.CONSUME(mi)},{ALT:()=>this.CONSUME(di)},{ALT:()=>this.CONSUME(gi)},{ALT:()=>this.CONSUME(Ei)},{ALT:()=>this.CONSUME(xi)},{ALT:()=>this.CONSUME(Ti)},{ALT:()=>this.CONSUME(Si)},{ALT:()=>this.CONSUME(Ai)},{ALT:()=>this.CONSUME(Ni)},{ALT:()=>this.CONSUME(Ii)},{ALT:()=>this.CONSUME(Oi)},{ALT:()=>this.CONSUME(p)}]),this.OPTION(()=>{this.CONSUME(Ot),this.CONSUME(cn),this.CONSUME(Ct)})});columnConstraint=this.RULE("columnConstraint",()=>{this.OR([{ALT:()=>this.CONSUME(Wo)},{ALT:()=>this.CONSUME(Ko)},{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.SUBRULE(this.defaultConstraint)},{ALT:()=>this.SUBRULE(this.refConstraint)},{ALT:()=>this.SUBRULE(this.checkConstraint)},{ALT:()=>this.SUBRULE(this.onDeleteConstraint)}])});defaultConstraint=this.RULE("defaultConstraint",()=>{this.CONSUME(Ho),this.CONSUME(Ot),this.SUBRULE(this.defaultValue),this.CONSUME(Ct)});defaultValue=this.RULE("defaultValue",()=>{this.OR([{ALT:()=>this.CONSUME(Ci)},{ALT:()=>this.CONSUME(cn)},{ALT:()=>this.CONSUME(Ri)},{ALT:()=>this.CONSUME(yi)},{ALT:()=>this.SUBRULE(this.functionCallExpr)},{ALT:()=>{this.SUBRULE(this.anyIdentifier),this.CONSUME(Li),this.SUBRULE2(this.anyIdentifier)}},{ALT:()=>this.SUBRULE3(this.anyIdentifier)}])});refConstraint=this.RULE("refConstraint",()=>{this.CONSUME(qo),this.CONSUME(Ot),this.CONSUME(p),this.CONSUME(fn),this.CONSUME2(p),this.CONSUME(Ct)});checkConstraint=this.RULE("checkConstraint",()=>{this.CONSUME(tn),this.CONSUME(Ot),this.SUBRULE(this.checkExpression),this.CONSUME(Ct)});checkExpression=this.RULE("checkExpression",()=>{this.MANY(()=>{this.OR([{ALT:()=>{this.CONSUME(Ot),this.SUBRULE(this.checkExpression),this.CONSUME(Ct)}},{ALT:()=>this.CONSUME(p)},{ALT:()=>this.CONSUME(Zr)},{ALT:()=>this.CONSUME(cn)},{ALT:()=>this.CONSUME(Ci)},{ALT:()=>this.CONSUME(Ri)},{ALT:()=>this.CONSUME(yi)},{ALT:()=>this.CONSUME(Li)},{ALT:()=>this.CONSUME(hn)},{ALT:()=>this.CONSUME(Qt)},{ALT:()=>this.CONSUME(fn)},{ALT:()=>this.CONSUME(ln)},{ALT:()=>this.CONSUME(un)}])})});onDeleteConstraint=this.RULE("onDeleteConstraint",()=>{this.CONSUME(Do),this.CONSUME(Ot),this.OR([{ALT:()=>this.CONSUME(zo)},{ALT:()=>this.CONSUME(Vo)},{ALT:()=>this.CONSUME(Yo)},{ALT:()=>this.CONSUME(Xo)},{ALT:()=>this.CONSUME(Qo)}]),this.CONSUME(Ct)});indexDef=this.RULE("indexDef",()=>{this.CONSUME(Jr),this.CONSUME(Ot),this.SUBRULE(this.indexColumnList),this.CONSUME(Ct),this.MANY(()=>{this.OR([{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.CONSUME(en)},{ALT:()=>this.CONSUME(rn)},{ALT:()=>this.CONSUME(nn)},{ALT:()=>this.CONSUME(on)}])}),this.CONSUME(kt)});indexColumnList=this.RULE("indexColumnList",()=>{this.SUBRULE(this.indexColumn),this.MANY(()=>{this.CONSUME(Qt),this.SUBRULE2(this.indexColumn)})});indexColumn=this.RULE("indexColumn",()=>{this.OR([{ALT:()=>this.CONSUME(Zr)},{ALT:()=>this.CONSUME(p)}]),this.OPTION(()=>{this.CONSUME2(p)})});checkDef=this.RULE("checkDef",()=>{this.CONSUME(tn),this.CONSUME(Ot),this.SUBRULE(this.checkExpression),this.CONSUME(Ct),this.CONSUME(kt)});triggerDef=this.RULE("triggerDef",()=>{this.CONSUME(Po),this.CONSUME(p),this.OR([{ALT:()=>this.CONSUME(Uo)},{ALT:()=>this.CONSUME(wo)}]),this.OR2([{ALT:()=>this.CONSUME(Zo)},{ALT:()=>this.CONSUME(Jo)},{ALT:()=>this.CONSUME(ti)}]),this.CONSUME(Fo),this.CONSUME(Bo),this.OR3([{ALT:()=>this.CONSUME(Go)},{ALT:()=>this.CONSUME($o)}]),this.CONSUME(jo),this.CONSUME(bo),this.CONSUME2(p),this.CONSUME(Ot),this.CONSUME(Ct),this.CONSUME(kt)});instantiation=this.RULE("instantiation",()=>{this.SUBRULE(this.instantiationTargetList),this.CONSUME(hn),this.SUBRULE(this.conceptReference),this.CONSUME(kt)});instantiationTargetList=this.RULE("instantiationTargetList",()=>{this.SUBRULE(this.instantiationTarget),this.MANY(()=>{this.CONSUME(Qt),this.SUBRULE2(this.instantiationTarget)})});instantiationTarget=this.RULE("instantiationTarget",()=>{this.CONSUME(p),this.OPTION(()=>{this.CONSUME(_i),this.CONSUME2(p),this.CONSUME(vi)})});conceptReference=this.RULE("conceptReference",()=>{this.CONSUME(p),this.OPTION(()=>{this.CONSUME(ln),this.SUBRULE(this.typeArgList),this.CONSUME(un)})});typeArgList=this.RULE("typeArgList",()=>{this.SUBRULE(this.typeArg),this.MANY(()=>{this.CONSUME(Qt),this.SUBRULE2(this.typeArg)})});typeArg=this.RULE("typeArg",()=>{this.CONSUME(p),this.OPTION(()=>{this.CONSUME(_i),this.CONSUME2(p),this.CONSUME(vi)})});perInstanceIndex=this.RULE("perInstanceIndex",()=>{this.CONSUME(Jr),this.CONSUME(Ot),this.CONSUME(p),this.CONSUME(Qt),this.CONSUME2(p),this.MANY(()=>{this.CONSUME2(Qt),this.CONSUME3(p)}),this.CONSUME(Ct),this.MANY2(()=>{this.OR([{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.CONSUME(en)},{ALT:()=>this.CONSUME(rn)},{ALT:()=>this.CONSUME(nn)},{ALT:()=>this.CONSUME(on)}])}),this.CONSUME(kt)})},Is=new Cs;function nt(e,t){let r=e.children[t];if(r&&r.length>0){let n=r[0];if(n&&"image"in n)return n.image}return""}function De(e,t){let r=e.children[t];return r?r.map(n=>"image"in n?n.image:"").filter(n=>n!==""):[]}function M(e,t){let n=e.children[t]?.[0];if(n&&"children"in n)return n}function Ft(e,t){let r=e.children[t];return r?r.filter(n=>"children"in n):[]}function Fu(e){let r=Ft(e,"anyIdentifier")[0];if(r)for(let n of Object.keys(r.children)){let i=r.children[n]?.[0];if(i&&"image"in i)return i.image}return""}function Os(e){let t=Ft(e,"anyIdentifier"),r=[];for(let n of t)for(let o of Object.keys(n.children)){let s=n.children[o]?.[0];if(s&&"image"in s){r.push(s.image);break}}return r}var Rs=class{visit(t){let r=[],n=Ft(t,"topLevelDeclaration");for(let o of n){let i=this.visitTopLevelDeclaration(o);i&&r.push(i)}return{type:"Program",declarations:r}}visitTopLevelDeclaration(t){let r=M(t,"extensionDecl");if(r)return this.visitExtensionDecl(r);let n=M(t,"functionDecl");if(n)return this.visitFunctionDecl(n);let o=M(t,"conceptDecl");if(o)return this.visitConceptDecl(o);let i=M(t,"enumDecl");if(i)return this.visitEnumDecl(i);let s=M(t,"schemaDecl");if(s)return this.visitSchemaDecl(s);let a=M(t,"instantiation");if(a)return this.visitInstantiation(a);let c=M(t,"perInstanceIndex");return c?this.visitPerInstanceIndex(c):null}visitExtensionDecl(t){return{type:"ExtensionDecl",name:Fu(t)}}visitFunctionDecl(t){let r=Os(t),n=r[0]??"",o=r[1]??"",i=M(t,"functionBody"),s="";if(i){let a=Ft(i,"functionStatement"),c=[];for(let l of a){let u=M(l,"returnStatement");if(u){let h=nt(u,"Identifier");h||(h=nt(u,"New")),h||(h=nt(u,"Old")),c.push(`RETURN ${h};`)}let f=M(l,"assignmentStatement");if(f){let h=nt(f,"Identifier");h||(h=nt(f,"New")),h||(h=nt(f,"Old"));let x=Fu(f),T=M(f,"functionCallExpr"),O=T?nt(T,"Identifier"):"";c.push(`${h}.${x} := ${O}();`)}}s=c.join(`
|
|
110
|
-
`)}return{type:"FunctionDecl",name:n,returnType:
|
|
109
|
+
For further details.`);this.skipValidations=A(r,"skipValidations")?r.skipValidations:Tt.skipValidations}};Xr.DEFER_DEFINITION_ERRORS_HANDLING=!1;Uu(Xr,[li,hi,gi,Ei,Ti,xi,Si,Ai,Ni,Ci]);var Qr=class extends Xr{constructor(t,r=Tt){let n=w(r);n.outputCst=!0,super(t,n)}};var UT=m({name:"WhiteSpace",pattern:/\s+/,group:H.SKIPPED}),wT=m({name:"LineComment",pattern:/\/\/[^\n]*/,group:H.SKIPPED}),DT=m({name:"BlockComment",pattern:/\/\*[\s\S]*?\*\//,group:H.SKIPPED}),p=m({name:"Identifier",pattern:/[a-zA-Z_][a-zA-Z0-9_]*/}),Zr=m({name:"TemplateIdentifier",pattern:/\{[a-zA-Z_][a-zA-Z0-9_]*\}/}),Ri=m({name:"Concept",pattern:/concept/,longer_alt:p}),yi=m({name:"Schema",pattern:/schema/,longer_alt:p}),Li=m({name:"Mixin",pattern:/mixin/,longer_alt:p}),_i=m({name:"Enum",pattern:/enum/,longer_alt:p}),vi=m({name:"Extension",pattern:/extension/,longer_alt:p}),Mi=m({name:"Function",pattern:/function/,longer_alt:p}),bi=m({name:"Func",pattern:/func/,longer_alt:p}),ki=m({name:"Trigger",pattern:/trigger/,longer_alt:p}),Jr=m({name:"Index",pattern:/index/,longer_alt:p}),tn=m({name:"Check",pattern:/check/,longer_alt:p}),Pi=m({name:"Before",pattern:/before/,longer_alt:p}),Ui=m({name:"After",pattern:/after/,longer_alt:p}),wi=m({name:"Ondelete",pattern:/ondelete/,longer_alt:p}),Di=m({name:"On",pattern:/on/,longer_alt:p}),Fi=m({name:"Each",pattern:/each/,longer_alt:p}),Bi=m({name:"Row",pattern:/row/,longer_alt:p}),Gi=m({name:"Statement",pattern:/statement/,longer_alt:p}),$i=m({name:"Execute",pattern:/execute/,longer_alt:p}),Tr=m({name:"Unique",pattern:/unique/,longer_alt:p}),en=m({name:"Gin",pattern:/gin/,longer_alt:p}),rn=m({name:"Gist",pattern:/gist/,longer_alt:p}),nn=m({name:"Btree",pattern:/btree/,longer_alt:p}),on=m({name:"Hash",pattern:/hash/,longer_alt:p}),ji=m({name:"Pkey",pattern:/pkey/,longer_alt:p}),Wi=m({name:"Nonull",pattern:/nonull/,longer_alt:p}),Ki=m({name:"Default",pattern:/default/,longer_alt:p}),Hi=m({name:"Ref",pattern:/ref/,longer_alt:p}),qi=m({name:"Cascade",pattern:/cascade/,longer_alt:p}),zi=m({name:"Restrict",pattern:/restrict/,longer_alt:p}),Vi=m({name:"SetNull",pattern:/setnull/,longer_alt:p}),Yi=m({name:"SetDefault",pattern:/setdefault/,longer_alt:p}),Xi=m({name:"NoAction",pattern:/noaction/,longer_alt:p}),Qi=m({name:"Update",pattern:/update/,longer_alt:p}),Zi=m({name:"Insert",pattern:/insert/,longer_alt:p}),Ji=m({name:"Delete",pattern:/delete/,longer_alt:p}),to=m({name:"Return",pattern:/return/,longer_alt:p}),sn=m({name:"New",pattern:/NEW/,longer_alt:p}),an=m({name:"Old",pattern:/OLD/,longer_alt:p}),eo=m({name:"Serial",pattern:/serial/i,longer_alt:p}),ro=m({name:"BigSerial",pattern:/bigserial/i,longer_alt:p}),no=m({name:"Integer",pattern:/integer/i,longer_alt:p}),io=m({name:"Bigint",pattern:/bigint/i,longer_alt:p}),oo=m({name:"SmallInt",pattern:/smallint/i,longer_alt:p}),so=m({name:"Text",pattern:/text/i,longer_alt:p}),ao=m({name:"Varchar",pattern:/varchar/i,longer_alt:p}),co=m({name:"Char",pattern:/char/i,longer_alt:p}),lo=m({name:"Boolean",pattern:/boolean/i,longer_alt:p}),uo=m({name:"Timestamptz",pattern:/timestamptz/i,longer_alt:p}),fo=m({name:"Timestamp",pattern:/timestamp/i,longer_alt:p}),ho=m({name:"Date",pattern:/date/i,longer_alt:p}),po=m({name:"Time",pattern:/time/i,longer_alt:p}),mo=m({name:"Jsonb",pattern:/jsonb/i,longer_alt:p}),go=m({name:"Json",pattern:/json/i,longer_alt:p}),Eo=m({name:"Uuid",pattern:/uuid/i,longer_alt:p}),xo=m({name:"Inet",pattern:/inet/i,longer_alt:p}),To=m({name:"Citext",pattern:/citext/i,longer_alt:p}),So=m({name:"Decimal",pattern:/decimal/i,longer_alt:p}),Ao=m({name:"Numeric",pattern:/numeric/i,longer_alt:p}),No=m({name:"Real",pattern:/real/i,longer_alt:p}),Oo=m({name:"DoublePrecision",pattern:/double\s+precision/i,longer_alt:p}),Io=m({name:"Bytea",pattern:/bytea/i,longer_alt:p}),Co=m({name:"StringLiteral",pattern:/'(?:[^'\\]|\\.)*'/}),cn=m({name:"NumberLiteral",pattern:/-?\d+(?:\.\d+)?/}),Ro=m({name:"BooleanLiteral",pattern:/true|false/,longer_alt:p}),yo=m({name:"NullLiteral",pattern:/null/i,longer_alt:p}),As=m({name:"Arrow",pattern:/->/}),Lo=m({name:"DoubleColon",pattern:/::/}),Sr=m({name:"LBrace",pattern:/\{/}),Ar=m({name:"RBrace",pattern:/\}/}),It=m({name:"LParen",pattern:/\(/}),Ct=m({name:"RParen",pattern:/\)/}),_o=m({name:"LBracket",pattern:/\[/}),vo=m({name:"RBracket",pattern:/\]/}),ln=m({name:"LAngle",pattern:/</}),un=m({name:"RAngle",pattern:/>/}),kt=m({name:"Semicolon",pattern:/;/}),Qt=m({name:"Comma",pattern:/,/}),fn=m({name:"Dot",pattern:/\./}),hn=m({name:"Equals",pattern:/=/}),Ns=[UT,wT,DT,As,Lo,Ri,yi,Li,_i,vi,Mi,bi,ki,Jr,tn,Pi,Ui,wi,Di,Fi,Bi,Gi,$i,Tr,en,rn,nn,on,ji,Wi,Ki,Hi,Yi,Vi,qi,zi,Xi,Qi,Zi,Ji,to,sn,an,Oo,uo,fo,ro,eo,oo,io,no,ao,co,so,lo,ho,po,mo,go,Eo,xo,To,So,Ao,No,Io,Co,cn,Ro,yo,Zr,p,Sr,Ar,It,Ct,_o,vo,ln,un,kt,Qt,fn,hn],FT=new H(Ns,{ensureOptimizations:!0});function wu(e){return FT.tokenize(e)}var Cs=class extends Qr{constructor(){super(Ns,{recoveryEnabled:!0,maxLookahead:3}),this.performSelfAnalysis()}anyIdentifier=this.RULE("anyIdentifier",()=>{this.OR([{ALT:()=>this.CONSUME(p)},{ALT:()=>this.CONSUME(Ri)},{ALT:()=>this.CONSUME(yi)},{ALT:()=>this.CONSUME(Li)},{ALT:()=>this.CONSUME(_i)},{ALT:()=>this.CONSUME(vi)},{ALT:()=>this.CONSUME(bi)},{ALT:()=>this.CONSUME(ki)},{ALT:()=>this.CONSUME(Jr)},{ALT:()=>this.CONSUME(tn)},{ALT:()=>this.CONSUME(Pi)},{ALT:()=>this.CONSUME(Ui)},{ALT:()=>this.CONSUME(Di)},{ALT:()=>this.CONSUME(Fi)},{ALT:()=>this.CONSUME(Bi)},{ALT:()=>this.CONSUME(Gi)},{ALT:()=>this.CONSUME($i)},{ALT:()=>this.CONSUME(Mi)},{ALT:()=>this.CONSUME(to)},{ALT:()=>this.CONSUME(sn)},{ALT:()=>this.CONSUME(an)},{ALT:()=>this.CONSUME(Qi)},{ALT:()=>this.CONSUME(Zi)},{ALT:()=>this.CONSUME(Ji)},{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.CONSUME(ji)},{ALT:()=>this.CONSUME(Wi)},{ALT:()=>this.CONSUME(Ki)},{ALT:()=>this.CONSUME(Hi)},{ALT:()=>this.CONSUME(wi)},{ALT:()=>this.CONSUME(qi)},{ALT:()=>this.CONSUME(zi)},{ALT:()=>this.CONSUME(Vi)},{ALT:()=>this.CONSUME(Yi)},{ALT:()=>this.CONSUME(Xi)},{ALT:()=>this.CONSUME(en)},{ALT:()=>this.CONSUME(rn)},{ALT:()=>this.CONSUME(nn)},{ALT:()=>this.CONSUME(on)},{ALT:()=>this.CONSUME(eo)},{ALT:()=>this.CONSUME(ro)},{ALT:()=>this.CONSUME(no)},{ALT:()=>this.CONSUME(io)},{ALT:()=>this.CONSUME(oo)},{ALT:()=>this.CONSUME(so)},{ALT:()=>this.CONSUME(ao)},{ALT:()=>this.CONSUME(co)},{ALT:()=>this.CONSUME(lo)},{ALT:()=>this.CONSUME(uo)},{ALT:()=>this.CONSUME(fo)},{ALT:()=>this.CONSUME(ho)},{ALT:()=>this.CONSUME(po)},{ALT:()=>this.CONSUME(mo)},{ALT:()=>this.CONSUME(go)},{ALT:()=>this.CONSUME(Eo)},{ALT:()=>this.CONSUME(xo)},{ALT:()=>this.CONSUME(To)},{ALT:()=>this.CONSUME(So)},{ALT:()=>this.CONSUME(Ao)},{ALT:()=>this.CONSUME(No)},{ALT:()=>this.CONSUME(Oo)},{ALT:()=>this.CONSUME(Io)}])});program=this.RULE("program",()=>{this.MANY(()=>{this.SUBRULE(this.topLevelDeclaration)})});topLevelDeclaration=this.RULE("topLevelDeclaration",()=>{this.OR([{ALT:()=>this.SUBRULE(this.extensionDecl)},{ALT:()=>this.SUBRULE(this.functionDecl)},{ALT:()=>this.SUBRULE(this.conceptDecl)},{ALT:()=>this.SUBRULE(this.enumDecl)},{ALT:()=>this.SUBRULE(this.schemaDecl)},{ALT:()=>this.SUBRULE(this.instantiation)},{ALT:()=>this.SUBRULE(this.perInstanceIndex)}])});extensionDecl=this.RULE("extensionDecl",()=>{this.CONSUME(vi),this.SUBRULE(this.anyIdentifier),this.CONSUME(kt)});functionDecl=this.RULE("functionDecl",()=>{this.CONSUME(bi),this.SUBRULE(this.anyIdentifier),this.CONSUME(It),this.CONSUME(Ct),this.CONSUME(As),this.SUBRULE2(this.anyIdentifier),this.SUBRULE(this.functionBody)});functionBody=this.RULE("functionBody",()=>{this.CONSUME(Sr),this.MANY(()=>{this.SUBRULE(this.functionStatement)}),this.CONSUME(Ar)});functionStatement=this.RULE("functionStatement",()=>{this.OR([{ALT:()=>this.SUBRULE(this.returnStatement)},{ALT:()=>this.SUBRULE(this.assignmentStatement)}])});returnStatement=this.RULE("returnStatement",()=>{this.CONSUME(to),this.OR([{ALT:()=>this.CONSUME(sn)},{ALT:()=>this.CONSUME(an)},{ALT:()=>this.CONSUME(p)}]),this.CONSUME(kt)});assignmentStatement=this.RULE("assignmentStatement",()=>{this.OR([{ALT:()=>this.CONSUME(sn)},{ALT:()=>this.CONSUME(an)},{ALT:()=>this.CONSUME(p)}]),this.CONSUME(fn),this.SUBRULE(this.anyIdentifier),this.CONSUME(hn),this.SUBRULE(this.functionCallExpr),this.CONSUME(kt)});functionCallExpr=this.RULE("functionCallExpr",()=>{this.CONSUME(p),this.CONSUME(It),this.CONSUME(Ct)});conceptDecl=this.RULE("conceptDecl",()=>{this.CONSUME(Ri),this.CONSUME(p),this.OPTION(()=>{this.SUBRULE(this.typeParamList)}),this.CONSUME(Sr),this.MANY(()=>{this.OR([{ALT:()=>this.SUBRULE(this.enumDecl)},{ALT:()=>this.SUBRULE(this.schemaDecl)}])}),this.CONSUME(Ar)});typeParamList=this.RULE("typeParamList",()=>{this.CONSUME(ln),this.CONSUME(p),this.MANY(()=>{this.CONSUME(Qt),this.CONSUME2(p)}),this.CONSUME(un)});enumDecl=this.RULE("enumDecl",()=>{this.CONSUME(_i),this.SUBRULE(this.anyIdentifier),this.CONSUME(Sr),this.MANY(()=>{this.SUBRULE2(this.anyIdentifier),this.CONSUME(kt)}),this.CONSUME(Ar)});schemaDecl=this.RULE("schemaDecl",()=>{this.CONSUME(yi),this.CONSUME(p),this.OPTION(()=>{this.SUBRULE(this.mixinList)}),this.CONSUME(Sr),this.MANY(()=>{this.SUBRULE(this.schemaBodyItem)}),this.CONSUME(Ar)});mixinList=this.RULE("mixinList",()=>{this.CONSUME(Li),this.CONSUME(p),this.MANY(()=>{this.CONSUME(Qt),this.CONSUME2(p)})});schemaBodyItem=this.RULE("schemaBodyItem",()=>{this.OR([{ALT:()=>this.SUBRULE(this.indexDef)},{ALT:()=>this.SUBRULE(this.checkDef)},{ALT:()=>this.SUBRULE(this.triggerDef)},{ALT:()=>this.SUBRULE(this.columnDef)}])});columnDef=this.RULE("columnDef",()=>{this.SUBRULE(this.columnName),this.SUBRULE(this.dataType),this.MANY(()=>{this.SUBRULE(this.columnConstraint)}),this.CONSUME(kt)});columnName=this.RULE("columnName",()=>{this.OR([{ALT:()=>{this.CONSUME(Zr),this.OPTION(()=>{this.CONSUME(p)})}},{ALT:()=>this.CONSUME2(p)}])});dataType=this.RULE("dataType",()=>{this.OR([{ALT:()=>this.CONSUME(eo)},{ALT:()=>this.CONSUME(ro)},{ALT:()=>this.CONSUME(no)},{ALT:()=>this.CONSUME(io)},{ALT:()=>this.CONSUME(oo)},{ALT:()=>this.CONSUME(so)},{ALT:()=>this.CONSUME(ao)},{ALT:()=>this.CONSUME(co)},{ALT:()=>this.CONSUME(lo)},{ALT:()=>this.CONSUME(uo)},{ALT:()=>this.CONSUME(fo)},{ALT:()=>this.CONSUME(ho)},{ALT:()=>this.CONSUME(po)},{ALT:()=>this.CONSUME(mo)},{ALT:()=>this.CONSUME(go)},{ALT:()=>this.CONSUME(Eo)},{ALT:()=>this.CONSUME(xo)},{ALT:()=>this.CONSUME(To)},{ALT:()=>this.CONSUME(So)},{ALT:()=>this.CONSUME(Ao)},{ALT:()=>this.CONSUME(No)},{ALT:()=>this.CONSUME(Oo)},{ALT:()=>this.CONSUME(Io)},{ALT:()=>this.CONSUME(p)}]),this.OPTION(()=>{this.CONSUME(It),this.CONSUME(cn),this.CONSUME(Ct)})});columnConstraint=this.RULE("columnConstraint",()=>{this.OR([{ALT:()=>this.CONSUME(ji)},{ALT:()=>this.CONSUME(Wi)},{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.SUBRULE(this.defaultConstraint)},{ALT:()=>this.SUBRULE(this.refConstraint)},{ALT:()=>this.SUBRULE(this.checkConstraint)},{ALT:()=>this.SUBRULE(this.onDeleteConstraint)}])});defaultConstraint=this.RULE("defaultConstraint",()=>{this.CONSUME(Ki),this.CONSUME(It),this.SUBRULE(this.defaultValue),this.CONSUME(Ct)});defaultValue=this.RULE("defaultValue",()=>{this.OR([{ALT:()=>this.CONSUME(Co)},{ALT:()=>this.CONSUME(cn)},{ALT:()=>this.CONSUME(Ro)},{ALT:()=>this.CONSUME(yo)},{ALT:()=>this.SUBRULE(this.functionCallExpr)},{ALT:()=>{this.SUBRULE(this.anyIdentifier),this.CONSUME(Lo),this.SUBRULE2(this.anyIdentifier)}},{ALT:()=>this.SUBRULE3(this.anyIdentifier)}])});refConstraint=this.RULE("refConstraint",()=>{this.CONSUME(Hi),this.CONSUME(It),this.CONSUME(p),this.CONSUME(fn),this.CONSUME2(p),this.CONSUME(Ct)});checkConstraint=this.RULE("checkConstraint",()=>{this.CONSUME(tn),this.CONSUME(It),this.SUBRULE(this.checkExpression),this.CONSUME(Ct)});checkExpression=this.RULE("checkExpression",()=>{this.MANY(()=>{this.OR([{ALT:()=>{this.CONSUME(It),this.SUBRULE(this.checkExpression),this.CONSUME(Ct)}},{ALT:()=>this.CONSUME(p)},{ALT:()=>this.CONSUME(Zr)},{ALT:()=>this.CONSUME(cn)},{ALT:()=>this.CONSUME(Co)},{ALT:()=>this.CONSUME(Ro)},{ALT:()=>this.CONSUME(yo)},{ALT:()=>this.CONSUME(Lo)},{ALT:()=>this.CONSUME(hn)},{ALT:()=>this.CONSUME(Qt)},{ALT:()=>this.CONSUME(fn)},{ALT:()=>this.CONSUME(ln)},{ALT:()=>this.CONSUME(un)}])})});onDeleteConstraint=this.RULE("onDeleteConstraint",()=>{this.CONSUME(wi),this.CONSUME(It),this.OR([{ALT:()=>this.CONSUME(qi)},{ALT:()=>this.CONSUME(zi)},{ALT:()=>this.CONSUME(Vi)},{ALT:()=>this.CONSUME(Yi)},{ALT:()=>this.CONSUME(Xi)}]),this.CONSUME(Ct)});indexDef=this.RULE("indexDef",()=>{this.CONSUME(Jr),this.CONSUME(It),this.SUBRULE(this.indexColumnList),this.CONSUME(Ct),this.MANY(()=>{this.OR([{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.CONSUME(en)},{ALT:()=>this.CONSUME(rn)},{ALT:()=>this.CONSUME(nn)},{ALT:()=>this.CONSUME(on)}])}),this.CONSUME(kt)});indexColumnList=this.RULE("indexColumnList",()=>{this.SUBRULE(this.indexColumn),this.MANY(()=>{this.CONSUME(Qt),this.SUBRULE2(this.indexColumn)})});indexColumn=this.RULE("indexColumn",()=>{this.OR([{ALT:()=>this.CONSUME(Zr)},{ALT:()=>this.CONSUME(p)}]),this.OPTION(()=>{this.CONSUME2(p)})});checkDef=this.RULE("checkDef",()=>{this.CONSUME(tn),this.CONSUME(It),this.SUBRULE(this.checkExpression),this.CONSUME(Ct),this.CONSUME(kt)});triggerDef=this.RULE("triggerDef",()=>{this.CONSUME(ki),this.CONSUME(p),this.OR([{ALT:()=>this.CONSUME(Pi)},{ALT:()=>this.CONSUME(Ui)}]),this.OR2([{ALT:()=>this.CONSUME(Qi)},{ALT:()=>this.CONSUME(Zi)},{ALT:()=>this.CONSUME(Ji)}]),this.CONSUME(Di),this.CONSUME(Fi),this.OR3([{ALT:()=>this.CONSUME(Bi)},{ALT:()=>this.CONSUME(Gi)}]),this.CONSUME($i),this.CONSUME(Mi),this.CONSUME2(p),this.CONSUME(It),this.CONSUME(Ct),this.CONSUME(kt)});instantiation=this.RULE("instantiation",()=>{this.SUBRULE(this.instantiationTargetList),this.CONSUME(hn),this.SUBRULE(this.conceptReference),this.CONSUME(kt)});instantiationTargetList=this.RULE("instantiationTargetList",()=>{this.SUBRULE(this.instantiationTarget),this.MANY(()=>{this.CONSUME(Qt),this.SUBRULE2(this.instantiationTarget)})});instantiationTarget=this.RULE("instantiationTarget",()=>{this.CONSUME(p),this.OPTION(()=>{this.CONSUME(_o),this.CONSUME2(p),this.CONSUME(vo)})});conceptReference=this.RULE("conceptReference",()=>{this.CONSUME(p),this.OPTION(()=>{this.CONSUME(ln),this.SUBRULE(this.typeArgList),this.CONSUME(un)})});typeArgList=this.RULE("typeArgList",()=>{this.SUBRULE(this.typeArg),this.MANY(()=>{this.CONSUME(Qt),this.SUBRULE2(this.typeArg)})});typeArg=this.RULE("typeArg",()=>{this.CONSUME(p),this.OPTION(()=>{this.CONSUME(_o),this.CONSUME2(p),this.CONSUME(vo)})});perInstanceIndex=this.RULE("perInstanceIndex",()=>{this.CONSUME(Jr),this.CONSUME(It),this.CONSUME(p),this.CONSUME(Qt),this.CONSUME2(p),this.MANY(()=>{this.CONSUME2(Qt),this.CONSUME3(p)}),this.CONSUME(Ct),this.MANY2(()=>{this.OR([{ALT:()=>this.CONSUME(Tr)},{ALT:()=>this.CONSUME(en)},{ALT:()=>this.CONSUME(rn)},{ALT:()=>this.CONSUME(nn)},{ALT:()=>this.CONSUME(on)}])}),this.CONSUME(kt)})},Os=new Cs;function nt(e,t){let r=e.children[t];if(r&&r.length>0){let n=r[0];if(n&&"image"in n)return n.image}return""}function De(e,t){let r=e.children[t];return r?r.map(n=>"image"in n?n.image:"").filter(n=>n!==""):[]}function M(e,t){let n=e.children[t]?.[0];if(n&&"children"in n)return n}function Ft(e,t){let r=e.children[t];return r?r.filter(n=>"children"in n):[]}function Du(e){let r=Ft(e,"anyIdentifier")[0];if(r)for(let n of Object.keys(r.children)){let o=r.children[n]?.[0];if(o&&"image"in o)return o.image}return""}function Is(e){let t=Ft(e,"anyIdentifier"),r=[];for(let n of t)for(let i of Object.keys(n.children)){let s=n.children[i]?.[0];if(s&&"image"in s){r.push(s.image);break}}return r}var Rs=class{visit(t){let r=[],n=Ft(t,"topLevelDeclaration");for(let i of n){let o=this.visitTopLevelDeclaration(i);o&&r.push(o)}return{type:"Program",declarations:r}}visitTopLevelDeclaration(t){let r=M(t,"extensionDecl");if(r)return this.visitExtensionDecl(r);let n=M(t,"functionDecl");if(n)return this.visitFunctionDecl(n);let i=M(t,"conceptDecl");if(i)return this.visitConceptDecl(i);let o=M(t,"enumDecl");if(o)return this.visitEnumDecl(o);let s=M(t,"schemaDecl");if(s)return this.visitSchemaDecl(s);let a=M(t,"instantiation");if(a)return this.visitInstantiation(a);let c=M(t,"perInstanceIndex");return c?this.visitPerInstanceIndex(c):null}visitExtensionDecl(t){return{type:"ExtensionDecl",name:Du(t)}}visitFunctionDecl(t){let r=Is(t),n=r[0]??"",i=r[1]??"",o=M(t,"functionBody"),s="";if(o){let a=Ft(o,"functionStatement"),c=[];for(let l of a){let u=M(l,"returnStatement");if(u){let h=nt(u,"Identifier");h||(h=nt(u,"New")),h||(h=nt(u,"Old")),c.push(`RETURN ${h};`)}let f=M(l,"assignmentStatement");if(f){let h=nt(f,"Identifier");h||(h=nt(f,"New")),h||(h=nt(f,"Old"));let g=Du(f),T=M(f,"functionCallExpr"),I=T?nt(T,"Identifier"):"";c.push(`${h}.${g} := ${I}();`)}}s=c.join(`
|
|
110
|
+
`)}return{type:"FunctionDecl",name:n,returnType:i,body:s}}visitConceptDecl(t){let r=nt(t,"Identifier"),n=[],i=M(t,"typeParamList");i&&n.push(...De(i,"Identifier"));let o=[],s=Ft(t,"schemaDecl");for(let c of s){let l=this.visitSchemaDecl(c);l.conceptScope=r,o.push(l)}let a=Ft(t,"enumDecl");for(let c of a){let l=this.visitEnumDecl(c);l.conceptScope=r,o.push(l)}return{type:"ConceptDecl",name:r,typeParams:n,members:o}}visitEnumDecl(t){let r=Is(t),n=r[0]??"",i=r.slice(1);return{type:"EnumDecl",name:n,values:i}}visitSchemaDecl(t){let r=nt(t,"Identifier"),n=[],i=M(t,"mixinList");i&&n.push(...De(i,"Identifier"));let o=[],s=Ft(t,"schemaBodyItem");for(let a of s){let c=this.visitSchemaBodyItem(a);c&&o.push(c)}return{type:"SchemaDecl",name:r,mixins:n,members:o}}visitSchemaBodyItem(t){let r=M(t,"columnDef");if(r)return this.visitColumnDef(r);let n=M(t,"indexDef");if(n)return this.visitIndexDef(n);let i=M(t,"checkDef");if(i)return this.visitCheckDef(i);let o=M(t,"triggerDef");return o?this.visitTriggerDef(o):null}visitColumnDef(t){let r=M(t,"columnName"),n="";if(r){let c=nt(r,"TemplateIdentifier"),l=nt(r,"Identifier");n=c?c+l:l}let i=M(t,"dataType"),o="";if(i){for(let u of Object.keys(i.children)){let h=i.children[u]?.[0];if(h&&"image"in h){o=h.image;break}}let l=i.children.NumberLiteral?.[0];l&&"image"in l&&(o+=`(${l.image})`)}let s=[],a=Ft(t,"columnConstraint");for(let c of a){let l=this.visitColumnConstraint(c);l&&s.push(l)}return{type:"ColumnDef",name:n,dataType:o,constraints:s}}visitColumnConstraint(t){if(t.children.Pkey)return{type:"PrimaryKey"};if(t.children.Nonull)return{type:"NotNull"};if(t.children.Unique)return{type:"Unique"};let r=M(t,"defaultConstraint");if(r){let s=M(r,"defaultValue"),a="";if(s){let c=nt(s,"StringLiteral"),l=nt(s,"NumberLiteral"),u=nt(s,"BooleanLiteral"),f=nt(s,"NullLiteral"),h=M(s,"functionCallExpr"),g=nt(s,"DoubleColon"),T=Is(s);c?a=c:l?a=l:u?a=u:f?a=f:h?a=nt(h,"Identifier")+"()":g&&T.length===2&&T[0]&&T[1]?a=`${T[0]}::${T[1]}`:T.length>0&&T[0]&&(a=T[0])}return{type:"Default",value:a}}let n=M(t,"refConstraint");if(n){let s=De(n,"Identifier");return{type:"Reference",table:s[0]??"",column:s[1]??""}}let i=M(t,"checkConstraint");if(i){let s=M(i,"checkExpression");return{type:"Check",value:s?this.reconstructCheckExpression(s):""}}let o=M(t,"onDeleteConstraint");if(o){let s={Cascade:"CASCADE",Restrict:"RESTRICT",SetNull:"SET NULL",SetDefault:"SET DEFAULT",NoAction:"NO ACTION"};for(let[a,c]of Object.entries(s))if(o.children[a])return{type:"OnDelete",action:c}}return null}reconstructCheckExpression(t){let r=[];for(let i of Object.keys(t.children)){let o=t.children[i];if(o){for(let s of o)if("image"in s&&"startOffset"in s){let a=typeof s.startOffset=="number"?s.startOffset:0;r.push({image:s.image,startOffset:a,isParenExpr:!1})}else if("children"in s&&i==="checkExpression"){let a=this.reconstructCheckExpression(s);if(a){let c=1/0;for(let l of Object.keys(s.children)){let u=s.children[l];if(u)for(let f of u)"startOffset"in f&&typeof f.startOffset=="number"&&(c=Math.min(c,f.startOffset))}r.push({image:a,startOffset:c===1/0?0:c,isParenExpr:!1})}}}}r.sort((i,o)=>i.startOffset-o.startOffset);let n="";for(let i=0;i<r.length;i++){let o=r[i],s=i>0?r[i-1]:null;if(!o)continue;let a=o.image,c=[")",",",".","::",">","<"],l=["(",".","::"];if(s&&!o.isParenExpr){let u=s.image,f=u[u.length-1]??"",h=(u===">"||u==="<")&&a==="=",g=(a===">"||a==="<")&&!l.includes(u)&&f!=="(";(!c.includes(a)&&!l.includes(u)&&f!=="("&&!h||g)&&(n+=" ")}else if(s&&o.isParenExpr){let u=s.image;(u[u.length-1]??"")!=="("&&(n+=" ")}n+=a}return n}visitIndexDef(t){let r=[],n=M(t,"indexColumnList");if(n){let s=Ft(n,"indexColumn");for(let a of s){let c=nt(a,"TemplateIdentifier"),l=nt(a,"Identifier");r.push(c?c+l:l)}}let i=t.children.Unique!==void 0,o;return t.children.Gin&&(o="gin"),t.children.Gist&&(o="gist"),t.children.Btree&&(o="btree"),t.children.Hash&&(o="hash"),{type:"IndexDef",columns:r,unique:i,using:o}}visitCheckDef(t){let r=M(t,"checkExpression");return{type:"CheckDef",expression:r?this.reconstructCheckExpression(r):""}}visitTriggerDef(t){let r=De(t,"Identifier"),n=r[0]??"",i=r[1]??"",o=t.children.Before?"before":"after",s="update";t.children.Insert&&(s="insert"),t.children.Delete&&(s="delete");let a=t.children.Row?"row":"statement";return{type:"TriggerDef",name:n,timing:o,event:s,forEach:a,executeFunction:i}}visitInstantiation(t){let r=[],n=M(t,"instantiationTargetList");if(n){let a=Ft(n,"instantiationTarget");for(let c of a){let l=De(c,"Identifier");r.push({tableName:l[0]??"",alias:l[1]})}}let i=M(t,"conceptReference"),o="",s=[];if(i){o=nt(i,"Identifier");let a=M(i,"typeArgList");if(a){let c=Ft(a,"typeArg");for(let l of c){let u=De(l,"Identifier");s.push({tableName:u[0]??"",alias:u[1]})}}}return{type:"Instantiation",targets:r,conceptName:o,typeArgs:s}}visitPerInstanceIndex(t){let r=De(t,"Identifier"),n=r[0]??"",i=r.slice(1),o=t.children.Unique!==void 0,s;return t.children.Gin&&(s="gin"),t.children.Gist&&(s="gist"),t.children.Btree&&(s="btree"),t.children.Hash&&(s="hash"),{type:"PerInstanceIndex",tableName:n,columns:i,unique:o,using:s}}};function Fu(e){let t=wu(e),r=[];for(let s of t.errors)r.push({message:s.message,location:{start:{line:s.line??0,column:s.column??0,offset:s.offset},end:{line:s.line??0,column:s.column??0,offset:s.offset}},severity:"error"});if(r.length>0)return{ast:null,errors:r};Os.input=t.tokens;let n=Os.program();for(let s of Os.errors){let a=s.token;r.push({message:s.message,location:{start:{line:a.startLine??0,column:a.startColumn??0,offset:a.startOffset},end:{line:a.endLine??0,column:a.endColumn??0,offset:a.endOffset??a.startOffset}},severity:"error"})}return r.length>0?{ast:null,errors:r}:{ast:new Rs().visit(n),errors:r}}function ys(e){return e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").toLowerCase()}function $u(e){return e.includes("::")?e.replace(/(\w+)::(\w+)/g,"'$2'::$1"):e}function BT(e,t){return e==="NULL"||/^'[^']*'::\w+$/.test(e)?e:e.includes("::")?$u(e):`'${e}'::${t}`}function GT(){return{concepts:new Map,schemas:new Map,enums:new Map,tableToSchema:new Map,templateSubs:new Map,enumSql:[],tableSql:[],indexSql:[],triggerSql:[],extensionSql:[],functionSql:[],perInstanceIndexSql:[],generatedEnums:new Set,generatedTables:new Set}}function $T(e,t){for(let r of e.declarations)switch(r.type){case"ConceptDecl":t.concepts.set(r.name,r);break;case"SchemaDecl":t.schemas.set(r.name,r);break;case"EnumDecl":t.enums.set(r.name,r);break}}function ju(e,t){let r=e.match(/^\{([^}]+)\}(.*)$/);if(r){let[,n,i]=r,o;for(let[s,a]of t.templateSubs)if(s===n){o=a;break}return(o??ys(n??""))+(i??"")}return e}function jT(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wu(e,t){let r=e;for(let[n,i]of t.templateSubs){let o=jT(n),s=new RegExp(`\\{${o}\\}`,"g");r=r.replace(s,i)}return r=$u(r),r}function Ku(e,t){let r=e.name;if(t.generatedEnums.has(r))return;t.generatedEnums.add(r),t.enums.set(r,e);let n=e.values.map(i=>`'${i}'`).join(", ");t.enumSql.push(`DO $$ BEGIN
|
|
111
111
|
CREATE TYPE ${r} AS ENUM (${n});
|
|
112
112
|
EXCEPTION
|
|
113
113
|
WHEN duplicate_object THEN null;
|
|
114
|
-
END $$;`)}function
|
|
115
|
-
${n} ${
|
|
116
|
-
${
|
|
114
|
+
END $$;`)}function WT(e,t){let r=ju(e.name,t),n=e.dataType.toUpperCase(),i=[` ${r} ${n}`],o=[];for(let s of e.constraints)switch(s.type){case"PrimaryKey":i.push("PRIMARY KEY");break;case"NotNull":i.push("NOT NULL");break;case"Unique":i.push("UNIQUE");break;case"Default":{let a=s.value??"NULL",c=e.dataType.toLowerCase();t.enums.has(c)&&(a=BT(a,c)),i.push(`DEFAULT ${a}`);break}case"Reference":{let a=s.table??"";t.tableToSchema.has(a)&&(a=t.tableToSchema.get(a)??a),o.push(`REFERENCES ${a}(${s.column??"id"})`);break}case"Check":i.push(`CHECK (${Wu(s.value??"",t)})`);break;case"OnDelete":o.push(`ON DELETE ${s.action??"NO ACTION"}`);break}return[...i,...o].join(" ")}function Hu(e,t,r){let n=t.columns.map(l=>ju(l,r)),i=n.join(", "),o=n.join("_"),s=`idx_${e}_${o}`,a=t.unique===!0?"UNIQUE ":"",c=t.using?`USING ${t.using} `:"";return`CREATE ${a}INDEX ${s} ON ${e} ${c}(${i});`}function KT(e,t,r){return` CHECK (${Wu(t.expression,r)})`}function HT(e,t,r){let n=t.timing.toUpperCase(),i=t.event.toUpperCase(),o=t.forEach==="row"?"FOR EACH ROW":"FOR EACH STATEMENT";return`CREATE TRIGGER ${t.name}_${e}
|
|
115
|
+
${n} ${i} ON ${e}
|
|
116
|
+
${o} EXECUTE FUNCTION ${t.executeFunction}();`}function qu(e,t){let r=[];for(let n of e.mixins){let i=t.schemas.get(n);i&&r.push(...qu(i,t))}return r.push(...e.members),r}function Bu(e,t,r){let n=qu(e,r),i=[],o=[],s=[],a=[];for(let c of n)switch(c.type){case"ColumnDef":i.push(c);break;case"IndexDef":o.push(c);break;case"CheckDef":s.push(c);break;case"TriggerDef":a.push(c);break}return{tableName:t,columns:i,indexes:o,checks:s,triggers:a}}function Gu(e,t){if(t.generatedTables.has(e.tableName))return;t.generatedTables.add(e.tableName);let r=e.columns.map(s=>WT(s,t)),n=e.checks.map(s=>KT(e.tableName,s,t)),o=[...r,...n].join(`,
|
|
117
117
|
`);t.tableSql.push(`CREATE TABLE ${e.tableName} (
|
|
118
|
-
${
|
|
119
|
-
);`);for(let s of e.indexes)t.indexSql.push(
|
|
118
|
+
${o}
|
|
119
|
+
);`);for(let s of e.indexes)t.indexSql.push(Hu(e.tableName,s,t));for(let s of e.triggers)t.triggerSql.push(HT(e.tableName,s,t))}function qT(e,t){t.extensionSql.push(`CREATE EXTENSION IF NOT EXISTS "${e.name}";`)}function zT(e,t){t.functionSql.push(`CREATE OR REPLACE FUNCTION ${e.name}()
|
|
120
120
|
RETURNS TRIGGER AS $$
|
|
121
121
|
BEGIN
|
|
122
122
|
${e.body}
|
|
123
123
|
END;
|
|
124
|
-
$$ LANGUAGE plpgsql;`)}function
|
|
124
|
+
$$ LANGUAGE plpgsql;`)}function VT(e,t){Ku(e,t)}function YT(e,t){t.schemas.set(e.name,e)}function XT(e,t){let r=t.concepts.get(e.conceptName);if(!r){let s=t.schemas.get(e.conceptName);if(s){let a=e.targets[0];if(a){let c=a.tableName;t.tableToSchema.set(s.name,c);let l=Bu(s,c,t);Gu(l,t)}}return}t.templateSubs.clear();for(let s=0;s<r.typeParams.length;s++){let a=r.typeParams[s],c=e.typeArgs[s];a&&c&&(t.templateSubs.set(a,c.alias??ys(a)),t.tableToSchema.set(a,c.tableName))}let n=r.members.filter(s=>s.type==="SchemaDecl"),i=new Map;for(let s=0;s<e.targets.length&&s<n.length;s++){let a=e.targets[s],c=n[s];a&&c&&(i.set(c.name,{name:a.tableName,alias:a.alias}),t.tableToSchema.set(c.name,a.tableName),a.alias?t.templateSubs.set(c.name,a.alias):t.templateSubs.set(c.name,ys(c.name)))}let o=r.members.filter(s=>s.type==="EnumDecl");for(let s of o)Ku(s,t);for(let s of n){let a=i.get(s.name);if(a){let c=Bu(s,a.name,t);Gu(c,t)}}}function QT(e,t){let r={type:"IndexDef",columns:e.columns,unique:e.unique,using:e.using};t.perInstanceIndexSql.push(Hu(e.tableName,r,t))}function zu(e){let t=GT();$T(e,t);for(let i of e.declarations)ZT(i,t);let r=[];t.extensionSql.length>0&&r.push(t.extensionSql.join(`
|
|
125
125
|
|
|
126
126
|
`)),t.functionSql.length>0&&r.push(t.functionSql.join(`
|
|
127
127
|
|
|
128
128
|
`)),t.enumSql.length>0&&r.push(t.enumSql.join(`
|
|
129
129
|
|
|
130
|
-
`));let n=[];for(let
|
|
130
|
+
`));let n=[];for(let i of t.tableSql){i&&n.push(i);let o=i.match(/CREATE TABLE (\w+)/);if(o){let s=o[1]??"";for(let a of t.indexSql)a.includes(` ON ${s} `)&&n.push(a);for(let a of t.triggerSql)a.includes(` ON ${s}`)&&n.push(a)}}return n.length>0&&r.push(n.join(`
|
|
131
131
|
|
|
132
132
|
`)),t.perInstanceIndexSql.length>0&&r.push(t.perInstanceIndexSql.join(`
|
|
133
133
|
|
|
@@ -136,7 +136,7 @@ $$ LANGUAGE plpgsql;`)}function qT(e,t){Wu(e,t)}function zT(e,t){t.schemas.set(e
|
|
|
136
136
|
`+r.join(`
|
|
137
137
|
|
|
138
138
|
`)+`
|
|
139
|
-
`}function
|
|
139
|
+
`}function ZT(e,t){switch(e.type){case"ExtensionDecl":qT(e,t);break;case"FunctionDecl":zT(e,t);break;case"EnumDecl":VT(e,t);break;case"SchemaDecl":YT(e,t);break;case"ConceptDecl":break;case"Instantiation":XT(e,t);break;case"PerInstanceIndex":QT(e,t);break}}function Vu(e){let t=[],r=Fu(e);if(r.errors.length>0)return{success:!1,errors:r.errors,ast:r.ast??void 0};if(!r.ast)return t.push({message:"Failed to parse source code",severity:"error"}),{success:!1,errors:t};try{return{success:!0,sql:zu(r.ast),errors:[],ast:r.ast}}catch(n){let i=n instanceof Error?n.message:String(n);return t.push({message:`Code generation failed: ${i}`,severity:"error"}),{success:!1,errors:t,ast:r.ast}}}var oS=rS(iS(import.meta.url)),sS=JSON.parse(Xu(nS(oS,"..","package.json"),"utf-8")),aS=sS.version,Mo=`
|
|
140
140
|
GSQL - Generic SQL Compiler
|
|
141
141
|
Parametric polymorphism for SQL schemas
|
|
142
142
|
|
|
@@ -158,7 +158,7 @@ Examples:
|
|
|
158
158
|
gsql compile schema.gsql
|
|
159
159
|
gsql compile schema.gsql -o schema.sql
|
|
160
160
|
gsql compile schema.gsql > schema.sql
|
|
161
|
-
`,
|
|
161
|
+
`,Ls=class{constructor(t){this.args=t}index=0;current(){return this.args[this.index]}next(){return this.index++,this.args[this.index]}advance(){this.index++}hasMore(){return this.index<this.args.length}};function cS(e){let t={command:"",inputFile:"",outputFile:null,verbose:!1,help:!1,version:!1},r=new Ls(e);for(;r.hasMore();){let n=r.current();if(!n){r.advance();continue}if(n==="-h"||n==="--help")t.help=!0;else if(n==="--version")t.version=!0;else if(n==="-v"||n==="--verbose")t.verbose=!0;else if(n==="-o"||n==="--output"){let i=r.next();i&&(t.outputFile=i)}else n.startsWith("-")||(t.command?t.inputFile||(t.inputFile=n):t.command=n);r.advance()}return t}function lS(e,t,r){let n=`Error: ${e}`;return t!==void 0&&r!==void 0&&(n=`Error [${t}:${r}]: ${e}`),n}function uS(){let e=process.argv.slice(2),t=cS(e);t.help&&(console.log(Mo),process.exit(0)),t.version&&(console.log(`gsql version ${aS}`),process.exit(0)),t.command||(console.error("Error: No command specified"),console.log(Mo),process.exit(1)),t.command!=="compile"&&(console.error(`Error: Unknown command '${t.command}'`),console.log(Mo),process.exit(1)),t.inputFile||(console.error("Error: No input file specified"),console.log(Mo),process.exit(1));let r=Yu(process.cwd(),t.inputFile);tS(r)||(console.error(`Error: File not found: ${t.inputFile}`),process.exit(1));let n;try{n=Xu(r,"utf-8")}catch(o){let s=o instanceof Error?o.message:String(o);console.error(`Error reading file: ${s}`),process.exit(1)}t.verbose&&console.error(`Compiling ${eS(r)}...`);let i=Vu(n);if(!i.success){for(let o of i.errors)console.error(lS(o.message,o.location?.start.line,o.location?.start.column));process.exit(1)}if(t.outputFile){let o=Yu(process.cwd(),t.outputFile);try{JT(o,i.sql??""),t.verbose&&console.error(`Output written to ${t.outputFile}`)}catch(s){let a=s instanceof Error?s.message:String(s);console.error(`Error writing file: ${a}`),process.exit(1)}}else console.log(i.sql)}uS();
|
|
162
162
|
/*! Bundled license information:
|
|
163
163
|
|
|
164
164
|
lodash-es/lodash.js:
|