@likec4/mcp 1.48.0 → 1.49.0
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/THIRD-PARTY-LICENSES.md +2417 -0
- package/dist/_chunks/libs/@chevrotain/gast.mjs +1 -1
- package/dist/_chunks/libs/@hono/mcp.mjs +34 -0
- package/dist/_chunks/libs/@mantine/colors-generator.mjs +2 -2
- package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +7 -36
- package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
- package/dist/_chunks/libs/chevrotain-allstar.mjs +2 -2
- package/dist/_chunks/libs/chevrotain.mjs +30 -30
- package/dist/_chunks/libs/is-error-instance.mjs +1 -1
- package/dist/_chunks/libs/khroma.mjs +1 -1
- package/dist/_chunks/libs/langium.mjs +3 -3
- package/dist/_chunks/libs/merge-error-cause.mjs +2 -2
- package/dist/_chunks/libs/mnemonist.mjs +1 -1
- package/dist/_chunks/libs/p-limit.mjs +1 -1
- package/dist/_chunks/libs/pathe.mjs +1 -0
- package/dist/_chunks/libs/remeda.mjs +1 -1
- package/dist/_chunks/libs/safe-stringify.mjs +1 -1
- package/dist/_chunks/libs/ufo.mjs +1 -1
- package/dist/_chunks/rolldown-runtime.mjs +1 -1
- package/dist/index.mjs +73 -67
- package/package.json +15 -15
- package/dist/_chunks/libs/hono.mjs +0 -1
- package/dist/_chunks/libs/nanoid.mjs +0 -1
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import{n as e,t}from"./@chevrotain/regexp-to-ast.mjs";import{$ as n,A as r,B as i,C as a,D as o,E as s,F as c,G as l,H as u,I as d,J as f,K as p,L as m,M as h,N as g,O as _,P as v,Q as y,R as ee,S as b,T as x,U as te,V as ne,W as S,X as re,Y as ie,Z as ae,_ as oe,_t as C,a as w,at as se,b as T,c as E,ct as ce,d as le,dt as ue,et as de,f as D,ft as fe,g as pe,gt as me,h as O,i as he,it as ge,j as _e,k as ve,l as k,lt as ye,m as be,mt as xe,n as Se,nt as Ce,o as we,ot as Te,p as Ee,pt as A,q as De,r as Oe,rt as ke,s as j,st as Ae,t as M,tt as je,u as N,ut as Me,v as Ne,vt as Pe,w as P,x as F,y as I,z as Fe}from"./@chevrotain/gast.mjs";import{i as Ie,n as Le,r as Re,t as ze}from"./@chevrotain/utils.mjs";var Be=Object.create,Ve=function(){function e(){}return function(t){if(!fe(t))return{};if(Be)return Be(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function He(){}var L=He;function Ue(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}var We=Ue;function Ge(e,t){return!!(e!=null&&e.length)&&Te(e,t,0)>-1}var Ke=Ge,qe=C?C.isConcatSpreadable:void 0;function Je(e){return A(e)||ae(e)||!!(qe&&e&&e[qe])}var Ye=Je;function Xe(e,t,n,r,i){var a=-1,o=e.length;for(n||=Ye,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?Xe(s,t-1,n,r,i):u(i,s):r||(i[i.length]=s)}return i}var Ze=Xe;function Qe(e){return e!=null&&e.length?Ze(e,1):[]}var R=Qe;function $e(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=Array(i);++r<i;)a[r]=e[r+t];return a}var et=$e;function tt(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}var nt=tt;function rt(e,t){return e&&Ce(t,l(t),e)}var it=rt;function at(e,t){return e&&Ce(t,te(t),e)}var ot=at,st=typeof exports==`object`&&exports&&!exports.nodeType&&exports,ct=st&&typeof module==`object`&&module&&!module.nodeType&&module,lt=ct&&ct.exports===st?Pe.Buffer:void 0,ut=lt?lt.allocUnsafe:void 0;function dt(e,t){if(t)return e.slice();var n=e.length,r=ut?ut(n):new e.constructor(n);return e.copy(r),r}var ft=dt;function pt(e,t){return Ce(e,ee(e),t)}var mt=pt;function ht(e,t){return Ce(e,m(e),t)}var gt=ht,_t=Object.prototype.hasOwnProperty;function vt(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&_t.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}var yt=vt;function bt(e){var t=new e.constructor(e.byteLength);return new h(t).set(new h(e)),t}var xt=bt;function St(e,t){var n=t?xt(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}var Ct=St,wt=/\w*$/;function Tt(e){var t=new e.constructor(e.source,wt.exec(e));return t.lastIndex=e.lastIndex,t}var Et=Tt,Dt=C?C.prototype:void 0,Ot=Dt?Dt.valueOf:void 0;function kt(e){return Ot?Object(Ot.call(e)):{}}var At=kt;function jt(e,t){var n=t?xt(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var Mt=jt,Nt=`[object Boolean]`,Pt=`[object Date]`,Ft=`[object Map]`,It=`[object Number]`,Lt=`[object RegExp]`,Rt=`[object Set]`,zt=`[object String]`,Bt=`[object Symbol]`,Vt=`[object ArrayBuffer]`,Ht=`[object DataView]`,Ut=`[object Float32Array]`,Wt=`[object Float64Array]`,Gt=`[object Int8Array]`,Kt=`[object Int16Array]`,qt=`[object Int32Array]`,Jt=`[object Uint8Array]`,Yt=`[object Uint8ClampedArray]`,Xt=`[object Uint16Array]`,Zt=`[object Uint32Array]`;function Qt(e,t,n){var r=e.constructor;switch(t){case Vt:return xt(e);case Nt:case Pt:return new r(+e);case Ht:return Ct(e,n);case Ut:case Wt:case Gt:case Kt:case qt:case Jt:case Yt:case Xt:case Zt:return Mt(e,n);case Ft:return new r;case It:case zt:return new r(e);case Lt:return Et(e);case Rt:return new r;case Bt:return At(e)}}var $t=Qt;function en(e){return typeof e.constructor==`function`&&!y(e)?Ve(ne(e)):{}}var tn=en,nn=`[object Map]`;function rn(e){return me(e)&&g(e)==nn}var an=rn,on=f&&f.isMap,sn=on?ie(on):an,cn=`[object Set]`;function ln(e){return me(e)&&g(e)==cn}var un=ln,dn=f&&f.isSet,fn=dn?ie(dn):un,pn=1,mn=2,hn=4,gn=`[object Arguments]`,_n=`[object Array]`,vn=`[object Boolean]`,yn=`[object Date]`,bn=`[object Error]`,xn=`[object Function]`,Sn=`[object GeneratorFunction]`,Cn=`[object Map]`,wn=`[object Number]`,Tn=`[object Object]`,En=`[object RegExp]`,Dn=`[object Set]`,On=`[object String]`,kn=`[object Symbol]`,An=`[object WeakMap]`,jn=`[object ArrayBuffer]`,Mn=`[object DataView]`,Nn=`[object Float32Array]`,Pn=`[object Float64Array]`,Fn=`[object Int8Array]`,In=`[object Int16Array]`,Ln=`[object Int32Array]`,Rn=`[object Uint8Array]`,zn=`[object Uint8ClampedArray]`,Bn=`[object Uint16Array]`,Vn=`[object Uint32Array]`,z={};z[gn]=z[_n]=z[jn]=z[Mn]=z[vn]=z[yn]=z[Nn]=z[Pn]=z[Fn]=z[In]=z[Ln]=z[Cn]=z[wn]=z[Tn]=z[En]=z[Dn]=z[On]=z[kn]=z[Rn]=z[zn]=z[Bn]=z[Vn]=!0,z[bn]=z[xn]=z[An]=!1;function Hn(e,t,n,r,a,o){var s,u=t&pn,f=t&mn,p=t&hn;if(n&&(s=a?n(e,r,a,o):n(e)),s!==void 0)return s;if(!fe(e))return e;var m=A(e);if(m){if(s=yt(e),!u)return We(e,s)}else{var h=g(e),_=h==xn||h==Sn;if(re(e))return ft(e,u);if(h==Tn||h==gn||_&&!a){if(s=f||_?{}:tn(e),!u)return f?gt(e,ot(s,e)):mt(e,it(s,e))}else{if(!z[h])return a?e:{};s=$t(e,h,u)}}o||=new i;var v=o.get(e);if(v)return v;o.set(e,s),fn(e)?e.forEach(function(r){s.add(Hn(r,t,n,r,e,o))}):sn(e)&&e.forEach(function(r,i){s.set(i,Hn(r,t,n,i,e,o))});var y=m?void 0:(p?f?c:d:f?te:l)(e);return ce(y||e,function(r,i){y&&(i=r,r=e[i]),ke(s,i,Hn(r,t,n,i,e,o))}),s}var Un=Hn,Wn=4;function Gn(e){return Un(e,Wn)}var B=Gn;function Kn(e){for(var t=-1,n=e==null?0:e.length,r=0,i=[];++t<n;){var a=e[t];a&&(i[r++]=a)}return i}var qn=Kn;function Jn(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}var Yn=Jn;function Xn(e,t,n,r){return s(e,function(e,i,a){t(r,e,n(e),a)}),r}var Zn=Xn;function Qn(e,t){return function(n,r){var i=A(n)?Yn:Zn,a=t?t():{};return i(n,e,o(r,2),a)}}var $n=Qn,er=Object.prototype,tr=er.hasOwnProperty,nr=je(function(e,t){e=Object(e);var r=-1,i=t.length,a=i>2?t[2]:void 0;for(a&&n(t[0],t[1],a)&&(i=1);++r<i;)for(var o=t[r],s=te(o),c=-1,l=s.length;++c<l;){var u=s[c],d=e[u];(d===void 0||ge(d,er[u])&&!tr.call(e,u))&&(e[u]=o[u])}return e});function rr(e){return me(e)&&de(e)}var ir=rr;function ar(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}var or=ar,sr=200;function cr(e,t,n,i){var a=-1,o=Ke,s=!0,c=e.length,l=[],u=t.length;if(!c)return l;n&&(t=xe(t,ie(n))),i?(o=or,s=!1):t.length>=sr&&(o=r,s=!1,t=new _e(t));outer:for(;++a<c;){var d=e[a],f=n==null?d:n(d);if(d=i||d!==0?d:0,s&&f===f){for(var p=u;p--;)if(t[p]===f)continue outer;l.push(d)}else o(t,f,i)||l.push(d)}return l}var lr=cr,ur=je(function(e,t){return ir(e)?lr(e,Ze(t,1,ir,!0)):[]});function dr(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var fr=dr;function pr(e,t,n){var r=e==null?0:e.length;return r?(t=n||t===void 0?1:ue(t),et(e,t<0?0:t,r)):[]}var V=pr;function mr(e,t,n){var r=e==null?0:e.length;return r?(t=n||t===void 0?1:ue(t),t=r-t,et(e,0,t<0?0:t)):[]}var hr=mr;function gr(e,t){var n=[];return s(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}var _r=gr;function vr(e,t){return(A(e)?Fe:_r)(e,o(t,3))}var H=vr;function yr(e){return function(t,n,r){var i=Object(t);if(!de(t)){var a=o(n,3);t=l(t),n=function(e){return a(i[e],e,i)}}var s=e(t,n,r);return s>-1?i[a?t[s]:s]:void 0}}var br=yr,xr=Math.max;function Sr(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:ue(n);return i<0&&(i=xr(r+i,0)),Ae(e,o(t,3),i)}var Cr=br(Sr);function wr(e){return e&&e.length?e[0]:void 0}var U=wr;function Tr(e,t){return Ze(a(e,t),1)}var W=Tr,Er=Object.prototype.hasOwnProperty,Dr=$n(function(e,t,n){Er.call(e,n)?e[n].push(t):se(e,n,[t])}),Or=Object.prototype.hasOwnProperty;function kr(e,t){return e!=null&&Or.call(e,t)}var Ar=kr;function jr(e,t){return e!=null&&_(e,t,Ar)}var G=jr,Mr=Math.max;function Nr(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:ue(n);return i<0&&(i=Mr(r+i,0)),Te(e,t,i)}var Pr=Nr,Fr=`[object Map]`,Ir=`[object Set]`,Lr=Object.prototype.hasOwnProperty;function Rr(e){if(e==null)return!0;if(de(e)&&(A(e)||typeof e==`string`||typeof e.splice==`function`||re(e)||De(e)||ae(e)))return!e.length;var t=g(e);if(t==Fr||t==Ir)return!e.size;if(y(e))return!p(e).length;for(var n in e)if(Lr.call(e,n))return!1;return!0}var K=Rr;function zr(e){return e===void 0}var q=zr,Br=`Expected a function`;function Vr(e){if(typeof e!=`function`)throw TypeError(Br);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 Hr=Vr;function Ur(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}var Wr=Ur;function Gr(e,t,n){var r=A(e)?nt:Wr,i=arguments.length<3;return r(e,o(t,4),n,i,s)}var J=Gr;function Kr(e,t){return(A(e)?Fe:_r)(e,Hr(o(t,3)))}var qr=Kr,Jr=v&&1/ve(new v([,-0]))[1]==1/0?function(e){return new v(e)}:L,Yr=200;function Xr(e,t,n){var i=-1,a=Ke,o=e.length,s=!0,c=[],l=c;if(n)s=!1,a=or;else if(o>=Yr){var u=t?null:Jr(e);if(u)return ve(u);s=!1,a=r,l=new _e}else l=t?[]:c;outer:for(;++i<o;){var d=e[i],f=t?t(d):d;if(d=n||d!==0?d:0,s&&f===f){for(var p=l.length;p--;)if(l[p]===f)continue outer;t&&l.push(f),c.push(d)}else a(l,f,n)||(l!==c&&l.push(f),c.push(d))}return c}var Zr=Xr;function Qr(e){return e&&e.length?Zr(e):[]}var $r=Qr,ei=class{walk(e,t=[]){x(e.definition,(n,r)=>{let i=V(e.definition,r+1);if(n instanceof E)this.walkProdRef(n,i,t);else if(n instanceof O)this.walkTerminal(n,i,t);else if(n instanceof j)this.walkFlat(n,i,t);else if(n instanceof k)this.walkOption(n,i,t);else if(n instanceof le)this.walkAtLeastOne(n,i,t);else if(n instanceof D)this.walkAtLeastOneSep(n,i,t);else if(n instanceof Ee)this.walkManySep(n,i,t);else if(n instanceof N)this.walkMany(n,i,t);else if(n instanceof we)this.walkOr(n,i,t);else throw Error(`non exhaustive match`)})}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){let r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){let r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){let r=[new k({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){let r=ti(e,t,n);this.walk(e,r)}walkMany(e,t,n){let r=[new k({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){let r=ti(e,t,n);this.walk(e,r)}walkOr(e,t,n){let r=t.concat(n);x(e.definition,e=>{let t=new j({definition:[e]});this.walk(t,r)})}};function ti(e,t,n){return[new k({definition:[new O({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function ni(e){if(e instanceof E)return ni(e.referencedRule);if(e instanceof O)return ai(e);if(he(e))return ri(e);if(Se(e))return ii(e);throw Error(`non exhaustive match`)}function ri(e){let t=[],n=e.definition,r=0,i=n.length>r,a,o=!0;for(;i&&o;)a=n[r],o=Oe(a),t=t.concat(ni(a)),r+=1,i=n.length>r;return $r(t)}function ii(e){return $r(R(a(e.definition,e=>ni(e))))}function ai(e){return[e.terminalType]}const oi=`_~IN~_`;var si=class extends ei{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){let r=li(e.referencedRule,e.idx)+this.topProd.name,i=ni(new j({definition:t.concat(n)}));this.follows[r]=i}};function ci(e){let t={};return x(e,e=>{S(t,new si(e).startWalking())}),t}function li(e,t){return e.name+t+oi}let ui={};const di=new e;function fi(e){let t=e.toString();if(ui.hasOwnProperty(t))return ui[t];{let e=di.pattern(t);return ui[t]=e,e}}function pi(){ui={}}const mi=`Complement Sets are not supported for first char optimization`,hi=`Unable to use "first char" lexer optimizations:
|
|
2
|
-
`;function
|
|
1
|
+
import{n as e,t}from"./@chevrotain/regexp-to-ast.mjs";import{$ as n,A as r,B as i,C as a,D as o,E as s,F as c,G as l,H as u,I as d,J as f,K as p,L as m,M as h,N as g,O as _,P as v,Q as y,R as ee,S as b,T as x,U as te,V as ne,W as S,X as re,Y as ie,Z as ae,_ as oe,_t as C,a as w,at as se,b as T,c as E,ct as ce,d as le,dt as ue,et as de,f as D,ft as fe,g as pe,gt as me,h as O,i as he,it as ge,j as _e,k as ve,l as k,lt as ye,m as be,mt as xe,n as Se,nt as Ce,o as we,ot as Te,p as Ee,pt as A,q as De,r as Oe,rt as ke,s as j,st as Ae,t as M,tt as je,u as N,ut as Me,v as Ne,vt as Pe,w as P,x as F,y as I,z as Fe}from"./@chevrotain/gast.mjs";import{i as Ie,n as Le,r as Re,t as ze}from"./@chevrotain/utils.mjs";var Be=Object.create,Ve=function(){function e(){}return function(t){if(!fe(t))return{};if(Be)return Be(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function L(){}function He(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}function Ue(e,t){return!!(e!=null&&e.length)&&Te(e,t,0)>-1}var We=C?C.isConcatSpreadable:void 0;function Ge(e){return A(e)||ae(e)||!!(We&&e&&e[We])}function Ke(e,t,n,r,i){var a=-1,o=e.length;for(n||=Ge,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?Ke(s,t-1,n,r,i):u(i,s):r||(i[i.length]=s)}return i}function R(e){return e!=null&&e.length?Ke(e,1):[]}function qe(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=Array(i);++r<i;)a[r]=e[r+t];return a}function Je(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function Ye(e,t){return e&&Ce(t,l(t),e)}function Xe(e,t){return e&&Ce(t,te(t),e)}var Ze=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Qe=Ze&&typeof module==`object`&&module&&!module.nodeType&&module,$e=Qe&&Qe.exports===Ze?Pe.Buffer:void 0,et=$e?$e.allocUnsafe:void 0;function tt(e,t){if(t)return e.slice();var n=e.length,r=et?et(n):new e.constructor(n);return e.copy(r),r}function nt(e,t){return Ce(e,ee(e),t)}function rt(e,t){return Ce(e,m(e),t)}var it=Object.prototype.hasOwnProperty;function at(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&it.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}function ot(e){var t=new e.constructor(e.byteLength);return new h(t).set(new h(e)),t}function st(e,t){var n=t?ot(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}var ct=/\w*$/;function lt(e){var t=new e.constructor(e.source,ct.exec(e));return t.lastIndex=e.lastIndex,t}var ut=C?C.prototype:void 0,dt=ut?ut.valueOf:void 0;function ft(e){return dt?Object(dt.call(e)):{}}function pt(e,t){var n=t?ot(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var mt=`[object Boolean]`,ht=`[object Date]`,gt=`[object Map]`,_t=`[object Number]`,vt=`[object RegExp]`,yt=`[object Set]`,bt=`[object String]`,xt=`[object Symbol]`,St=`[object ArrayBuffer]`,Ct=`[object DataView]`,wt=`[object Float32Array]`,Tt=`[object Float64Array]`,Et=`[object Int8Array]`,Dt=`[object Int16Array]`,Ot=`[object Int32Array]`,kt=`[object Uint8Array]`,At=`[object Uint8ClampedArray]`,jt=`[object Uint16Array]`,Mt=`[object Uint32Array]`;function Nt(e,t,n){var r=e.constructor;switch(t){case St:return ot(e);case mt:case ht:return new r(+e);case Ct:return st(e,n);case wt:case Tt:case Et:case Dt:case Ot:case kt:case At:case jt:case Mt:return pt(e,n);case gt:return new r;case _t:case bt:return new r(e);case vt:return lt(e);case yt:return new r;case xt:return ft(e)}}function Pt(e){return typeof e.constructor==`function`&&!y(e)?Ve(ne(e)):{}}var Ft=`[object Map]`;function It(e){return me(e)&&g(e)==Ft}var Lt=f&&f.isMap,Rt=Lt?ie(Lt):It,zt=`[object Set]`;function Bt(e){return me(e)&&g(e)==zt}var Vt=f&&f.isSet,Ht=Vt?ie(Vt):Bt,Ut=1,Wt=2,Gt=4,Kt=`[object Arguments]`,qt=`[object Array]`,Jt=`[object Boolean]`,Yt=`[object Date]`,Xt=`[object Error]`,Zt=`[object Function]`,Qt=`[object GeneratorFunction]`,$t=`[object Map]`,en=`[object Number]`,tn=`[object Object]`,nn=`[object RegExp]`,rn=`[object Set]`,an=`[object String]`,on=`[object Symbol]`,sn=`[object WeakMap]`,cn=`[object ArrayBuffer]`,ln=`[object DataView]`,un=`[object Float32Array]`,dn=`[object Float64Array]`,fn=`[object Int8Array]`,pn=`[object Int16Array]`,mn=`[object Int32Array]`,hn=`[object Uint8Array]`,gn=`[object Uint8ClampedArray]`,_n=`[object Uint16Array]`,vn=`[object Uint32Array]`,z={};z[Kt]=z[qt]=z[cn]=z[ln]=z[Jt]=z[Yt]=z[un]=z[dn]=z[fn]=z[pn]=z[mn]=z[$t]=z[en]=z[tn]=z[nn]=z[rn]=z[an]=z[on]=z[hn]=z[gn]=z[_n]=z[vn]=!0,z[Xt]=z[Zt]=z[sn]=!1;function yn(e,t,n,r,a,o){var s,u=t&Ut,f=t&Wt,p=t≫if(n&&(s=a?n(e,r,a,o):n(e)),s!==void 0)return s;if(!fe(e))return e;var m=A(e);if(m){if(s=at(e),!u)return He(e,s)}else{var h=g(e),_=h==Zt||h==Qt;if(re(e))return tt(e,u);if(h==tn||h==Kt||_&&!a){if(s=f||_?{}:Pt(e),!u)return f?rt(e,Xe(s,e)):nt(e,Ye(s,e))}else{if(!z[h])return a?e:{};s=Nt(e,h,u)}}o||=new i;var v=o.get(e);if(v)return v;o.set(e,s),Ht(e)?e.forEach(function(r){s.add(yn(r,t,n,r,e,o))}):Rt(e)&&e.forEach(function(r,i){s.set(i,yn(r,t,n,i,e,o))});var y=m?void 0:(p?f?c:d:f?te:l)(e);return ce(y||e,function(r,i){y&&(i=r,r=e[i]),ke(s,i,yn(r,t,n,i,e,o))}),s}var bn=4;function B(e){return yn(e,bn)}function xn(e){for(var t=-1,n=e==null?0:e.length,r=0,i=[];++t<n;){var a=e[t];a&&(i[r++]=a)}return i}function Sn(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}function Cn(e,t,n,r){return s(e,function(e,i,a){t(r,e,n(e),a)}),r}function wn(e,t){return function(n,r){var i=A(n)?Sn:Cn,a=t?t():{};return i(n,e,o(r,2),a)}}var Tn=Object.prototype,En=Tn.hasOwnProperty,Dn=je(function(e,t){e=Object(e);var r=-1,i=t.length,a=i>2?t[2]:void 0;for(a&&n(t[0],t[1],a)&&(i=1);++r<i;)for(var o=t[r],s=te(o),c=-1,l=s.length;++c<l;){var u=s[c],d=e[u];(d===void 0||ge(d,Tn[u])&&!En.call(e,u))&&(e[u]=o[u])}return e});function On(e){return me(e)&&de(e)}function kn(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}var An=200;function jn(e,t,n,i){var a=-1,o=Ue,s=!0,c=e.length,l=[],u=t.length;if(!c)return l;n&&(t=xe(t,ie(n))),i?(o=kn,s=!1):t.length>=An&&(o=r,s=!1,t=new _e(t));outer:for(;++a<c;){var d=e[a],f=n==null?d:n(d);if(d=i||d!==0?d:0,s&&f===f){for(var p=u;p--;)if(t[p]===f)continue outer;l.push(d)}else o(t,f,i)||l.push(d)}return l}var Mn=je(function(e,t){return On(e)?jn(e,Ke(t,1,On,!0)):[]});function Nn(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}function V(e,t,n){var r=e==null?0:e.length;return r?(t=n||t===void 0?1:ue(t),qe(e,t<0?0:t,r)):[]}function Pn(e,t,n){var r=e==null?0:e.length;return r?(t=n||t===void 0?1:ue(t),t=r-t,qe(e,0,t<0?0:t)):[]}function Fn(e,t){var n=[];return s(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function H(e,t){return(A(e)?Fe:Fn)(e,o(t,3))}function In(e){return function(t,n,r){var i=Object(t);if(!de(t)){var a=o(n,3);t=l(t),n=function(e){return a(i[e],e,i)}}var s=e(t,n,r);return s>-1?i[a?t[s]:s]:void 0}}var Ln=Math.max;function Rn(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:ue(n);return i<0&&(i=Ln(r+i,0)),Ae(e,o(t,3),i)}var zn=In(Rn);function U(e){return e&&e.length?e[0]:void 0}function W(e,t){return Ke(a(e,t),1)}var Bn=Object.prototype.hasOwnProperty,Vn=wn(function(e,t,n){Bn.call(e,n)?e[n].push(t):se(e,n,[t])}),Hn=Object.prototype.hasOwnProperty;function Un(e,t){return e!=null&&Hn.call(e,t)}function G(e,t){return e!=null&&_(e,t,Un)}var Wn=Math.max;function Gn(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:ue(n);return i<0&&(i=Wn(r+i,0)),Te(e,t,i)}var Kn=`[object Map]`,qn=`[object Set]`,Jn=Object.prototype.hasOwnProperty;function K(e){if(e==null)return!0;if(de(e)&&(A(e)||typeof e==`string`||typeof e.splice==`function`||re(e)||De(e)||ae(e)))return!e.length;var t=g(e);if(t==Kn||t==qn)return!e.size;if(y(e))return!p(e).length;for(var n in e)if(Jn.call(e,n))return!1;return!0}function q(e){return e===void 0}var Yn=`Expected a function`;function Xn(e){if(typeof e!=`function`)throw TypeError(Yn);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)}}function Zn(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}function J(e,t,n){var r=A(e)?Je:Zn,i=arguments.length<3;return r(e,o(t,4),n,i,s)}function Qn(e,t){return(A(e)?Fe:Fn)(e,Xn(o(t,3)))}var $n=v&&1/ve(new v([,-0]))[1]==1/0?function(e){return new v(e)}:L,er=200;function tr(e,t,n){var i=-1,a=Ue,o=e.length,s=!0,c=[],l=c;if(n)s=!1,a=kn;else if(o>=er){var u=t?null:$n(e);if(u)return ve(u);s=!1,a=r,l=new _e}else l=t?[]:c;outer:for(;++i<o;){var d=e[i],f=t?t(d):d;if(d=n||d!==0?d:0,s&&f===f){for(var p=l.length;p--;)if(l[p]===f)continue outer;t&&l.push(f),c.push(d)}else a(l,f,n)||(l!==c&&l.push(f),c.push(d))}return c}function nr(e){return e&&e.length?tr(e):[]}var rr=class{walk(e,t=[]){x(e.definition,(n,r)=>{let i=V(e.definition,r+1);if(n instanceof E)this.walkProdRef(n,i,t);else if(n instanceof O)this.walkTerminal(n,i,t);else if(n instanceof j)this.walkFlat(n,i,t);else if(n instanceof k)this.walkOption(n,i,t);else if(n instanceof le)this.walkAtLeastOne(n,i,t);else if(n instanceof D)this.walkAtLeastOneSep(n,i,t);else if(n instanceof Ee)this.walkManySep(n,i,t);else if(n instanceof N)this.walkMany(n,i,t);else if(n instanceof we)this.walkOr(n,i,t);else throw Error(`non exhaustive match`)})}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){let r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){let r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){let r=[new k({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){let r=ir(e,t,n);this.walk(e,r)}walkMany(e,t,n){let r=[new k({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){let r=ir(e,t,n);this.walk(e,r)}walkOr(e,t,n){let r=t.concat(n);x(e.definition,e=>{let t=new j({definition:[e]});this.walk(t,r)})}};function ir(e,t,n){return[new k({definition:[new O({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function ar(e){if(e instanceof E)return ar(e.referencedRule);if(e instanceof O)return cr(e);if(he(e))return or(e);if(Se(e))return sr(e);throw Error(`non exhaustive match`)}function or(e){let t=[],n=e.definition,r=0,i=n.length>r,a,o=!0;for(;i&&o;)a=n[r],o=Oe(a),t=t.concat(ar(a)),r+=1,i=n.length>r;return nr(t)}function sr(e){return nr(R(a(e.definition,e=>ar(e))))}function cr(e){return[e.terminalType]}const lr=`_~IN~_`;var ur=class extends rr{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){let r=fr(e.referencedRule,e.idx)+this.topProd.name,i=ar(new j({definition:t.concat(n)}));this.follows[r]=i}};function dr(e){let t={};return x(e,e=>{S(t,new ur(e).startWalking())}),t}function fr(e,t){return e.name+t+lr}let pr={};const mr=new e;function hr(e){let t=e.toString();if(pr.hasOwnProperty(t))return pr[t];{let e=mr.pattern(t);return pr[t]=e,e}}function gr(){pr={}}const _r=`Complement Sets are not supported for first char optimization`,vr=`Unable to use "first char" lexer optimizations:
|
|
2
|
+
`;function yr(e,t=!1){try{let t=hr(e);return br(t.value,{},t.flags.ignoreCase)}catch(n){if(n.message===_r)t&&Ie(`${vr}\tUnable to optimize: < ${e.toString()} >\n Complement Sets cannot be automatically optimized.
|
|
3
3
|
This will disable the lexer's first char optimizations.
|
|
4
4
|
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n=``;t&&(n=`
|
|
5
5
|
This will disable the lexer's first char optimizations.
|
|
6
|
-
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),Re(`${
|
|
7
|
-
`],tracer:(e,t)=>t()});let n=t.tracer;n(`initCharCodeToOptimizedIndexMap`,()=>{
|
|
6
|
+
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),Re(`${vr}\n\tFailed parsing: < ${e.toString()} >\n\tUsing the @chevrotain/regexp-to-ast library\n Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function br(e,t,n){switch(e.type){case`Disjunction`:for(let r=0;r<e.value.length;r++)br(e.value[r],t,n);break;case`Alternative`:let r=e.value;for(let e=0;e<r.length;e++){let i=r[e];switch(i.type){case`EndAnchor`:case`GroupBackReference`:case`Lookahead`:case`NegativeLookahead`:case`StartAnchor`:case`WordBoundary`:case`NonWordBoundary`:continue}let a=i;switch(a.type){case`Character`:xr(a.value,t,n);break;case`Set`:if(a.complement===!0)throw Error(_r);x(a.value,e=>{if(typeof e==`number`)xr(e,t,n);else{let r=e;if(n===!0)for(let e=r.from;e<=r.to;e++)xr(e,t,n);else{for(let e=r.from;e<=r.to&&e<oi;e++)xr(e,t,n);if(r.to>=oi){let e=r.from>=oi?r.from:oi,n=r.to,i=ci(e),a=ci(n);for(let e=i;e<=a;e++)t[e]=e}}}});break;case`Group`:br(a.value,t,n);break;default:throw Error(`Non Exhaustive Match`)}let o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type===`Group`&&wr(a)===!1||a.type!==`Group`&&o===!1)break}break;default:throw Error(`non exhaustive match!`)}return F(t)}function xr(e,t,n){let r=ci(e);t[r]=r,n===!0&&Sr(e,t)}function Sr(e,t){let n=String.fromCharCode(e),r=n.toUpperCase();if(r!==n){let e=ci(r.charCodeAt(0));t[e]=e}else{let e=n.toLowerCase();if(e!==n){let n=ci(e.charCodeAt(0));t[n]=n}}}function Cr(e,t){return zn(e.value,e=>{if(typeof e==`number`)return T(t,e);{let n=e;return zn(t,e=>n.from<=e&&e<=n.to)!==void 0}})}function wr(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?A(e.value)?P(e.value,wr):wr(e.value):!1}var Tr=class extends t{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case`Lookahead`:this.visitLookahead(e);return;case`NegativeLookahead`:this.visitNegativeLookahead(e);return}super.visitChildren(e)}}visitCharacter(e){T(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?Cr(e,this.targetCharCodes)===void 0&&(this.found=!0):Cr(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function Er(e,t){if(t instanceof RegExp){let n=hr(t),r=new Tr(e);return r.visit(n),r.found}else return zn(t,t=>T(e,t.charCodeAt(0)))!==void 0}const Dr=`PATTERN`,Or=`defaultMode`,kr=`modes`;let Ar=typeof RegExp(`(?:)`).sticky==`boolean`;function jr(e,t){t=Dn(t,{useSticky:Ar,debug:!1,safeMode:!1,positionTracking:`full`,lineTerminatorCharacters:[`\r`,`
|
|
7
|
+
`],tracer:(e,t)=>t()});let n=t.tracer;n(`initCharCodeToOptimizedIndexMap`,()=>{li()});let r;n(`Reject Lexer.NA`,()=>{r=Qn(e,e=>e[Dr]===X.NA)});let i=!1,o;n(`Transform Patterns`,()=>{i=!1,o=a(r,e=>{let n=e[Dr];if(I(n)){let e=n.source;return e.length===1&&e!==`^`&&e!==`$`&&e!==`.`&&!n.ignoreCase?e:e.length===2&&e[0]===`\\`&&!T([`d`,`D`,`s`,`S`,`t`,`r`,`n`,`t`,`0`,`c`,`b`,`B`,`f`,`v`,`w`,`W`],e[1])?e[1]:t.useSticky?Yr(n):Jr(n)}else if(ye(n))return i=!0,{exec:n};else if(typeof n==`object`)return i=!0,n;else if(typeof n==`string`){if(n.length===1)return n;{let e=n.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`),r=new RegExp(e);return t.useSticky?Yr(r):Jr(r)}}else throw Error(`non exhaustive match`)})});let s,c,l,u,d;n(`misc mapping`,()=>{s=a(r,e=>e.tokenTypeIdx),c=a(r,e=>{let t=e.GROUP;if(t!==X.SKIPPED){if(b(t))return t;if(q(t))return!1;throw Error(`non exhaustive match`)}}),l=a(r,e=>{let t=e.LONGER_ALT;if(t)return A(t)?a(t,e=>Gn(r,e)):[Gn(r,t)]}),u=a(r,e=>e.PUSH_MODE),d=a(r,e=>G(e,`POP_MODE`))});let f;n(`Line Terminator Handling`,()=>{let e=ii(t.lineTerminatorCharacters);f=a(r,e=>!1),t.positionTracking!==`onlyOffset`&&(f=a(r,t=>G(t,`LINE_BREAKS`)?!!t.LINE_BREAKS:ni(t,e)===!1&&Er(e,t.PATTERN)))});let p,m,h,g;n(`Misc Mapping #2`,()=>{p=a(r,$r),m=a(o,ei),h=J(r,(e,t)=>{let n=t.GROUP;return b(n)&&n!==X.SKIPPED&&(e[n]=[]),e},{}),g=a(o,(e,t)=>({pattern:o[t],longerAlt:l[t],canLineTerminator:f[t],isCustom:p[t],short:m[t],group:c[t],push:u[t],pop:d[t],tokenTypeIdx:s[t],tokenType:r[t]}))});let _=!0,v=[];return t.safeMode||n(`First Char Optimization`,()=>{v=J(r,(e,n,r)=>{if(typeof n.PATTERN==`string`)ai(e,ci(n.PATTERN.charCodeAt(0)),g[r]);else if(A(n.START_CHARS_HINT)){let t;x(n.START_CHARS_HINT,n=>{let i=ci(typeof n==`string`?n.charCodeAt(0):n);t!==i&&(t=i,ai(e,i,g[r]))})}else if(I(n.PATTERN))if(n.PATTERN.unicode)_=!1,t.ensureOptimizations&&Re(`${vr}\tUnable to analyze < ${n.PATTERN.toString()} > pattern.\n The regexp unicode flag is not currently supported by the regexp-to-ast library.
|
|
8
8
|
This will disable the lexer's first char optimizations.
|
|
9
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let i=
|
|
10
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),_=!1;return e},[])}),{emptyGroups:h,patternIdxToConfig:g,charCodeToPatternIdxToConfig:v,hasCustom:i,canBeOptimized:_}}function
|
|
9
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let i=yr(n.PATTERN,t.ensureOptimizations);K(i)&&(_=!1),x(i,t=>{ai(e,t,g[r])})}else t.ensureOptimizations&&Re(`${vr}\tTokenType: <${n.name}> is using a custom token pattern without providing <start_chars_hint> parameter.\n This will disable the lexer's first char optimizations.
|
|
10
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),_=!1;return e},[])}),{emptyGroups:h,patternIdxToConfig:g,charCodeToPatternIdxToConfig:v,hasCustom:i,canBeOptimized:_}}function Mr(e,t){let n=[],r=Pr(e);n=n.concat(r.errors);let i=Fr(r.valid),a=i.valid;return n=n.concat(i.errors),n=n.concat(Nr(a)),n=n.concat(Ur(a)),n=n.concat(Wr(a,t)),n=n.concat(Gr(a)),n}function Nr(e){let t=[],n=H(e,e=>I(e[Dr]));return t=t.concat(Lr(n)),t=t.concat(Br(n)),t=t.concat(Vr(n)),t=t.concat(Hr(n)),t=t.concat(Rr(n)),t}function Pr(e){let t=H(e,e=>!G(e,Dr));return{errors:a(t,e=>({message:`Token Type: ->`+e.name+`<- missing static 'PATTERN' property`,type:Y.MISSING_PATTERN,tokenTypes:[e]})),valid:Mn(e,t)}}function Fr(e){let t=H(e,e=>{let t=e[Dr];return!I(t)&&!ye(t)&&!G(t,`exec`)&&!b(t)});return{errors:a(t,e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.`,type:Y.INVALID_PATTERN,tokenTypes:[e]})),valid:Mn(e,t)}}const Ir=/[^\\][$]/;function Lr(e){class n extends t{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}return a(H(e,e=>{let t=e.PATTERN;try{let e=hr(t),r=new n;return r.visit(e),r.found}catch{return Ir.test(t.source)}}),e=>({message:`Unexpected RegExp Anchor Error:
|
|
11
11
|
Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
|
|
12
|
-
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:Y.EOI_ANCHOR_FOUND,tokenTypes:[e]}))}function
|
|
12
|
+
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:Y.EOI_ANCHOR_FOUND,tokenTypes:[e]}))}function Rr(e){return a(H(e,e=>e.PATTERN.test(``)),e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' must not match an empty string`,type:Y.EMPTY_MATCH_PATTERN,tokenTypes:[e]}))}const zr=/[^\\[][\^]|^\^/;function Br(e){class n extends t{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}return a(H(e,e=>{let t=e.PATTERN;try{let e=hr(t),r=new n;return r.visit(e),r.found}catch{return zr.test(t.source)}}),e=>({message:`Unexpected RegExp Anchor Error:
|
|
13
13
|
Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
|
|
14
|
-
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:Y.SOI_ANCHOR_FOUND,tokenTypes:[e]}))}function
|
|
15
|
-
`,type:Y.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),G(e,
|
|
16
|
-
`,type:Y.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),G(e,
|
|
14
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:Y.SOI_ANCHOR_FOUND,tokenTypes:[e]}))}function Vr(e){return a(H(e,e=>{let t=e[Dr];return t instanceof RegExp&&(t.multiline||t.global)}),e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' may NOT contain global('g') or multiline('m')`,type:Y.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]}))}function Hr(e){let t=[],n=a(e,n=>J(e,(e,r)=>n.PATTERN.source===r.PATTERN.source&&!T(t,r)&&r.PATTERN!==X.NA?(t.push(r),e.push(r),e):e,[]));return n=xn(n),a(H(n,e=>e.length>1),e=>{let t=a(e,e=>e.name);return{message:`The same RegExp pattern ->${U(e).PATTERN}<-has been used in all of the following Token Types: ${t.join(`, `)} <-`,type:Y.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}})}function Ur(e){return a(H(e,e=>{if(!G(e,`GROUP`))return!1;let t=e.GROUP;return t!==X.SKIPPED&&t!==X.NA&&!b(t)}),e=>({message:`Token Type: ->`+e.name+`<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String`,type:Y.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]}))}function Wr(e,t){return a(H(e,e=>e.PUSH_MODE!==void 0&&!T(t,e.PUSH_MODE)),e=>({message:`Token Type: ->${e.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${e.PUSH_MODE}<-which does not exist`,type:Y.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}))}function Gr(e){let t=[],n=J(e,(e,t,n)=>{let r=t.PATTERN;return r===X.NA||(b(r)?e.push({str:r,idx:n,tokenType:t}):I(r)&&qr(r)&&e.push({str:r.source,idx:n,tokenType:t})),e},[]);return x(e,(e,r)=>{x(n,({str:n,idx:i,tokenType:a})=>{if(r<i&&Kr(n,e.PATTERN)){let n=`Token: ->${a.name}<- can never be matched.\nBecause it appears AFTER the Token Type ->${e.name}<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:n,type:Y.UNREACHABLE_PATTERN,tokenTypes:[e,a]})}})}),t}function Kr(e,t){if(I(t)){let n=t.exec(e);return n!==null&&n.index===0}else if(ye(t))return t(e,0,[],{});else if(G(t,`exec`))return t.exec(e,0,[],{});else if(typeof t==`string`)return t===e;else throw Error(`non exhaustive match`)}function qr(e){return zn([`.`,`\\`,`[`,`]`,`|`,`^`,`$`,`(`,`)`,`?`,`*`,`+`,`{`],t=>e.source.indexOf(t)!==-1)===void 0}function Jr(e){let t=e.ignoreCase?`i`:``;return RegExp(`^(?:${e.source})`,t)}function Yr(e){let t=e.ignoreCase?`iy`:`y`;return RegExp(`${e.source}`,t)}function Xr(e,t,n){let r=[];return G(e,Or)||r.push({message:`A MultiMode Lexer cannot be initialized without a <`+Or+`> property in its definition
|
|
15
|
+
`,type:Y.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),G(e,kr)||r.push({message:`A MultiMode Lexer cannot be initialized without a <`+kr+`> property in its definition
|
|
16
|
+
`,type:Y.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),G(e,kr)&&G(e,Or)&&!G(e.modes,e.defaultMode)&&r.push({message:`A MultiMode Lexer cannot be initialized with a ${Or}: <${e.defaultMode}>which does not exist\n`,type:Y.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),G(e,kr)&&x(e.modes,(e,t)=>{x(e,(n,i)=>{q(n)?r.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${t}> at index: <${i}>\n`,type:Y.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):G(n,`LONGER_ALT`)&&x(A(n.LONGER_ALT)?n.LONGER_ALT:[n.LONGER_ALT],i=>{!q(i)&&!T(e,i)&&r.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${i.name}> on token <${n.name}> outside of mode <${t}>\n`,type:Y.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),r}function Zr(e,t,n){let r=[],i=!1,a=Qn(xn(R(F(e.modes))),e=>e[Dr]===X.NA),o=ii(n);return t&&x(a,e=>{let t=ni(e,o);if(t!==!1){let n={message:ri(e,t),type:t.issue,tokenType:e};r.push(n)}else G(e,`LINE_BREAKS`)?e.LINE_BREAKS===!0&&(i=!0):Er(o,e.PATTERN)&&(i=!0)}),t&&!i&&r.push({message:`Warning: No LINE_BREAKS Found.
|
|
17
17
|
This Lexer has been defined to track line and column information,
|
|
18
18
|
But none of the Token Types can be identified as matching a line terminator.
|
|
19
19
|
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
|
|
20
|
-
for details.`,type:Y.NO_LINE_BREAKS_FLAGS}),r}function
|
|
20
|
+
for details.`,type:Y.NO_LINE_BREAKS_FLAGS}),r}function Qr(e){let t={};return x(l(e),n=>{let r=e[n];if(A(r))t[n]=[];else throw Error(`non exhaustive match`)}),t}function $r(e){let t=e.PATTERN;if(I(t))return!1;if(ye(t)||G(t,`exec`))return!0;if(b(t))return!1;throw Error(`non exhaustive match`)}function ei(e){return b(e)&&e.length===1?e.charCodeAt(0):!1}const ti={test:function(e){let t=e.length;for(let n=this.lastIndex;n<t;n++){let t=e.charCodeAt(n);if(t===10)return this.lastIndex=n+1,!0;if(t===13)return e.charCodeAt(n+1)===10?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},lastIndex:0};function ni(e,t){if(G(e,`LINE_BREAKS`))return!1;if(I(e.PATTERN)){try{Er(t,e.PATTERN)}catch(e){return{issue:Y.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}else if(b(e.PATTERN))return!1;else if($r(e))return{issue:Y.CUSTOM_LINE_BREAK};else throw Error(`non exhaustive match`)}function ri(e,t){if(t.issue===Y.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
|
|
21
21
|
\tThe problem is in the <${e.name}> Token Type\n\t Root cause: ${t.errMsg}.\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===Y.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
|
|
22
|
-
\tThe problem is in the <${e.name}> Token Type\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error(`non exhaustive match`)}function
|
|
23
|
-
`,`\r`],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:
|
|
24
|
-
a boolean 2nd argument is no longer supported`);this.config=S({},
|
|
25
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error(`"safeMode" and "ensureOptimizations" flags are mutually exclusive.`);this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),A(e)?n={modes:{defaultMode:B(e)},defaultMode:
|
|
22
|
+
\tThe problem is in the <${e.name}> Token Type\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error(`non exhaustive match`)}function ii(e){return a(e,e=>b(e)?e.charCodeAt(0):e)}function ai(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}const oi=256;let si=[];function ci(e){return e<256?e:si[e]}function li(){if(K(si)){si=Array(65536);for(let e=0;e<65536;e++)si[e]=e>255?255+~~(e/255):e}}function ui(e,t){let n=e.tokenTypeIdx;return n===t.tokenTypeIdx?!0:t.isParent===!0&&t.categoryMatchesMap[n]===!0}function di(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}let fi=1;const pi={};function mi(e){let t=hi(e);gi(t),vi(t),_i(t),x(t,e=>{e.isParent=e.categoryMatches.length>0})}function hi(e){let t=B(e),n=e,r=!0;for(;r;){n=xn(R(a(n,e=>e.CATEGORIES)));let e=Mn(n,t);t=t.concat(e),K(e)?r=!1:n=e}return t}function gi(e){x(e,e=>{bi(e)||(pi[fi]=e,e.tokenTypeIdx=fi++),xi(e)&&!A(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),xi(e)||(e.CATEGORIES=[]),Si(e)||(e.categoryMatches=[]),Ci(e)||(e.categoryMatchesMap={})})}function _i(e){x(e,e=>{e.categoryMatches=[],x(e.categoryMatchesMap,(t,n)=>{e.categoryMatches.push(pi[n].tokenTypeIdx)})})}function vi(e){x(e,e=>{yi([],e)})}function yi(e,t){x(e,e=>{t.categoryMatchesMap[e.tokenTypeIdx]=!0}),x(t.CATEGORIES,n=>{let r=e.concat(t);T(r,n)||yi(r,n)})}function bi(e){return G(e,`tokenTypeIdx`)}function xi(e){return G(e,`CATEGORIES`)}function Si(e){return G(e,`categoryMatches`)}function Ci(e){return G(e,`categoryMatchesMap`)}function wi(e){return G(e,`tokenTypeIdx`)}const Ti={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,n,r,i){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters.`}};var Y;(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`})(Y||={});const Ei={deferDefinitionErrorsHandling:!1,positionTracking:`full`,lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
|
|
23
|
+
`,`\r`],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:Ti,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Ei);var X=class{constructor(e,t=Ei){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(e,t)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=Le(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}else return t()},typeof t==`boolean`)throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
|
|
24
|
+
a boolean 2nd argument is no longer supported`);this.config=S({},Ei,t);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 n,r=!0;this.TRACE_INIT(`Lexer Config handling`,()=>{if(this.config.lineTerminatorsPattern===Ei.lineTerminatorsPattern)this.config.lineTerminatorsPattern=ti;else if(this.config.lineTerminatorCharacters===Ei.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
|
|
25
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error(`"safeMode" and "ensureOptimizations" flags are mutually exclusive.`);this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),A(e)?n={modes:{defaultMode:B(e)},defaultMode:Or}:(r=!1,n=B(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT(`performRuntimeChecks`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Xr(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT(`performWarningRuntimeChecks`,()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Zr(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},x(n.modes,(e,t)=>{n.modes[t]=Qn(e,e=>q(e))});let i=l(n.modes);if(x(n.modes,(e,n)=>{this.TRACE_INIT(`Mode: <${n}> processing`,()=>{if(this.modes.push(n),this.config.skipValidations===!1&&this.TRACE_INIT(`validatePatterns`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Mr(e,i))}),K(this.lexerDefinitionErrors)){mi(e);let r;this.TRACE_INIT(`analyzeTokenTypes`,()=>{r=jr(e,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[n]=r.patternIdxToConfig,this.charCodeToPatternIdxToConfig[n]=r.charCodeToPatternIdxToConfig,this.emptyGroups=S({},this.emptyGroups,r.emptyGroups),this.hasCustom=r.hasCustom||this.hasCustom,this.canModeBeOptimized[n]=r.canBeOptimized}})}),this.defaultMode=n.defaultMode,!K(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let e=a(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
|
|
26
26
|
`);throw Error(`Errors detected in definition of Lexer:
|
|
27
|
-
`+e)}x(this.lexerDefinitionWarning,e=>{Ie(e.message)}),this.TRACE_INIT(`Choosing sub-methods implementations`,()=>{if(
|
|
28
|
-
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT(`clearRegExpParserCache`,()=>{
|
|
27
|
+
`+e)}x(this.lexerDefinitionWarning,e=>{Ie(e.message)}),this.TRACE_INIT(`Choosing sub-methods implementations`,()=>{if(Ar?(this.chopInput=Me,this.match=this.matchWithTest):(this.updateLastIndex=L,this.match=this.matchWithExec),r&&(this.handleModes=L),this.trackStartLines===!1&&(this.computeNewColumn=Me),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=L),/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 e=J(this.canModeBeOptimized,(e,t,n)=>(t===!1&&e.push(n),e),[]);if(t.ensureOptimizations&&!K(e))throw Error(`Lexer Modes: < ${e.join(`, `)} > cannot be optimized.\n Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
|
|
28
|
+
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT(`clearRegExpParserCache`,()=>{gr()}),this.TRACE_INIT(`toFastProperties`,()=>{ze(this)})})}tokenize(e,t=this.defaultMode){if(!K(this.lexerDefinitionErrors)){let e=a(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
|
|
29
29
|
`);throw Error(`Unable to Tokenize because Errors detected in definition of Lexer:
|
|
30
|
-
`+e)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=e,v=_.length,y=0,ee=0,b=this.hasCustom?0:Math.floor(e.length/10),x=Array(b),te=[],ne=this.trackStartLines?1:void 0,S=this.trackStartLines?1:void 0,re=
|
|
31
|
-
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return G(e,
|
|
32
|
-
but found: '`+U(t).image+`'`;return r?`Expecting: `+r+o:`Expecting: one of these possible Token sequences:\n${a(a(J(e,(e,t)=>e.concat(t),[]),e=>`[${a(e,e=>
|
|
30
|
+
`+e)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=e,v=_.length,y=0,ee=0,b=this.hasCustom?0:Math.floor(e.length/10),x=Array(b),te=[],ne=this.trackStartLines?1:void 0,S=this.trackStartLines?1:void 0,re=Qr(this.emptyGroups),ie=this.trackStartLines,ae=this.config.lineTerminatorsPattern,oe=0,C=[],w=[],se=[],T=[];Object.freeze(T);let E;function ce(){return C}function le(e){let t=ci(e),n=w[t];return n===void 0?T:n}let ue=e=>{if(se.length===1&&e.tokenType.PUSH_MODE===void 0){let t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);te.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{se.pop();let e=Nn(se);C=this.patternIdxToConfig[e],w=this.charCodeToPatternIdxToConfig[e],oe=C.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;E=w&&t?le:ce}};function de(e){se.push(e),w=this.charCodeToPatternIdxToConfig[e],C=this.patternIdxToConfig[e],oe=C.length,oe=C.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;E=w&&t?le:ce}de.call(this,t);let D,fe=this.config.recoveryEnabled;for(;y<v;){s=null;let t=_.charCodeAt(y),b=E(t),w=b.length;for(n=0;n<w;n++){D=b[n];let r=D.pattern;c=null;let u=D.short;if(u===!1?D.isCustom===!0?(g=r.exec(_,y,x,re),g===null?s=null:(s=g[0],g.payload!==void 0&&(c=g.payload))):(this.updateLastIndex(r,y),s=this.match(r,e,y)):t===u&&(s=r),s!==null){if(o=D.longerAlt,o!==void 0){let t=o.length;for(i=0;i<t;i++){let t=C[o[i]],n=t.pattern;if(l=null,t.isCustom===!0?(g=n.exec(_,y,x,re),g===null?a=null:(a=g[0],g.payload!==void 0&&(l=g.payload))):(this.updateLastIndex(n,y),a=this.match(n,e,y)),a&&a.length>s.length){s=a,c=l,D=t;break}}}break}}if(s!==null){if(u=s.length,d=D.group,d!==void 0&&(f=D.tokenTypeIdx,p=this.createTokenInstance(s,y,f,D.tokenType,ne,S,u),this.handlePayload(p,c),d===!1?ee=this.addToken(x,ee,p):re[d].push(p)),e=this.chopInput(e,u),y+=u,S=this.computeNewColumn(S,u),ie===!0&&D.canLineTerminator===!0){let e=0,t,n;ae.lastIndex=0;do t=ae.test(s),t===!0&&(n=ae.lastIndex-1,e++);while(t===!0);e!==0&&(ne+=e,S=u-n,this.updateTokenEndLineColumnLocation(p,d,n,e,ne,S,u))}this.handleModes(D,ue,de,p)}else{let t=y,n=ne,i=S,a=fe===!1;for(;a===!1&&y<v;)for(e=this.chopInput(e,1),y++,r=0;r<oe;r++){let t=C[r],n=t.pattern,i=t.short;if(i===!1?t.isCustom===!0?a=n.exec(_,y,x,re)!==null:(this.updateLastIndex(n,y),a=n.exec(e)!==null):_.charCodeAt(y)===i&&(a=!0),a===!0)break}if(m=y-t,S=this.computeNewColumn(S,m),h=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(_,t,m,n,i),te.push({offset:t,line:n,column:i,length:m,message:h}),fe===!1)break}}return this.hasCustom||(x.length=ee),{tokens:x,groups:re,errors:te}}handleModes(e,t,n,r){if(e.pop===!0){let i=e.push;t(r),i!==void 0&&n.call(this,i)}else e.push!==void 0&&n.call(this,e.push)}chopInput(e,t){return e.substring(t)}updateLastIndex(e,t){e.lastIndex=t}updateTokenEndLineColumnLocation(e,t,n,r,i,a,o){let s,c;t!==void 0&&(s=n===o-1,c=s?-1:0,r===1&&s===!0||(e.endLine=i+c,e.endColumn=a-1+-c))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,n,r){return{image:e,startOffset:t,tokenTypeIdx:n,tokenType:r}}createStartOnlyToken(e,t,n,r,i,a){return{image:e,startOffset:t,startLine:i,startColumn:a,tokenTypeIdx:n,tokenType:r}}createFullToken(e,t,n,r,i,a,o){return{image:e,startOffset:t,endOffset:t+o-1,startLine:i,endLine:i,startColumn:a,endColumn:a+o-1,tokenTypeIdx:n,tokenType:r}}addTokenUsingPush(e,t,n){return e.push(n),t}addTokenUsingMemberAccess(e,t,n){return e[t]=n,t++,t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){t!==null&&(e.payload=t)}matchWithTest(e,t,n){return e.test(t)===!0?t.substring(n,e.lastIndex):null}matchWithExec(e,t){let n=e.exec(t);return n===null?null:n[0]}};X.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.`,X.NA=/NOT_APPLICABLE/;function Di(e){return Oi(e)?e.LABEL:e.name}function Oi(e){return b(e.LABEL)&&e.LABEL!==``}const ki=`categories`,Ai=`label`,ji=`group`,Mi=`push_mode`,Ni=`pop_mode`,Pi=`longer_alt`,Fi=`line_breaks`,Ii=`start_chars_hint`;function Li(e){return Ri(e)}function Ri(e){let t=e.pattern,n={};if(n.name=e.name,q(t)||(n.PATTERN=t),G(e,`parent`))throw`The parent property is no longer supported.
|
|
31
|
+
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return G(e,ki)&&(n.CATEGORIES=e[ki]),mi([n]),G(e,Ai)&&(n.LABEL=e[Ai]),G(e,ji)&&(n.GROUP=e[ji]),G(e,Ni)&&(n.POP_MODE=e[Ni]),G(e,Mi)&&(n.PUSH_MODE=e[Mi]),G(e,Pi)&&(n.LONGER_ALT=e[Pi]),G(e,Fi)&&(n.LINE_BREAKS=e[Fi]),G(e,Ii)&&(n.START_CHARS_HINT=e[Ii]),n}const zi=Li({name:`EOF`,pattern:X.NA});mi([zi]);function Bi(e,t,n,r,i,a,o,s){return{image:t,startOffset:n,endOffset:r,startLine:i,endLine:a,startColumn:o,endColumn:s,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function Vi(e,t){return ui(e,t)}const Hi={buildMismatchTokenMessage({expected:e,actual:t,previous:n,ruleName:r}){return`Expecting ${Oi(e)?`--> ${Di(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:n,customUserDescription:r,ruleName:i}){let o=`
|
|
32
|
+
but found: '`+U(t).image+`'`;return r?`Expecting: `+r+o:`Expecting: one of these possible Token sequences:\n${a(a(J(e,(e,t)=>e.concat(t),[]),e=>`[${a(e,e=>Di(e)).join(`, `)}]`),(e,t)=>` ${t+1}. ${e}`).join(`
|
|
33
33
|
`)}`+o},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:n,ruleName:r}){let i=`
|
|
34
|
-
but found: '`+U(t).image+`'`;return n?`Expecting: `+n+i:`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::\n <${a(e,e=>`[${a(e,e=>
|
|
35
|
-
inside top level rule: ->`+e.name+`<-`}},
|
|
34
|
+
but found: '`+U(t).image+`'`;return n?`Expecting: `+n+i:`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::\n <${a(e,e=>`[${a(e,e=>Di(e)).join(`,`)}]`).join(` ,`)}>`+i}};Object.freeze(Hi);const Ui={buildRuleNotFoundError(e,t){return`Invalid grammar, reference to a rule which is not defined: ->`+t.nonTerminalName+`<-
|
|
35
|
+
inside top level rule: ->`+e.name+`<-`}},Wi={buildDuplicateFoundError(e,t){function n(e){return e instanceof O?e.terminalType.name:e instanceof E?e.nonTerminalName:``}let r=e.name,i=U(t),a=i.idx,o=M(i),s=n(i),c=`->${o}${a>0?a:``}<- ${s?`with argument: ->${s}<-`:``}
|
|
36
36
|
appears more than once (${t.length} times) in the top level rule: ->${r}<-.
|
|
37
37
|
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
|
|
38
38
|
`;return c=c.replace(/[ \t]+/g,` `),c=c.replace(/\s\s+/g,`
|
|
39
|
-
`),c},buildNamespaceConflictError(e){return`Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=a(e.prefixPath,e=>
|
|
40
|
-
For Further details.`,r},buildEmptyRepetitionError(e){let t=M(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis 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.\nOnly the last alternative may be an empty alternative.`},buildTooManyAlternativesError(e){return`An Alternation cannot have more than 256 alternatives:\n<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\n has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name;return`Left Recursion found in grammar.\nrule: <${t}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${`${t} --> ${a(e.leftRecursionPath,e=>e.name).concat([t]).join(` --> `)}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return`deprecated`},buildDuplicateRuleNameError(e){let t;return t=e.topLevelRule instanceof be?e.topLevelRule.name:e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function Ha(e,t){let n=new Ua(e,t);return n.resolveRefs(),n.errors}var Ua=class extends w{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){x(F(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let t=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:t,type:$.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},Wa=class extends ei{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName=``,this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error(`The path does not start with the walker's top Rule!`);return this.ruleStack=B(this.path.ruleStack).reverse(),this.occurrenceStack=B(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let r=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,r)}}updateExpectedNext(){K(this.ruleStack)?(this.nextProductionName=``,this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},Ga=class extends Wa{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName=``,this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,n){this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found&&(this.possibleTokTypes=ni(new j({definition:t.concat(n)})),this.found=!0)}},Ka=class extends ei{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},qa=class extends Ka{walkMany(e,t,n){if(e.idx===this.occurrence){let e=U(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof O&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,n)}},Ja=class extends Ka{walkManySep(e,t,n){if(e.idx===this.occurrence){let e=U(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof O&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,n)}},Ya=class extends Ka{walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){let e=U(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof O&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,n)}},Xa=class extends Ka{walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){let e=U(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof O&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,n)}};function Za(e,t,n=[]){n=B(n);let r=[],i=0;function a(t){return t.concat(V(e,i+1))}function o(e){let i=Za(a(e),t,n);return r.concat(i)}for(;n.length<t&&i<e.length;){let t=e[i];if(t instanceof j||t instanceof E)return o(t.definition);if(t instanceof k)r=o(t.definition);else if(t instanceof le)return o(t.definition.concat([new N({definition:t.definition})]));else if(t instanceof D)return o([new j({definition:t.definition}),new N({definition:[new O({terminalType:t.separator})].concat(t.definition)})]);else if(t instanceof Ee)r=o(t.definition.concat([new N({definition:[new O({terminalType:t.separator})].concat(t.definition)})]));else if(t instanceof N)r=o(t.definition.concat([new N({definition:t.definition})]));else if(t instanceof we)return x(t.definition,e=>{K(e.definition)===!1&&(r=o(e.definition))}),r;else if(t instanceof O)n.push(t.terminalType);else throw Error(`non exhaustive match`);i++}return r.push({partialPath:n,suffixDef:V(e,i)}),r}function Qa(e,t,n,r){let i=`EXIT_NONE_TERMINAL`,a=[i],o=`EXIT_ALTERNATIVE`,s=!1,c=t.length,l=c-r-1,u=[],d=[];for(d.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!K(d);){let e=d.pop();if(e===o){s&&fr(d).idx<=l&&d.pop();continue}let r=e.def,f=e.idx,p=e.ruleStack,m=e.occurrenceStack;if(K(r))continue;let h=r[0];if(h===i){let e={idx:f,def:V(r),ruleStack:hr(p),occurrenceStack:hr(m)};d.push(e)}else if(h instanceof O)if(f<c-1){let e=f+1,i=t[e];if(n(i,h.terminalType)){let t={idx:e,def:V(r),ruleStack:p,occurrenceStack:m};d.push(t)}}else if(f===c-1)u.push({nextTokenType:h.terminalType,nextTokenOccurrence:h.idx,ruleStack:p,occurrenceStack:m}),s=!0;else throw Error(`non exhaustive match`);else if(h instanceof E){let e=B(p);e.push(h.nonTerminalName);let t=B(m);t.push(h.idx);let n={idx:f,def:h.definition.concat(a,V(r)),ruleStack:e,occurrenceStack:t};d.push(n)}else if(h instanceof k){let e={idx:f,def:V(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t={idx:f,def:h.definition.concat(V(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof le){let e=new N({definition:h.definition,idx:h.idx}),t={idx:f,def:h.definition.concat([e],V(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof D){let e=new N({definition:[new O({terminalType:h.separator})].concat(h.definition),idx:h.idx}),t={idx:f,def:h.definition.concat([e],V(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof Ee){let e={idx:f,def:V(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new N({definition:[new O({terminalType:h.separator})].concat(h.definition),idx:h.idx}),n={idx:f,def:h.definition.concat([t],V(r)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof N){let e={idx:f,def:V(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new N({definition:h.definition,idx:h.idx}),n={idx:f,def:h.definition.concat([t],V(r)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof we)for(let e=h.definition.length-1;e>=0;e--){let t={idx:f,def:h.definition[e].definition.concat(V(r)),ruleStack:p,occurrenceStack:m};d.push(t),d.push(o)}else if(h instanceof j)d.push({idx:f,def:h.definition.concat(V(r)),ruleStack:p,occurrenceStack:m});else if(h instanceof be)d.push($a(h,f,p,m));else throw Error(`non exhaustive match`)}return u}function $a(e,t,n,r){let i=B(n);i.push(e.name);let a=B(r);return a.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:a}}var Z;(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`})(Z||={});function eo(e){if(e instanceof k||e===`Option`)return Z.OPTION;if(e instanceof N||e===`Repetition`)return Z.REPETITION;if(e instanceof le||e===`RepetitionMandatory`)return Z.REPETITION_MANDATORY;if(e instanceof D||e===`RepetitionMandatoryWithSeparator`)return Z.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof Ee||e===`RepetitionWithSeparator`)return Z.REPETITION_WITH_SEPARATOR;if(e instanceof we||e===`Alternation`)return Z.ALTERNATION;throw Error(`non exhaustive match`)}function to(e){let{occurrence:t,rule:n,prodType:r,maxLookahead:i}=e,a=eo(r);return a===Z.ALTERNATION?po(t,n,i):mo(t,n,a,i)}function no(e,t,n,r,i,a){let o=po(e,t,n);return a(o,r,_o(o)?ca:sa,i)}function ro(e,t,n,r,i,a){let o=mo(e,t,i,n),s=_o(o)?ca:sa;return a(o[0],s,r)}function io(e,t,n,r){let i=e.length,o=P(e,e=>P(e,e=>e.length===1));if(t)return function(t){let r=a(t,e=>e.GATE);for(let t=0;t<i;t++){let i=e[t],a=i.length,o=r[t];if(!(o!==void 0&&o.call(this)===!1))nextPath:for(let e=0;e<a;e++){let r=i[e],a=r.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),r[e])===!1)continue nextPath;return t}}};if(o&&!r){let t=J(a(e,e=>R(e)),(e,t,n)=>(x(t,t=>{G(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=n),x(t.categoryMatches,t=>{G(e,t)||(e[t]=n)})}),e),{});return function(){return t[this.LA(1).tokenTypeIdx]}}else return function(){for(let t=0;t<i;t++){let r=e[t],i=r.length;nextPath:for(let e=0;e<i;e++){let i=r[e],a=i.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),i[e])===!1)continue nextPath;return t}}}}function ao(e,t,n){let r=P(e,e=>e.length===1),i=e.length;if(r&&!n){let t=R(e);if(t.length===1&&K(t[0].categoryMatches)){let e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}else{let e=J(t,(e,t,n)=>(e[t.tokenTypeIdx]=!0,x(t.categoryMatches,t=>{e[t]=!0}),e),[]);return function(){return e[this.LA(1).tokenTypeIdx]===!0}}}else return function(){nextPath:for(let n=0;n<i;n++){let r=e[n],i=r.length;for(let e=0;e<i;e++)if(t(this.LA(e+1),r[e])===!1)continue nextPath;return!0}return!1}}var oo=class extends ei{constructor(e,t,n){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,n,r){return e.idx===this.targetOccurrence&&this.targetProdType===t?(this.restDef=n.concat(r),!0):!1}walkOption(e,t,n){this.checkIsTarget(e,Z.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,Z.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,Z.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,Z.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}},so=class extends w{constructor(e,t,n){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=n,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,Z.OPTION)}visitRepetition(e){this.checkIsTarget(e,Z.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,Z.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,Z.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,Z.ALTERNATION)}};function co(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=[];return t}function lo(e){let t=[``];for(let n=0;n<e.length;n++){let r=e[n],i=[];for(let e=0;e<t.length;e++){let n=t[e];i.push(n+`_`+r.tokenTypeIdx);for(let e=0;e<r.categoryMatches.length;e++){let t=`_`+r.categoryMatches[e];i.push(n+t)}}t=i}return t}function uo(e,t,n){for(let r=0;r<e.length;r++){if(r===n)continue;let i=e[r];for(let e=0;e<t.length;e++)if(i[t[e]]===!0)return!1}return!0}function fo(e,t){let n=a(e,e=>Za([e],1)),r=co(n.length),i=a(n,e=>{let t={};return x(e,e=>{x(lo(e.partialPath),e=>{t[e]=!0})}),t}),o=n;for(let e=1;e<=t;e++){let n=o;o=co(n.length);for(let a=0;a<n.length;a++){let s=n[a];for(let n=0;n<s.length;n++){let c=s[n].partialPath,l=s[n].suffixDef,u=lo(c);if(uo(i,u,a)||K(l)||c.length===t){let e=r[a];if(ho(e,c)===!1){e.push(c);for(let e=0;e<u.length;e++){let t=u[e];i[a][t]=!0}}}else{let t=Za(l,e+1,c);o[a]=o[a].concat(t),x(t,e=>{x(lo(e.partialPath),e=>{i[a][e]=!0})})}}}}return r}function po(e,t,n,r){let i=new so(e,Z.ALTERNATION,r);return t.accept(i),fo(i.result,n)}function mo(e,t,n,r){let i=new so(e,n);t.accept(i);let a=i.result,o=new oo(t,e,n).startWalking();return fo([new j({definition:a}),new j({definition:o})],r)}function ho(e,t){compareOtherPath:for(let n=0;n<e.length;n++){let r=e[n];if(r.length===t.length){for(let e=0;e<r.length;e++){let n=t[e],i=r[e];if(!(n===i||i.categoryMatchesMap[n.tokenTypeIdx]!==void 0))continue compareOtherPath}return!0}}return!1}function go(e,t){return e.length<t.length&&P(e,(e,n)=>{let r=t[n];return e===r||r.categoryMatchesMap[e.tokenTypeIdx]})}function _o(e){return P(e,e=>P(e,e=>P(e,e=>K(e.categoryMatches))))}function vo(e){return a(e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}),e=>Object.assign({type:$.CUSTOM_LOOKAHEAD_VALIDATION},e))}function yo(e,t,n,r){let i=W(e,e=>bo(e,n)),a=Io(e,t,n),o=W(e,e=>Mo(e,n)),s=W(e,t=>wo(t,e,r,n));return i.concat(a,o,s)}function bo(e,t){let n=new Co;e.accept(n);let r=n.allProductions;return a(F(Ne(Dr(r,xo),e=>e.length>1)),n=>{let r=U(n),i=t.buildDuplicateFoundError(e,n),a=M(r),o={message:i,type:$.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:a,occurrence:r.idx},s=So(r);return s&&(o.parameter=s),o})}function xo(e){return`${M(e)}_#_${e.idx}_#_${So(e)}`}function So(e){return e instanceof O?e.terminalType.name:e instanceof E?e.nonTerminalName:``}var Co=class extends w{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}};function wo(e,t,n,r){let i=[];if(J(t,(t,n)=>n.name===e.name?t+1:t,0)>1){let t=r.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});i.push({message:t,type:$.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function To(e,t,n){let r=[],i;return T(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,r.push({message:i,type:$.INVALID_RULE_OVERRIDE,ruleName:e})),r}function Eo(e,t,n,r=[]){let i=[],a=Do(t.definition);if(K(a))return[];{let t=e.name;T(a,e)&&i.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:r}),type:$.LEFT_RECURSION,ruleName:t});let o=W(ur(a,r.concat([e])),t=>{let i=B(r);return i.push(t),Eo(e,t,n,i)});return i.concat(o)}}function Do(e){let t=[];if(K(e))return t;let n=U(e);if(n instanceof E)t.push(n.referencedRule);else if(n instanceof j||n instanceof k||n instanceof le||n instanceof D||n instanceof Ee||n instanceof N)t=t.concat(Do(n.definition));else if(n instanceof we)t=R(a(n.definition,e=>Do(e.definition)));else if(!(n instanceof O))throw Error(`non exhaustive match`);let r=Oe(n),i=e.length>1;if(r&&i){let n=V(e);return t.concat(Do(n))}else return t}var Oo=class extends w{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function ko(e,t){let n=new Oo;e.accept(n);let r=n.alternations;return W(r,n=>W(hr(n.definition),(r,i)=>K(Qa([r],[],sa,1))?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:n,emptyChoiceIdx:i}),type:$.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:n.idx,alternative:i+1}]:[]))}function Ao(e,t,n){let r=new Oo;e.accept(r);let i=r.alternations;return i=qr(i,e=>e.ignoreAmbiguities===!0),W(i,r=>{let i=r.idx,a=po(i,e,r.maxLookahead||t,r),o=Po(a,r,e,n),s=Fo(a,r,e,n);return o.concat(s)})}var jo=class extends w{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}};function Mo(e,t){let n=new Oo;e.accept(n);let r=n.alternations;return W(r,n=>n.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:n}),type:$.TOO_MANY_ALTS,ruleName:e.name,occurrence:n.idx}]:[])}function No(e,t,n){let r=[];return x(e,e=>{let i=new jo;e.accept(i);let a=i.allProductions;x(a,i=>{let a=eo(i),o=i.maxLookahead||t,s=i.idx,c=mo(s,e,a,o)[0];if(K(R(c))){let t=n.buildEmptyRepetitionError({topLevelRule:e,repetition:i});r.push({message:t,type:$.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),r}function Po(e,t,n,r){let i=[];return a(J(e,(n,r,a)=>(t.definition[a].ignoreAmbiguities===!0||x(r,r=>{let o=[a];x(e,(e,n)=>{a!==n&&ho(e,r)&&t.definition[n].ignoreAmbiguities!==!0&&o.push(n)}),o.length>1&&!ho(i,r)&&(i.push(r),n.push({alts:o,path:r}))}),n),[]),e=>{let i=a(e.alts,e=>e+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:$.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:t.idx,alternatives:e.alts}})}function Fo(e,t,n,r){let i=J(e,(e,t,n)=>{let r=a(t,e=>({idx:n,path:e}));return e.concat(r)},[]);return qn(W(i,e=>{if(t.definition[e.idx].ignoreAmbiguities===!0)return[];let o=e.idx,s=e.path;return a(H(i,e=>t.definition[e.idx].ignoreAmbiguities!==!0&&e.idx<o&&go(e.path,s)),e=>{let i=[e.idx+1,o+1],a=t.idx===0?``:t.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:$.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:a,alternatives:i}})}))}function Io(e,t,n){let r=[],i=a(t,e=>e.name);return x(e,e=>{let t=e.name;if(T(i,t)){let i=n.buildNamespaceConflictError(e);r.push({message:i,type:$.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),r}function Lo(e){let t=nr(e,{errMsgProvider:Ba}),n={};return x(e.rules,e=>{n[e.name]=e}),Ha(n,t.errMsgProvider)}function Ro(e){return e=nr(e,{errMsgProvider:Va}),yo(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}const zo=`MismatchedTokenException`,Bo=`NoViableAltException`,Vo=`EarlyExitException`,Ho=`NotAllInputParsedException`,Uo=[zo,Bo,Vo,Ho];Object.freeze(Uo);function Wo(e){return T(Uo,e.name)}var Go=class extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Ko=class extends Go{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=zo}},qo=class extends Go{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Bo}},Jo=class extends Go{constructor(e,t){super(e,t),this.name=Ho}},Yo=class extends Go{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Vo}};const Xo={},Zo=`InRuleRecoveryException`;var Qo=class extends Error{constructor(e){super(e),this.name=Zo}},$o=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=G(e,`recoveryEnabled`)?e.recoveryEnabled:Q.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=es)}getTokenToInsert(e){let t=La(e,``,NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,n,r){let i=this.findReSyncTokenType(),a=this.exportLexerState(),o=[],s=!1,c=this.LA(1),l=this.LA(1),u=()=>{let e=this.LA(0),t=new Ko(this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:c,previous:e,ruleName:this.getCurrRuleFullName()}),c,this.LA(0));t.resyncedTokens=hr(o),this.SAVE_ERROR(t)};for(;!s;)if(this.tokenMatcher(l,r)){u();return}else if(n.call(this)){u(),e.apply(this,t);return}else this.tokenMatcher(l,i)?s=!0:(l=this.SKIP_TOKEN(),this.addToResyncTokens(l,o));this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,t,n){return!(n===!1||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){let n=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new Qo(`sad sad panda`)}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||K(t))return!1;let n=this.LA(1);return Cr(t,e=>this.tokenMatcher(n,e))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey();return T(this.getFollowSetFromFollowKey(t),e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA(1),n=2;for(;;){let r=Cr(e,e=>Ra(t,e));if(r!==void 0)return r;t=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return Xo;let e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK;return a(e,(n,r)=>r===0?Xo:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:t[r],inRule:this.shortRuleNameToFullName(e[r-1])})}flattenFollowSet(){return R(a(this.buildFullFollowKeyStack(),e=>this.getFollowSetFromFollowKey(e)))}getFollowSetFromFollowKey(e){if(e===Xo)return[Ia];let t=e.ruleName+e.idxInCallingRule+oi+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,Ia)||t.push(e),t}reSyncTo(e){let t=[],n=this.LA(1);for(;this.tokenMatcher(n,e)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,t);return hr(t)}attemptInRepetitionRecovery(e,t,n,r,i,a,o){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:B(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return a(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}};function es(e,t,n,r,i,a,o){let s=this.getKeyForAutomaticLookahead(r,i),c=this.firstAfterRepMap[s];if(c===void 0){let e=this.getCurrRuleFullName(),t=this.getGAstProductions()[e];c=new a(t,i).startWalking(),this.firstAfterRepMap[s]=c}let l=c.token,u=c.occurrence,d=c.isEndOfRule;this.RULE_STACK.length===1&&d&&l===void 0&&(l=Ia,u=1),!(l===void 0||u===void 0)&&this.shouldInRepetitionRecoveryBeTried(l,u,o)&&this.tryInRepetitionRecovery(e,t,n,l)}const ts=1024,ns=1280,rs=1536;function is(e,t,n){return n|t|e}var as=class{constructor(e){this.maxLookahead=e?.maxLookahead??Q.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);if(K(t)){let n=this.validateEmptyOrAlternatives(e.rules),r=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...n,...r,...i]}return t}validateNoLeftRecursion(e){return W(e,e=>Eo(e,e,Va))}validateEmptyOrAlternatives(e){return W(e,e=>ko(e,Va))}validateAmbiguousAlternationAlternatives(e,t){return W(e,e=>Ao(e,t,Va))}validateSomeNonEmptyLookaheadPath(e,t){return No(e,t,Va)}buildLookaheadForAlternation(e){return no(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,io)}buildLookaheadForOptional(e){return ro(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,eo(e.prodType),ao)}},os=class{initLooksAhead(e){this.dynamicTokensEnabled=G(e,`dynamicTokensEnabled`)?e.dynamicTokensEnabled:Q.dynamicTokensEnabled,this.maxLookahead=G(e,`maxLookahead`)?e.maxLookahead:Q.maxLookahead,this.lookaheadStrategy=G(e,`lookaheadStrategy`)?e.lookaheadStrategy:new as({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){x(e,e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{let{alternation:t,repetition:n,option:r,repetitionMandatory:i,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:o}=cs(e);x(t,t=>{let n=t.idx===0?``:t.idx;this.TRACE_INIT(`${M(t)}${n}`,()=>{let n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),r=is(this.fullRuleNameToShort[e.name],256,t.idx);this.setLaFuncCache(r,n)})}),x(n,t=>{this.computeLookaheadFunc(e,t.idx,768,`Repetition`,t.maxLookahead,M(t))}),x(r,t=>{this.computeLookaheadFunc(e,t.idx,512,`Option`,t.maxLookahead,M(t))}),x(i,t=>{this.computeLookaheadFunc(e,t.idx,ts,`RepetitionMandatory`,t.maxLookahead,M(t))}),x(a,t=>{this.computeLookaheadFunc(e,t.idx,rs,`RepetitionMandatoryWithSeparator`,t.maxLookahead,M(t))}),x(o,t=>{this.computeLookaheadFunc(e,t.idx,ns,`RepetitionWithSeparator`,t.maxLookahead,M(t))})})})}computeLookaheadFunc(e,t,n,r,i,a){this.TRACE_INIT(`${a}${t===0?``:t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r}),o=is(this.fullRuleNameToShort[e.name],n,t);this.setLaFuncCache(o,a)})}getKeyForAutomaticLookahead(e,t){return is(this.getLastExplicitRuleShortName(),e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}};const ss=new class extends w{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}};function cs(e){ss.reset(),e.accept(ss);let t=ss.dslMethods;return ss.reset(),t}function ls(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function us(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 ds(e,t,n){e.children[n]===void 0?e.children[n]=[t]:e.children[n].push(t)}function fs(e,t,n){e.children[t]===void 0?e.children[t]=[n]:e.children[t].push(n)}function ps(e,t){Object.defineProperty(e,`name`,{enumerable:!1,configurable:!0,writable:!1,value:t})}function ms(e,t){let n=l(e),r=n.length;for(let i=0;i<r;i++){let r=e[n[i]],a=r.length;for(let e=0;e<a;e++){let n=r[e];n.tokenTypeIdx===void 0&&this[n.name](n.children,t)}}}function hs(e,t){let n=function(){};return ps(n,e+`BaseSemantics`),n.prototype={visit:function(e,t){if(A(e)&&(e=e[0]),!q(e))return this[e.name](e.children,t)},validateVisitor:function(){let e=vs(this,t);if(!K(e)){let t=a(e,e=>e.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${t.join(`
|
|
39
|
+
`),c},buildNamespaceConflictError(e){return`Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=a(e.prefixPath,e=>Di(e)).join(`, `),n=e.alternation.idx===0?``:e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(` ,`)}> due to common lookahead prefix\nin <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details.`},buildAlternationAmbiguityError(e){let t=a(e.prefixPath,e=>Di(e)).join(`, `),n=e.alternation.idx===0?``:e.alternation.idx,r=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(` ,`)}> in <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\n`;return r+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
|
|
40
|
+
For Further details.`,r},buildEmptyRepetitionError(e){let t=M(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis 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.\nOnly the last alternative may be an empty alternative.`},buildTooManyAlternativesError(e){return`An Alternation cannot have more than 256 alternatives:\n<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\n has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name;return`Left Recursion found in grammar.\nrule: <${t}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${`${t} --> ${a(e.leftRecursionPath,e=>e.name).concat([t]).join(` --> `)}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return`deprecated`},buildDuplicateRuleNameError(e){let t;return t=e.topLevelRule instanceof be?e.topLevelRule.name:e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function Gi(e,t){let n=new Ki(e,t);return n.resolveRefs(),n.errors}var Ki=class extends w{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){x(F(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let t=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:t,type:$.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},qi=class extends rr{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName=``,this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error(`The path does not start with the walker's top Rule!`);return this.ruleStack=B(this.path.ruleStack).reverse(),this.occurrenceStack=B(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let r=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,r)}}updateExpectedNext(){K(this.ruleStack)?(this.nextProductionName=``,this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},Ji=class extends qi{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName=``,this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,n){this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found&&(this.possibleTokTypes=ar(new j({definition:t.concat(n)})),this.found=!0)}},Yi=class extends rr{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},Xi=class extends Yi{walkMany(e,t,n){if(e.idx===this.occurrence){let e=U(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof O&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,n)}},Zi=class extends Yi{walkManySep(e,t,n){if(e.idx===this.occurrence){let e=U(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof O&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,n)}},Qi=class extends Yi{walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){let e=U(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof O&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,n)}},$i=class extends Yi{walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){let e=U(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof O&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,n)}};function ea(e,t,n=[]){n=B(n);let r=[],i=0;function a(t){return t.concat(V(e,i+1))}function o(e){let i=ea(a(e),t,n);return r.concat(i)}for(;n.length<t&&i<e.length;){let t=e[i];if(t instanceof j||t instanceof E)return o(t.definition);if(t instanceof k)r=o(t.definition);else if(t instanceof le)return o(t.definition.concat([new N({definition:t.definition})]));else if(t instanceof D)return o([new j({definition:t.definition}),new N({definition:[new O({terminalType:t.separator})].concat(t.definition)})]);else if(t instanceof Ee)r=o(t.definition.concat([new N({definition:[new O({terminalType:t.separator})].concat(t.definition)})]));else if(t instanceof N)r=o(t.definition.concat([new N({definition:t.definition})]));else if(t instanceof we)return x(t.definition,e=>{K(e.definition)===!1&&(r=o(e.definition))}),r;else if(t instanceof O)n.push(t.terminalType);else throw Error(`non exhaustive match`);i++}return r.push({partialPath:n,suffixDef:V(e,i)}),r}function ta(e,t,n,r){let i=`EXIT_NONE_TERMINAL`,a=[i],o=`EXIT_ALTERNATIVE`,s=!1,c=t.length,l=c-r-1,u=[],d=[];for(d.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!K(d);){let e=d.pop();if(e===o){s&&Nn(d).idx<=l&&d.pop();continue}let r=e.def,f=e.idx,p=e.ruleStack,m=e.occurrenceStack;if(K(r))continue;let h=r[0];if(h===i){let e={idx:f,def:V(r),ruleStack:Pn(p),occurrenceStack:Pn(m)};d.push(e)}else if(h instanceof O)if(f<c-1){let e=f+1,i=t[e];if(n(i,h.terminalType)){let t={idx:e,def:V(r),ruleStack:p,occurrenceStack:m};d.push(t)}}else if(f===c-1)u.push({nextTokenType:h.terminalType,nextTokenOccurrence:h.idx,ruleStack:p,occurrenceStack:m}),s=!0;else throw Error(`non exhaustive match`);else if(h instanceof E){let e=B(p);e.push(h.nonTerminalName);let t=B(m);t.push(h.idx);let n={idx:f,def:h.definition.concat(a,V(r)),ruleStack:e,occurrenceStack:t};d.push(n)}else if(h instanceof k){let e={idx:f,def:V(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t={idx:f,def:h.definition.concat(V(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof le){let e=new N({definition:h.definition,idx:h.idx}),t={idx:f,def:h.definition.concat([e],V(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof D){let e=new N({definition:[new O({terminalType:h.separator})].concat(h.definition),idx:h.idx}),t={idx:f,def:h.definition.concat([e],V(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof Ee){let e={idx:f,def:V(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new N({definition:[new O({terminalType:h.separator})].concat(h.definition),idx:h.idx}),n={idx:f,def:h.definition.concat([t],V(r)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof N){let e={idx:f,def:V(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new N({definition:h.definition,idx:h.idx}),n={idx:f,def:h.definition.concat([t],V(r)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof we)for(let e=h.definition.length-1;e>=0;e--){let t={idx:f,def:h.definition[e].definition.concat(V(r)),ruleStack:p,occurrenceStack:m};d.push(t),d.push(o)}else if(h instanceof j)d.push({idx:f,def:h.definition.concat(V(r)),ruleStack:p,occurrenceStack:m});else if(h instanceof be)d.push(na(h,f,p,m));else throw Error(`non exhaustive match`)}return u}function na(e,t,n,r){let i=B(n);i.push(e.name);let a=B(r);return a.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:a}}var Z;(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`})(Z||={});function ra(e){if(e instanceof k||e===`Option`)return Z.OPTION;if(e instanceof N||e===`Repetition`)return Z.REPETITION;if(e instanceof le||e===`RepetitionMandatory`)return Z.REPETITION_MANDATORY;if(e instanceof D||e===`RepetitionMandatoryWithSeparator`)return Z.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof Ee||e===`RepetitionWithSeparator`)return Z.REPETITION_WITH_SEPARATOR;if(e instanceof we||e===`Alternation`)return Z.ALTERNATION;throw Error(`non exhaustive match`)}function ia(e){let{occurrence:t,rule:n,prodType:r,maxLookahead:i}=e,a=ra(r);return a===Z.ALTERNATION?ha(t,n,i):ga(t,n,a,i)}function aa(e,t,n,r,i,a){let o=ha(e,t,n);return a(o,r,ya(o)?di:ui,i)}function oa(e,t,n,r,i,a){let o=ga(e,t,i,n),s=ya(o)?di:ui;return a(o[0],s,r)}function sa(e,t,n,r){let i=e.length,o=P(e,e=>P(e,e=>e.length===1));if(t)return function(t){let r=a(t,e=>e.GATE);for(let t=0;t<i;t++){let i=e[t],a=i.length,o=r[t];if(!(o!==void 0&&o.call(this)===!1))nextPath:for(let e=0;e<a;e++){let r=i[e],a=r.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),r[e])===!1)continue nextPath;return t}}};if(o&&!r){let t=J(a(e,e=>R(e)),(e,t,n)=>(x(t,t=>{G(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=n),x(t.categoryMatches,t=>{G(e,t)||(e[t]=n)})}),e),{});return function(){return t[this.LA(1).tokenTypeIdx]}}else return function(){for(let t=0;t<i;t++){let r=e[t],i=r.length;nextPath:for(let e=0;e<i;e++){let i=r[e],a=i.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),i[e])===!1)continue nextPath;return t}}}}function ca(e,t,n){let r=P(e,e=>e.length===1),i=e.length;if(r&&!n){let t=R(e);if(t.length===1&&K(t[0].categoryMatches)){let e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}else{let e=J(t,(e,t,n)=>(e[t.tokenTypeIdx]=!0,x(t.categoryMatches,t=>{e[t]=!0}),e),[]);return function(){return e[this.LA(1).tokenTypeIdx]===!0}}}else return function(){nextPath:for(let n=0;n<i;n++){let r=e[n],i=r.length;for(let e=0;e<i;e++)if(t(this.LA(e+1),r[e])===!1)continue nextPath;return!0}return!1}}var la=class extends rr{constructor(e,t,n){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,n,r){return e.idx===this.targetOccurrence&&this.targetProdType===t?(this.restDef=n.concat(r),!0):!1}walkOption(e,t,n){this.checkIsTarget(e,Z.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,Z.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,Z.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,Z.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}},ua=class extends w{constructor(e,t,n){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=n,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,Z.OPTION)}visitRepetition(e){this.checkIsTarget(e,Z.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,Z.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,Z.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,Z.ALTERNATION)}};function da(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=[];return t}function fa(e){let t=[``];for(let n=0;n<e.length;n++){let r=e[n],i=[];for(let e=0;e<t.length;e++){let n=t[e];i.push(n+`_`+r.tokenTypeIdx);for(let e=0;e<r.categoryMatches.length;e++){let t=`_`+r.categoryMatches[e];i.push(n+t)}}t=i}return t}function pa(e,t,n){for(let r=0;r<e.length;r++){if(r===n)continue;let i=e[r];for(let e=0;e<t.length;e++)if(i[t[e]]===!0)return!1}return!0}function ma(e,t){let n=a(e,e=>ea([e],1)),r=da(n.length),i=a(n,e=>{let t={};return x(e,e=>{x(fa(e.partialPath),e=>{t[e]=!0})}),t}),o=n;for(let e=1;e<=t;e++){let n=o;o=da(n.length);for(let a=0;a<n.length;a++){let s=n[a];for(let n=0;n<s.length;n++){let c=s[n].partialPath,l=s[n].suffixDef,u=fa(c);if(pa(i,u,a)||K(l)||c.length===t){let e=r[a];if(_a(e,c)===!1){e.push(c);for(let e=0;e<u.length;e++){let t=u[e];i[a][t]=!0}}}else{let t=ea(l,e+1,c);o[a]=o[a].concat(t),x(t,e=>{x(fa(e.partialPath),e=>{i[a][e]=!0})})}}}}return r}function ha(e,t,n,r){let i=new ua(e,Z.ALTERNATION,r);return t.accept(i),ma(i.result,n)}function ga(e,t,n,r){let i=new ua(e,n);t.accept(i);let a=i.result,o=new la(t,e,n).startWalking();return ma([new j({definition:a}),new j({definition:o})],r)}function _a(e,t){compareOtherPath:for(let n=0;n<e.length;n++){let r=e[n];if(r.length===t.length){for(let e=0;e<r.length;e++){let n=t[e],i=r[e];if(!(n===i||i.categoryMatchesMap[n.tokenTypeIdx]!==void 0))continue compareOtherPath}return!0}}return!1}function va(e,t){return e.length<t.length&&P(e,(e,n)=>{let r=t[n];return e===r||r.categoryMatchesMap[e.tokenTypeIdx]})}function ya(e){return P(e,e=>P(e,e=>P(e,e=>K(e.categoryMatches))))}function ba(e){return a(e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}),e=>Object.assign({type:$.CUSTOM_LOOKAHEAD_VALIDATION},e))}function xa(e,t,n,r){let i=W(e,e=>Sa(e,n)),a=Ra(e,t,n),o=W(e,e=>Pa(e,n)),s=W(e,t=>Ea(t,e,r,n));return i.concat(a,o,s)}function Sa(e,t){let n=new Ta;e.accept(n);let r=n.allProductions;return a(F(Ne(Vn(r,Ca),e=>e.length>1)),n=>{let r=U(n),i=t.buildDuplicateFoundError(e,n),a=M(r),o={message:i,type:$.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:a,occurrence:r.idx},s=wa(r);return s&&(o.parameter=s),o})}function Ca(e){return`${M(e)}_#_${e.idx}_#_${wa(e)}`}function wa(e){return e instanceof O?e.terminalType.name:e instanceof E?e.nonTerminalName:``}var Ta=class extends w{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}};function Ea(e,t,n,r){let i=[];if(J(t,(t,n)=>n.name===e.name?t+1:t,0)>1){let t=r.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});i.push({message:t,type:$.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function Da(e,t,n){let r=[],i;return T(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,r.push({message:i,type:$.INVALID_RULE_OVERRIDE,ruleName:e})),r}function Oa(e,t,n,r=[]){let i=[],a=ka(t.definition);if(K(a))return[];{let t=e.name;T(a,e)&&i.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:r}),type:$.LEFT_RECURSION,ruleName:t});let o=W(Mn(a,r.concat([e])),t=>{let i=B(r);return i.push(t),Oa(e,t,n,i)});return i.concat(o)}}function ka(e){let t=[];if(K(e))return t;let n=U(e);if(n instanceof E)t.push(n.referencedRule);else if(n instanceof j||n instanceof k||n instanceof le||n instanceof D||n instanceof Ee||n instanceof N)t=t.concat(ka(n.definition));else if(n instanceof we)t=R(a(n.definition,e=>ka(e.definition)));else if(!(n instanceof O))throw Error(`non exhaustive match`);let r=Oe(n),i=e.length>1;if(r&&i){let n=V(e);return t.concat(ka(n))}else return t}var Aa=class extends w{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function ja(e,t){let n=new Aa;e.accept(n);let r=n.alternations;return W(r,n=>W(Pn(n.definition),(r,i)=>K(ta([r],[],ui,1))?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:n,emptyChoiceIdx:i}),type:$.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:n.idx,alternative:i+1}]:[]))}function Ma(e,t,n){let r=new Aa;e.accept(r);let i=r.alternations;return i=Qn(i,e=>e.ignoreAmbiguities===!0),W(i,r=>{let i=r.idx,a=ha(i,e,r.maxLookahead||t,r),o=Ia(a,r,e,n),s=La(a,r,e,n);return o.concat(s)})}var Na=class extends w{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}};function Pa(e,t){let n=new Aa;e.accept(n);let r=n.alternations;return W(r,n=>n.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:n}),type:$.TOO_MANY_ALTS,ruleName:e.name,occurrence:n.idx}]:[])}function Fa(e,t,n){let r=[];return x(e,e=>{let i=new Na;e.accept(i);let a=i.allProductions;x(a,i=>{let a=ra(i),o=i.maxLookahead||t,s=i.idx,c=ga(s,e,a,o)[0];if(K(R(c))){let t=n.buildEmptyRepetitionError({topLevelRule:e,repetition:i});r.push({message:t,type:$.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),r}function Ia(e,t,n,r){let i=[];return a(J(e,(n,r,a)=>(t.definition[a].ignoreAmbiguities===!0||x(r,r=>{let o=[a];x(e,(e,n)=>{a!==n&&_a(e,r)&&t.definition[n].ignoreAmbiguities!==!0&&o.push(n)}),o.length>1&&!_a(i,r)&&(i.push(r),n.push({alts:o,path:r}))}),n),[]),e=>{let i=a(e.alts,e=>e+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:$.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:t.idx,alternatives:e.alts}})}function La(e,t,n,r){let i=J(e,(e,t,n)=>{let r=a(t,e=>({idx:n,path:e}));return e.concat(r)},[]);return xn(W(i,e=>{if(t.definition[e.idx].ignoreAmbiguities===!0)return[];let o=e.idx,s=e.path;return a(H(i,e=>t.definition[e.idx].ignoreAmbiguities!==!0&&e.idx<o&&va(e.path,s)),e=>{let i=[e.idx+1,o+1],a=t.idx===0?``:t.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:$.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:a,alternatives:i}})}))}function Ra(e,t,n){let r=[],i=a(t,e=>e.name);return x(e,e=>{let t=e.name;if(T(i,t)){let i=n.buildNamespaceConflictError(e);r.push({message:i,type:$.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),r}function za(e){let t=Dn(e,{errMsgProvider:Ui}),n={};return x(e.rules,e=>{n[e.name]=e}),Gi(n,t.errMsgProvider)}function Ba(e){return e=Dn(e,{errMsgProvider:Wi}),xa(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}const Va=`MismatchedTokenException`,Ha=`NoViableAltException`,Ua=`EarlyExitException`,Wa=`NotAllInputParsedException`,Ga=[Va,Ha,Ua,Wa];Object.freeze(Ga);function Ka(e){return T(Ga,e.name)}var qa=class extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Ja=class extends qa{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Va}},Ya=class extends qa{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Ha}},Xa=class extends qa{constructor(e,t){super(e,t),this.name=Wa}},Za=class extends qa{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Ua}};const Qa={},$a=`InRuleRecoveryException`;var eo=class extends Error{constructor(e){super(e),this.name=$a}},to=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=G(e,`recoveryEnabled`)?e.recoveryEnabled:Q.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=no)}getTokenToInsert(e){let t=Bi(e,``,NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,n,r){let i=this.findReSyncTokenType(),a=this.exportLexerState(),o=[],s=!1,c=this.LA(1),l=this.LA(1),u=()=>{let e=this.LA(0),t=new Ja(this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:c,previous:e,ruleName:this.getCurrRuleFullName()}),c,this.LA(0));t.resyncedTokens=Pn(o),this.SAVE_ERROR(t)};for(;!s;)if(this.tokenMatcher(l,r)){u();return}else if(n.call(this)){u(),e.apply(this,t);return}else this.tokenMatcher(l,i)?s=!0:(l=this.SKIP_TOKEN(),this.addToResyncTokens(l,o));this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,t,n){return!(n===!1||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){let n=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new eo(`sad sad panda`)}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||K(t))return!1;let n=this.LA(1);return zn(t,e=>this.tokenMatcher(n,e))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey();return T(this.getFollowSetFromFollowKey(t),e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA(1),n=2;for(;;){let r=zn(e,e=>Vi(t,e));if(r!==void 0)return r;t=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return Qa;let e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK;return a(e,(n,r)=>r===0?Qa:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:t[r],inRule:this.shortRuleNameToFullName(e[r-1])})}flattenFollowSet(){return R(a(this.buildFullFollowKeyStack(),e=>this.getFollowSetFromFollowKey(e)))}getFollowSetFromFollowKey(e){if(e===Qa)return[zi];let t=e.ruleName+e.idxInCallingRule+lr+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,zi)||t.push(e),t}reSyncTo(e){let t=[],n=this.LA(1);for(;this.tokenMatcher(n,e)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,t);return Pn(t)}attemptInRepetitionRecovery(e,t,n,r,i,a,o){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:B(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return a(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}};function no(e,t,n,r,i,a,o){let s=this.getKeyForAutomaticLookahead(r,i),c=this.firstAfterRepMap[s];if(c===void 0){let e=this.getCurrRuleFullName(),t=this.getGAstProductions()[e];c=new a(t,i).startWalking(),this.firstAfterRepMap[s]=c}let l=c.token,u=c.occurrence,d=c.isEndOfRule;this.RULE_STACK.length===1&&d&&l===void 0&&(l=zi,u=1),!(l===void 0||u===void 0)&&this.shouldInRepetitionRecoveryBeTried(l,u,o)&&this.tryInRepetitionRecovery(e,t,n,l)}const ro=1024,io=1280,ao=1536;function oo(e,t,n){return n|t|e}var so=class{constructor(e){this.maxLookahead=e?.maxLookahead??Q.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);if(K(t)){let n=this.validateEmptyOrAlternatives(e.rules),r=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...n,...r,...i]}return t}validateNoLeftRecursion(e){return W(e,e=>Oa(e,e,Wi))}validateEmptyOrAlternatives(e){return W(e,e=>ja(e,Wi))}validateAmbiguousAlternationAlternatives(e,t){return W(e,e=>Ma(e,t,Wi))}validateSomeNonEmptyLookaheadPath(e,t){return Fa(e,t,Wi)}buildLookaheadForAlternation(e){return aa(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,sa)}buildLookaheadForOptional(e){return oa(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,ra(e.prodType),ca)}},co=class{initLooksAhead(e){this.dynamicTokensEnabled=G(e,`dynamicTokensEnabled`)?e.dynamicTokensEnabled:Q.dynamicTokensEnabled,this.maxLookahead=G(e,`maxLookahead`)?e.maxLookahead:Q.maxLookahead,this.lookaheadStrategy=G(e,`lookaheadStrategy`)?e.lookaheadStrategy:new so({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){x(e,e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{let{alternation:t,repetition:n,option:r,repetitionMandatory:i,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:o}=uo(e);x(t,t=>{let n=t.idx===0?``:t.idx;this.TRACE_INIT(`${M(t)}${n}`,()=>{let n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),r=oo(this.fullRuleNameToShort[e.name],256,t.idx);this.setLaFuncCache(r,n)})}),x(n,t=>{this.computeLookaheadFunc(e,t.idx,768,`Repetition`,t.maxLookahead,M(t))}),x(r,t=>{this.computeLookaheadFunc(e,t.idx,512,`Option`,t.maxLookahead,M(t))}),x(i,t=>{this.computeLookaheadFunc(e,t.idx,ro,`RepetitionMandatory`,t.maxLookahead,M(t))}),x(a,t=>{this.computeLookaheadFunc(e,t.idx,ao,`RepetitionMandatoryWithSeparator`,t.maxLookahead,M(t))}),x(o,t=>{this.computeLookaheadFunc(e,t.idx,io,`RepetitionWithSeparator`,t.maxLookahead,M(t))})})})}computeLookaheadFunc(e,t,n,r,i,a){this.TRACE_INIT(`${a}${t===0?``:t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r}),o=oo(this.fullRuleNameToShort[e.name],n,t);this.setLaFuncCache(o,a)})}getKeyForAutomaticLookahead(e,t){return oo(this.getLastExplicitRuleShortName(),e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}};const lo=new class extends w{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}};function uo(e){lo.reset(),e.accept(lo);let t=lo.dslMethods;return lo.reset(),t}function fo(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function po(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 mo(e,t,n){e.children[n]===void 0?e.children[n]=[t]:e.children[n].push(t)}function ho(e,t,n){e.children[t]===void 0?e.children[t]=[n]:e.children[t].push(n)}function go(e,t){Object.defineProperty(e,`name`,{enumerable:!1,configurable:!0,writable:!1,value:t})}function _o(e,t){let n=l(e),r=n.length;for(let i=0;i<r;i++){let r=e[n[i]],a=r.length;for(let e=0;e<a;e++){let n=r[e];n.tokenTypeIdx===void 0&&this[n.name](n.children,t)}}}function vo(e,t){let n=function(){};return go(n,e+`BaseSemantics`),n.prototype={visit:function(e,t){if(A(e)&&(e=e[0]),!q(e))return this[e.name](e.children,t)},validateVisitor:function(){let e=xo(this,t);if(!K(e)){let t=a(e,e=>e.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${t.join(`
|
|
41
41
|
|
|
42
42
|
`).replace(/\n/g,`
|
|
43
|
-
`)}`)}}},n.prototype.constructor=n,n._RULE_NAMES=t,n}function
|
|
43
|
+
`)}`)}}},n.prototype.constructor=n,n._RULE_NAMES=t,n}function yo(e,t,n){let r=function(){};go(r,e+`BaseSemanticsWithDefaults`);let i=Object.create(n.prototype);return x(t,e=>{i[e]=_o}),r.prototype=i,r.prototype.constructor=r,r}var bo;(function(e){e[e.REDUNDANT_METHOD=0]=`REDUNDANT_METHOD`,e[e.MISSING_METHOD=1]=`MISSING_METHOD`})(bo||={});function xo(e,t){return So(e,t)}function So(e,t){return xn(a(H(t,t=>ye(e[t])===!1),t=>({msg:`Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,type:bo.MISSING_METHOD,methodName:t})))}var Co=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=G(e,`nodeLocationTracking`)?e.nodeLocationTracking:Q.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=L,this.cstFinallyStateUpdate=L,this.cstPostTerminal=L,this.cstPostNonTerminal=L,this.cstPostRule=L;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=po,this.setNodeLocationFromNode=po,this.cstPostRule=L,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=L,this.setNodeLocationFromNode=L,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=fo,this.setNodeLocationFromNode=fo,this.cstPostRule=L,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=L,this.setNodeLocationFromNode=L,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=L,this.setNodeLocationFromNode=L,this.cstPostRule=L,this.setInitialNodeLocation=L;else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){let t=this.LA(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?(n.endOffset=t.endOffset,n.endLine=t.endLine,n.endColumn=t.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)}cstPostRuleOnlyOffset(e){let t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?n.endOffset=t.endOffset:n.startOffset=NaN}cstPostTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];mo(n,t,e),this.setNodeLocationFromToken(n.location,t)}cstPostNonTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];ho(n,t,e),this.setNodeLocationFromNode(n.location,e.location)}getBaseCstVisitorConstructor(){if(q(this.baseCstVisitorConstructor)){let e=vo(this.className,l(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(q(this.baseCstVisitorWithDefaultsConstructor)){let e=yo(this.className,l(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-1]}getPreviousExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-2]}getLastExplicitRuleOccurrenceIndex(){let e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]}},wo=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error(`Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.`);this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):Bo}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?Bo:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}},To=class{ACTION(e){return e.call(this)}consume(e,t,n){return this.consumeInternal(t,e,n)}subrule(e,t,n){return this.subruleInternal(t,e,n)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,n=Vo){if(T(this.definedRulesNames,e)){let t={message:Wi.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:$.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);let r=this.defineRule(e,t,n);return this[e]=r,r}OVERRIDE_RULE(e,t,n=Vo){let r=Da(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);let i=this.defineRule(e,t,n);return this[e]=i,i}BACKTRACK(e,t){return function(){this.isBackTrackingStack.push(1);let n=this.saveRecogState();try{return e.apply(this,t),!0}catch(e){if(Ka(e))return!1;throw e}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return pe(F(this.gastProductionsCache))}},Eo=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=di,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},G(t,`serializedGrammar`))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
|
|
44
44
|
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
|
|
45
45
|
For Further details.`);if(A(e)){if(K(e))throw Error(`A Token Vocabulary cannot be empty.
|
|
46
46
|
Note that the first argument for the parser constructor
|
|
47
47
|
is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset==`number`)throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
|
|
48
48
|
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
|
|
49
|
-
For Further details.`)}if(A(e))this.tokensMap=J(e,(e,t)=>(e[t.name]=t,e),{});else if(G(e,`modes`)&&P(R(F(e.modes)),
|
|
50
|
-
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(
|
|
51
|
-
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};var
|
|
49
|
+
For Further details.`)}if(A(e))this.tokensMap=J(e,(e,t)=>(e[t.name]=t,e),{});else if(G(e,`modes`)&&P(R(F(e.modes)),wi))this.tokensMap=J(nr(R(F(e.modes))),(e,t)=>(e[t.name]=t,e),{});else if(fe(e))this.tokensMap=B(e);else throw Error(`<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition`);this.tokensMap.EOF=zi,this.tokenMatcher=P(G(e,`modes`)?R(F(e.modes)):F(e),e=>K(e.categoryMatches))?di:ui,mi(F(this.tokensMap))}defineRule(e,t,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let r=G(n,`resyncEnabled`)?n.resyncEnabled:Vo.resyncEnabled,i=G(n,`recoveryValueFunc`)?n.recoveryValueFunc:Vo.recoveryValueFunc,a=this.ruleShortNameIdx<<12;this.ruleShortNameIdx++,this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a;let o;return o=this.outputCst===!0?function(...n){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n);let r=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(r),r}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}}:function(...n){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n)}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(o,{ruleName:e,originalGrammarAction:t})}invokeRuleCatch(e,t,n){let r=this.RULE_STACK.length===1,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if(Ka(e)){let t=e;if(i){let r=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(r))if(t.resyncedTokens=this.reSyncTo(r),this.outputCst){let e=this.CST_STACK[this.CST_STACK.length-1];return e.recoveredNode=!0,e}else return n(e);else{if(this.outputCst){let e=this.CST_STACK[this.CST_STACK.length-1];e.recoveredNode=!0,t.partialCstResult=e}throw t}}else if(r)return this.moveToTerminatedState(),n(e);else throw t}else throw e}optionInternal(e,t){let n=this.getKeyForAutomaticLookahead(512,t);return this.optionInternalLogic(e,t,n)}optionInternalLogic(e,t,n){let r=this.getLaFuncFromCache(n),i;if(typeof e!=`function`){i=e.DEF;let t=e.GATE;if(t!==void 0){let e=r;r=()=>t.call(this)&&e.call(this)}}else i=e;if(r.call(this)===!0)return i.call(this)}atLeastOneInternal(e,t){let n=this.getKeyForAutomaticLookahead(ro,e);return this.atLeastOneInternalLogic(e,t,n)}atLeastOneInternalLogic(e,t,n){let r=this.getLaFuncFromCache(n),i;if(typeof t!=`function`){i=t.DEF;let e=t.GATE;if(e!==void 0){let t=r;r=()=>e.call(this)&&t.call(this)}}else i=t;if(r.call(this)===!0){let e=this.doSingleRepetition(i);for(;r.call(this)===!0&&e===!0;)e=this.doSingleRepetition(i)}else throw this.raiseEarlyExitException(e,Z.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],r,ro,e,Qi)}atLeastOneSepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(ao,e);this.atLeastOneSepFirstInternalLogic(e,t,n)}atLeastOneSepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){r.call(this);let t=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,$i],t,ao,e,$i)}else throw this.raiseEarlyExitException(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let n=this.getKeyForAutomaticLookahead(768,e);return this.manyInternalLogic(e,t,n)}manyInternalLogic(e,t,n){let r=this.getLaFuncFromCache(n),i;if(typeof t!=`function`){i=t.DEF;let e=t.GATE;if(e!==void 0){let t=r;r=()=>e.call(this)&&t.call(this)}}else i=t;let a=!0;for(;r.call(this)===!0&&a===!0;)a=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],r,768,e,Xi,a)}manySepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(io,e);this.manySepFirstInternalLogic(e,t,n)}manySepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){r.call(this);let t=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,Zi],t,io,e,Zi)}}repetitionSepSecondInternal(e,t,n,r,i){for(;n();)this.CONSUME(t),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,n,r,i],n,ao,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let n=this.getKeyForAutomaticLookahead(256,t),r=A(e)?e:e.DEF,i=this.getLaFuncFromCache(n).call(this,r);if(i!==void 0)return r[i].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){let e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Xa(t,e))}}subruleInternal(e,t,n){let r;try{let i=n===void 0?void 0:n.ARGS;return this.subruleIdx=t,r=e.apply(this,i),this.cstPostNonTerminal(r,n!==void 0&&n.LABEL!==void 0?n.LABEL:e.ruleName),r}catch(t){throw this.subruleInternalError(t,n,e.ruleName)}}subruleInternalError(e,t,n){throw Ka(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:n),delete e.partialCstResult),e}consumeInternal(e,t,n){let r;try{let t=this.LA(1);this.tokenMatcher(t,e)===!0?(this.consumeToken(),r=t):this.consumeInternalError(e,t,n)}catch(n){r=this.consumeInternalRecovery(e,t,n)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:e.name,r),r}consumeInternalError(e,t,n){let r,i=this.LA(0);throw r=n!==void 0&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Ja(r,t,i))}consumeInternalRecovery(e,t,n){if(this.recoveryEnabled&&n.name===`MismatchedTokenException`&&!this.isBackTracking()){let r=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,r)}catch(e){throw e.name===$a?n:e}}else throw n}saveRecogState(){let e=this.errors,t=B(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState),this.RULE_STACK=e.RULE_STACK}ruleInvocationStateUpdate(e,t,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(t)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),zi)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}},Do=class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=G(e,`errorMessageProvider`)?e.errorMessageProvider:Q.errorMessageProvider}SAVE_ERROR(e){if(Ka(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:B(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error(`Trying to save an Error which is not a RecognitionException`)}get errors(){return B(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,t,n){let r=this.getCurrRuleFullName(),i=this.getGAstProductions()[r],a=ga(e,i,t,this.maxLookahead)[0],o=[];for(let e=1;e<=this.maxLookahead;e++)o.push(this.LA(e));let s=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:a,actual:o,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new Za(s,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){let n=this.getCurrRuleFullName(),r=this.getGAstProductions()[n],i=ha(e,r,this.maxLookahead),a=[];for(let e=1;e<=this.maxLookahead;e++)a.push(this.LA(e));let o=this.LA(0),s=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:i,actual:a,previous:o,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new Ya(s,this.LA(1),o))}},Oo=class{initContentAssist(){}computeContentAssist(e,t){let n=this.gastProductionsCache[e];if(q(n))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return ta([n],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let t=U(e.ruleStack),n=this.getGAstProductions()[t];return new Ji(n,e).startWalking()}};const ko={description:`This Object indicates the Parser is during Recording Phase`};Object.freeze(ko);const Ao=Li({name:`RECORDING_PHASE_TOKEN`,pattern:X.NA});mi([Ao]);const jo=Bi(Ao,`This IToken indicates the Parser is in Recording Phase
|
|
50
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(jo);const Mo={name:`This CSTNode indicates the Parser is in Recording Phase
|
|
51
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};var No=class{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT(`Enable Recording`,()=>{for(let e=0;e<10;e++){let t=e>0?e:``;this[`CONSUME${t}`]=function(t,n){return this.consumeInternalRecord(t,e,n)},this[`SUBRULE${t}`]=function(t,n){return this.subruleInternalRecord(t,e,n)},this[`OPTION${t}`]=function(t){return this.optionInternalRecord(t,e)},this[`OR${t}`]=function(t){return this.orInternalRecord(t,e)},this[`MANY${t}`]=function(t){this.manyInternalRecord(e,t)},this[`MANY_SEP${t}`]=function(t){this.manySepFirstInternalRecord(e,t)},this[`AT_LEAST_ONE${t}`]=function(t){this.atLeastOneInternalRecord(e,t)},this[`AT_LEAST_ONE_SEP${t}`]=function(t){this.atLeastOneSepFirstInternalRecord(e,t)}}this.consume=function(e,t,n){return this.consumeInternalRecord(t,e,n)},this.subrule=function(e,t,n){return this.subruleInternalRecord(t,e,n)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT(`Deleting Recording methods`,()=>{let e=this;for(let t=0;t<10;t++){let n=t>0?t:``;delete e[`CONSUME${n}`],delete e[`SUBRULE${n}`],delete e[`OPTION${n}`],delete e[`OR${n}`],delete e[`MANY${n}`],delete e[`MANY_SEP${n}`],delete e[`AT_LEAST_ONE${n}`],delete e[`AT_LEAST_ONE_SEP${n}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return Bo}topLevelRuleRecord(e,t){try{let n=new be({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),t.call(this),this.recordingProdStack.pop(),n}catch(e){if(e.KNOWN_RECORDER_ERROR!==!0)try{e.message+=`
|
|
52
52
|
This error was thrown during the "grammar recording phase" For more info see:
|
|
53
|
-
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw e}throw e}}optionInternalRecord(e,t){return
|
|
53
|
+
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw e}throw e}}optionInternalRecord(e,t){return Po.call(this,k,e,t)}atLeastOneInternalRecord(e,t){Po.call(this,le,t,e)}atLeastOneSepFirstInternalRecord(e,t){Po.call(this,D,t,e,!0)}manyInternalRecord(e,t){Po.call(this,N,t,e)}manySepFirstInternalRecord(e,t){Po.call(this,Ee,t,e,!0)}orInternalRecord(e,t){return Fo.call(this,e,t)}subruleInternalRecord(e,t,n){if(Lo(t),!e||G(e,`ruleName`)===!1){let n=Error(`<SUBRULE${Io(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}let r=Nn(this.recordingProdStack),i=e.ruleName,a=new E({idx:t,nonTerminalName:i,label:n?.LABEL,referencedRule:void 0});return r.definition.push(a),this.outputCst?Mo:ko}consumeInternalRecord(e,t,n){if(Lo(t),!bi(e)){let n=Error(`<CONSUME${Io(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}let r=Nn(this.recordingProdStack),i=new O({idx:t,terminalType:e,label:n?.LABEL});return r.definition.push(i),jo}};function Po(e,t,n,r=!1){Lo(n);let i=Nn(this.recordingProdStack),a=ye(t)?t:t.DEF,o=new e({definition:[],idx:n});return r&&(o.separator=t.SEP),G(t,`MAX_LOOKAHEAD`)&&(o.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(o),a.call(this),i.definition.push(o),this.recordingProdStack.pop(),ko}function Fo(e,t){Lo(t);let n=Nn(this.recordingProdStack),r=A(e)===!1,i=r===!1?e:e.DEF,a=new we({definition:[],idx:t,ignoreAmbiguities:r&&e.IGNORE_AMBIGUITIES===!0});return G(e,`MAX_LOOKAHEAD`)&&(a.maxLookahead=e.MAX_LOOKAHEAD),a.hasPredicates=oe(i,e=>ye(e.GATE)),n.definition.push(a),x(i,e=>{let t=new j({definition:[]});a.definition.push(t),G(e,`IGNORE_AMBIGUITIES`)?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:G(e,`GATE`)&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()}),ko}function Io(e){return e===0?``:`${e}`}function Lo(e){if(e<0||e>255){let t=Error(`Invalid DSL Method idx value: <${e}>\n\tIdx value must be a none negative value smaller than 256`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var Ro=class{initPerformanceTracer(e){if(G(e,`traceInitPerf`)){let t=e.traceInitPerf,n=typeof t==`number`;this.traceInitMaxIdent=n?t:1/0,this.traceInitPerf=n?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=Q.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=Le(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}else return t()}};function zo(e,t){t.forEach(t=>{let n=t.prototype;Object.getOwnPropertyNames(n).forEach(r=>{if(r===`constructor`)return;let i=Object.getOwnPropertyDescriptor(n,r);i&&(i.get||i.set)?Object.defineProperty(e.prototype,r,i):e.prototype[r]=t.prototype[r]})})}const Bo=Bi(zi,``,NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Bo);const Q=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:Hi,nodeLocationTracking:`none`,traceInitPerf:!1,skipValidations:!1}),Vo=Object.freeze({recoveryValueFunc:()=>void 0,resyncEnabled:!0});var $;(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`})($||={});function Ho(e=void 0){return function(){return e}}var Uo=class e{static performSelfAnalysis(e){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 n=this.className;this.TRACE_INIT(`toFastProps`,()=>{ze(this)}),this.TRACE_INIT(`Grammar Recording`,()=>{try{this.enableRecording(),x(this.definedRulesNames,e=>{let t=this[e].originalGrammarAction,n;this.TRACE_INIT(`${e} Rule`,()=>{n=this.topLevelRuleRecord(e,t)}),this.gastProductionsCache[e]=n})}finally{this.disableRecording()}});let r=[];if(this.TRACE_INIT(`Grammar Resolving`,()=>{r=za({rules:F(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(r)}),this.TRACE_INIT(`Grammar Validations`,()=>{if(K(r)&&this.skipValidations===!1){let e=Ba({rules:F(this.gastProductionsCache),tokenTypes:F(this.tokensMap),errMsgProvider:Wi,grammarName:n}),t=ba({lookaheadStrategy:this.lookaheadStrategy,rules:F(this.gastProductionsCache),tokenTypes:F(this.tokensMap),grammarName:n});this.definitionErrors=this.definitionErrors.concat(e,t)}}),K(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT(`computeAllProdsFollows`,()=>{this.resyncFollows=dr(F(this.gastProductionsCache))}),this.TRACE_INIT(`ComputeLookaheadFunctions`,()=>{var e,t;(t=(e=this.lookaheadStrategy).initialize)==null||t.call(e,{rules:F(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(F(this.gastProductionsCache))})),!e.DEFER_DEFINITION_ERRORS_HANDLING&&!K(this.definitionErrors))throw t=a(this.definitionErrors,e=>e.message),Error(`Parser Definition Errors detected:\n ${t.join(`
|
|
54
54
|
-------------------------------
|
|
55
55
|
`)}`)})}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(t),n.initLexerAdapter(),n.initLooksAhead(t),n.initRecognizerEngine(e,t),n.initRecoverable(t),n.initTreeBuilder(t),n.initContentAssist(),n.initGastRecorder(t),n.initPerformanceTracer(t),G(t,`ignoredIssues`))throw Error(`The <ignoredIssues> IParserConfig property has been deprecated.
|
|
56
56
|
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
|
|
57
57
|
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
|
|
58
|
-
For further details.`);this.skipValidations=G(t,`skipValidations`)?t.skipValidations:Q.skipValidations}};
|
|
58
|
+
For further details.`);this.skipValidations=G(t,`skipValidations`)?t.skipValidations:Q.skipValidations}};Uo.DEFER_DEFINITION_ERRORS_HANDLING=!1,zo(Uo,[to,co,Co,wo,Eo,To,Do,Oo,No,Ro]);var Wo=class extends Uo{constructor(e,t=Q){let n=B(t);n.outputCst=!1,super(e,n)}};export{Hi as a,Vi as c,tr as d,J as f,R as g,H as h,ia as i,X as l,W as m,Wo as n,zi as o,K as p,so as r,Di as s,Ho as t,Ti as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=e=>t(e)||n(e),t=e=>{try{return e instanceof Error}catch{return!1}},n=e=>{try{return r.has(Object.prototype.toString.call(e))}catch{return!1}},r=new Set([`[object Error]`,`[object DOMException]`,`[object DOMError]`,`[object Exception]`]);export{e as t};
|