@bkm016/basalt 0.1.10 → 0.1.11
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/{chunk-0mjb3sm3.js → chunk-jymx3a77.js} +165 -152
- package/{chunk-3mqf9ped.js → chunk-zq32mwxj.js} +110 -110
- package/compiled.js +1 -1
- package/package.json +1 -1
- package/ui-test-worker.js +1 -1
- package/web/{chunk-9yfftz38.js → chunk-05mvzx00.js} +1 -1
- package/web/chunk-086dshck.js +1 -0
- package/web/chunk-0fy590s0.js +1 -0
- package/web/{chunk-se4h6wx0.js → chunk-0hvxb5d5.js} +1 -1
- package/web/chunk-0mdf1qja.js +1 -0
- package/web/{chunk-w3zgfhjb.js → chunk-0y971zgq.js} +2 -2
- package/web/{chunk-j89s11x8.js → chunk-1t38sgrk.js} +2 -2
- package/web/{chunk-z4bp6p32.js → chunk-1zfxaafq.js} +1 -1
- package/web/{chunk-g7kz8f7q.js → chunk-27812gqr.js} +5 -5
- package/web/{chunk-rag65pfs.js → chunk-2ds0a2z1.js} +3 -3
- package/web/{chunk-rh3xb76f.js → chunk-2f2agfpj.js} +11 -11
- package/web/{chunk-wtvch4ad.js → chunk-2tsxj613.js} +3 -3
- package/web/{chunk-y2rzeb4v.js → chunk-2weaa3gn.js} +2 -2
- package/web/{chunk-8h2x89tw.js → chunk-3020mmp1.js} +1 -1
- package/web/{chunk-mykrm8ba.js → chunk-30aeb767.js} +2 -2
- package/web/chunk-32zmk3f5.js +1 -0
- package/web/{chunk-rxvm70w5.js → chunk-36dc7tcg.js} +2 -2
- package/web/{chunk-j37p0b13.js → chunk-3a57m7xm.js} +3 -3
- package/web/{chunk-tt93zbn4.js → chunk-3b4wqmnh.js} +7 -7
- package/web/chunk-3d3wnh8a.js +2 -0
- package/web/{chunk-zse05v6j.js → chunk-3ftb27f3.js} +8 -8
- package/web/{chunk-de40q05r.js → chunk-47mbbmst.js} +3 -3
- package/web/chunk-48479gnx.js +1 -0
- package/web/{chunk-5v5q13hz.js → chunk-4gc663j0.js} +2 -2
- package/web/{chunk-88wd49xe.js → chunk-4rwwtfnd.js} +2 -2
- package/web/{chunk-eqndhs21.js → chunk-4wwd3pfz.js} +2 -2
- package/web/{chunk-myd6sc76.js → chunk-57pyz29y.js} +2 -2
- package/web/{chunk-32ty2xfn.js → chunk-59nk506k.js} +1 -1
- package/web/{chunk-m4fxd5d9.js → chunk-5ahx98zj.js} +8 -8
- package/web/chunk-6cjm2yr7.js +1 -0
- package/web/{chunk-frnh4zqf.js → chunk-6jb2zyp6.js} +2 -2
- package/web/{chunk-3eexx7y5.js → chunk-793m5jjh.js} +1 -1
- package/web/{chunk-p55vhns6.js → chunk-7dycbjxn.js} +4 -4
- package/web/chunk-7ycxz39p.js +1 -0
- package/web/{chunk-gw8x1g61.js → chunk-8151c970.js} +1 -1
- package/web/{chunk-jccz14ye.js → chunk-885kpj14.js} +2 -2
- package/web/{chunk-vasppf6b.js → chunk-8csw0mvf.js} +2 -2
- package/web/{chunk-x850q01z.js → chunk-8z7texmv.js} +1 -1
- package/web/{chunk-sd3xat3r.js → chunk-90fkdzx3.js} +6 -6
- package/web/chunk-94denx9h.js +39 -0
- package/web/{chunk-zms6mrqk.js → chunk-96xhmmqz.js} +6 -6
- package/web/chunk-9jy8nc4r.js +1 -0
- package/web/{chunk-dv1berk6.js → chunk-9kkzmss7.js} +3 -3
- package/web/chunk-9wr33d0t.js +1 -0
- package/web/{chunk-fmmrthpa.js → chunk-a3pye9ag.js} +3 -3
- package/web/chunk-a4tdrxdh.js +1 -0
- package/web/chunk-a9fvsyc1.js +1 -0
- package/web/chunk-apvbvg4d.js +1 -0
- package/web/{chunk-wrevb4ew.js → chunk-b3j07x0n.js} +6 -6
- package/web/{chunk-0770q5e1.js → chunk-b6sqwmq7.js} +1 -1
- package/web/chunk-bkxcc7v5.js +1 -0
- package/web/chunk-bve354k7.js +1 -0
- package/web/{chunk-nawxgz87.js → chunk-cbwvfedy.js} +8 -8
- package/web/{chunk-x5g1yy12.js → chunk-cpshsp24.js} +1 -1
- package/web/chunk-cwpxakby.js +1 -0
- package/web/chunk-d3f763n7.js +2 -0
- package/web/{chunk-grm2208k.js → chunk-d4519smc.js} +14 -14
- package/web/chunk-de29pe57.js +1 -0
- package/web/chunk-dk0fnj87.js +1 -0
- package/web/{chunk-c57f714b.js → chunk-drchr3yn.js} +2 -2
- package/web/chunk-dsbyfvwz.js +1 -0
- package/web/{chunk-xtn305fd.js → chunk-dtrh40vr.js} +1 -1
- package/web/chunk-e68jw0bg.js +1 -0
- package/web/{chunk-tfqarvdx.js → chunk-e763h2px.js} +67 -67
- package/web/{chunk-pgwf37s2.js → chunk-enryqmj7.js} +5 -5
- package/web/{chunk-jke2ev6m.js → chunk-f79ajymt.js} +2 -2
- package/web/{chunk-qq6m2my8.js → chunk-fj753yzt.js} +2 -2
- package/web/{chunk-5svqfj4g.js → chunk-g0rtcedn.js} +3 -3
- package/web/{chunk-18neka5g.js → chunk-g31dbnzm.js} +4 -4
- package/web/{chunk-1ev0n3n4.js → chunk-g4as4zzd.js} +4 -4
- package/web/{chunk-6e87m0nm.js → chunk-gten0rpx.js} +2 -2
- package/web/{chunk-sjkg40ay.js → chunk-gyhr27dm.js} +1 -1
- package/web/{chunk-js6kb05s.js → chunk-hjyev38w.js} +6 -6
- package/web/{chunk-rwfmccmh.js → chunk-hm8thq7c.js} +4 -4
- package/web/{chunk-07agqp8h.js → chunk-j4gvtszc.js} +2 -2
- package/web/chunk-jd7npyv9.js +8 -0
- package/web/chunk-jhpg2kcf.js +1 -0
- package/web/{chunk-qdzy124b.js → chunk-jqqbkdtw.js} +2 -2
- package/web/chunk-jzz5htxp.js +1 -0
- package/web/chunk-ka3q31t1.js +1 -0
- package/web/chunk-kahab58k.js +1139 -0
- package/web/{chunk-q4bst4an.js → chunk-kfbgvh0c.js} +1 -1
- package/web/chunk-krgvx75q.js +1 -0
- package/web/chunk-kxeaj44h.js +1 -0
- package/web/chunk-m1rdyvb5.js +1 -0
- package/web/{chunk-z5qn0xev.js → chunk-m24yb8md.js} +2 -2
- package/web/chunk-m7k4wr3k.js +1 -0
- package/web/chunk-mdj3r75b.js +1 -0
- package/web/{chunk-h5ckjk48.js → chunk-mpdeqzc9.js} +10 -10
- package/web/{chunk-knm82fw9.js → chunk-mykbcvqz.js} +1 -1
- package/web/{chunk-1qh7f5kr.js → chunk-n33753da.js} +1 -1
- package/web/{chunk-yppgejg7.js → chunk-nafe18y9.js} +10 -10
- package/web/chunk-nbcpbqq4.js +1 -0
- package/web/{chunk-bc3ajvfg.js → chunk-nhx8pw7p.js} +1 -1
- package/web/chunk-nkpdd9hw.js +1 -0
- package/web/{chunk-eh7wp62z.js → chunk-p1yc8hwn.js} +1 -1
- package/web/chunk-p29brxyt.js +1 -0
- package/web/chunk-p8fbes0t.js +1 -0
- package/web/chunk-pbp1p5ex.js +1 -0
- package/web/{chunk-n4yzs2q0.js → chunk-ppjw1mps.js} +4 -4
- package/web/{chunk-7tkgbbf9.js → chunk-pq56b3mq.js} +2 -2
- package/web/{chunk-vvvd3grf.js → chunk-pzg25qqe.js} +2 -2
- package/web/{chunk-t5nvgz7z.js → chunk-q65zxczs.js} +7 -7
- package/web/{chunk-g7dc4hrd.js → chunk-q8v5j963.js} +2 -2
- package/web/{chunk-zz1qkaar.js → chunk-qykt7avq.js} +2 -2
- package/web/chunk-r6q1301x.js +1 -0
- package/web/chunk-r8kghrkb.js +1 -0
- package/web/chunk-rhxn7mxg.js +1 -0
- package/web/{chunk-46jnkghq.js → chunk-rqympya7.js} +2 -2
- package/web/{chunk-k0cg4n2k.js → chunk-s0xy00v5.js} +2 -2
- package/web/chunk-svqshmpg.js +1 -0
- package/web/chunk-swzxq7r3.css +1 -0
- package/web/{chunk-905vw286.js → chunk-t18tn37m.js} +2 -2
- package/web/chunk-tbsaseer.js +1 -0
- package/web/{chunk-rbqnre6q.js → chunk-tggja45g.js} +3 -3
- package/web/chunk-tgkdyxbn.js +1 -0
- package/web/{chunk-sc63488q.js → chunk-tpdcrrf1.js} +1 -1
- package/web/chunk-v0zfnvc1.js +1 -0
- package/web/{chunk-tqze6d6b.js → chunk-v3dn9bfw.js} +1 -1
- package/web/chunk-vj31fs16.js +1 -0
- package/web/chunk-vr79r8vh.js +1 -0
- package/web/chunk-wb9tax0m.js +1 -0
- package/web/{chunk-26ecc2xh.js → chunk-wbwets5x.js} +19 -19
- package/web/chunk-x9eghjjd.js +1 -0
- package/web/{chunk-awkdw9rw.js → chunk-xbyrgyy0.js} +2 -2
- package/web/{chunk-qy1zx2yw.js → chunk-xjc5fmcr.js} +24 -24
- package/web/{chunk-qh62nkem.js → chunk-ydtrc1ay.js} +2 -2
- package/web/chunk-yrh86m0n.js +1 -0
- package/web/chunk-z3ky5ews.js +2 -0
- package/web/{chunk-ehtmb6sn.js → chunk-zdhyq3ch.js} +13 -13
- package/web/{chunk-gsw1tv96.js → chunk-zv73g4qq.js} +2 -2
- package/web/index.html +1 -1
- package/web/chunk-045d3b5d.js +0 -1
- package/web/chunk-12qf1r6m.js +0 -1
- package/web/chunk-1ex3wgms.js +0 -2
- package/web/chunk-2cz7tx8q.js +0 -1
- package/web/chunk-4am8j3k3.js +0 -1
- package/web/chunk-5qvmefq2.js +0 -1
- package/web/chunk-5z2n4z9x.css +0 -1
- package/web/chunk-6y55gk1n.js +0 -1
- package/web/chunk-7np1jp3x.js +0 -8
- package/web/chunk-7qq1ypvj.js +0 -1
- package/web/chunk-87e8d1hv.js +0 -1
- package/web/chunk-8y2526ve.js +0 -1
- package/web/chunk-918e5t4x.js +0 -2
- package/web/chunk-96m2m3e8.js +0 -1
- package/web/chunk-9f4zzqbx.js +0 -1
- package/web/chunk-a1n4468c.js +0 -1
- package/web/chunk-arnzrqnm.js +0 -1
- package/web/chunk-b46ws7rf.js +0 -1
- package/web/chunk-bwy3e58v.js +0 -1
- package/web/chunk-d5gshd1a.js +0 -1
- package/web/chunk-dp0k5vhd.js +0 -1
- package/web/chunk-et1hytyv.js +0 -1
- package/web/chunk-f7jpakwh.js +0 -1
- package/web/chunk-f9m9seam.js +0 -1
- package/web/chunk-g2erm7k0.js +0 -1
- package/web/chunk-g3kbn0t2.js +0 -1
- package/web/chunk-ght0t49g.js +0 -1
- package/web/chunk-ghwm7bdj.js +0 -2
- package/web/chunk-gx340asc.js +0 -1
- package/web/chunk-h0c42zy3.js +0 -1
- package/web/chunk-h2txs73e.js +0 -39
- package/web/chunk-h3tkacc7.js +0 -1
- package/web/chunk-je78j3vr.js +0 -1
- package/web/chunk-kxdtg9dt.js +0 -1
- package/web/chunk-m9xzt9p7.js +0 -1
- package/web/chunk-mzzaet63.js +0 -1
- package/web/chunk-ngt1j8py.js +0 -1139
- package/web/chunk-q34as3v6.js +0 -1
- package/web/chunk-qe0bgeda.js +0 -1
- package/web/chunk-sat7zyva.js +0 -1
- package/web/chunk-sk0hpa80.js +0 -1
- package/web/chunk-tj1fn8v2.js +0 -1
- package/web/chunk-tvcxrx6h.js +0 -1
- package/web/chunk-tzpnh70q.js +0 -1
- package/web/chunk-vb7g4xg6.js +0 -1
- package/web/chunk-wzfe6jtq.js +0 -1
- package/web/chunk-xh4xn1az.js +0 -1
- package/web/chunk-xk904wqv.js +0 -1
- package/web/chunk-xzwxcxb4.js +0 -1
- package/web/chunk-yekaz74b.js +0 -1
- package/web/chunk-ys2tns0p.js +0 -1
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import{t,a,
|
|
1
|
+
import{t,a,M,x,O,C,S,E,T,A,L,R,l,p,N,si,pe,se,le,vt,ge,ye}from"./chunk-e763h2px.js";import{he}from"./chunk-tpdcrrf1.js";import{ue}from"./chunk-n33753da.js";function tt(e){if(console&&console.error)console.error(`Error: ${e}`)}function Tt(e){if(console&&console.warn)console.warn(`Warning: ${e}`)}function gt(e){let s=new Date().getTime(),n=e();return{time:new Date().getTime()-s,value:n}}function At(e){function s(){}s.prototype=e;let n=new s;function i(){return typeof n.bar}return i(),i(),e;(0,eval)(e)}function Gr(e){if(Wr(e))return e.LABEL;else return e.name}function Wr(e){return typeof e.LABEL==="string"&&e.LABEL!==""}class Ne{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),this.definition.forEach((s)=>{s.accept(e)})}}class W extends Ne{constructor(e){super([]);this.idx=1,Object.assign(this,xe(e))}set definition(e){}get definition(){if(this.referencedRule!==void 0)return this.referencedRule.definition;return[]}accept(e){e.visit(this)}}class Te extends Ne{constructor(e){super(e.definition);this.orgText="",Object.assign(this,xe(e))}}class j extends Ne{constructor(e){super(e.definition);this.ignoreAmbiguities=!1,Object.assign(this,xe(e))}}class K extends Ne{constructor(e){super(e.definition);this.idx=1,Object.assign(this,xe(e))}}class Z extends Ne{constructor(e){super(e.definition);this.idx=1,Object.assign(this,xe(e))}}class Q extends Ne{constructor(e){super(e.definition);this.idx=1,Object.assign(this,xe(e))}}class G extends Ne{constructor(e){super(e.definition);this.idx=1,Object.assign(this,xe(e))}}class q extends Ne{constructor(e){super(e.definition);this.idx=1,Object.assign(this,xe(e))}}class J extends Ne{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition);this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,Object.assign(this,xe(e))}}class F{constructor(e){this.idx=1,Object.assign(this,xe(e))}accept(e){e.visit(this)}}function Wt(e){return e.map(st)}function st(e){function s(n){return n.map(st)}if(e instanceof W){let n={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};if(typeof e.label==="string")n.label=e.label;return n}else if(e instanceof j)return{type:"Alternative",definition:s(e.definition)};else if(e instanceof K)return{type:"Option",idx:e.idx,definition:s(e.definition)};else if(e instanceof Z)return{type:"RepetitionMandatory",idx:e.idx,definition:s(e.definition)};else if(e instanceof Q)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:st(new F({terminalType:e.separator})),definition:s(e.definition)};else if(e instanceof q)return{type:"RepetitionWithSeparator",idx:e.idx,separator:st(new F({terminalType:e.separator})),definition:s(e.definition)};else if(e instanceof G)return{type:"Repetition",idx:e.idx,definition:s(e.definition)};else if(e instanceof J)return{type:"Alternation",idx:e.idx,definition:s(e.definition)};else if(e instanceof F){let n={type:"Terminal",name:e.terminalType.name,label:Gr(e.terminalType),idx:e.idx};if(typeof e.label==="string")n.terminalLabel=e.label;let i=e.terminalType.PATTERN;if(e.terminalType.PATTERN)n.pattern=i instanceof RegExp?i.source:i;return n}else if(e instanceof Te)return{type:"Rule",name:e.name,orgText:e.orgText,definition:s(e.definition)};else throw Error("non exhaustive match")}function xe(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))}class Ae{visit(e){let s=e;switch(s.constructor){case W:return this.visitNonTerminal(s);case j:return this.visitAlternative(s);case K:return this.visitOption(s);case Z:return this.visitRepetitionMandatory(s);case Q:return this.visitRepetitionMandatoryWithSeparator(s);case q:return this.visitRepetitionWithSeparator(s);case G:return this.visitRepetition(s);case J:return this.visitAlternation(s);case F:return this.visitTerminal(s);case Te:return this.visitRule(s);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}}function vs(e){return e instanceof j||e instanceof K||e instanceof G||e instanceof Z||e instanceof Q||e instanceof q||e instanceof F||e instanceof Te}function je(e,s=[]){if(e instanceof K||e instanceof G||e instanceof q)return!0;if(e instanceof J)return e.definition.some((i)=>je(i,s));else if(e instanceof W&&s.includes(e))return!1;else if(e instanceof Ne){if(e instanceof W)s.push(e);return e.definition.every((i)=>je(i,s))}else return!1}function Ms(e){return e instanceof J}function Se(e){if(e instanceof W)return"SUBRULE";else if(e instanceof K)return"OPTION";else if(e instanceof J)return"OR";else if(e instanceof Z)return"AT_LEAST_ONE";else if(e instanceof Q)return"AT_LEAST_ONE_SEP";else if(e instanceof q)return"MANY_SEP";else if(e instanceof G)return"MANY";else if(e instanceof F)return"CONSUME";else throw Error("non exhaustive match")}class $e{walk(e,s=[]){e.definition.forEach((n,i)=>{let r=e.definition.slice(i+1);if(n instanceof W)this.walkProdRef(n,r,s);else if(n instanceof F)this.walkTerminal(n,r,s);else if(n instanceof j)this.walkFlat(n,r,s);else if(n instanceof K)this.walkOption(n,r,s);else if(n instanceof Z)this.walkAtLeastOne(n,r,s);else if(n instanceof Q)this.walkAtLeastOneSep(n,r,s);else if(n instanceof q)this.walkManySep(n,r,s);else if(n instanceof G)this.walkMany(n,r,s);else if(n instanceof J)this.walkOr(n,r,s);else throw Error("non exhaustive match")})}walkTerminal(e,s,n){}walkProdRef(e,s,n){}walkFlat(e,s,n){let i=s.concat(n);this.walk(e,i)}walkOption(e,s,n){let i=s.concat(n);this.walk(e,i)}walkAtLeastOne(e,s,n){let i=[new K({definition:e.definition})].concat(s,n);this.walk(e,i)}walkAtLeastOneSep(e,s,n){let i=Nn(e,s,n);this.walk(e,i)}walkMany(e,s,n){let i=[new K({definition:e.definition})].concat(s,n);this.walk(e,i)}walkManySep(e,s,n){let i=Nn(e,s,n);this.walk(e,i)}walkOr(e,s,n){let i=s.concat(n);e.definition.forEach((r)=>{let o=new j({definition:[r]});this.walk(o,i)})}}function Nn(e,s,n){return[new K({definition:[new F({terminalType:e.separator})].concat(e.definition)})].concat(s,n)}function Ke(e){if(e instanceof W)return Ke(e.referencedRule);else if(e instanceof F)return Vr(e);else if(vs(e))return jr(e);else if(Ms(e))return Kr(e);else throw Error("non exhaustive match")}function jr(e){let s=[],n=e.definition,i=0,r=n.length>i,o,h=!0;while(r&&h)o=n[i],h=je(o),s=s.concat(Ke(o)),i=i+1,r=n.length>i;return[...new Set(s)]}function Kr(e){let s=e.definition.map((n)=>Ke(n));return[...new Set(s.flat())]}function Vr(e){return[e.terminalType]}var jt="_~IN~_";class In extends $e{constructor(e){super();this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,s,n){}walkProdRef(e,s,n){let i=zr(e.referencedRule,e.idx)+this.topProd.name,r=s.concat(n),o=new j({definition:r}),h=Ke(o);this.follows[i]=h}}function kn(e){let s={};return e.forEach((n)=>{let i=new In(n).startWalking();Object.assign(s,i)}),s}function zr(e,s){return e.name+s+jt}function v(e){return e.charCodeAt(0)}function Kt(e,s){if(Array.isArray(e))e.forEach(function(n){s.push(n)});else s.push(e)}function nt(e,s){if(e[s]===!0)throw"duplicate flag "+s;let n=e[s];e[s]=!0}function Ve(e){if(e===void 0)throw Error("Internal Error - Should never get here!");return!0}function St(){throw Error("Internal Error - Should never get here!")}function ws(e){return e.type==="Character"}var Rt=[];for(let e=v("0");e<=v("9");e++)Rt.push(e);var yt=[v("_")].concat(Rt);for(let e=v("a");e<=v("z");e++)yt.push(e);for(let e=v("A");e<=v("Z");e++)yt.push(e);var Us=[v(" "),v("\f"),v(`
|
|
2
2
|
`),v("\r"),v("\t"),v("\v"),v("\t"),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v("\u2028"),v("\u2029"),v(" "),v(" "),v(" "),v("\uFEFF")];var Hr=/[0-9a-fA-F]/,Vt=/[0-9]/,Xr=/[1-9]/;class zt{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");let s=this.disjunction();this.consumeChar("/");let n={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};while(this.isRegExpFlag())switch(this.popChar()){case"g":nt(n,"global");break;case"i":nt(n,"ignoreCase");break;case"m":nt(n,"multiLine");break;case"u":nt(n,"unicode");break;case"y":nt(n,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:s,loc:this.loc(0)}}disjunction(){let e=[],s=this.idx;e.push(this.alternative());while(this.peekChar()==="|")this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(s)}}alternative(){let e=[],s=this.idx;while(this.isTerm())e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(s)}}term(){if(this.isAssertion())return this.assertion();else return this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let s;switch(this.popChar()){case"=":s="Lookahead";break;case"!":s="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":s="Lookbehind";break;case"!":s="NegativeLookbehind"}break}}Ve(s);let n=this.disjunction();return this.consumeChar(")"),{type:s,value:n,loc:this.loc(e)}}return St()}quantifier(e=!1){let s=void 0,n=this.idx;switch(this.popChar()){case"*":s={atLeast:0,atMost:1/0};break;case"+":s={atLeast:1,atMost:1/0};break;case"?":s={atLeast:0,atMost:1};break;case"{":let i=this.integerIncludingZero();switch(this.popChar()){case"}":s={atLeast:i,atMost:i};break;case",":let r;if(this.isDigit())r=this.integerIncludingZero(),s={atLeast:i,atMost:r};else s={atLeast:i,atMost:1/0};this.consumeChar("}");break}if(e===!0&&s===void 0)return;Ve(s);break}if(e===!0&&s===void 0)return;if(Ve(s)){if(this.peekChar(0)==="?")this.consumeChar("?"),s.greedy=!1;else s.greedy=!0;return s.type="Quantifier",s.loc=this.loc(n),s}}atom(){let e,s=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group();break}if(e===void 0&&this.isPatternCharacter())e=this.patternCharacter();if(Ve(e)){if(e.loc=this.loc(s),this.isQuantifier())e.quantifier=this.quantifier();return e}return St()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[v(`
|
|
3
|
-
`),v("\r"),v("\u2028"),v("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,s=!1;switch(this.popChar()){case"d":e=Rt;break;case"D":e=Rt,s=!0;break;case"s":e=Us;break;case"S":e=Us,s=!0;break;case"w":e=
|
|
3
|
+
`),v("\r"),v("\u2028"),v("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,s=!1;switch(this.popChar()){case"d":e=Rt;break;case"D":e=Rt,s=!0;break;case"s":e=Us;break;case"S":e=Us,s=!0;break;case"w":e=yt;break;case"W":e=yt,s=!0;break}if(Ve(e))return{type:"Set",value:e,complement:s};return St()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=v("\f");break;case"n":e=v(`
|
|
4
4
|
`);break;case"r":e=v("\r");break;case"t":e=v("\t");break;case"v":e=v("\v");break}if(Ve(e))return{type:"Character",value:e};return St()}controlLetterEscapeAtom(){this.consumeChar("c");let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:v("\x00")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){let e=this.popChar();return{type:"Character",value:v(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
|
|
5
5
|
`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let e=this.popChar();return{type:"Character",value:v(e)}}}characterClass(){let e=[],s=!1;if(this.consumeChar("["),this.peekChar(0)==="^")this.consumeChar("^"),s=!0;while(this.isClassAtom()){let n=this.classAtom(),i=n.type==="Character";if(ws(n)&&this.isRangeDash()){this.consumeChar("-");let r=this.classAtom(),o=r.type==="Character";if(ws(r)){if(r.value<n.value)throw Error("Range out of order in character class");e.push({from:n.value,to:r.value})}else Kt(n.value,e),e.push(v("-")),Kt(r.value,e)}else Kt(n.value,e)}return this.consumeChar("]"),{type:"Set",complement:s,value:e}}classAtom(){switch(this.peekChar()){case"]":case`
|
|
6
6
|
`:case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:v("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),e=!1;break;default:this.groupIdx++;break}let s=this.disjunction();this.consumeChar(")");let n={type:"Group",capturing:e,value:s};if(e)n.idx=this.groupIdx;return n}positiveInteger(){let e=this.popChar();if(Xr.test(e)===!1)throw Error("Expecting a positive integer");while(Vt.test(this.peekChar(0)))e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(Vt.test(e)===!1)throw Error("Expecting an integer");while(Vt.test(this.peekChar(0)))e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case`
|
|
7
7
|
`:case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:v(e)}}}isRegExpFlag(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}}isRangeDash(){return this.peekChar()==="-"&&this.isClassAtom(1)}isDigit(){return Vt.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case`
|
|
8
8
|
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return this.peekChar(1)==="?"&&(this.peekChar(2)==="="||this.peekChar(2)==="!"||this.peekChar(2)==="<"&&(this.peekChar(3)==="="||this.peekChar(3)==="!"));default:return!1}}isQuantifier(){let e=this.saveState();try{return this.quantifier(!0)!==void 0}catch(s){return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
|
|
9
|
-
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let s="";for(let i=0;i<e;i++){let r=this.popChar();if(Hr.test(r)===!1)throw Error("Expecting a HexDecimal digits");s+=r}return{type:"Character",value:parseInt(s,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(e!==void 0&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}}class ze{visitChildren(e){for(let s in e){let n=e[s];if(e.hasOwnProperty(s)){if(n.type!==void 0)this.visit(n);else if(Array.isArray(n))n.forEach((i)=>{this.visit(i)},this)}}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Lookbehind":this.visitLookbehind(e);break;case"NegativeLookbehind":this.visitNegativeLookbehind(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e);break}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}}var Ht={},Yr=new zt;function He(e){let s=e.toString();if(Ht.hasOwnProperty(s))return Ht[s];else{let n=Yr.pattern(s);return Ht[s]=n,n}}function Cn(){Ht={}}var _n="Complement Sets are not supported for first char optimization",
|
|
10
|
-
`;function xn(e,s=!1){try{let n=He(e);return Ps(n.value,{},n.flags.ignoreCase)}catch(n){if(n.message===_n){if(s)Tt(`${
|
|
9
|
+
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let s="";for(let i=0;i<e;i++){let r=this.popChar();if(Hr.test(r)===!1)throw Error("Expecting a HexDecimal digits");s+=r}return{type:"Character",value:parseInt(s,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(e!==void 0&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}}class ze{visitChildren(e){for(let s in e){let n=e[s];if(e.hasOwnProperty(s)){if(n.type!==void 0)this.visit(n);else if(Array.isArray(n))n.forEach((i)=>{this.visit(i)},this)}}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Lookbehind":this.visitLookbehind(e);break;case"NegativeLookbehind":this.visitNegativeLookbehind(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e);break}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}}var Ht={},Yr=new zt;function He(e){let s=e.toString();if(Ht.hasOwnProperty(s))return Ht[s];else{let n=Yr.pattern(s);return Ht[s]=n,n}}function Cn(){Ht={}}var _n="Complement Sets are not supported for first char optimization",Ot=`Unable to use "first char" lexer optimizations:
|
|
10
|
+
`;function xn(e,s=!1){try{let n=He(e);return Ps(n.value,{},n.flags.ignoreCase)}catch(n){if(n.message===_n){if(s)Tt(`${Ot} Unable to optimize: < ${e.toString()} >
|
|
11
11
|
Complement Sets cannot be automatically optimized.
|
|
12
12
|
This will disable the lexer's first char optimizations.
|
|
13
13
|
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`)}else{let i="";if(s)i=`
|
|
14
14
|
This will disable the lexer's first char optimizations.
|
|
15
|
-
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`;tt(`${
|
|
15
|
+
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`;tt(`${Ot}
|
|
16
16
|
Failed parsing: < ${e.toString()} >
|
|
17
17
|
Using the @chevrotain/regexp-to-ast library
|
|
18
|
-
Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+i)}}return[]}function Ps(e,s,n){switch(e.type){case"Disjunction":for(let r=0;r<e.value.length;r++)Ps(e.value[r],s,n);break;case"Alternative":let i=e.value;for(let r=0;r<i.length;r++){let o=i[r];switch(o.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}let h=o;switch(h.type){case"Character":Xt(h.value,s,n);break;case"Set":if(h.complement===!0)throw Error(_n);h.value.forEach((c)=>{if(typeof c==="number")Xt(c,s,n);else{let d=c;if(n===!0)for(let f=d.from;f<=d.to;f++)Xt(f,s,n);else{for(let f=d.from;f<=d.to&&f<it;f++)Xt(f,s,n);if(d.to>=it){let f=d.from>=it?d.from:it,m=d.to,y=ve(f),I=ve(m);for(let P=y;P<=I;P++)s[P]=P}}}});break;case"Group":Ps(h.value,s,n);break;default:throw Error("Non Exhaustive Match")}let u=h.quantifier!==void 0&&h.quantifier.atLeast===0;if(h.type==="Group"&&Ds(h)===!1||h.type!=="Group"&&u===!1)break}break;default:throw Error("non exhaustive match!")}return Object.values(s)}function Xt(e,s,n){let i=ve(e);if(s[i]=i,n===!0)qr(e,s)}function qr(e,s){let n=String.fromCharCode(e),i=n.toUpperCase();if(i!==n){let r=ve(i.charCodeAt(0));s[r]=r}else{let r=n.toLowerCase();if(r!==n){let o=ve(r.charCodeAt(0));s[o]=o}}}function bn(e,s){return e.value.find((n)=>{if(typeof n==="number")return s.includes(n);else{let i=n;return s.find((r)=>i.from<=r&&r<=i.to)!==void 0}})}function Ds(e){let s=e.quantifier;if(s&&s.atLeast===0)return!0;if(!e.value)return!1;return Array.isArray(e.value)?e.value.every(Ds):Ds(e.value)}class vn extends ze{constructor(e){super();this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found===!0)return;switch(e.type){case"Lookahead":this.visitLookahead(e);return;case"NegativeLookahead":this.visitNegativeLookahead(e);return;case"Lookbehind":this.visitLookbehind(e);return;case"NegativeLookbehind":this.visitNegativeLookbehind(e);return}super.visitChildren(e)}visitCharacter(e){if(this.targetCharCodes.includes(e.value))this.found=!0}visitSet(e){if(e.complement){if(bn(e,this.targetCharCodes)===void 0)this.found=!0}else if(bn(e,this.targetCharCodes)!==void 0)this.found=!0}}function Yt(e,s){if(s instanceof RegExp){let n=He(s),i=new vn(e);return i.visit(n),i.found}else{for(let n of s){let i=n.charCodeAt(0);if(e.includes(i))return!0}return!1}}var Xe="PATTERN",rt="defaultMode",qt="modes",Zt=0,
|
|
19
|
-
`],tracer:(b,g)=>g()},s);let n=s.tracer;n("initCharCodeToOptimizedIndexMap",()=>{Ea()});let i;n("Reject Lexer.NA",()=>{i=e.filter((b)=>b[Xe]!==z.NA)});let r=!1,o;n("Transform Patterns",()=>{r=!1,o=i.map((b)=>{let g=b[Xe];if(g instanceof RegExp){let U=g.source;if(U.length===1&&U!=="^"&&U!=="$"&&U!=="."&&!g.ignoreCase)return U;else if(U.length===2&&U[0]==="\\"&&!["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"].includes(U[1]))return U[1];else return Mn(g)}else if(typeof g==="function")return r=!0,{exec:g};else if(typeof g==="object")return r=!0,g;else if(typeof g==="string")if(g.length===1)return g;else{let U=g.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),te=new RegExp(U);return Mn(te)}else throw Error("non exhaustive match")})});let h,u,c,d,f;n("misc mapping",()=>{h=i.map((b)=>b.tokenTypeIdx),u=i.map((b)=>{let g=b.GROUP;if(g===z.SKIPPED)return;else if(typeof g==="string")return g;else if(g===void 0)return!1;else throw Error("non exhaustive match")}),c=i.map((b)=>{let g=b.LONGER_ALT;if(g)return Array.isArray(g)?g.map((te)=>i.indexOf(te)):[i.indexOf(g)]}),d=i.map((b)=>b.PUSH_MODE),f=i.map((b)=>Object.hasOwn(b,"POP_MODE"))});let m;n("Line Terminator Handling",()=>{let b=Gn(s.lineTerminatorCharacters);if(m=i.map((g)=>!1),s.positionTracking!=="onlyOffset")m=i.map((g)=>{if(Object.hasOwn(g,"LINE_BREAKS"))return!!g.LINE_BREAKS;else return $n(g,b)===!1&&Yt(b,g.PATTERN)})});let y,I,P,D;n("Misc Mapping #2",()=>{y=i.map(Fn),I=o.map(fa),P=i.reduce((b,g)=>{let U=g.GROUP;if(typeof U==="string"&&U!==z.SKIPPED)b[U]=[];return b},{}),D=o.map((b,g)=>{let U=u[g]===void 0&&c[g]===void 0?Jr(i[g].PATTERN):void 0;return{pattern:o[g],asciiClass:U,longerAlt:c[g],canLineTerminator:m[g],matchType:U!==void 0?es:I[g]!==!1?Zt:y[g]?
|
|
18
|
+
Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+i)}}return[]}function Ps(e,s,n){switch(e.type){case"Disjunction":for(let r=0;r<e.value.length;r++)Ps(e.value[r],s,n);break;case"Alternative":let i=e.value;for(let r=0;r<i.length;r++){let o=i[r];switch(o.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}let h=o;switch(h.type){case"Character":Xt(h.value,s,n);break;case"Set":if(h.complement===!0)throw Error(_n);h.value.forEach((c)=>{if(typeof c==="number")Xt(c,s,n);else{let d=c;if(n===!0)for(let f=d.from;f<=d.to;f++)Xt(f,s,n);else{for(let f=d.from;f<=d.to&&f<it;f++)Xt(f,s,n);if(d.to>=it){let f=d.from>=it?d.from:it,m=d.to,y=ve(f),I=ve(m);for(let P=y;P<=I;P++)s[P]=P}}}});break;case"Group":Ps(h.value,s,n);break;default:throw Error("Non Exhaustive Match")}let u=h.quantifier!==void 0&&h.quantifier.atLeast===0;if(h.type==="Group"&&Ds(h)===!1||h.type!=="Group"&&u===!1)break}break;default:throw Error("non exhaustive match!")}return Object.values(s)}function Xt(e,s,n){let i=ve(e);if(s[i]=i,n===!0)qr(e,s)}function qr(e,s){let n=String.fromCharCode(e),i=n.toUpperCase();if(i!==n){let r=ve(i.charCodeAt(0));s[r]=r}else{let r=n.toLowerCase();if(r!==n){let o=ve(r.charCodeAt(0));s[o]=o}}}function bn(e,s){return e.value.find((n)=>{if(typeof n==="number")return s.includes(n);else{let i=n;return s.find((r)=>i.from<=r&&r<=i.to)!==void 0}})}function Ds(e){let s=e.quantifier;if(s&&s.atLeast===0)return!0;if(!e.value)return!1;return Array.isArray(e.value)?e.value.every(Ds):Ds(e.value)}class vn extends ze{constructor(e){super();this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found===!0)return;switch(e.type){case"Lookahead":this.visitLookahead(e);return;case"NegativeLookahead":this.visitNegativeLookahead(e);return;case"Lookbehind":this.visitLookbehind(e);return;case"NegativeLookbehind":this.visitNegativeLookbehind(e);return}super.visitChildren(e)}visitCharacter(e){if(this.targetCharCodes.includes(e.value))this.found=!0}visitSet(e){if(e.complement){if(bn(e,this.targetCharCodes)===void 0)this.found=!0}else if(bn(e,this.targetCharCodes)!==void 0)this.found=!0}}function Yt(e,s){if(s instanceof RegExp){let n=He(s),i=new vn(e);return i.visit(n),i.found}else{for(let n of s){let i=n.charCodeAt(0);if(e.includes(i))return!0}return!1}}var Xe="PATTERN",rt="defaultMode",qt="modes",Zt=0,Lt=1,Qt=2,es=3;function wn(e,s){s=Object.assign({safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
|
|
19
|
+
`],tracer:(b,g)=>g()},s);let n=s.tracer;n("initCharCodeToOptimizedIndexMap",()=>{Ea()});let i;n("Reject Lexer.NA",()=>{i=e.filter((b)=>b[Xe]!==z.NA)});let r=!1,o;n("Transform Patterns",()=>{r=!1,o=i.map((b)=>{let g=b[Xe];if(g instanceof RegExp){let U=g.source;if(U.length===1&&U!=="^"&&U!=="$"&&U!=="."&&!g.ignoreCase)return U;else if(U.length===2&&U[0]==="\\"&&!["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"].includes(U[1]))return U[1];else return Mn(g)}else if(typeof g==="function")return r=!0,{exec:g};else if(typeof g==="object")return r=!0,g;else if(typeof g==="string")if(g.length===1)return g;else{let U=g.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),te=new RegExp(U);return Mn(te)}else throw Error("non exhaustive match")})});let h,u,c,d,f;n("misc mapping",()=>{h=i.map((b)=>b.tokenTypeIdx),u=i.map((b)=>{let g=b.GROUP;if(g===z.SKIPPED)return;else if(typeof g==="string")return g;else if(g===void 0)return!1;else throw Error("non exhaustive match")}),c=i.map((b)=>{let g=b.LONGER_ALT;if(g)return Array.isArray(g)?g.map((te)=>i.indexOf(te)):[i.indexOf(g)]}),d=i.map((b)=>b.PUSH_MODE),f=i.map((b)=>Object.hasOwn(b,"POP_MODE"))});let m;n("Line Terminator Handling",()=>{let b=Gn(s.lineTerminatorCharacters);if(m=i.map((g)=>!1),s.positionTracking!=="onlyOffset")m=i.map((g)=>{if(Object.hasOwn(g,"LINE_BREAKS"))return!!g.LINE_BREAKS;else return $n(g,b)===!1&&Yt(b,g.PATTERN)})});let y,I,P,D;n("Misc Mapping #2",()=>{y=i.map(Fn),I=o.map(fa),P=i.reduce((b,g)=>{let U=g.GROUP;if(typeof U==="string"&&U!==z.SKIPPED)b[U]=[];return b},{}),D=o.map((b,g)=>{let U=u[g]===void 0&&c[g]===void 0?Jr(i[g].PATTERN):void 0;return{pattern:o[g],asciiClass:U,longerAlt:c[g],canLineTerminator:m[g],matchType:U!==void 0?es:I[g]!==!1?Zt:y[g]?Lt:Qt,short:I[g],group:u[g],push:d[g],pop:f[g],tokenTypeIdx:h[g],tokenType:i[g]}})});let w=!0,_=[];if(!s.safeMode)n("First Char Optimization",()=>{_=i.reduce((b,g,U)=>{if(typeof g.PATTERN==="string"){let te=g.PATTERN.charCodeAt(0),ce=ve(te);Fs(b,ce,D[U])}else if(Array.isArray(g.START_CHARS_HINT)){let te;g.START_CHARS_HINT.forEach((ce)=>{let pt=typeof ce==="string"?ce.charCodeAt(0):ce,Me=ve(pt);if(te!==Me)te=Me,Fs(b,Me,D[U])})}else if(g.PATTERN instanceof RegExp)if(g.PATTERN.unicode){if(w=!1,s.ensureOptimizations)tt(`${Ot} Unable to analyze < ${g.PATTERN.toString()} > pattern.
|
|
20
20
|
The regexp unicode flag is not currently supported by the regexp-to-ast library.
|
|
21
21
|
This will disable the lexer's first char optimizations.
|
|
22
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`)}else{let te=xn(g.PATTERN,s.ensureOptimizations);if(te.length===0)w=!1;te.forEach((ce)=>{Fs(b,ce,D[U])})}else{if(s.ensureOptimizations)tt(`${
|
|
22
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`)}else{let te=xn(g.PATTERN,s.ensureOptimizations);if(te.length===0)w=!1;te.forEach((ce)=>{Fs(b,ce,D[U])})}else{if(s.ensureOptimizations)tt(`${Ot} TokenType: <${g.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
|
|
23
23
|
This will disable the lexer's first char optimizations.
|
|
24
24
|
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`);w=!1}return b},[])});return{emptyGroups:P,patternIdxToConfig:D,charCodeToPatternIdxToConfig:_,hasCustom:r,canBeOptimized:w}}function Jr(e){var s,n;if(!(e instanceof RegExp)||e.flags!=="")return;let i;try{i=He(e)}catch(u){return}if(i.value.value.length!==1||i.value.value[0].value.length!==1)return;let r=i.value.value[0].value[0],o;while(r.type==="Group"){if(r.capturing||r.quantifier!==void 0&&o!==void 0||r.value.value.length!==1||r.value.value[0].value.length!==1)return;o=(s=r.quantifier)!==null&&s!==void 0?s:o,r=r.value.value[0].value[0]}if(r.type!=="Set"||r.complement||r.quantifier!==void 0&&o!==void 0)return;if(o=(n=r.quantifier)!==null&&n!==void 0?n:o,(o===null||o===void 0?void 0:o.atLeast)!==1||o.atMost!==1/0||!o.greedy)return;let h=new Uint8Array(128);for(let u of r.value){let c=typeof u==="number"?u:u.from,d=typeof u==="number"?u:u.to;if(c<0||d>=h.length)return;h.fill(1,c,d+1)}return h}function Un(e,s){let n=[],i=Qr(e);n=n.concat(i.errors);let r=ea(i.valid),o=r.valid;return n=n.concat(r.errors),n=n.concat(Zr(o)),n=n.concat(la(o)),n=n.concat(ca(o,s)),n=n.concat(ha(o)),n}function Zr(e){let s=[],n=e.filter((i)=>i[Xe]instanceof RegExp);return s=s.concat(sa(n)),s=s.concat(ra(n)),s=s.concat(aa(n)),s=s.concat(oa(n)),s=s.concat(na(n)),s}function Qr(e){let s=e.filter((r)=>!Object.hasOwn(r,Xe)),n=s.map((r)=>({message:"Token Type: ->"+r.name+"<- missing static 'PATTERN' property",type:V.MISSING_PATTERN,tokenTypes:[r]})),i=e.filter((r)=>!s.includes(r));return{errors:n,valid:i}}function ea(e){let s=e.filter((r)=>{let o=r[Xe];return!(o instanceof RegExp)&&typeof o!=="function"&&!Object.hasOwn(o,"exec")&&typeof o!=="string"}),n=s.map((r)=>({message:"Token Type: ->"+r.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:V.INVALID_PATTERN,tokenTypes:[r]})),i=e.filter((r)=>!s.includes(r));return{errors:n,valid:i}}var ta=/[^\\][$]/;function sa(e){class s extends ze{constructor(){super(...arguments);this.found=!1}visitEndAnchor(r){this.found=!0}}return e.filter((r)=>{let o=r.PATTERN;try{let h=He(o),u=new s;return u.visit(h),u.found}catch(h){return ta.test(o.source)}}).map((r)=>({message:`Unexpected RegExp Anchor Error:
|
|
25
25
|
Token Type: ->`+r.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
|
|
@@ -41,17 +41,17 @@ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;s.
|
|
|
41
41
|
Root cause: ${s.errMsg}.
|
|
42
42
|
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;else if(s.issue===V.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
|
|
43
43
|
The problem is in the <${e.name}> Token Type
|
|
44
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;else throw Error("non exhaustive match")}function Gn(e){return e.map((n)=>{if(typeof n==="string")return n.charCodeAt(0);else return n})}function Fs(e,s,n){if(e[s]===void 0)e[s]=[n];else e[s].push(n)}var it=256,Jt=[];function ve(e){return e<it?e:Jt[e]}function Ea(){if(Jt.length===0){Jt=Array(65536);for(let e=0;e<65536;e++)Jt[e]=e>255?255+~~(e/255):e}}function Ue(e,s){let n=e.tokenTypeIdx;if(n===s.tokenTypeIdx)return!0;else return s.isParent===!0&&s.categoryMatchesMap[n]===!0}function at(e,s){return e.tokenTypeIdx===s.tokenTypeIdx}var Wn=1,Kn={};function Pe(e){let s=Ta(e);ga(s),Sa(s),Aa(s),s.forEach((n)=>{n.isParent=n.categoryMatches.length>0})}function Ta(e){let s=[...e],n=e,i=!0;while(i){n=n.map((o)=>o.CATEGORIES).flat().filter(Boolean);let r=n.filter((o)=>!s.includes(o));if(s=s.concat(r),r.length===0)i=!1;else n=r}return s}function ga(e){e.forEach((s)=>{if(!Bs(s))Kn[Wn]=s,s.tokenTypeIdx=Wn++;if(jn(s)&&!Array.isArray(s.CATEGORIES))s.CATEGORIES=[s.CATEGORIES];if(!jn(s))s.CATEGORIES=[];if(!Ra(s))s.categoryMatches=[];if(!ya(s))s.categoryMatchesMap={}})}function Aa(e){e.forEach((s)=>{s.categoryMatches=[],Object.keys(s.categoryMatchesMap).forEach((n)=>{s.categoryMatches.push(Kn[n].tokenTypeIdx)})})}function Sa(e){e.forEach((s)=>{Vn([],s)})}function Vn(e,s){e.forEach((n)=>{s.categoryMatchesMap[n.tokenTypeIdx]=!0}),s.CATEGORIES.forEach((n)=>{let i=e.concat(s);if(!i.includes(n))Vn(i,n)})}function Bs(e){return Object.hasOwn(e!==null&&e!==void 0?e:{},"tokenTypeIdx")}function jn(e){return Object.hasOwn(e!==null&&e!==void 0?e:{},"CATEGORIES")}function Ra(e){return Object.hasOwn(e!==null&&e!==void 0?e:{},"categoryMatches")}function ya(e){return Object.hasOwn(e!==null&&e!==void 0?e:{},"categoryMatchesMap")}function zn(e){return Object.hasOwn(e!==null&&e!==void 0?e:{},"tokenTypeIdx")}var $s={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,s,n,i,r,o){return`unexpected character: ->${e.charAt(s)}<- at offset: ${s}, skipped ${n} characters.`}};var V;(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"})(V||(V={}));var
|
|
45
|
-
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:$s,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(
|
|
46
|
-
a boolean 2nd argument is no longer supported`);this.config=Object.assign({},
|
|
44
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;else throw Error("non exhaustive match")}function Gn(e){return e.map((n)=>{if(typeof n==="string")return n.charCodeAt(0);else return n})}function Fs(e,s,n){if(e[s]===void 0)e[s]=[n];else e[s].push(n)}var it=256,Jt=[];function ve(e){return e<it?e:Jt[e]}function Ea(){if(Jt.length===0){Jt=Array(65536);for(let e=0;e<65536;e++)Jt[e]=e>255?255+~~(e/255):e}}function Ue(e,s){let n=e.tokenTypeIdx;if(n===s.tokenTypeIdx)return!0;else return s.isParent===!0&&s.categoryMatchesMap[n]===!0}function at(e,s){return e.tokenTypeIdx===s.tokenTypeIdx}var Wn=1,Kn={};function Pe(e){let s=Ta(e);ga(s),Sa(s),Aa(s),s.forEach((n)=>{n.isParent=n.categoryMatches.length>0})}function Ta(e){let s=[...e],n=e,i=!0;while(i){n=n.map((o)=>o.CATEGORIES).flat().filter(Boolean);let r=n.filter((o)=>!s.includes(o));if(s=s.concat(r),r.length===0)i=!1;else n=r}return s}function ga(e){e.forEach((s)=>{if(!Bs(s))Kn[Wn]=s,s.tokenTypeIdx=Wn++;if(jn(s)&&!Array.isArray(s.CATEGORIES))s.CATEGORIES=[s.CATEGORIES];if(!jn(s))s.CATEGORIES=[];if(!Ra(s))s.categoryMatches=[];if(!ya(s))s.categoryMatchesMap={}})}function Aa(e){e.forEach((s)=>{s.categoryMatches=[],Object.keys(s.categoryMatchesMap).forEach((n)=>{s.categoryMatches.push(Kn[n].tokenTypeIdx)})})}function Sa(e){e.forEach((s)=>{Vn([],s)})}function Vn(e,s){e.forEach((n)=>{s.categoryMatchesMap[n.tokenTypeIdx]=!0}),s.CATEGORIES.forEach((n)=>{let i=e.concat(s);if(!i.includes(n))Vn(i,n)})}function Bs(e){return Object.hasOwn(e!==null&&e!==void 0?e:{},"tokenTypeIdx")}function jn(e){return Object.hasOwn(e!==null&&e!==void 0?e:{},"CATEGORIES")}function Ra(e){return Object.hasOwn(e!==null&&e!==void 0?e:{},"categoryMatches")}function ya(e){return Object.hasOwn(e!==null&&e!==void 0?e:{},"categoryMatchesMap")}function zn(e){return Object.hasOwn(e!==null&&e!==void 0?e:{},"tokenTypeIdx")}var $s={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,s,n,i,r,o){return`unexpected character: ->${e.charAt(s)}<- at offset: ${s}, skipped ${n} characters.`}};var V;(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"})(V||(V={}));var Nt={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
|
|
45
|
+
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:$s,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Nt);class z{constructor(e,s=Nt){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.cachedGroupKeys=[],this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(i,r)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let o=Array(this.traceInitIndent+1).join("\t");if(this.traceInitIndent<this.traceInitMaxIdent)console.log(`${o}--> <${i}>`);let{time:h,value:u}=gt(r),c=h>10?console.warn:console.log;if(this.traceInitIndent<this.traceInitMaxIdent)c(`${o}<-- <${i}> time: ${h}ms`);return this.traceInitIndent--,u}else return r()},typeof s==="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
|
|
46
|
+
a boolean 2nd argument is no longer supported`);this.config=Object.assign({},Nt,s);let n=this.config.traceInitPerf;if(n===!0)this.traceInitMaxIdent=1/0,this.traceInitPerf=!0;else if(typeof n==="number")this.traceInitMaxIdent=n,this.traceInitPerf=!0;this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let i,r=!0;if(this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===Nt.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Bn;else if(this.config.lineTerminatorCharacters===Nt.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
|
|
47
47
|
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(s.safeMode&&s.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');if(this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),Array.isArray(e))i={modes:{defaultMode:[...e]},defaultMode:rt};else r=!1,i=Object.assign({},e)}),this.config.skipValidations===!1)this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Pn(i,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Dn(i,this.trackStartLines,this.config.lineTerminatorCharacters))});i.modes=i.modes?i.modes:{},Object.entries(i.modes).forEach(([h,u])=>{i.modes[h]=u.filter((c)=>c!==void 0)});let o=Object.keys(i.modes);if(Object.entries(i.modes).forEach(([h,u])=>{this.TRACE_INIT(`Mode: <${h}> processing`,()=>{if(this.modes.push(h),this.config.skipValidations===!1)this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Un(u,o))});if(this.lexerDefinitionErrors.length===0){Pe(u);let c;this.TRACE_INIT("analyzeTokenTypes",()=>{c=wn(u,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:s.positionTracking,ensureOptimizations:s.ensureOptimizations,safeMode:s.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[h]=c.patternIdxToConfig,this.charCodeToPatternIdxToConfig[h]=c.charCodeToPatternIdxToConfig,this.emptyGroups=Object.assign({},this.emptyGroups,c.emptyGroups),this.hasCustom=c.hasCustom||this.hasCustom,this.canModeBeOptimized[h]=c.canBeOptimized}})}),this.defaultMode=i.defaultMode,this.cachedGroupKeys=Object.keys(this.emptyGroups),this.lexerDefinitionErrors.length>0&&!this.config.deferDefinitionErrorsHandling){let u=this.lexerDefinitionErrors.map((c)=>c.message).join(`-----------------------
|
|
48
48
|
`);throw Error(`Errors detected in definition of Lexer:
|
|
49
49
|
`+u)}this.lexerDefinitionWarning.forEach((h)=>{Tt(h.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(r)this.handleModes=()=>{};if(this.trackStartLines===!1)this.computeNewColumn=(h)=>h;if(this.trackEndLines===!1)this.updateTokenEndLineColumnLocation=()=>{};if(/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}"`);if(this.hasCustom)this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom;else this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom}),this.TRACE_INIT("Failed Optimization Warnings",()=>{let h=Object.entries(this.canModeBeOptimized).reduce((u,[c,d])=>{if(d===!1)u.push(c);return u},[]);if(s.ensureOptimizations&&h.length>0)throw Error(`Lexer Modes: < ${h.join(", ")} > cannot be optimized.
|
|
50
50
|
Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
|
|
51
51
|
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{Cn()}),this.TRACE_INIT("toFastProperties",()=>{At(this)})})}tokenize(e,s=this.defaultMode){if(this.lexerDefinitionErrors.length>0){let i=this.lexerDefinitionErrors.map((r)=>r.message).join(`-----------------------
|
|
52
52
|
`);throw Error(`Unable to Tokenize because Errors detected in definition of Lexer:
|
|
53
|
-
`+i)}return this.tokenizeInternal(e,s)}tokenizeInternal(e,s){let n,i,r,o,h,u,c,d,f,m,y,I,P,D,w,_=e,b=_.length,g=0,U=0,te=this.hasCustom?0:Math.floor(e.length/10),ce=Array(te),pt=[],Me=this.trackStartLines?1:void 0,_e=this.trackStartLines?1:void 0,et={};for(let ne=0;ne<this.cachedGroupKeys.length;ne++)et[this.cachedGroupKeys[ne]]=[];let Br=this.trackStartLines,ks=this.config.lineTerminatorsPattern,Cs=0,We=[],ft=[],mt=[],yn=[];Object.freeze(yn);let Et=!1,$r=(ne)=>{if(mt.length===1&&ne.tokenType.PUSH_MODE===void 0){let Le=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(ne);pt.push({offset:ne.startOffset,line:ne.startLine,column:ne.startColumn,length:ne.image.length,message:Le})}else{mt.pop();let Le=mt.at(-1);We=this.patternIdxToConfig[Le],ft=this.charCodeToPatternIdxToConfig[Le],Cs=We.length;let bs=this.canModeBeOptimized[Le]&&this.config.safeMode===!1;if(ft&&bs)Et=!0;else Et=!1}};function On(ne){mt.push(ne),ft=this.charCodeToPatternIdxToConfig[ne],We=this.patternIdxToConfig[ne],Cs=We.length;let Le=this.canModeBeOptimized[ne]&&this.config.safeMode===!1;if(ft&&Le)Et=!0;else Et=!1}On.call(this,s);let Oe,Ln=this.config.recoveryEnabled;while(g<b){u=null,f=-1;let ne=_.charCodeAt(g),Le;if(Et){let ae=ve(ne),Ee=ft[ae];Le=Ee!==void 0?Ee:yn}else Le=We;let bs=Le.length;for(n=0;n<bs;n++){Oe=Le[n];let ae=Oe.pattern;switch(c=null,Oe.matchType){case Zt:if(ne===Oe.short)f=1,u=ae;break;case
|
|
54
|
-
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;if(Object.hasOwn(e,Hn))n.CATEGORIES=e[Hn];if(Pe([n]),Object.hasOwn(e,Xn))n.LABEL=e[Xn];if(Object.hasOwn(e,Yn))n.GROUP=e[Yn];if(Object.hasOwn(e,Jn))n.POP_MODE=e[Jn];if(Object.hasOwn(e,qn))n.PUSH_MODE=e[qn];if(Object.hasOwn(e,Zn))n.LONGER_ALT=e[Zn];if(Object.hasOwn(e,Qn))n.LINE_BREAKS=e[Qn];if(Object.hasOwn(e,ei))n.START_CHARS_HINT=e[ei];return n}var Re=k({name:"EOF",pattern:z.NA});Pe([Re]);function qe(e,s,n,i,r,o,h,u){return{image:s,startOffset:n,endOffset:i,startLine:r,endLine:o,startColumn:h,endColumn:u,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function
|
|
53
|
+
`+i)}return this.tokenizeInternal(e,s)}tokenizeInternal(e,s){let n,i,r,o,h,u,c,d,f,m,y,I,P,D,w,_=e,b=_.length,g=0,U=0,te=this.hasCustom?0:Math.floor(e.length/10),ce=Array(te),pt=[],Me=this.trackStartLines?1:void 0,_e=this.trackStartLines?1:void 0,et={};for(let ne=0;ne<this.cachedGroupKeys.length;ne++)et[this.cachedGroupKeys[ne]]=[];let Br=this.trackStartLines,ks=this.config.lineTerminatorsPattern,Cs=0,We=[],ft=[],mt=[],yn=[];Object.freeze(yn);let Et=!1,$r=(ne)=>{if(mt.length===1&&ne.tokenType.PUSH_MODE===void 0){let Le=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(ne);pt.push({offset:ne.startOffset,line:ne.startLine,column:ne.startColumn,length:ne.image.length,message:Le})}else{mt.pop();let Le=mt.at(-1);We=this.patternIdxToConfig[Le],ft=this.charCodeToPatternIdxToConfig[Le],Cs=We.length;let bs=this.canModeBeOptimized[Le]&&this.config.safeMode===!1;if(ft&&bs)Et=!0;else Et=!1}};function On(ne){mt.push(ne),ft=this.charCodeToPatternIdxToConfig[ne],We=this.patternIdxToConfig[ne],Cs=We.length;let Le=this.canModeBeOptimized[ne]&&this.config.safeMode===!1;if(ft&&Le)Et=!0;else Et=!1}On.call(this,s);let Oe,Ln=this.config.recoveryEnabled;while(g<b){u=null,f=-1;let ne=_.charCodeAt(g),Le;if(Et){let ae=ve(ne),Ee=ft[ae];Le=Ee!==void 0?Ee:yn}else Le=We;let bs=Le.length;for(n=0;n<bs;n++){Oe=Le[n];let ae=Oe.pattern;switch(c=null,Oe.matchType){case Zt:if(ne===Oe.short)f=1,u=ae;break;case Lt:if(w=ae.exec(_,g,ce,et),w!==null){if(u=w[0],f=u.length,w.payload!==void 0)c=w.payload}else u=null;break;case es:{let Ee=Oe.asciiClass;if(Ee[ne]!==1){ae.lastIndex=0;break}let fe=g+1;while(Ee[_.charCodeAt(fe)]===1)fe++;f=fe-g,ae.lastIndex=fe;break}case Qt:ae.lastIndex=g,f=this.matchLength(ae,e,g);break}if(f!==-1){if(h=Oe.longerAlt,h!==void 0){u=e.substring(g,g+f);let Ee=h.length;for(r=0;r<Ee;r++){let fe=We[h[r]],we=fe.pattern;if(d=null,fe.matchType===Lt)if(w=we.exec(_,g,ce,et),w!==null){if(o=w[0],w.payload!==void 0)d=w.payload}else o=null;else we.lastIndex=g,o=this.match(we,e,g);if(o&&o.length>u.length){u=o,f=o.length,c=d,Oe=fe;break}}}break}}if(f!==-1){if(m=Oe.group,m!==void 0)if(u=u!==null?u:e.substring(g,g+f),y=Oe.tokenTypeIdx,I=this.createTokenInstance(u,g,y,Oe.tokenType,Me,_e,f),this.handlePayload(I,c),m===!1)U=this.addToken(ce,U,I);else et[m].push(I);if(Br===!0&&Oe.canLineTerminator===!0){let ae=0,Ee,fe;ks.lastIndex=0;do if(u=u!==null?u:e.substring(g,g+f),Ee=ks.test(u),Ee===!0)fe=ks.lastIndex-1,ae++;while(Ee===!0);if(ae!==0)Me=Me+ae,_e=f-fe,this.updateTokenEndLineColumnLocation(I,m,fe,ae,Me,_e,f);else _e=this.computeNewColumn(_e,f)}else _e=this.computeNewColumn(_e,f);g=g+f,this.handleModes(Oe,$r,On,I)}else{let ae=g,Ee=Me,fe=_e,we=Ln===!1;while(we===!1&&g<b){g++;for(i=0;i<Cs;i++){let _s=We[i],xs=_s.pattern;switch(_s.matchType){case Zt:if(_.charCodeAt(g)===_s.short)we=!0;break;case Lt:we=xs.exec(_,g,ce,et)!==null;break;case es:case Qt:xs.lastIndex=g,we=xs.exec(e)!==null;break}if(we===!0)break}}if(P=g-ae,_e=this.computeNewColumn(_e,P),D=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(_,ae,P,Ee,fe,mt.at(-1)),pt.push({offset:ae,line:Ee,column:fe,length:P,message:D}),Ln===!1)break}}if(!this.hasCustom)ce.length=U;return{tokens:ce,groups:et,errors:pt}}handleModes(e,s,n,i){if(e.pop===!0){let r=e.push;if(s(i),r!==void 0)n.call(this,r)}else if(e.push!==void 0)n.call(this,e.push)}updateTokenEndLineColumnLocation(e,s,n,i,r,o,h){let u,c;if(s!==void 0){if(u=n===h-1,c=u?-1:0,!(i===1&&u===!0))e.endLine=r+c,e.endColumn=o-1+-c}}computeNewColumn(e,s){return e+s}createOffsetOnlyToken(e,s,n,i){return{image:e,startOffset:s,tokenTypeIdx:n,tokenType:i}}createStartOnlyToken(e,s,n,i,r,o){return{image:e,startOffset:s,startLine:r,startColumn:o,tokenTypeIdx:n,tokenType:i}}createFullToken(e,s,n,i,r,o,h){return{image:e,startOffset:s,endOffset:s+h-1,startLine:r,endLine:r,startColumn:o,endColumn:o+h-1,tokenTypeIdx:n,tokenType:i}}addTokenUsingPush(e,s,n){return e.push(n),s}addTokenUsingMemberAccess(e,s,n){return e[s]=n,s++,s}handlePayloadNoCustom(e,s){}handlePayloadWithCustom(e,s){if(s!==null)e.payload=s}match(e,s,n){if(e.test(s)===!0)return s.substring(n,e.lastIndex);return null}matchLength(e,s,n){if(e.test(s)===!0)return e.lastIndex-n;return-1}}z.SKIPPED="This marks a skipped Token pattern, this means each token identified by it will be consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.";z.NA=/NOT_APPLICABLE/;function Ye(e){if(Gs(e))return e.LABEL;else return e.name}function Gs(e){return typeof e.LABEL==="string"&&e.LABEL!==""}var Oa="parent",Hn="categories",Xn="label",Yn="group",qn="push_mode",Jn="pop_mode",Zn="longer_alt",Qn="line_breaks",ei="start_chars_hint";function k(e){return La(e)}function La(e){let s=e.pattern,n={};if(n.name=e.name,s!==void 0)n.PATTERN=s;if(Object.hasOwn(e,Oa))throw`The parent property is no longer supported.
|
|
54
|
+
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;if(Object.hasOwn(e,Hn))n.CATEGORIES=e[Hn];if(Pe([n]),Object.hasOwn(e,Xn))n.LABEL=e[Xn];if(Object.hasOwn(e,Yn))n.GROUP=e[Yn];if(Object.hasOwn(e,Jn))n.POP_MODE=e[Jn];if(Object.hasOwn(e,qn))n.PUSH_MODE=e[qn];if(Object.hasOwn(e,Zn))n.LONGER_ALT=e[Zn];if(Object.hasOwn(e,Qn))n.LINE_BREAKS=e[Qn];if(Object.hasOwn(e,ei))n.START_CHARS_HINT=e[ei];return n}var Re=k({name:"EOF",pattern:z.NA});Pe([Re]);function qe(e,s,n,i,r,o,h,u){return{image:s,startOffset:n,endOffset:i,startLine:r,endLine:o,startColumn:h,endColumn:u,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function It(e,s){return Ue(e,s)}var ts={buildMismatchTokenMessage({expected:e,actual:s,previous:n,ruleName:i}){return`Expecting ${Gs(e)?`--> ${Ye(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${s.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:s}){return"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:s,previous:n,customUserDescription:i,ruleName:r}){let u=`
|
|
55
55
|
but found: '`+s[0].image+"'";if(i)return"Expecting: "+i+u;else return`Expecting: one of these possible Token sequences:
|
|
56
56
|
${e.reduce((y,I)=>y.concat(I),[]).map((y)=>`[${y.map((I)=>Ye(I)).join(", ")}]`).map((y,I)=>` ${I+1}. ${y}`).join(`
|
|
57
57
|
`)}`+u},buildEarlyExitMessage({expectedIterationPaths:e,actual:s,customUserDescription:n,ruleName:i}){let h=`
|
|
@@ -83,7 +83,7 @@ rule: <${s}> can be invoked from itself (directly or indirectly)
|
|
|
83
83
|
without consuming any Tokens. The grammar path that causes this is:
|
|
84
84
|
${i}
|
|
85
85
|
To fix this refactor your grammar to remove the left recursion.
|
|
86
|
-
see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return"deprecated"},buildDuplicateRuleNameError(e){let s;if(e.topLevelRule instanceof Te)s=e.topLevelRule.name;else s=e.topLevelRule;return`Duplicate definition, rule: ->${s}<- is already defined in the grammar: ->${e.grammarName}<-`}};function si(e,s){let n=new ni(e,s);return n.resolveRefs(),n.errors}class ni extends Ae{constructor(e,s){super();this.nameToTopRule=e,this.errMsgProvider=s,this.errors=[]}resolveRefs(){Object.values(this.nameToTopRule).forEach((e)=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let s=this.nameToTopRule[e.nonTerminalName];if(!s){let n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:n,type:ie.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}else e.referencedRule=s}}class ii extends $e{constructor(e,s){super();this.topProd=e,this.path=s,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=[...this.path.ruleStack].reverse(),this.occurrenceStack=[...this.path.occurrenceStack].reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,s=[]){if(!this.found)super.walk(e,s)}walkProdRef(e,s,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let i=s.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,i)}}updateExpectedNext(){if(this.ruleStack.length===0)this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0;else this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop()}}class Ws extends ii{constructor(e,s){super(e,s);this.path=s,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,s,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let i=s.concat(n),r=new j({definition:i});this.possibleTokTypes=Ke(r),this.found=!0}}}class Ct extends $e{constructor(e,s){super();this.topRule=e,this.occurrence=s,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class js extends Ct{walkMany(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof F)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkMany(e,s,n)}}class ss extends Ct{walkManySep(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof F)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkManySep(e,s,n)}}class Ks extends Ct{walkAtLeastOne(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof F)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkAtLeastOne(e,s,n)}}class ns extends Ct{walkAtLeastOneSep(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof F)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkAtLeastOneSep(e,s,n)}}function is(e,s,n=[]){n=[...n];let i=[],r=0;function o(u){return u.concat(e.slice(r+1))}function h(u){let c=is(o(u),s,n);return i.concat(c)}while(n.length<s&&r<e.length){let u=e[r];if(u instanceof j)return h(u.definition);else if(u instanceof W)return h(u.definition);else if(u instanceof K)i=h(u.definition);else if(u instanceof Z){let c=u.definition.concat([new G({definition:u.definition})]);return h(c)}else if(u instanceof Q){let c=[new j({definition:u.definition}),new G({definition:[new F({terminalType:u.separator})].concat(u.definition)})];return h(c)}else if(u instanceof q){let c=u.definition.concat([new G({definition:[new F({terminalType:u.separator})].concat(u.definition)})]);i=h(c)}else if(u instanceof G){let c=u.definition.concat([new G({definition:u.definition})]);i=h(c)}else if(u instanceof J)return u.definition.forEach((c)=>{if(c.definition.length!==0)i=h(c.definition)}),i;else if(u instanceof F)n.push(u.terminalType);else throw Error("non exhaustive match");r++}return i.push({partialPath:n,suffixDef:e.slice(r)}),i}function ri(e,s,n,i){let o=["EXIT_NONE_TERMINAL"],h="EXIT_ALTERNATIVE",u=!1,c=s.length,d=c-i-1,f=[],m=[];m.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});while(m.length!==0){let y=m.pop();if(y==="EXIT_ALTERNATIVE"){if(u&&m.at(-1).idx<=d)m.pop();continue}let{def:I,idx:P,ruleStack:D,occurrenceStack:w}=y;if(I.length===0)continue;let _=I[0];if(_==="EXIT_NONE_TERMINAL"){let b={idx:P,def:I.slice(1),ruleStack:D.slice(0,-1),occurrenceStack:w.slice(0,-1)};m.push(b)}else if(_ instanceof F)if(P<c-1){let b=P+1,g=s[b];if(n(g,_.terminalType)){let U={idx:b,def:I.slice(1),ruleStack:D,occurrenceStack:w};m.push(U)}}else if(P===c-1)f.push({nextTokenType:_.terminalType,nextTokenOccurrence:_.idx,ruleStack:D,occurrenceStack:w}),u=!0;else throw Error("non exhaustive match");else if(_ instanceof W){let b=[...D];b.push(_.nonTerminalName);let g=[...w];g.push(_.idx);let U={idx:P,def:_.definition.concat(o,I.slice(1)),ruleStack:b,occurrenceStack:g};m.push(U)}else if(_ instanceof K){let b={idx:P,def:I.slice(1),ruleStack:D,occurrenceStack:w};m.push(b),m.push("EXIT_ALTERNATIVE");let g={idx:P,def:_.definition.concat(I.slice(1)),ruleStack:D,occurrenceStack:w};m.push(g)}else if(_ instanceof Z){let b=new G({definition:_.definition,idx:_.idx}),g=_.definition.concat([b],I.slice(1)),U={idx:P,def:g,ruleStack:D,occurrenceStack:w};m.push(U)}else if(_ instanceof Q){let b=new F({terminalType:_.separator}),g=new G({definition:[b].concat(_.definition),idx:_.idx}),U=_.definition.concat([g],I.slice(1)),te={idx:P,def:U,ruleStack:D,occurrenceStack:w};m.push(te)}else if(_ instanceof q){let b={idx:P,def:I.slice(1),ruleStack:D,occurrenceStack:w};m.push(b),m.push("EXIT_ALTERNATIVE");let g=new F({terminalType:_.separator}),U=new G({definition:[g].concat(_.definition),idx:_.idx}),te=_.definition.concat([U],I.slice(1)),ce={idx:P,def:te,ruleStack:D,occurrenceStack:w};m.push(ce)}else if(_ instanceof G){let b={idx:P,def:I.slice(1),ruleStack:D,occurrenceStack:w};m.push(b),m.push("EXIT_ALTERNATIVE");let g=new G({definition:_.definition,idx:_.idx}),U=_.definition.concat([g],I.slice(1)),te={idx:P,def:U,ruleStack:D,occurrenceStack:w};m.push(te)}else if(_ instanceof J)for(let b=_.definition.length-1;b>=0;b--){let g=_.definition[b],U={idx:P,def:g.definition.concat(I.slice(1)),ruleStack:D,occurrenceStack:w};m.push(U),m.push("EXIT_ALTERNATIVE")}else if(_ instanceof j)m.push({idx:P,def:_.definition.concat(I.slice(1)),ruleStack:D,occurrenceStack:w});else if(_ instanceof Te)m.push(Na(_,P,D,w));else throw Error("non exhaustive match")}return f}function Na(e,s,n,i){let r=[...n];r.push(e.name);let o=[...i];return o.push(1),{idx:s,def:e.definition,ruleStack:r,occurrenceStack:o}}var H;(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"})(H||(H={}));function rs(e){if(e instanceof K||e==="Option")return H.OPTION;else if(e instanceof G||e==="Repetition")return H.REPETITION;else if(e instanceof Z||e==="RepetitionMandatory")return H.REPETITION_MANDATORY;else if(e instanceof Q||e==="RepetitionMandatoryWithSeparator")return H.REPETITION_MANDATORY_WITH_SEPARATOR;else if(e instanceof q||e==="RepetitionWithSeparator")return H.REPETITION_WITH_SEPARATOR;else if(e instanceof J||e==="Alternation")return H.ALTERNATION;else throw Error("non exhaustive match")}function oi(e,s,n,i,r,o){let h=bt(e,s,n),u=mi(h)?at:Ue;return o(h,i,u,r)}function li(e,s,n,i,r,o){let h=_t(e,s,r,n),u=mi(h)?at:Ue;return o(h[0],u,i)}function hi(e,s,n,i){let r=e.length,o=e.every((h)=>h.every((u)=>u.length===1));if(s)return function(h){let u=h.map((c)=>c.GATE);for(let c=0;c<r;c++){let d=e[c],f=d.length,m=u[c];if(m!==void 0&&m.call(this)===!1)continue;e:for(let y=0;y<f;y++){let I=d[y],P=I.length;for(let D=0;D<P;D++){let w=this.LA_FAST(D+1);if(n(w,I[D])===!1)continue e}return c}}return};else if(o&&!i){let u=e.map((c)=>c.flat()).reduce((c,d,f)=>(d.forEach((m)=>{if(!(m.tokenTypeIdx in c))c[m.tokenTypeIdx]=f;m.categoryMatches.forEach((y)=>{if(!Object.hasOwn(c,y))c[y]=f})}),c),{});return function(){let c=this.LA_FAST(1);return u[c.tokenTypeIdx]}}else return function(){for(let h=0;h<r;h++){let u=e[h],c=u.length;e:for(let d=0;d<c;d++){let f=u[d],m=f.length;for(let y=0;y<m;y++){let I=this.LA_FAST(y+1);if(n(I,f[y])===!1)continue e}return h}}return}}function ui(e,s,n){let i=e.every((o)=>o.length===1),r=e.length;if(i&&!n){let o=e.flat();if(o.length===1&&o[0].categoryMatches.length===0){let u=o[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===u}}else{let h=o.reduce((u,c,d)=>(u[c.tokenTypeIdx]=!0,c.categoryMatches.forEach((f)=>{u[f]=!0}),u),[]);return function(){let u=this.LA_FAST(1);return h[u.tokenTypeIdx]===!0}}}else return function(){e:for(let o=0;o<r;o++){let h=e[o],u=h.length;for(let c=0;c<u;c++){let d=this.LA_FAST(c+1);if(s(d,h[c])===!1)continue e}return!0}return!1}}class di extends $e{constructor(e,s,n){super();this.topProd=e,this.targetOccurrence=s,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,s,n,i){if(e.idx===this.targetOccurrence&&this.targetProdType===s)return this.restDef=n.concat(i),!0;return!1}walkOption(e,s,n){if(!this.checkIsTarget(e,H.OPTION,s,n))super.walkOption(e,s,n)}walkAtLeastOne(e,s,n){if(!this.checkIsTarget(e,H.REPETITION_MANDATORY,s,n))super.walkOption(e,s,n)}walkAtLeastOneSep(e,s,n){if(!this.checkIsTarget(e,H.REPETITION_MANDATORY_WITH_SEPARATOR,s,n))super.walkOption(e,s,n)}walkMany(e,s,n){if(!this.checkIsTarget(e,H.REPETITION,s,n))super.walkOption(e,s,n)}walkManySep(e,s,n){if(!this.checkIsTarget(e,H.REPETITION_WITH_SEPARATOR,s,n))super.walkOption(e,s,n)}}class zs extends Ae{constructor(e,s,n){super();this.targetOccurrence=e,this.targetProdType=s,this.targetRef=n,this.result=[]}checkIsTarget(e,s){if(e.idx===this.targetOccurrence&&this.targetProdType===s&&(this.targetRef===void 0||e===this.targetRef))this.result=e.definition}visitOption(e){this.checkIsTarget(e,H.OPTION)}visitRepetition(e){this.checkIsTarget(e,H.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,H.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,H.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,H.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,H.ALTERNATION)}}function ai(e){let s=Array(e);for(let n=0;n<e;n++)s[n]=[];return s}function Vs(e){let s=[""];for(let n=0;n<e.length;n++){let i=e[n],r=[];for(let o=0;o<s.length;o++){let h=s[o];r.push(h+"_"+i.tokenTypeIdx);for(let u=0;u<i.categoryMatches.length;u++){let c="_"+i.categoryMatches[u];r.push(h+c)}}s=r}return s}function Ia(e,s,n){for(let i=0;i<e.length;i++){if(i===n)continue;let r=e[i];for(let o=0;o<s.length;o++){let h=s[o];if(r[h]===!0)return!1}}return!0}function pi(e,s){let n=e.map((h)=>is([h],1)),i=ai(n.length),r=n.map((h)=>{let u={};return h.forEach((c)=>{Vs(c.partialPath).forEach((f)=>{u[f]=!0})}),u}),o=n;for(let h=1;h<=s;h++){let u=o;o=ai(u.length);for(let c=0;c<u.length;c++){let d=u[c];for(let f=0;f<d.length;f++){let m=d[f].partialPath,y=d[f].suffixDef,I=Vs(m);if(Ia(r,I,c)||y.length===0||m.length===s){let D=i[c];if(as(D,m)===!1){D.push(m);for(let w=0;w<I.length;w++){let _=I[w];r[c][_]=!0}}}else{let D=is(y,h+1,m);o[c]=o[c].concat(D),D.forEach((w)=>{Vs(w.partialPath).forEach((b)=>{r[c][b]=!0})})}}}}return i}function bt(e,s,n,i){let r=new zs(e,H.ALTERNATION,i);return s.accept(r),pi(r.result,n)}function _t(e,s,n,i){let r=new zs(e,n);s.accept(r);let o=r.result,u=new di(s,e,n).startWalking(),c=new j({definition:o}),d=new j({definition:u});return pi([c,d],i)}function as(e,s){e:for(let n=0;n<e.length;n++){let i=e[n];if(i.length!==s.length)continue;for(let r=0;r<i.length;r++){let o=s[r],h=i[r];if((o===h||h.categoryMatchesMap[o.tokenTypeIdx]!==void 0)===!1)continue e}return!0}return!1}function fi(e,s){return e.length<s.length&&e.every((n,i)=>{let r=s[i];return n===r||r.categoryMatchesMap[n.tokenTypeIdx]})}function mi(e){return e.every((s)=>s.every((n)=>n.every((i)=>i.categoryMatches.length===0)))}function Ei(e){return e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}).map((n)=>Object.assign({type:ie.CUSTOM_LOOKAHEAD_VALIDATION},n))}function Ti(e,s,n,i){let r=e.flatMap((c)=>ka(c,n)),o=Ma(e,s,n),h=e.flatMap((c)=>_a(c,n)),u=e.flatMap((c)=>ba(c,e,i,n));return r.concat(o,h,u)}function ka(e,s){let n=new Ai;e.accept(n);let i=n.allProductions,r=Object.groupBy(i,Ca),o=Object.fromEntries(Object.entries(r).filter(([u,c])=>c.length>1));return Object.values(o).map((u)=>{let c=u[0],d=s.buildDuplicateFoundError(e,u),f=Se(c),m={message:d,type:ie.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:f,occurrence:c.idx},y=gi(c);if(y)m.parameter=y;return m})}function Ca(e){return`${Se(e)}_#_${e.idx}_#_${gi(e)}`}function gi(e){if(e instanceof F)return e.terminalType.name;else if(e instanceof W)return e.nonTerminalName;else return""}class Ai extends Ae{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 ba(e,s,n,i){let r=[];if(s.reduce((h,u)=>{if(u.name===e.name)return h+1;return h},0)>1){let h=i.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});r.push({message:h,type:ie.DUPLICATE_RULE_NAME,ruleName:e.name})}return r}function Si(e,s,n){let i=[],r;if(!s.includes(e))r=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,i.push({message:r,type:ie.INVALID_RULE_OVERRIDE,ruleName:e});return i}function Hs(e,s,n,i=[]){let r=[],o=os(s.definition);if(o.length===0)return[];else{let h=e.name;if(o.includes(e))r.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:i}),type:ie.LEFT_RECURSION,ruleName:h});let c=i.concat([e]),f=o.filter((m)=>!c.includes(m)).flatMap((m)=>{let y=[...i];return y.push(m),Hs(e,m,n,y)});return r.concat(f)}}function os(e){let s=[];if(e.length===0)return s;let n=e[0];if(n instanceof W)s.push(n.referencedRule);else if(n instanceof j||n instanceof K||n instanceof Z||n instanceof Q||n instanceof q||n instanceof G)s=s.concat(os(n.definition));else if(n instanceof J)s=n.definition.map((o)=>os(o.definition)).flat();else if(n instanceof F);else throw Error("non exhaustive match");let i=je(n),r=e.length>1;if(i&&r){let o=e.slice(1);return s.concat(os(o))}else return s}class ls extends Ae{constructor(){super(...arguments);this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}function Ri(e,s){let n=new ls;return e.accept(n),n.alternations.flatMap((o)=>o.definition.slice(0,-1).flatMap((u,c)=>{if(ri([u],[],Ue,1).length===0)return[{message:s.buildEmptyAlternationError({topLevelRule:e,alternation:o,emptyChoiceIdx:c}),type:ie.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:o.idx,alternative:c+1}];else return[]}))}function yi(e,s,n){let i=new ls;e.accept(i);let r=i.alternations;return r=r.filter((h)=>h.ignoreAmbiguities!==!0),r.flatMap((h)=>{let u=h.idx,c=h.maxLookahead||s,d=bt(u,e,c,h),f=xa(d,h,e,n),m=va(d,h,e,n);return f.concat(m)})}class Oi extends Ae{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 _a(e,s){let n=new ls;return e.accept(n),n.alternations.flatMap((o)=>{if(o.definition.length>255)return[{message:s.buildTooManyAlternativesError({topLevelRule:e,alternation:o}),type:ie.TOO_MANY_ALTS,ruleName:e.name,occurrence:o.idx}];else return[]})}function Li(e,s,n){let i=[];return e.forEach((r)=>{let o=new Oi;r.accept(o),o.allProductions.forEach((u)=>{let c=rs(u),d=u.maxLookahead||s,f=u.idx;if(_t(f,r,c,d)[0].flat().length===0){let I=n.buildEmptyRepetitionError({topLevelRule:r,repetition:u});i.push({message:I,type:ie.NO_NON_EMPTY_LOOKAHEAD,ruleName:r.name})}})}),i}function xa(e,s,n,i){let r=[];return e.reduce((u,c,d)=>{if(s.definition[d].ignoreAmbiguities===!0)return u;return c.forEach((f)=>{let m=[d];if(e.forEach((y,I)=>{if(d!==I&&as(y,f)&&s.definition[I].ignoreAmbiguities!==!0)m.push(I)}),m.length>1&&!as(r,f))r.push(f),u.push({alts:m,path:f})}),u},[]).map((u)=>{let c=u.alts.map((f)=>f+1);return{message:i.buildAlternationAmbiguityError({topLevelRule:n,alternation:s,ambiguityIndices:c,prefixPath:u.path}),type:ie.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:s.idx,alternatives:u.alts}})}function va(e,s,n,i){let r=e.reduce((h,u,c)=>{let d=u.map((f)=>({idx:c,path:f}));return h.concat(d)},[]);return r.flatMap((h)=>{if(s.definition[h.idx].ignoreAmbiguities===!0)return[];let{idx:c,path:d}=h;return r.filter((y)=>s.definition[y.idx].ignoreAmbiguities!==!0&&y.idx<c&&fi(y.path,d)).map((y)=>{let I=[y.idx+1,c+1],P=s.idx===0?"":s.idx;return{message:i.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:s,ambiguityIndices:I,prefixPath:y.path}),type:ie.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:P,alternatives:I}})})}function Ma(e,s,n){let i=[],r=s.map((o)=>o.name);return e.forEach((o)=>{let h=o.name;if(r.includes(h)){let u=n.buildNamespaceConflictError(o);i.push({message:u,type:ie.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:h})}}),i}function Ni(e){let s=Object.assign({errMsgProvider:ti},e),n={};return e.rules.forEach((i)=>{n[i.name]=i}),si(n,s.errMsgProvider)}function Ii(e){var s;let n=(s=e.errMsgProvider)!==null&&s!==void 0?s:Ce;return Ti(e.rules,e.tokenTypes,n,e.grammarName)}var ki=["MismatchedTokenException","NoViableAltException","EarlyExitException","NotAllInputParsedException"];Object.freeze(ki);function Ge(e){return ki.includes(e.name)}class xt extends Error{constructor(e,s){super(e);if(this.token=s,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}}class ot extends xt{constructor(e,s,n){super(e,s);this.previousToken=n,this.name="MismatchedTokenException"}}class cs extends xt{constructor(e,s,n){super(e,s);this.previousToken=n,this.name="NoViableAltException"}}class hs extends xt{constructor(e,s){super(e,s);this.name="NotAllInputParsedException"}}class us extends xt{constructor(e,s,n){super(e,s);this.previousToken=n,this.name="EarlyExitException"}}var Xs={},Ys="InRuleRecoveryException";class Ci extends Error{constructor(e){super(e);this.name=Ys}}class qs{initRecoverable(e){if(this.firstAfterRepMap=[],this.resyncFollows={},this.recoveryEnabled=Object.hasOwn(e,"recoveryEnabled")?e.recoveryEnabled:me.recoveryEnabled,this.recoveryEnabled)this.attemptInRepetitionRecovery=wa}getTokenToInsert(e){let s=qe(e,"",-1,-1,-1,-1,-1,-1);return s.isInsertedInRecovery=!0,s}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,s,n,i){let r=this.findReSyncTokenType(),o=this.exportLexerState(),h=[],u=!1,c=this.LA_FAST(1),d=this.LA_FAST(1),f=()=>{let m=this.LA(0),y=this.errorMessageProvider.buildMismatchTokenMessage({expected:i,actual:c,previous:m,ruleName:this.getCurrRuleFullName()}),I=new ot(y,c,this.LA(0));I.resyncedTokens=h.slice(0,-1),this.SAVE_ERROR(I)};while(!u)if(this.tokenMatcher(d,i)){f();return}else if(n.call(this)){f(),e.apply(this,s);return}else if(this.tokenMatcher(d,r))u=!0;else d=this.SKIP_TOKEN(),this.addToResyncTokens(d,h);this.importLexerState(o)}shouldInRepetitionRecoveryBeTried(e,s,n){if(n===!1)return!1;if(this.tokenMatcher(this.LA_FAST(1),e))return!1;if(this.isBackTracking())return!1;if(this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,s)))return!1;return!0}getNextPossibleTokenTypes(e){let s=e.ruleStack[0],i=this.getGAstProductions()[s];return new Ws(i,e).startWalking()}getFollowsForInRuleRecovery(e,s){let n=this.getCurrentGrammarPath(e,s);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,s){if(this.canRecoverWithSingleTokenInsertion(e,s))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new Ci("sad sad panda")}canPerformInRuleRecovery(e,s){return this.canRecoverWithSingleTokenInsertion(e,s)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,s){if(!this.canTokenTypeBeInsertedInRecovery(e))return!1;if(s.length===0)return!1;let n=this.LA_FAST(1);return s.find((r)=>this.tokenMatcher(n,r))!==void 0}canRecoverWithSingleTokenDeletion(e){if(!this.canTokenTypeBeDeletedInRecovery(e))return!1;return this.tokenMatcher(this.LA(2),e)}isInCurrentRuleReSyncSet(e){let s=this.getCurrFollowKey();return this.getFollowSetFromFollowKey(s).includes(e)}findReSyncTokenType(){let e=this.flattenFollowSet(),s=this.LA_FAST(1),n=2;while(!0){let i=e.find((r)=>kt(s,r));if(i!==void 0)return i;s=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return Xs;let e=this.currRuleShortName,s=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:s,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,s=this.RULE_OCCURRENCE_STACK,n=this.RULE_STACK_IDX+1,i=Array(n);for(let r=0;r<n;r++)if(r===0)i[r]=Xs;else i[r]={ruleName:this.shortRuleNameToFullName(e[r]),idxInCallingRule:s[r],inRule:this.shortRuleNameToFullName(e[r-1])};return i}flattenFollowSet(){return this.buildFullFollowKeyStack().map((s)=>this.getFollowSetFromFollowKey(s)).flat()}getFollowSetFromFollowKey(e){if(e===Xs)return[Re];let s=e.ruleName+e.idxInCallingRule+jt+e.inRule;return this.resyncFollows[s]}addToResyncTokens(e,s){if(!this.tokenMatcher(e,Re))s.push(e);return s}reSyncTo(e){let s=[],n=this.LA_FAST(1);while(this.tokenMatcher(n,e)===!1)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,s);return s.slice(0,-1)}attemptInRepetitionRecovery(e,s,n,i,r,o,h){}getCurrentGrammarPath(e,s){let n=this.getHumanReadableRuleStack(),i=this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1);return{ruleStack:n,occurrenceStack:i,lastTok:e,lastTokOccurrence:s}}getHumanReadableRuleStack(){let e=this.RULE_STACK_IDX+1,s=Array(e);for(let n=0;n<e;n++)s[n]=this.shortRuleNameToFullName(this.RULE_STACK[n]);return s}}function wa(e,s,n,i,r,o,h){var u,c,d;let f=i|r,m=(u=(c=this.firstAfterRepMap)[d=this.currRuleShortName])!==null&&u!==void 0?u:c[d]=[],y=m[f];if(y===void 0){let w=this.getCurrRuleFullName(),_=this.getGAstProductions()[w];y=new o(_,r).startWalking(),m[f]=y}let I=y.token,P=y.occurrence,D=y.isEndOfRule;if(this.RULE_STACK_IDX===0&&D&&I===void 0)I=Re,P=1;if(I===void 0||P===void 0)return;if(this.shouldInRepetitionRecoveryBeTried(I,P,h))this.tryInRepetitionRecovery(e,s,n,I)}var ds=256,ps=512,vt=768,Mt=1024,wt=1280,lt=1536;class fs{constructor(e){var s;this.maxLookahead=(s=e===null||e===void 0?void 0:e.maxLookahead)!==null&&s!==void 0?s:me.maxLookahead}validate(e){let s=this.validateNoLeftRecursion(e.rules);if(s.length===0){let n=this.validateEmptyOrAlternatives(e.rules),i=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),r=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...s,...n,...i,...r]}return s}validateNoLeftRecursion(e){return e.flatMap((s)=>Hs(s,s,Ce))}validateEmptyOrAlternatives(e){return e.flatMap((s)=>Ri(s,Ce))}validateAmbiguousAlternationAlternatives(e,s){return e.flatMap((n)=>yi(n,s,Ce))}validateSomeNonEmptyLookaheadPath(e,s){return Li(e,s,Ce)}buildLookaheadForAlternation(e){return oi(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,hi)}buildLookaheadForOptional(e){return li(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,rs(e.prodType),ui)}}class Js{initLooksAhead(e){this.dynamicTokensEnabled=Object.hasOwn(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:me.dynamicTokensEnabled,this.maxLookahead=Object.hasOwn(e,"maxLookahead")?e.maxLookahead:me.maxLookahead,this.lookaheadStrategy=Object.hasOwn(e,"lookaheadStrategy")?e.lookaheadStrategy:new fs({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=[],this.currRuleLookaheadFuncs=[]}preComputeLookaheadFunctions(e){e.forEach((s)=>{this.TRACE_INIT(`${s.name} Rule Lookahead`,()=>{let{alternation:n,repetition:i,option:r,repetitionMandatory:o,repetitionMandatoryWithSeparator:h,repetitionWithSeparator:u}=Ua(s);n.forEach((c)=>{let d=c.idx===0?"":c.idx;this.TRACE_INIT(`${Se(c)}${d}`,()=>{let f=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:c.idx,rule:s,maxLookahead:c.maxLookahead||this.maxLookahead,hasPredicates:c.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled});this.setLaFuncCache(this.fullRuleNameToShort[s.name],ds|c.idx,f)})}),i.forEach((c)=>{this.computeLookaheadFunc(s,c.idx,vt,"Repetition",c.maxLookahead,Se(c))}),r.forEach((c)=>{this.computeLookaheadFunc(s,c.idx,ps,"Option",c.maxLookahead,Se(c))}),o.forEach((c)=>{this.computeLookaheadFunc(s,c.idx,Mt,"RepetitionMandatory",c.maxLookahead,Se(c))}),h.forEach((c)=>{this.computeLookaheadFunc(s,c.idx,lt,"RepetitionMandatoryWithSeparator",c.maxLookahead,Se(c))}),u.forEach((c)=>{this.computeLookaheadFunc(s,c.idx,wt,"RepetitionWithSeparator",c.maxLookahead,Se(c))})})})}computeLookaheadFunc(e,s,n,i,r,o){this.TRACE_INIT(`${o}${s===0?"":s}`,()=>{let h=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:s,rule:e,maxLookahead:r||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:i});this.setLaFuncCache(this.fullRuleNameToShort[e.name],n|s,h)})}setLaFuncCache(e,s,n){let i=this.lookAheadFuncsCache[e];if(i===void 0)i=[],this.lookAheadFuncsCache[e]=i;i[s]=n}}class bi extends Ae{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)}}var ms=new bi;function Ua(e){ms.reset(),e.accept(ms);let s=ms.dslMethods;return ms.reset(),s}function Zs(e,s){if(e.startOffset===-1)e.startOffset=s.startOffset,e.endOffset=s.endOffset;else if(e.endOffset<s.endOffset===!0)e.endOffset=s.endOffset}function Qs(e,s){if(e.startOffset===-1)e.startOffset=s.startOffset,e.startColumn=s.startColumn,e.startLine=s.startLine,e.endOffset=s.endOffset,e.endColumn=s.endColumn,e.endLine=s.endLine;else if(e.endOffset<s.endOffset===!0)e.endOffset=s.endOffset,e.endColumn=s.endColumn,e.endLine=s.endLine}function _i(e,s,n){if(e.children[n]===void 0)e.children[n]=[s];else e.children[n].push(s)}function xi(e,s,n){if(e.children[s]===void 0)e.children[s]=[n];else e.children[s].push(n)}function en(e,s){Object.defineProperty(e,"name",{enumerable:!1,configurable:!0,writable:!1,value:s})}function Pa(e,s){let n=Object.keys(e),i=n.length;for(let r=0;r<i;r++){let o=n[r],h=e[o],u=h.length;for(let c=0;c<u;c++){let d=h[c];if(d.tokenTypeIdx===void 0)this[d.name](d.children,s)}}}function vi(e,s){let n=function(){};en(n,e+"BaseSemantics");let i={visit:function(r,o){if(Array.isArray(r))r=r[0];if(r===void 0)return;return this[r.name](r.children,o)},validateVisitor:function(){let r=Da(this,s);if(r.length!==0){let o=r.map((h)=>h.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
|
|
86
|
+
see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return"deprecated"},buildDuplicateRuleNameError(e){let s;if(e.topLevelRule instanceof Te)s=e.topLevelRule.name;else s=e.topLevelRule;return`Duplicate definition, rule: ->${s}<- is already defined in the grammar: ->${e.grammarName}<-`}};function ni(e,s){let n=new ii(e,s);return n.resolveRefs(),n.errors}class ii extends Ae{constructor(e,s){super();this.nameToTopRule=e,this.errMsgProvider=s,this.errors=[]}resolveRefs(){Object.values(this.nameToTopRule).forEach((e)=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let s=this.nameToTopRule[e.nonTerminalName];if(!s){let n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:n,type:ie.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}else e.referencedRule=s}}class ri extends $e{constructor(e,s){super();this.topProd=e,this.path=s,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=[...this.path.ruleStack].reverse(),this.occurrenceStack=[...this.path.occurrenceStack].reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,s=[]){if(!this.found)super.walk(e,s)}walkProdRef(e,s,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let i=s.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,i)}}updateExpectedNext(){if(this.ruleStack.length===0)this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0;else this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop()}}class Ws extends ri{constructor(e,s){super(e,s);this.path=s,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,s,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let i=s.concat(n),r=new j({definition:i});this.possibleTokTypes=Ke(r),this.found=!0}}}class kt extends $e{constructor(e,s){super();this.topRule=e,this.occurrence=s,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class js extends kt{walkMany(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof F)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkMany(e,s,n)}}class ss extends kt{walkManySep(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof F)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkManySep(e,s,n)}}class Ks extends kt{walkAtLeastOne(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof F)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkAtLeastOne(e,s,n)}}class ns extends kt{walkAtLeastOneSep(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof F)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkAtLeastOneSep(e,s,n)}}function is(e,s,n=[]){n=[...n];let i=[],r=0;function o(u){return u.concat(e.slice(r+1))}function h(u){let c=is(o(u),s,n);return i.concat(c)}while(n.length<s&&r<e.length){let u=e[r];if(u instanceof j)return h(u.definition);else if(u instanceof W)return h(u.definition);else if(u instanceof K)i=h(u.definition);else if(u instanceof Z){let c=u.definition.concat([new G({definition:u.definition})]);return h(c)}else if(u instanceof Q){let c=[new j({definition:u.definition}),new G({definition:[new F({terminalType:u.separator})].concat(u.definition)})];return h(c)}else if(u instanceof q){let c=u.definition.concat([new G({definition:[new F({terminalType:u.separator})].concat(u.definition)})]);i=h(c)}else if(u instanceof G){let c=u.definition.concat([new G({definition:u.definition})]);i=h(c)}else if(u instanceof J)return u.definition.forEach((c)=>{if(c.definition.length!==0)i=h(c.definition)}),i;else if(u instanceof F)n.push(u.terminalType);else throw Error("non exhaustive match");r++}return i.push({partialPath:n,suffixDef:e.slice(r)}),i}function ai(e,s,n,i){let o=["EXIT_NONE_TERMINAL"],h="EXIT_ALTERNATIVE",u=!1,c=s.length,d=c-i-1,f=[],m=[];m.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});while(m.length!==0){let y=m.pop();if(y==="EXIT_ALTERNATIVE"){if(u&&m.at(-1).idx<=d)m.pop();continue}let{def:I,idx:P,ruleStack:D,occurrenceStack:w}=y;if(I.length===0)continue;let _=I[0];if(_==="EXIT_NONE_TERMINAL"){let b={idx:P,def:I.slice(1),ruleStack:D.slice(0,-1),occurrenceStack:w.slice(0,-1)};m.push(b)}else if(_ instanceof F)if(P<c-1){let b=P+1,g=s[b];if(n(g,_.terminalType)){let U={idx:b,def:I.slice(1),ruleStack:D,occurrenceStack:w};m.push(U)}}else if(P===c-1)f.push({nextTokenType:_.terminalType,nextTokenOccurrence:_.idx,ruleStack:D,occurrenceStack:w}),u=!0;else throw Error("non exhaustive match");else if(_ instanceof W){let b=[...D];b.push(_.nonTerminalName);let g=[...w];g.push(_.idx);let U={idx:P,def:_.definition.concat(o,I.slice(1)),ruleStack:b,occurrenceStack:g};m.push(U)}else if(_ instanceof K){let b={idx:P,def:I.slice(1),ruleStack:D,occurrenceStack:w};m.push(b),m.push("EXIT_ALTERNATIVE");let g={idx:P,def:_.definition.concat(I.slice(1)),ruleStack:D,occurrenceStack:w};m.push(g)}else if(_ instanceof Z){let b=new G({definition:_.definition,idx:_.idx}),g=_.definition.concat([b],I.slice(1)),U={idx:P,def:g,ruleStack:D,occurrenceStack:w};m.push(U)}else if(_ instanceof Q){let b=new F({terminalType:_.separator}),g=new G({definition:[b].concat(_.definition),idx:_.idx}),U=_.definition.concat([g],I.slice(1)),te={idx:P,def:U,ruleStack:D,occurrenceStack:w};m.push(te)}else if(_ instanceof q){let b={idx:P,def:I.slice(1),ruleStack:D,occurrenceStack:w};m.push(b),m.push("EXIT_ALTERNATIVE");let g=new F({terminalType:_.separator}),U=new G({definition:[g].concat(_.definition),idx:_.idx}),te=_.definition.concat([U],I.slice(1)),ce={idx:P,def:te,ruleStack:D,occurrenceStack:w};m.push(ce)}else if(_ instanceof G){let b={idx:P,def:I.slice(1),ruleStack:D,occurrenceStack:w};m.push(b),m.push("EXIT_ALTERNATIVE");let g=new G({definition:_.definition,idx:_.idx}),U=_.definition.concat([g],I.slice(1)),te={idx:P,def:U,ruleStack:D,occurrenceStack:w};m.push(te)}else if(_ instanceof J)for(let b=_.definition.length-1;b>=0;b--){let g=_.definition[b],U={idx:P,def:g.definition.concat(I.slice(1)),ruleStack:D,occurrenceStack:w};m.push(U),m.push("EXIT_ALTERNATIVE")}else if(_ instanceof j)m.push({idx:P,def:_.definition.concat(I.slice(1)),ruleStack:D,occurrenceStack:w});else if(_ instanceof Te)m.push(Na(_,P,D,w));else throw Error("non exhaustive match")}return f}function Na(e,s,n,i){let r=[...n];r.push(e.name);let o=[...i];return o.push(1),{idx:s,def:e.definition,ruleStack:r,occurrenceStack:o}}var H;(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"})(H||(H={}));function rs(e){if(e instanceof K||e==="Option")return H.OPTION;else if(e instanceof G||e==="Repetition")return H.REPETITION;else if(e instanceof Z||e==="RepetitionMandatory")return H.REPETITION_MANDATORY;else if(e instanceof Q||e==="RepetitionMandatoryWithSeparator")return H.REPETITION_MANDATORY_WITH_SEPARATOR;else if(e instanceof q||e==="RepetitionWithSeparator")return H.REPETITION_WITH_SEPARATOR;else if(e instanceof J||e==="Alternation")return H.ALTERNATION;else throw Error("non exhaustive match")}function li(e,s,n,i,r,o){let h=Ct(e,s,n),u=mi(h)?at:Ue;return o(h,i,u,r)}function ci(e,s,n,i,r,o){let h=bt(e,s,r,n),u=mi(h)?at:Ue;return o(h[0],u,i)}function hi(e,s,n,i){let r=e.length,o=e.every((h)=>h.every((u)=>u.length===1));if(s)return function(h){let u=h.map((c)=>c.GATE);for(let c=0;c<r;c++){let d=e[c],f=d.length,m=u[c];if(m!==void 0&&m.call(this)===!1)continue;e:for(let y=0;y<f;y++){let I=d[y],P=I.length;for(let D=0;D<P;D++){let w=this.LA_FAST(D+1);if(n(w,I[D])===!1)continue e}return c}}return};else if(o&&!i){let u=e.map((c)=>c.flat()).reduce((c,d,f)=>(d.forEach((m)=>{if(!(m.tokenTypeIdx in c))c[m.tokenTypeIdx]=f;m.categoryMatches.forEach((y)=>{if(!Object.hasOwn(c,y))c[y]=f})}),c),{});return function(){let c=this.LA_FAST(1);return u[c.tokenTypeIdx]}}else return function(){for(let h=0;h<r;h++){let u=e[h],c=u.length;e:for(let d=0;d<c;d++){let f=u[d],m=f.length;for(let y=0;y<m;y++){let I=this.LA_FAST(y+1);if(n(I,f[y])===!1)continue e}return h}}return}}function ui(e,s,n){let i=e.every((o)=>o.length===1),r=e.length;if(i&&!n){let o=e.flat();if(o.length===1&&o[0].categoryMatches.length===0){let u=o[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===u}}else{let h=o.reduce((u,c,d)=>(u[c.tokenTypeIdx]=!0,c.categoryMatches.forEach((f)=>{u[f]=!0}),u),[]);return function(){let u=this.LA_FAST(1);return h[u.tokenTypeIdx]===!0}}}else return function(){e:for(let o=0;o<r;o++){let h=e[o],u=h.length;for(let c=0;c<u;c++){let d=this.LA_FAST(c+1);if(s(d,h[c])===!1)continue e}return!0}return!1}}class di extends $e{constructor(e,s,n){super();this.topProd=e,this.targetOccurrence=s,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,s,n,i){if(e.idx===this.targetOccurrence&&this.targetProdType===s)return this.restDef=n.concat(i),!0;return!1}walkOption(e,s,n){if(!this.checkIsTarget(e,H.OPTION,s,n))super.walkOption(e,s,n)}walkAtLeastOne(e,s,n){if(!this.checkIsTarget(e,H.REPETITION_MANDATORY,s,n))super.walkOption(e,s,n)}walkAtLeastOneSep(e,s,n){if(!this.checkIsTarget(e,H.REPETITION_MANDATORY_WITH_SEPARATOR,s,n))super.walkOption(e,s,n)}walkMany(e,s,n){if(!this.checkIsTarget(e,H.REPETITION,s,n))super.walkOption(e,s,n)}walkManySep(e,s,n){if(!this.checkIsTarget(e,H.REPETITION_WITH_SEPARATOR,s,n))super.walkOption(e,s,n)}}class zs extends Ae{constructor(e,s,n){super();this.targetOccurrence=e,this.targetProdType=s,this.targetRef=n,this.result=[]}checkIsTarget(e,s){if(e.idx===this.targetOccurrence&&this.targetProdType===s&&(this.targetRef===void 0||e===this.targetRef))this.result=e.definition}visitOption(e){this.checkIsTarget(e,H.OPTION)}visitRepetition(e){this.checkIsTarget(e,H.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,H.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,H.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,H.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,H.ALTERNATION)}}function oi(e){let s=Array(e);for(let n=0;n<e;n++)s[n]=[];return s}function Vs(e){let s=[""];for(let n=0;n<e.length;n++){let i=e[n],r=[];for(let o=0;o<s.length;o++){let h=s[o];r.push(h+"_"+i.tokenTypeIdx);for(let u=0;u<i.categoryMatches.length;u++){let c="_"+i.categoryMatches[u];r.push(h+c)}}s=r}return s}function Ia(e,s,n){for(let i=0;i<e.length;i++){if(i===n)continue;let r=e[i];for(let o=0;o<s.length;o++){let h=s[o];if(r[h]===!0)return!1}}return!0}function pi(e,s){let n=e.map((h)=>is([h],1)),i=oi(n.length),r=n.map((h)=>{let u={};return h.forEach((c)=>{Vs(c.partialPath).forEach((f)=>{u[f]=!0})}),u}),o=n;for(let h=1;h<=s;h++){let u=o;o=oi(u.length);for(let c=0;c<u.length;c++){let d=u[c];for(let f=0;f<d.length;f++){let m=d[f].partialPath,y=d[f].suffixDef,I=Vs(m);if(Ia(r,I,c)||y.length===0||m.length===s){let D=i[c];if(as(D,m)===!1){D.push(m);for(let w=0;w<I.length;w++){let _=I[w];r[c][_]=!0}}}else{let D=is(y,h+1,m);o[c]=o[c].concat(D),D.forEach((w)=>{Vs(w.partialPath).forEach((b)=>{r[c][b]=!0})})}}}}return i}function Ct(e,s,n,i){let r=new zs(e,H.ALTERNATION,i);return s.accept(r),pi(r.result,n)}function bt(e,s,n,i){let r=new zs(e,n);s.accept(r);let o=r.result,u=new di(s,e,n).startWalking(),c=new j({definition:o}),d=new j({definition:u});return pi([c,d],i)}function as(e,s){e:for(let n=0;n<e.length;n++){let i=e[n];if(i.length!==s.length)continue;for(let r=0;r<i.length;r++){let o=s[r],h=i[r];if((o===h||h.categoryMatchesMap[o.tokenTypeIdx]!==void 0)===!1)continue e}return!0}return!1}function fi(e,s){return e.length<s.length&&e.every((n,i)=>{let r=s[i];return n===r||r.categoryMatchesMap[n.tokenTypeIdx]})}function mi(e){return e.every((s)=>s.every((n)=>n.every((i)=>i.categoryMatches.length===0)))}function Ei(e){return e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}).map((n)=>Object.assign({type:ie.CUSTOM_LOOKAHEAD_VALIDATION},n))}function Ti(e,s,n,i){let r=e.flatMap((c)=>ka(c,n)),o=Ma(e,s,n),h=e.flatMap((c)=>_a(c,n)),u=e.flatMap((c)=>ba(c,e,i,n));return r.concat(o,h,u)}function ka(e,s){let n=new Ai;e.accept(n);let i=n.allProductions,r=Object.groupBy(i,Ca),o=Object.fromEntries(Object.entries(r).filter(([u,c])=>c.length>1));return Object.values(o).map((u)=>{let c=u[0],d=s.buildDuplicateFoundError(e,u),f=Se(c),m={message:d,type:ie.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:f,occurrence:c.idx},y=gi(c);if(y)m.parameter=y;return m})}function Ca(e){return`${Se(e)}_#_${e.idx}_#_${gi(e)}`}function gi(e){if(e instanceof F)return e.terminalType.name;else if(e instanceof W)return e.nonTerminalName;else return""}class Ai extends Ae{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 ba(e,s,n,i){let r=[];if(s.reduce((h,u)=>{if(u.name===e.name)return h+1;return h},0)>1){let h=i.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});r.push({message:h,type:ie.DUPLICATE_RULE_NAME,ruleName:e.name})}return r}function Si(e,s,n){let i=[],r;if(!s.includes(e))r=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,i.push({message:r,type:ie.INVALID_RULE_OVERRIDE,ruleName:e});return i}function Hs(e,s,n,i=[]){let r=[],o=os(s.definition);if(o.length===0)return[];else{let h=e.name;if(o.includes(e))r.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:i}),type:ie.LEFT_RECURSION,ruleName:h});let c=i.concat([e]),f=o.filter((m)=>!c.includes(m)).flatMap((m)=>{let y=[...i];return y.push(m),Hs(e,m,n,y)});return r.concat(f)}}function os(e){let s=[];if(e.length===0)return s;let n=e[0];if(n instanceof W)s.push(n.referencedRule);else if(n instanceof j||n instanceof K||n instanceof Z||n instanceof Q||n instanceof q||n instanceof G)s=s.concat(os(n.definition));else if(n instanceof J)s=n.definition.map((o)=>os(o.definition)).flat();else if(n instanceof F);else throw Error("non exhaustive match");let i=je(n),r=e.length>1;if(i&&r){let o=e.slice(1);return s.concat(os(o))}else return s}class ls extends Ae{constructor(){super(...arguments);this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}function Ri(e,s){let n=new ls;return e.accept(n),n.alternations.flatMap((o)=>o.definition.slice(0,-1).flatMap((u,c)=>{if(ai([u],[],Ue,1).length===0)return[{message:s.buildEmptyAlternationError({topLevelRule:e,alternation:o,emptyChoiceIdx:c}),type:ie.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:o.idx,alternative:c+1}];else return[]}))}function yi(e,s,n){let i=new ls;e.accept(i);let r=i.alternations;return r=r.filter((h)=>h.ignoreAmbiguities!==!0),r.flatMap((h)=>{let u=h.idx,c=h.maxLookahead||s,d=Ct(u,e,c,h),f=xa(d,h,e,n),m=va(d,h,e,n);return f.concat(m)})}class Oi extends Ae{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 _a(e,s){let n=new ls;return e.accept(n),n.alternations.flatMap((o)=>{if(o.definition.length>255)return[{message:s.buildTooManyAlternativesError({topLevelRule:e,alternation:o}),type:ie.TOO_MANY_ALTS,ruleName:e.name,occurrence:o.idx}];else return[]})}function Li(e,s,n){let i=[];return e.forEach((r)=>{let o=new Oi;r.accept(o),o.allProductions.forEach((u)=>{let c=rs(u),d=u.maxLookahead||s,f=u.idx;if(bt(f,r,c,d)[0].flat().length===0){let I=n.buildEmptyRepetitionError({topLevelRule:r,repetition:u});i.push({message:I,type:ie.NO_NON_EMPTY_LOOKAHEAD,ruleName:r.name})}})}),i}function xa(e,s,n,i){let r=[];return e.reduce((u,c,d)=>{if(s.definition[d].ignoreAmbiguities===!0)return u;return c.forEach((f)=>{let m=[d];if(e.forEach((y,I)=>{if(d!==I&&as(y,f)&&s.definition[I].ignoreAmbiguities!==!0)m.push(I)}),m.length>1&&!as(r,f))r.push(f),u.push({alts:m,path:f})}),u},[]).map((u)=>{let c=u.alts.map((f)=>f+1);return{message:i.buildAlternationAmbiguityError({topLevelRule:n,alternation:s,ambiguityIndices:c,prefixPath:u.path}),type:ie.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:s.idx,alternatives:u.alts}})}function va(e,s,n,i){let r=e.reduce((h,u,c)=>{let d=u.map((f)=>({idx:c,path:f}));return h.concat(d)},[]);return r.flatMap((h)=>{if(s.definition[h.idx].ignoreAmbiguities===!0)return[];let{idx:c,path:d}=h;return r.filter((y)=>s.definition[y.idx].ignoreAmbiguities!==!0&&y.idx<c&&fi(y.path,d)).map((y)=>{let I=[y.idx+1,c+1],P=s.idx===0?"":s.idx;return{message:i.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:s,ambiguityIndices:I,prefixPath:y.path}),type:ie.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:P,alternatives:I}})})}function Ma(e,s,n){let i=[],r=s.map((o)=>o.name);return e.forEach((o)=>{let h=o.name;if(r.includes(h)){let u=n.buildNamespaceConflictError(o);i.push({message:u,type:ie.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:h})}}),i}function Ni(e){let s=Object.assign({errMsgProvider:ti},e),n={};return e.rules.forEach((i)=>{n[i.name]=i}),ni(n,s.errMsgProvider)}function Ii(e){var s;let n=(s=e.errMsgProvider)!==null&&s!==void 0?s:Ce;return Ti(e.rules,e.tokenTypes,n,e.grammarName)}var ki=["MismatchedTokenException","NoViableAltException","EarlyExitException","NotAllInputParsedException"];Object.freeze(ki);function Ge(e){return ki.includes(e.name)}class _t extends Error{constructor(e,s){super(e);if(this.token=s,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}}class ot extends _t{constructor(e,s,n){super(e,s);this.previousToken=n,this.name="MismatchedTokenException"}}class cs extends _t{constructor(e,s,n){super(e,s);this.previousToken=n,this.name="NoViableAltException"}}class hs extends _t{constructor(e,s){super(e,s);this.name="NotAllInputParsedException"}}class us extends _t{constructor(e,s,n){super(e,s);this.previousToken=n,this.name="EarlyExitException"}}var Xs={},Ys="InRuleRecoveryException";class Ci extends Error{constructor(e){super(e);this.name=Ys}}class qs{initRecoverable(e){if(this.firstAfterRepMap=[],this.resyncFollows={},this.recoveryEnabled=Object.hasOwn(e,"recoveryEnabled")?e.recoveryEnabled:me.recoveryEnabled,this.recoveryEnabled)this.attemptInRepetitionRecovery=wa}getTokenToInsert(e){let s=qe(e,"",-1,-1,-1,-1,-1,-1);return s.isInsertedInRecovery=!0,s}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,s,n,i){let r=this.findReSyncTokenType(),o=this.exportLexerState(),h=[],u=!1,c=this.LA_FAST(1),d=this.LA_FAST(1),f=()=>{let m=this.LA(0),y=this.errorMessageProvider.buildMismatchTokenMessage({expected:i,actual:c,previous:m,ruleName:this.getCurrRuleFullName()}),I=new ot(y,c,this.LA(0));I.resyncedTokens=h.slice(0,-1),this.SAVE_ERROR(I)};while(!u)if(this.tokenMatcher(d,i)){f();return}else if(n.call(this)){f(),e.apply(this,s);return}else if(this.tokenMatcher(d,r))u=!0;else d=this.SKIP_TOKEN(),this.addToResyncTokens(d,h);this.importLexerState(o)}shouldInRepetitionRecoveryBeTried(e,s,n){if(n===!1)return!1;if(this.tokenMatcher(this.LA_FAST(1),e))return!1;if(this.isBackTracking())return!1;if(this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,s)))return!1;return!0}getNextPossibleTokenTypes(e){let s=e.ruleStack[0],i=this.getGAstProductions()[s];return new Ws(i,e).startWalking()}getFollowsForInRuleRecovery(e,s){let n=this.getCurrentGrammarPath(e,s);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,s){if(this.canRecoverWithSingleTokenInsertion(e,s))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new Ci("sad sad panda")}canPerformInRuleRecovery(e,s){return this.canRecoverWithSingleTokenInsertion(e,s)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,s){if(!this.canTokenTypeBeInsertedInRecovery(e))return!1;if(s.length===0)return!1;let n=this.LA_FAST(1);return s.find((r)=>this.tokenMatcher(n,r))!==void 0}canRecoverWithSingleTokenDeletion(e){if(!this.canTokenTypeBeDeletedInRecovery(e))return!1;return this.tokenMatcher(this.LA(2),e)}isInCurrentRuleReSyncSet(e){let s=this.getCurrFollowKey();return this.getFollowSetFromFollowKey(s).includes(e)}findReSyncTokenType(){let e=this.flattenFollowSet(),s=this.LA_FAST(1),n=2;while(!0){let i=e.find((r)=>It(s,r));if(i!==void 0)return i;s=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return Xs;let e=this.currRuleShortName,s=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:s,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,s=this.RULE_OCCURRENCE_STACK,n=this.RULE_STACK_IDX+1,i=Array(n);for(let r=0;r<n;r++)if(r===0)i[r]=Xs;else i[r]={ruleName:this.shortRuleNameToFullName(e[r]),idxInCallingRule:s[r],inRule:this.shortRuleNameToFullName(e[r-1])};return i}flattenFollowSet(){return this.buildFullFollowKeyStack().map((s)=>this.getFollowSetFromFollowKey(s)).flat()}getFollowSetFromFollowKey(e){if(e===Xs)return[Re];let s=e.ruleName+e.idxInCallingRule+jt+e.inRule;return this.resyncFollows[s]}addToResyncTokens(e,s){if(!this.tokenMatcher(e,Re))s.push(e);return s}reSyncTo(e){let s=[],n=this.LA_FAST(1);while(this.tokenMatcher(n,e)===!1)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,s);return s.slice(0,-1)}attemptInRepetitionRecovery(e,s,n,i,r,o,h){}getCurrentGrammarPath(e,s){let n=this.getHumanReadableRuleStack(),i=this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1);return{ruleStack:n,occurrenceStack:i,lastTok:e,lastTokOccurrence:s}}getHumanReadableRuleStack(){let e=this.RULE_STACK_IDX+1,s=Array(e);for(let n=0;n<e;n++)s[n]=this.shortRuleNameToFullName(this.RULE_STACK[n]);return s}}function wa(e,s,n,i,r,o,h){var u,c,d;let f=i|r,m=(u=(c=this.firstAfterRepMap)[d=this.currRuleShortName])!==null&&u!==void 0?u:c[d]=[],y=m[f];if(y===void 0){let w=this.getCurrRuleFullName(),_=this.getGAstProductions()[w];y=new o(_,r).startWalking(),m[f]=y}let I=y.token,P=y.occurrence,D=y.isEndOfRule;if(this.RULE_STACK_IDX===0&&D&&I===void 0)I=Re,P=1;if(I===void 0||P===void 0)return;if(this.shouldInRepetitionRecoveryBeTried(I,P,h))this.tryInRepetitionRecovery(e,s,n,I)}var ds=256,ps=512,xt=768,Mt=1024,wt=1280,lt=1536;class fs{constructor(e){var s;this.maxLookahead=(s=e===null||e===void 0?void 0:e.maxLookahead)!==null&&s!==void 0?s:me.maxLookahead}validate(e){let s=this.validateNoLeftRecursion(e.rules);if(s.length===0){let n=this.validateEmptyOrAlternatives(e.rules),i=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),r=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...s,...n,...i,...r]}return s}validateNoLeftRecursion(e){return e.flatMap((s)=>Hs(s,s,Ce))}validateEmptyOrAlternatives(e){return e.flatMap((s)=>Ri(s,Ce))}validateAmbiguousAlternationAlternatives(e,s){return e.flatMap((n)=>yi(n,s,Ce))}validateSomeNonEmptyLookaheadPath(e,s){return Li(e,s,Ce)}buildLookaheadForAlternation(e){return li(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,hi)}buildLookaheadForOptional(e){return ci(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,rs(e.prodType),ui)}}class Js{initLooksAhead(e){this.dynamicTokensEnabled=Object.hasOwn(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:me.dynamicTokensEnabled,this.maxLookahead=Object.hasOwn(e,"maxLookahead")?e.maxLookahead:me.maxLookahead,this.lookaheadStrategy=Object.hasOwn(e,"lookaheadStrategy")?e.lookaheadStrategy:new fs({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=[],this.currRuleLookaheadFuncs=[]}preComputeLookaheadFunctions(e){e.forEach((s)=>{this.TRACE_INIT(`${s.name} Rule Lookahead`,()=>{let{alternation:n,repetition:i,option:r,repetitionMandatory:o,repetitionMandatoryWithSeparator:h,repetitionWithSeparator:u}=Ua(s);n.forEach((c)=>{let d=c.idx===0?"":c.idx;this.TRACE_INIT(`${Se(c)}${d}`,()=>{let f=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:c.idx,rule:s,maxLookahead:c.maxLookahead||this.maxLookahead,hasPredicates:c.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled});this.setLaFuncCache(this.fullRuleNameToShort[s.name],ds|c.idx,f)})}),i.forEach((c)=>{this.computeLookaheadFunc(s,c.idx,xt,"Repetition",c.maxLookahead,Se(c))}),r.forEach((c)=>{this.computeLookaheadFunc(s,c.idx,ps,"Option",c.maxLookahead,Se(c))}),o.forEach((c)=>{this.computeLookaheadFunc(s,c.idx,Mt,"RepetitionMandatory",c.maxLookahead,Se(c))}),h.forEach((c)=>{this.computeLookaheadFunc(s,c.idx,lt,"RepetitionMandatoryWithSeparator",c.maxLookahead,Se(c))}),u.forEach((c)=>{this.computeLookaheadFunc(s,c.idx,wt,"RepetitionWithSeparator",c.maxLookahead,Se(c))})})})}computeLookaheadFunc(e,s,n,i,r,o){this.TRACE_INIT(`${o}${s===0?"":s}`,()=>{let h=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:s,rule:e,maxLookahead:r||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:i});this.setLaFuncCache(this.fullRuleNameToShort[e.name],n|s,h)})}setLaFuncCache(e,s,n){let i=this.lookAheadFuncsCache[e];if(i===void 0)i=[],this.lookAheadFuncsCache[e]=i;i[s]=n}}class bi extends Ae{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)}}var ms=new bi;function Ua(e){ms.reset(),e.accept(ms);let s=ms.dslMethods;return ms.reset(),s}function Zs(e,s){if(e.startOffset===-1)e.startOffset=s.startOffset,e.endOffset=s.endOffset;else if(e.endOffset<s.endOffset===!0)e.endOffset=s.endOffset}function Qs(e,s){if(e.startOffset===-1)e.startOffset=s.startOffset,e.startColumn=s.startColumn,e.startLine=s.startLine,e.endOffset=s.endOffset,e.endColumn=s.endColumn,e.endLine=s.endLine;else if(e.endOffset<s.endOffset===!0)e.endOffset=s.endOffset,e.endColumn=s.endColumn,e.endLine=s.endLine}function _i(e,s,n){if(e.children[n]===void 0)e.children[n]=[s];else e.children[n].push(s)}function xi(e,s,n){if(e.children[s]===void 0)e.children[s]=[n];else e.children[s].push(n)}function en(e,s){Object.defineProperty(e,"name",{enumerable:!1,configurable:!0,writable:!1,value:s})}function Pa(e,s){let n=Object.keys(e),i=n.length;for(let r=0;r<i;r++){let o=n[r],h=e[o],u=h.length;for(let c=0;c<u;c++){let d=h[c];if(d.tokenTypeIdx===void 0)this[d.name](d.children,s)}}}function vi(e,s){let n=function(){};en(n,e+"BaseSemantics");let i={visit:function(r,o){if(Array.isArray(r))r=r[0];if(r===void 0)return;return this[r.name](r.children,o)},validateVisitor:function(){let r=Da(this,s);if(r.length!==0){let o=r.map((h)=>h.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
|
|
87
87
|
${o.join(`
|
|
88
88
|
|
|
89
89
|
`).replace(/\n/g,`
|
|
@@ -94,7 +94,7 @@ see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleN
|
|
|
94
94
|
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.
|
|
95
95
|
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
|
|
96
96
|
For Further details.`)}if(Array.isArray(e))this.tokensMap=e.reduce((r,o)=>(r[o.name]=o,r),{});else if(Object.hasOwn(e,"modes")&&Object.values(e.modes).flat().every(zn)){let r=Object.values(e.modes).flat(),o=[...new Set(r)];this.tokensMap=o.reduce((h,u)=>(h[u.name]=u,h),{})}else if(typeof e==="object"&&e!==null)this.tokensMap=Object.assign({},e);else throw Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=Re;let i=(Object.hasOwn(e,"modes")?Object.values(e.modes).flat():Object.values(e)).every((r)=>{var o;return((o=r.categoryMatches)===null||o===void 0?void 0:o.length)==0});this.tokenMatcher=i?at:Ue,Pe(Object.values(this.tokensMap))}defineRule(e,s,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'
|
|
97
|
-
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let i=Object.hasOwn(n,"resyncEnabled")?n.resyncEnabled:ct.resyncEnabled,r=Object.hasOwn(n,"recoveryValueFunc")?n.recoveryValueFunc:ct.recoveryValueFunc,o=this.ruleShortNameIdx++;this.shortRuleNameToFull[o]=e,this.fullRuleNameToShort[e]=o;let h;if(this.outputCst===!0)h=function(...f){try{this.ruleInvocationStateUpdate(o,e,this.subruleIdx),s.apply(this,f);let m=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(m),m}catch(m){return this.invokeRuleCatch(m,i,r)}finally{this.ruleFinallyStateUpdate()}};else h=function(...f){try{return this.ruleInvocationStateUpdate(o,e,this.subruleIdx),s.apply(this,f)}catch(m){return this.invokeRuleCatch(m,i,r)}finally{this.ruleFinallyStateUpdate()}};return Object.assign(function(...f){this.onBeforeParse(e);try{return h.apply(this,f)}finally{this.onAfterParse(e)}},{ruleName:e,originalGrammarAction:s,coreRule:h})}invokeRuleCatch(e,s,n){let i=this.RULE_STACK_IDX===0,r=s&&!this.isBackTracking()&&this.recoveryEnabled;if(Ge(e)){let o=e;if(r){let h=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(h))if(o.resyncedTokens=this.reSyncTo(h),this.outputCst){let u=this.CST_STACK[this.CST_STACK.length-1];return u.recoveredNode=!0,u}else return n(e);else{if(this.outputCst){let u=this.CST_STACK[this.CST_STACK.length-1];u.recoveredNode=!0,o.partialCstResult=u}throw o}}else if(i)return this.moveToTerminatedState(),n(e);else throw o}else throw e}optionInternal(e,s){let n=ps|s;return this.optionInternalLogic(e,s,n)}optionInternalLogic(e,s,n){let i=this.currRuleLookaheadFuncs[n],r;if(typeof e!=="function"){r=e.DEF;let o=e.GATE;if(o!==void 0){let h=i;i=()=>o.call(this)&&h.call(this)}}else r=e;if(i.call(this)===!0)return r.call(this);return}atLeastOneInternal(e,s){let n=Mt|e;return this.atLeastOneInternalLogic(e,s,n)}atLeastOneInternalLogic(e,s,n){let i=this.currRuleLookaheadFuncs[n],r;if(typeof s!=="function"){r=s.DEF;let o=s.GATE;if(o!==void 0){let h=i;i=()=>o.call(this)&&h.call(this)}}else r=s;if(i.call(this)===!0){let o=this.doSingleRepetition(r);while(i.call(this)===!0&&o===!0)o=this.doSingleRepetition(r)}else throw this.raiseEarlyExitException(e,H.REPETITION_MANDATORY,s.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,s],i,Mt,e,Ks)}atLeastOneSepFirstInternal(e,s){let n=lt|e;this.atLeastOneSepFirstInternalLogic(e,s,n)}atLeastOneSepFirstInternalLogic(e,s,n){let{DEF:i,SEP:r}=s;if(this.currRuleLookaheadFuncs[n].call(this)===!0){i.call(this);let h=()=>this.tokenMatcher(this.LA_FAST(1),r);while(this.tokenMatcher(this.LA_FAST(1),r)===!0)this.CONSUME(r),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,r,h,i,ns],h,lt,e,ns)}else throw this.raiseEarlyExitException(e,H.REPETITION_MANDATORY_WITH_SEPARATOR,s.ERR_MSG)}manyInternal(e,s){let n=
|
|
97
|
+
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let i=Object.hasOwn(n,"resyncEnabled")?n.resyncEnabled:ct.resyncEnabled,r=Object.hasOwn(n,"recoveryValueFunc")?n.recoveryValueFunc:ct.recoveryValueFunc,o=this.ruleShortNameIdx++;this.shortRuleNameToFull[o]=e,this.fullRuleNameToShort[e]=o;let h;if(this.outputCst===!0)h=function(...f){try{this.ruleInvocationStateUpdate(o,e,this.subruleIdx),s.apply(this,f);let m=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(m),m}catch(m){return this.invokeRuleCatch(m,i,r)}finally{this.ruleFinallyStateUpdate()}};else h=function(...f){try{return this.ruleInvocationStateUpdate(o,e,this.subruleIdx),s.apply(this,f)}catch(m){return this.invokeRuleCatch(m,i,r)}finally{this.ruleFinallyStateUpdate()}};return Object.assign(function(...f){this.onBeforeParse(e);try{return h.apply(this,f)}finally{this.onAfterParse(e)}},{ruleName:e,originalGrammarAction:s,coreRule:h})}invokeRuleCatch(e,s,n){let i=this.RULE_STACK_IDX===0,r=s&&!this.isBackTracking()&&this.recoveryEnabled;if(Ge(e)){let o=e;if(r){let h=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(h))if(o.resyncedTokens=this.reSyncTo(h),this.outputCst){let u=this.CST_STACK[this.CST_STACK.length-1];return u.recoveredNode=!0,u}else return n(e);else{if(this.outputCst){let u=this.CST_STACK[this.CST_STACK.length-1];u.recoveredNode=!0,o.partialCstResult=u}throw o}}else if(i)return this.moveToTerminatedState(),n(e);else throw o}else throw e}optionInternal(e,s){let n=ps|s;return this.optionInternalLogic(e,s,n)}optionInternalLogic(e,s,n){let i=this.currRuleLookaheadFuncs[n],r;if(typeof e!=="function"){r=e.DEF;let o=e.GATE;if(o!==void 0){let h=i;i=()=>o.call(this)&&h.call(this)}}else r=e;if(i.call(this)===!0)return r.call(this);return}atLeastOneInternal(e,s){let n=Mt|e;return this.atLeastOneInternalLogic(e,s,n)}atLeastOneInternalLogic(e,s,n){let i=this.currRuleLookaheadFuncs[n],r;if(typeof s!=="function"){r=s.DEF;let o=s.GATE;if(o!==void 0){let h=i;i=()=>o.call(this)&&h.call(this)}}else r=s;if(i.call(this)===!0){let o=this.doSingleRepetition(r);while(i.call(this)===!0&&o===!0)o=this.doSingleRepetition(r)}else throw this.raiseEarlyExitException(e,H.REPETITION_MANDATORY,s.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,s],i,Mt,e,Ks)}atLeastOneSepFirstInternal(e,s){let n=lt|e;this.atLeastOneSepFirstInternalLogic(e,s,n)}atLeastOneSepFirstInternalLogic(e,s,n){let{DEF:i,SEP:r}=s;if(this.currRuleLookaheadFuncs[n].call(this)===!0){i.call(this);let h=()=>this.tokenMatcher(this.LA_FAST(1),r);while(this.tokenMatcher(this.LA_FAST(1),r)===!0)this.CONSUME(r),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,r,h,i,ns],h,lt,e,ns)}else throw this.raiseEarlyExitException(e,H.REPETITION_MANDATORY_WITH_SEPARATOR,s.ERR_MSG)}manyInternal(e,s){let n=xt|e;return this.manyInternalLogic(e,s,n)}manyInternalLogic(e,s,n){let i=this.currRuleLookaheadFuncs[n],r;if(typeof s!=="function"){r=s.DEF;let h=s.GATE;if(h!==void 0){let u=i;i=()=>h.call(this)&&u.call(this)}}else r=s;let o=!0;while(i.call(this)===!0&&o===!0)o=this.doSingleRepetition(r);this.attemptInRepetitionRecovery(this.manyInternal,[e,s],i,xt,e,js,o)}manySepFirstInternal(e,s){let n=wt|e;this.manySepFirstInternalLogic(e,s,n)}manySepFirstInternalLogic(e,s,n){let{DEF:i,SEP:r}=s;if(this.currRuleLookaheadFuncs[n].call(this)===!0){i.call(this);let h=()=>this.tokenMatcher(this.LA_FAST(1),r);while(this.tokenMatcher(this.LA_FAST(1),r)===!0)this.CONSUME(r),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,r,h,i,ss],h,wt,e,ss)}}repetitionSepSecondInternal(e,s,n,i,r){while(n())this.CONSUME(s),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,s,n,i,r],n,lt,e,r)}doSingleRepetition(e){let s=this.getLexerPosition();return e.call(this),this.getLexerPosition()>s}orInternal(e,s){let n=ds|s,i=Array.isArray(e)?e:e.DEF,o=this.currRuleLookaheadFuncs[n].call(this,i);if(o!==void 0)return i[o].ALT.call(this);this.raiseNoAltException(s,e.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0)this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName];this.cstFinallyStateUpdate()}subruleInternal(e,s,n){let i;try{let r=n!==void 0?n.ARGS:void 0;return this.subruleIdx=s,i=e.coreRule.apply(this,r),this.cstPostNonTerminal(i,n!==void 0&&n.LABEL!==void 0?n.LABEL:e.ruleName),i}catch(r){throw this.subruleInternalError(r,n,e.ruleName)}}subruleInternalError(e,s,n){if(Ge(e)&&e.partialCstResult!==void 0)this.cstPostNonTerminal(e.partialCstResult,s!==void 0&&s.LABEL!==void 0?s.LABEL:n),delete e.partialCstResult;throw e}consumeInternal(e,s,n){let i;try{let r=this.LA_FAST(1);if(this.tokenMatcher(r,e)===!0)this.consumeToken(),i=r;else this.consumeInternalError(e,r,n)}catch(r){i=this.consumeInternalRecovery(e,s,r)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:e.name,i),i}consumeInternalError(e,s,n){let i,r=this.LA(0);if(n!==void 0&&n.ERR_MSG)i=n.ERR_MSG;else i=this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:s,previous:r,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new ot(i,s,r))}consumeInternalRecovery(e,s,n){if(this.recoveryEnabled&&n.name==="MismatchedTokenException"&&!this.isBackTracking()){let i=this.getFollowsForInRuleRecovery(e,s);try{return this.tryInRuleRecovery(e,i)}catch(r){if(r.name===Ys)throw n;else throw r}}else throw n}saveRecogState(){let e=this.errors,s=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:s,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState);let s=e.RULE_STACK;for(let n=0;n<s.length;n++)this.RULE_STACK[n]=s[n];if(this.RULE_STACK_IDX=s.length-1,this.RULE_STACK_IDX>=0)this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName]}ruleInvocationStateUpdate(e,s,n){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=n,this.RULE_STACK[++this.RULE_STACK_IDX]=e,this.currRuleShortName=e,this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[e],this.cstInvocationStateUpdate(s)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.currRuleShortName;return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Re)}reset(){this.resetLexerState(),this.subruleIdx=0,this.currRuleShortName=-1,this.currRuleLookaheadFuncs=[],this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK_IDX=-1,this.CST_STACK=[]}onBeforeParse(e){for(let s=0;s<this.maxLookahead+1;s++)this.tokVector.push(De)}onAfterParse(e){if(this.isAtEndOfInput()===!1){let s=this.LA(1),n=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:s,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new hs(n,s))}while(this.tokVector.at(-1)===De)this.tokVector.pop()}}class on{initErrorHandler(e){this._errors=[],this.errorMessageProvider=Object.hasOwn(e,"errorMessageProvider")?e.errorMessageProvider:me.errorMessageProvider}SAVE_ERROR(e){if(Ge(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1)},this._errors.push(e),e;else throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return[...this._errors]}set errors(e){this._errors=e}raiseEarlyExitException(e,s,n){let i=this.getCurrRuleFullName(),r=this.getGAstProductions()[i],h=bt(e,r,s,this.maxLookahead)[0],u=[];for(let d=1;d<=this.maxLookahead;d++)u.push(this.LA(d));let c=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:h,actual:u,previous:this.LA(0),customUserDescription:n,ruleName:i});throw this.SAVE_ERROR(new us(c,this.LA(1),this.LA(0)))}raiseNoAltException(e,s){let n=this.getCurrRuleFullName(),i=this.getGAstProductions()[n],r=Ct(e,i,this.maxLookahead),o=[];for(let c=1;c<=this.maxLookahead;c++)o.push(this.LA(c));let h=this.LA(0),u=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:r,actual:o,previous:h,customUserDescription:s,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new cs(u,this.LA(1),h))}}var Ts={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Ts);var wi=!0,Ui=255,Di=k({name:"RECORDING_PHASE_TOKEN",pattern:z.NA});Pe([Di]);var Fi=qe(Di,`This IToken indicates the Parser is in Recording Phase
|
|
98
98
|
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Fi);var Ba={name:`This CSTNode indicates the Parser is in Recording Phase
|
|
99
99
|
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};class ln{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 s=e>0?e:"";this[`CONSUME${s}`]=function(n,i){return this.consumeInternalRecord(n,e,i)},this[`SUBRULE${s}`]=function(n,i){return this.subruleInternalRecord(n,e,i)},this[`OPTION${s}`]=function(n){return this.optionInternalRecord(n,e)},this[`OR${s}`]=function(n){return this.orInternalRecord(n,e)},this[`MANY${s}`]=function(n){this.manyInternalRecord(e,n)},this[`MANY_SEP${s}`]=function(n){this.manySepFirstInternalRecord(e,n)},this[`AT_LEAST_ONE${s}`]=function(n){this.atLeastOneInternalRecord(e,n)},this[`AT_LEAST_ONE_SEP${s}`]=function(n){this.atLeastOneSepFirstInternalRecord(e,n)}}this.consume=function(e,s,n){return this.consumeInternalRecord(s,e,n)},this.subrule=function(e,s,n){return this.subruleInternalRecord(s,e,n)},this.option=function(e,s){return this.optionInternalRecord(s,e)},this.or=function(e,s){return this.orInternalRecord(s,e)},this.many=function(e,s){this.manyInternalRecord(e,s)},this.atLeastOne=function(e,s){this.atLeastOneInternalRecord(e,s)},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 s=0;s<10;s++){let n=s>0?s:"";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,s){return()=>!0}LA_RECORD(e){return De}topLevelRuleRecord(e,s){try{let n=new Te({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),s.call(this),this.recordingProdStack.pop(),n}catch(n){if(n.KNOWN_RECORDER_ERROR!==!0)try{n.message=n.message+`
|
|
100
100
|
This error was thrown during the "grammar recording phase" For more info see:
|
|
@@ -107,15 +107,15 @@ Make sure that all grammar rule definitions are done before 'performSelfAnalysis
|
|
|
107
107
|
`)}`)})}constructor(e,s){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(s),n.initLexerAdapter(),n.initLooksAhead(s),n.initRecognizerEngine(e,s),n.initRecoverable(s),n.initTreeBuilder(s),n.initGastRecorder(s),n.initPerformanceTracer(s),Object.hasOwn(s,"ignoredIssues"))throw Error(`The <ignoredIssues> IParserConfig property has been deprecated.
|
|
108
108
|
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
|
|
109
109
|
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
|
|
110
|
-
For further details.`);this.skipValidations=Object.hasOwn(s,"skipValidations")?s.skipValidations:me.skipValidations}}Pt.DEFER_DEFINITION_ERRORS_HANDLING=!1;Bi(Pt,[qs,Js,sn,nn,an,rn,on,ln,cn]);class gs extends Pt{constructor(e,s=me){let n=Object.assign({},s);n.outputCst=!0;super(e,n)}}var ut=t((e)=>e!==void 0&&e>=0,"isKnownLocation");function Xi(e,s){let n=e.lexer.tokenize(s);if(n.errors.length>0){let r=n.errors[0],o=ut(r.offset)?r.offset:s.length,h=o+(ut(r.length)?r.length:0);throw Error(`Error lexing ${e.diagramType} diagram: ${r.message} at line ${r.line??1}, column ${r.column??1} [${o},${h})`)}e.parser.input=n.tokens;let i=e.entry();if(e.parser.errors.length>0)throw Error(`Error parsing ${e.diagramType} diagram: ${e.parser.errors[0].message}`);e.visit(i)}t(Xi,"runChevrotainParse");var X={SOLID_ARROW:0,BACK_ARROW:1,LINE_SOLID:2,CIRCLE_ARROW:3,CROSS_ARROW:4,CIRCLE_ARROW_REVERSED:5,CROSS_ARROW_REVERSED:6},Wa="LR",ja=
|
|
110
|
+
For further details.`);this.skipValidations=Object.hasOwn(s,"skipValidations")?s.skipValidations:me.skipValidations}}Pt.DEFER_DEFINITION_ERRORS_HANDLING=!1;Bi(Pt,[qs,Js,sn,nn,an,rn,on,ln,cn]);class gs extends Pt{constructor(e,s=me){let n=Object.assign({},s);n.outputCst=!0;super(e,n)}}var ut=t((e)=>e!==void 0&&e>=0,"isKnownLocation");function Xi(e,s){let n=e.lexer.tokenize(s);if(n.errors.length>0){let r=n.errors[0],o=ut(r.offset)?r.offset:s.length,h=o+(ut(r.length)?r.length:0);throw Error(`Error lexing ${e.diagramType} diagram: ${r.message} at line ${r.line??1}, column ${r.column??1} [${o},${h})`)}e.parser.input=n.tokens;let i=e.entry();if(e.parser.errors.length>0)throw Error(`Error parsing ${e.diagramType} diagram: ${e.parser.errors[0].message}`);e.visit(i)}t(Xi,"runChevrotainParse");var X={SOLID_ARROW:0,BACK_ARROW:1,LINE_SOLID:2,CIRCLE_ARROW:3,CROSS_ARROW:4,CIRCLE_ARROW_REVERSED:5,CROSS_ARROW_REVERSED:6},Wa="LR",ja=M.usecase,Tn=t(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:Wa,relationshipCounter:0,noteCounter:0,accTitle:"",accDescription:"",ast:void 0,config:structuredClone(ja)}),"createModel"),Ka=t((e)=>{if(!(e.actors instanceof Map)||!(e.useCases instanceof Map)||!(e.systemBoundaries instanceof Map)||!Array.isArray(e.relationships)||!(e.notes instanceof Map)||!(e.jsonNodes instanceof Map)||!(e.classDefs instanceof Map)||!(e.symbols instanceof Map)||!["TB","TD","BT","RL","LR"].includes(e.direction)||!Number.isSafeInteger(e.relationshipCounter)||e.relationshipCounter<0||!Number.isSafeInteger(e.noteCounter)||e.noteCounter<0||typeof e.accTitle!=="string"||typeof e.accDescription!=="string"||!e.config)throw Error("Cannot commit an incomplete usecase model")},"assertCompleteModel"),B=Tn(),Va=t(()=>structuredClone(B.config),"getConfig"),za=t(()=>B.ast,"getAST"),Ha=t((e)=>{let s=structuredClone(e);Ka(s);let n=E(),i=A();try{S(s.accTitle),T(s.accDescription),B=s}catch(r){throw S(n),T(i),r}},"commit"),Xa=t(()=>{B=Tn(),C()},"clear"),Ya=t(()=>B.actors,"getActors"),qa=t((e)=>B.actors.get(e),"getActor"),Ja=t(()=>B.useCases,"getUseCases"),Za=t((e)=>B.useCases.get(e),"getUseCase"),Qa=t(()=>B.systemBoundaries,"getSystemBoundaries"),eo=t((e)=>B.systemBoundaries.get(e),"getSystemBoundary"),to=t(()=>B.relationships,"getRelationships"),so=t(()=>B.notes,"getNotes"),no=t((e)=>B.notes.get(e),"getNote"),io=t(()=>B.jsonNodes,"getJsonNodes"),ro=t((e)=>B.jsonNodes.get(e),"getJsonNode"),ao=t(()=>B.classDefs,"getClassDefs"),oo=t((e)=>B.classDefs.get(e),"getClassDef"),Yi=t(()=>B.direction,"getDirection"),Je=t((e)=>{let s=new Map;for(let n of["default",...e]){let i=B.classDefs.get(n);if(!i)continue;for(let r of i.styles){let o=r.trim(),h=o.indexOf(":"),u=(h===-1?o:o.slice(0,h)).trim();if(u)s.set(u,o)}}return[...s.values()]},"getCompiledStyles"),lo=t((e)=>e.replaceAll("~","~0").replaceAll("/","~1"),"escapeJsonPointerPart"),$i=t((e)=>typeof e==="string"?e:e===null?"null":String(e),"displayJsonScalar"),co=t((e,s,n=(i)=>i)=>{let i=[],r=t((h,u,c)=>{i.push({key:n(h),accessibleKey:n(u),value:n(c)})},"append"),o=t((h,u,c)=>{if(Array.isArray(h)){if(h.length===0){r(u,u,"[]");return}if(h.every((f)=>f===null||["string","number","boolean"].includes(typeof f))){for(let[f,m]of h.entries())r(f===0?u:"",u,$i(m));return}for(let[f,m]of h.entries())o(m,`${u}[${f}]`,`${c}/${f}`);return}if(h!==null&&typeof h==="object"){let d=h,f=s[c]??Object.keys(d);if(f.length===0){r(u,u,"{}");return}for(let m of f){let y=u?`${u}.${m}`:m;o(d[m],y,`${c}/${lo(m)}`)}return}r(u,u,$i(h))},"visit");return o(e,"",""),i},"flattenJsonRows"),ho=t((e)=>{switch(e.type){case"hollow":return"usecaseActorHollow";case"awesome":return"usecaseActorAwesome";case"icon":return"usecaseActorIcon";case"normal":return"usecaseActor"}},"actorShape"),uo=t((e)=>{if(e.shape==="ellipse")return e.business?"usecaseBusiness":"usecaseEllipse";return e.shape},"useCaseShape"),po=t((e)=>{switch(e){case X.SOLID_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point"};case X.BACK_ARROW:return{arrowTypeStart:"arrow_point",arrowTypeEnd:"none"};case X.CIRCLE_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_circle"};case X.CROSS_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_cross"};case X.CIRCLE_ARROW_REVERSED:return{arrowTypeStart:"arrow_circle",arrowTypeEnd:"none"};case X.CROSS_ARROW_REVERSED:return{arrowTypeStart:"arrow_cross",arrowTypeEnd:"none"};case X.LINE_SOLID:return{arrowTypeStart:"none",arrowTypeEnd:"none"}}},"associationMarkers"),fo=t((e)=>{switch(e.type){case"include":case"extend":return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point",pattern:"dotted",label:e.type,labelType:"text"};case"generalization":return{arrowTypeStart:"none",arrowTypeEnd:"extension",pattern:"solid"};case"association":return{...po(e.arrowType),pattern:"solid",...e.label?{label:e.label}:{},...e.labelType?{labelType:e.labelType}:{}}}},"relationshipVisuals"),mo=t((e)=>e.animate||e.animation?[`edge-animation-${e.animation??"fast"}`]:[],"animationClasses"),Dt=t((...e)=>e.filter((s)=>Boolean(s)).join(" "),"classNames"),Eo=t(()=>{let e=l(),s={...B.config,...e.usecase},n=t((c)=>O(c,e),"sanitize"),i=t((c)=>n(B.actors.get(c)?.label??B.useCases.get(c)?.label??B.jsonNodes.get(c)?.id??B.notes.get(c)?.label??c),"endpointLabel"),r=[],o=[],h=0,u=0;for(let c of B.actors.values())r.push({id:c.id,label:n(c.label),labelType:c.labelType,shape:ho(c),isGroup:!1,padding:10,look:e.look,colorIndex:h++,cssClasses:Dt("default","usecase-actor",`usecase-actor-${c.type}`,c.business&&"usecase-business",...c.classes),cssStyles:[...c.styles],cssCompiledStyles:Je(c.classes),actorType:c.type,business:c.business,...c.icon?{icon:c.icon}:{},...c.stereotype?{stereotype:n(c.stereotype)}:{},...c.parentId?{parentId:c.parentId}:{}});for(let c of B.useCases.values())r.push({id:c.id,label:n(c.label),labelType:c.labelType,shape:uo(c),isGroup:!1,padding:c.shape==="ellipse"?20:10,look:e.look,colorIndex:h++,cssClasses:Dt("default","usecase-element",`usecase-${c.shape}`,c.business&&"usecase-business",...c.classes),cssStyles:[...c.styles],cssCompiledStyles:Je(c.classes),business:c.business,...c.stereotype?{stereotype:n(c.stereotype)}:{},...c.parentId?{parentId:c.parentId}:{}});for(let c of B.notes.values())r.push({id:c.id,label:n(c.label),labelType:c.labelType,shape:"note",isGroup:!1,padding:10,look:e.look,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:Je([]),noteTarget:c.target,noteTargetLabel:n(B.actors.get(c.target)?.label??B.useCases.get(c.target)?.label??B.jsonNodes.get(c.target)?.id??c.target)});for(let c of B.jsonNodes.values())r.push({id:c.id,label:n(c.id),labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,look:e.look,cssClasses:Dt("default","usecase-json-table",...c.classes),cssStyles:[...c.styles],cssCompiledStyles:Je(c.classes),jsonRows:co(c.value,c.propertyOrder,n)});for(let c of B.systemBoundaries.values())r.push({id:c.id,label:n(c.label),labelType:c.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,look:e.look,colorIndex:u++,cssClasses:Dt("default","system-boundary",`system-boundary-${c.type}`,...c.classes),cssStyles:[...c.styles],cssCompiledStyles:Je(c.classes),boundaryType:c.type});for(let c of B.relationships){let{label:d,...f}=fo(c);o.push({id:c.id,start:c.source,end:c.target,source:c.source,target:c.target,sourceLabel:i(c.source),targetLabel:i(c.target),type:"edge",relationshipType:c.type,internal:!1,...f,...d!==void 0?{label:n(d)}:{},labelpos:"c",classes:Dt("default","relationship",`relationship-${c.type}`,...c.classes,...mo(c)),style:[...c.styles],cssCompiledStyles:Je(c.classes),animate:c.animate,...c.animation?{animation:c.animation}:{},look:e.look,thickness:"normal",minlen:c.minlen,isUserDefinedId:c.explicitId})}for(let c of B.notes.values())o.push({id:`${c.id}-edge`,start:c.id,end:c.target,source:c.id,target:c.target,type:"edge",relationshipType:"note",sourceLabel:i(c.id),targetLabel:i(c.target),internal:!0,pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",labelpos:"c",classes:"default relationship relationship-note",style:[],cssCompiledStyles:Je([]),animate:!1,look:e.look,thickness:"normal",minlen:1,isUserDefinedId:!1});for(let c of r){if(c.wrappingWidth??=s.wrappingWidth,!c.isGroup&&!c.shape.startsWith("usecaseActor"))c.minWidth??=s.minNodeWidth;if(c.shape==="usecaseEllipse"||c.shape==="usecaseBusiness")c.spreadPorts=!0}return{nodes:r,edges:o,config:e,type:"usecase",layoutAlgorithm:"dagre",direction:Yi(),nodeSpacing:s.nodeSpacing,rankSpacing:s.rankSpacing,actorFontSize:s.actorFontSize,actorFontFamily:s.actorFontFamily,actorFontWeight:s.actorFontWeight,usecaseFontSize:s.usecaseFontSize,usecaseFontFamily:s.usecaseFontFamily,usecaseFontWeight:s.usecaseFontWeight,diagramPadding:s.diagramPadding,useMaxWidth:s.useMaxWidth,markers:["point","circle","cross","extension"]}},"getData"),Ns={getConfig:Va,createModel:Tn,commit:Ha,getAST:za,clear:Xa,setDiagramTitle:L,getDiagramTitle:R,setAccTitle:S,getAccTitle:E,setAccDescription:T,getAccDescription:A,getActors:Ya,getActor:qa,getUseCases:Ja,getUseCase:Za,getSystemBoundaries:Qa,getSystemBoundary:eo,getRelationships:to,getNotes:so,getNote:no,getJsonNodes:io,getJsonNode:ro,getClassDefs:ao,getClassDef:oo,getDirection:Yi,getData:Eo};function Qe(e,s,n){let i=[n];return i.index=s,i.input=e,i}t(Qe,"customMatch");var To=t((e,s)=>{if(e[s]!=='"'||e[s+1]!=="`")return null;for(let n=s+2;n<e.length-1;n++)if(e[n]==="`"&&e[n+1]==='"')return Qe(e,s,e.slice(s,n+2));return null},"matchMarkdownString"),go=t((e,s)=>{if(e[s]!=="%"||e[s+1]!=="%")return null;for(let i=s-1;i>=0;i--){let r=e[i];if(r===`
|
|
111
111
|
`||r==="\r")break;if(r!==" "&&r!=="\t")return null}let n=s+2;while(n<e.length&&e[n]!==`
|
|
112
112
|
`&&e[n]!=="\r")n++;return Qe(e,s,e.slice(s,n))},"matchComment"),qi=t((e,s)=>{for(let n=s-1;n>=0;n--){let i=e[n];if(i===`
|
|
113
|
-
`||i==="\r")return!0;if(i!==" "&&i!=="\t")return!1}return!0},"isIndentedLineStart"),Ji=t((e,s,n)=>{if(!qi(e,s))return null;let i=n.exec(e.slice(s));return i?Qe(e,s,i[0]):null},"matchAccessibilityLine"),Ao=t((e,s)=>{if(!qi(e,s))return null;let n=/^accDescr[\t ]*{/.exec(e.slice(s));if(!n)return null;let i=e.indexOf("}",s+n[0].length);return i===-1?null:Qe(e,s,e.slice(s,i+1))},"matchAccDescrBlock"),So=t((e,s)=>{if(e[s]!=="{")return null;let n=0,i=!1,r=!1;for(let o=s;o<e.length;o++){let h=e[o];if(i){if(r)r=!1;else if(h==="\\")r=!0;else if(h==='"')i=!1;continue}if(h==='"')i=!0;else if(h==="{")n++;else if(h==="}"&&--n===0)return Qe(e,s,e.slice(s,o+1))}return null},"matchJsonObject"),Ro=t((e,s)=>{let n=e.indexOf(">>",s);if(n===-1||/[\n\r]/.test(e.slice(s,n)))return null;let i=e.slice(s,n);return i.trim()?Qe(e,s,i):null},"matchStereotypeText"),re=k({name:"LABEL_TEXT",pattern:z.NA}),dt=k({name:"WORD",pattern:z.NA,categories:re}),gn=k({name:"NUMBER",pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:re}),Y=k({name:"IDENTIFIER",pattern:/\w+/,longer_alt:gn,categories:dt}),yo=k({name:"HWS",pattern:/[\t ]+/,group:z.SKIPPED}),Be=k({name:"MARKDOWN_STRING",pattern:To,start_chars_hint:['"'],line_breaks:!0}),Oo=k({name:"UNCLOSED_MARKDOWN_STRING",pattern:/"`[^]*/,line_breaks:!0}),un=k({name:"COMMENT",pattern:go,start_chars_hint:["%"],line_breaks:!1}),Fe=k({name:"NEWLINE",pattern:/\r\n|\n|\r/,line_breaks:!0}),Zi=k({name:"ACC_DESCR_BLOCK",pattern:Ao,start_chars_hint:["a"],line_breaks:!0}),Lo=/^accTitle[\t ]*:[^\n\r]*/,No=/^accDescr[\t ]*:[^\n\r]*/,Qi=k({name:"ACC_TITLE_LINE",pattern:t((e,s)=>Ji(e,s,Lo),"pattern"),start_chars_hint:["a"],line_breaks:!1}),er=k({name:"ACC_DESCR_LINE",pattern:t((e,s)=>Ji(e,s,No),"pattern"),start_chars_hint:["a"],line_breaks:!1}),tr=k({name:"JSON_DECLARATION_START",pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:"jsonBody"}),An=k({name:"JSON_OBJECT_LITERAL",pattern:So,start_chars_hint:["{"],line_breaks:!0,pop_mode:!0}),sr=k({name:"UNCLOSED_JSON_OBJECT_LITERAL",pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),ee=t((e,s)=>k({name:e,pattern:s,longer_alt:Y,categories:dt}),"keyword"),nr=ee("USECASE",/usecase-beta/),dn=ee("ACTOR",/actor/),ir=ee("SYSTEM_BOUNDARY",/systemBoundary/),rr=ee("END",/end/),ar=ee("DIRECTION",/direction/),or=ee("TD",/TD/),lr=ee("TB",/TB/),cr=ee("BT",/BT/),hr=ee("LR",/LR/),ur=ee("RL",/RL/),dr=ee("NOTE",/note/),pr=ee("FOR",/for/),Io=ee("JSON",/json/),fr=ee("CLASS_DEF",/classDef/),mr=ee("CLASS",/class/),Er=ee("STYLE",/style/),Tr=ee("INCLUDE",/include/i),gr=ee("EXTEND",/extend/i),Ar=ee("TRUE",/true/),Sr=ee("FALSE",/false/),Rr=k({name:"GENERALIZATION",pattern:/--\|>/}),yr=k({name:"DEPENDENCY_ARROW",pattern:/\.\.>/}),Or=k({name:"STEREOTYPE_START",pattern:/<</,push_mode:"stereotype"}),Sn=k({name:"STEREOTYPE_END",pattern:/>>/,pop_mode:!0}),Rn=k({name:"STEREOTYPE_TEXT",pattern:Ro,line_breaks:!1}),Lr=k({name:"UNCLOSED_STEREOTYPE_TEXT",pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),Nr=k({name:"CLASS_SEPARATOR",pattern:/:::/}),As=k({name:"FORWARD_SOLID",pattern:/--+>/}),Ir=k({name:"BACKWARD_SOLID",pattern:/<--+/}),Ss=k({name:"FORWARD_CIRCLE",pattern:/--o/}),kr=k({name:"BACKWARD_CIRCLE",pattern:/o--/}),Rs=k({name:"FORWARD_CROSS",pattern:/--x/}),Cr=k({name:"BACKWARD_CROSS",pattern:/x--/}),Ie=k({name:"MARKERLESS_SOLID",pattern:/--+/}),pn=k({name:"METADATA_START",pattern:/@{/}),ys=k({name:"AT",pattern:/@/,categories:re}),br=k({name:"LBRACE",pattern:/{/}),fn=k({name:"RBRACE",pattern:/}/}),Os=k({name:"LBRACKET",pattern:/\[/}),Ls=k({name:"RBRACKET",pattern:/]/}),Ft=k({name:"LPAREN",pattern:/\(/}),Bt=k({name:"RPAREN",pattern:/\)/}),be=k({name:"COMMA",pattern:/,/,categories:re}),$t=k({name:"COLON",pattern:/:/,categories:re}),_r=k({name:"HASH_COLOR",pattern:/#[\dA-Fa-f]+/,categories:re}),ke=k({name:"PLAIN_STRING",pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),mn=k({name:"CSS_IDENTIFIER",pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:re}),xr=k({name:"CSS_ESCAPED_COMMA",pattern:/\\,/,categories:re}),vr=k({name:"DASH",pattern:/-/,categories:re}),Mr=k({name:"DOT",pattern:/\./,categories:re}),wr=k({name:"PERCENT",pattern:/%/,categories:re}),Ur=k({name:"CSS_PUNCTUATION",pattern:/[!#$&*+/=?^_|~]/,categories:re}),ko=k({name:"LABEL_PUNCTUATION",pattern:/[;<>\\`]/,categories:re}),Co=k({name:"LABEL_SYMBOL",pattern:/[^\t\n\r !-~]+/,categories:re}),Pr=[re,dt,yo,Be,Oo,un,Fe,Zi,Qi,er,tr,nr,dn,ir,rr,ar,or,lr,cr,hr,ur,dr,pr,Io,fr,mr,Er,Tr,gr,Ar,Sr,Rr,yr,Or,Nr,As,Ir,Ss,kr,Rs,Cr,Ie,pn,ys,br,fn,Os,Ls,Ft,Bt,be,$t,_r,ke,mn,Y,gn,xr,vr,Mr,wr,Ur,ko,Co],bo={defaultMode:"defaultMode",modes:{defaultMode:[...Pr],jsonBody:[An,sr],stereotype:[Sn,Rn,Lr]}},_o=[...Pr,An,sr,Sn,Rn,Lr],xo=new z(bo),Gi=t((e)=>kt(e,re)||e.tokenType===ke||e.tokenType===Be,"isLabelToken"),vo={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},Mo=class extends gs{static{t(this,"UsecaseParser")}constructor(){super(_o,{nodeLocationTracking:"full"});this.RULE("start",()=>{this.CONSUME(nr),this.SUBRULE(this.lineEnd),this.MANY(()=>this.SUBRULE(this.line))}),this.RULE("line",()=>{this.OR([{ALT:t(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:t(()=>this.SUBRULE(this.commentLine),"ALT")},{GATE:t(()=>this.isStatementStart(),"GATE"),ALT:t(()=>this.SUBRULE(this.statement),"ALT")}])}),this.RULE("statement",()=>{this.OR([{ALT:t(()=>this.SUBRULE(this.accTitleStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.accDescrStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.directionStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.actorStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.systemBoundaryStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.noteStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.jsonStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.classDefStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.classStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.styleStatement),"ALT")},{GATE:t(()=>this.isMetadataAssignment(),"GATE"),ALT:t(()=>this.SUBRULE(this.metadataAssignmentStatement),"ALT")},{GATE:t(()=>!this.isForbiddenPlantUmlStatement(),"GATE"),ALT:t(()=>this.SUBRULE(this.entityStatement),"ALT")}])}),this.RULE("lineEnd",()=>{this.OR([{ALT:t(()=>this.CONSUME(Fe),"ALT")},{ALT:t(()=>this.CONSUME(Re),"ALT")}])}),this.RULE("blankLine",()=>{this.CONSUME(Fe)}),this.RULE("commentLine",()=>{this.CONSUME(un),this.SUBRULE(this.lineEnd)}),this.RULE("accTitleStatement",()=>{this.CONSUME(Qi),this.SUBRULE(this.lineEnd)}),this.RULE("accDescrStatement",()=>{this.OR([{ALT:t(()=>this.CONSUME(er),"ALT")},{ALT:t(()=>this.CONSUME(Zi),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("actorStatement",()=>{this.CONSUME(dn),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:t(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(be),this.SUBRULE2(this.actorItem)}),"ALT")},{ALT:t(()=>this.SUBRULE(this.relationTail),"ALT")}])}),this.SUBRULE(this.lineEnd)}),this.RULE("actorItem",()=>{this.SUBRULE(this.actorName),this.OPTION(()=>this.SUBRULE(this.metadata)),this.OPTION2(()=>this.SUBRULE(this.stereotype)),this.OPTION3(()=>this.SUBRULE(this.classSuffix))}),this.RULE("actorName",()=>{this.OR([{ALT:t(()=>{this.CONSUME(Y),this.OPTION(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)})},"ALT")},{ALT:t(()=>this.CONSUME(ke),"ALT")},{ALT:t(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("actorDeclarationOnly",()=>{this.CONSUME(dn),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(be),this.SUBRULE2(this.actorItem)}),this.SUBRULE(this.lineEnd)}),this.RULE("entityStatement",()=>{this.SUBRULE(this.entityName),this.OPTION(()=>this.SUBRULE(this.relationTail)),this.SUBRULE(this.lineEnd)}),this.RULE("entityName",()=>{this.OR([{ALT:t(()=>{this.CONSUME(Y),this.OPTION(()=>{this.OR2([{ALT:t(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)},"ALT")},{ALT:t(()=>{this.CONSUME(Os),this.SUBRULE2(this.nodeLabel),this.CONSUME(Ls)},"ALT")}])})},"ALT")},{ALT:t(()=>this.CONSUME(ke),"ALT")},{ALT:t(()=>this.CONSUME(Be),"ALT")}]),this.OPTION2(()=>this.SUBRULE(this.useCaseMetadata)),this.OPTION3(()=>this.SUBRULE(this.stereotype)),this.OPTION4(()=>this.SUBRULE(this.classSuffix))}),this.RULE("nodeLabel",()=>{this.OR([{ALT:t(()=>this.CONSUME(ke),"ALT")},{ALT:t(()=>this.CONSUME(Be),"ALT")},{ALT:t(()=>this.AT_LEAST_ONE(()=>this.CONSUME(re)),"ALT")}])}),this.RULE("useCaseMetadata",()=>{this.SUBRULE(this.metadata)}),this.RULE("relationTail",()=>{this.OPTION({GATE:t(()=>this.LA(1).tokenType===Y&&this.LA(2).tokenType===ys,"GATE"),DEF:t(()=>{this.CONSUME(Y),this.CONSUME(ys)},"DEF")}),this.SUBRULE(this.arrow),this.SUBRULE(this.entityName)}),this.RULE("arrow",()=>{this.OR([{ALT:t(()=>this.SUBRULE(this.semanticRelation),"ALT")},{ALT:t(()=>this.SUBRULE(this.forwardSolidOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.backwardSolidOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.markerlessSolidOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.forwardCircleOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.backwardCircleOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.forwardCrossOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.backwardCrossOperator),"ALT")}])}),this.RULE("forwardSolidOperator",()=>{this.CONSUME(As)}),this.RULE("backwardSolidOperator",()=>{this.CONSUME(Ir),this.OPTION({GATE:t(()=>this.LA(0).image==="<--"&&this.hasLabeledRight([Ie]),"GATE"),DEF:t(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Ie)},"DEF")})}),this.RULE("markerlessSolidOperator",()=>{this.CONSUME(Ie),this.OPTION({GATE:t(()=>this.LA(0).image==="--"&&this.hasLabeledRight([As,Ie,Ss,Rs]),"GATE"),DEF:t(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:t(()=>this.CONSUME(As),"ALT")},{ALT:t(()=>this.CONSUME2(Ie),"ALT")},{ALT:t(()=>this.CONSUME(Ss),"ALT")},{ALT:t(()=>this.CONSUME(Rs),"ALT")}])},"DEF")})}),this.RULE("forwardCircleOperator",()=>{this.CONSUME(Ss)}),this.RULE("backwardCircleOperator",()=>{this.CONSUME(kr),this.OPTION({GATE:t(()=>this.hasLabeledRight([Ie]),"GATE"),DEF:t(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Ie)},"DEF")})}),this.RULE("forwardCrossOperator",()=>{this.CONSUME(Rs)}),this.RULE("backwardCrossOperator",()=>{this.CONSUME(Cr),this.OPTION({GATE:t(()=>this.hasLabeledRight([Ie]),"GATE"),DEF:t(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Ie)},"DEF")})}),this.RULE("edgeLabel",()=>{this.OR([{ALT:t(()=>this.CONSUME(ke),"ALT")},{ALT:t(()=>this.CONSUME(Be),"ALT")},{ALT:t(()=>this.AT_LEAST_ONE(()=>this.CONSUME(re)),"ALT")}])}),this.RULE("semanticRelation",()=>{this.OR([{ALT:t(()=>{this.CONSUME(yr),this.CONSUME($t),this.OR2([{ALT:t(()=>this.CONSUME(Tr),"ALT")},{ALT:t(()=>this.CONSUME(gr),"ALT")}])},"ALT")},{ALT:t(()=>this.CONSUME(Rr),"ALT")}])}),this.RULE("metadata",()=>{this.CONSUME(pn),this.MANY(()=>this.CONSUME(Fe)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(be)),this.MANY3(()=>this.CONSUME2(Fe))}),this.CONSUME(fn)}),this.RULE("metadataProperty",()=>{this.OR([{ALT:t(()=>this.CONSUME(Y),"ALT")},{ALT:t(()=>this.CONSUME(ke),"ALT")}]),this.CONSUME($t),this.OR2([{ALT:t(()=>this.CONSUME2(Y),"ALT")},{ALT:t(()=>this.CONSUME2(ke),"ALT")},{ALT:t(()=>this.CONSUME(Ar),"ALT")},{ALT:t(()=>this.CONSUME(Sr),"ALT")}])}),this.RULE("metadataSeparator",()=>{this.OR([{ALT:t(()=>{this.CONSUME(be),this.MANY(()=>this.CONSUME(Fe))},"ALT")},{ALT:t(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(Fe)),this.OPTION(()=>this.CONSUME2(be)),this.MANY2(()=>this.CONSUME3(Fe))},"ALT")}])}),this.RULE("systemBoundaryStatement",()=>{this.CONSUME(ir),this.SUBRULE(this.systemBoundaryName),this.OPTION(()=>this.SUBRULE(this.metadata)),this.OPTION2(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd),this.SUBRULE(this.systemBoundaryContent),this.CONSUME(rr),this.SUBRULE2(this.lineEnd)}),this.RULE("systemBoundaryName",()=>{this.OR([{ALT:t(()=>{this.CONSUME(Y),this.OPTION(()=>{this.OR2([{ALT:t(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)},"ALT")},{ALT:t(()=>{this.CONSUME(Os),this.SUBRULE2(this.nodeLabel),this.CONSUME(Ls)},"ALT")}])})},"ALT")},{ALT:t(()=>this.CONSUME(ke),"ALT")},{ALT:t(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("systemBoundaryContent",()=>{this.MANY(()=>{this.OR([{ALT:t(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:t(()=>this.SUBRULE(this.commentLine),"ALT")},{ALT:t(()=>this.SUBRULE(this.boundaryElement),"ALT")}])})}),this.RULE("boundaryElement",()=>{this.OR([{ALT:t(()=>this.SUBRULE(this.actorDeclarationOnly),"ALT")},{ALT:t(()=>{this.SUBRULE(this.entityName),this.SUBRULE(this.lineEnd)},"ALT")}])}),this.RULE("metadataAssignmentStatement",()=>{this.SUBRULE(this.metadataAssignmentTarget),this.SUBRULE(this.metadata),this.SUBRULE(this.lineEnd)}),this.RULE("metadataAssignmentTarget",()=>{this.OR([{ALT:t(()=>this.CONSUME(Y),"ALT")},{ALT:t(()=>this.CONSUME(ke),"ALT")},{ALT:t(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("noteStatement",()=>{this.CONSUME(dr),this.CONSUME(pr),this.CONSUME(Y),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE("stereotype",()=>{this.CONSUME(Or),this.CONSUME(Rn),this.CONSUME(Sn)}),this.RULE("classSuffix",()=>{this.CONSUME(Nr),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(be),this.CONSUME2(Y)})}),this.RULE("jsonStatement",()=>{this.CONSUME(tr),this.CONSUME(An),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE("directionStatement",()=>{this.CONSUME(ar),this.OR([{ALT:t(()=>this.CONSUME(or),"ALT")},{ALT:t(()=>this.CONSUME(lr),"ALT")},{ALT:t(()=>this.CONSUME(cr),"ALT")},{ALT:t(()=>this.CONSUME(hr),"ALT")},{ALT:t(()=>this.CONSUME(ur),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("classDefStatement",()=>{this.CONSUME(fr),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(be),this.CONSUME2(Y)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("classStatement",()=>{this.CONSUME(mr),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(be),this.CONSUME2(Y)}),this.CONSUME3(Y),this.MANY2(()=>{this.CONSUME2(be),this.CONSUME4(Y)}),this.SUBRULE(this.lineEnd)}),this.RULE("styleStatement",()=>{this.CONSUME(Er),this.CONSUME(Y),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("styles",()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(be),this.SUBRULE2(this.styleValue)})}),this.RULE("styleValue",()=>{this.OR([{ALT:t(()=>this.CONSUME(dt),"ALT")},{ALT:t(()=>this.CONSUME(mn),"ALT")},{ALT:t(()=>{this.CONSUME(Ie),this.CONSUME2(dt)},"ALT")}]),this.CONSUME($t),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE("styleComponent",()=>{this.OR([{ALT:t(()=>this.CONSUME(dt),"ALT")},{ALT:t(()=>this.CONSUME(ke),"ALT")},{ALT:t(()=>this.CONSUME(gn),"ALT")},{ALT:t(()=>this.CONSUME(_r),"ALT")},{ALT:t(()=>this.CONSUME(mn),"ALT")},{ALT:t(()=>this.CONSUME(xr),"ALT")},{ALT:t(()=>this.CONSUME(vr),"ALT")},{ALT:t(()=>this.CONSUME(Mr),"ALT")},{ALT:t(()=>this.CONSUME(wr),"ALT")},{ALT:t(()=>this.CONSUME(Ur),"ALT")},{ALT:t(()=>this.CONSUME($t),"ALT")},{ALT:t(()=>this.CONSUME(Ft),"ALT")},{ALT:t(()=>this.CONSUME(Bt),"ALT")},{ALT:t(()=>this.CONSUME(Os),"ALT")},{ALT:t(()=>this.CONSUME(Ls),"ALT")},{ALT:t(()=>this.CONSUME(br),"ALT")},{ALT:t(()=>this.CONSUME(fn),"ALT")},{ALT:t(()=>this.CONSUME(ys),"ALT")},{ALT:t(()=>this.CONSUME(Ie),"ALT")}])}),this.performSelfAnalysis()}isMetadataAssignment(){let e=this.LA(1).tokenType;return(e===Y||e===ke||e===Be)&&this.LA(2).tokenType===pn}isStatementStart(){let e=this.LA(1).tokenType;return e!==Re&&e!==Fe&&e!==un}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===Y&&vo[this.LA(1).image.toLowerCase()]===!0}hasLabeledRight(e){if(!Gi(this.LA(1)))return!1;for(let s=2;;s++){let n=this.LA(s);if(e.includes(n.tokenType))return!0;if(!Gi(n))return!1}}},Gt=new Mo,Wi=class extends Error{constructor(e,s,n){super(`${e} (line ${s}, column ${n})`);this.line=s,this.column=n,this.name="UsecaseJsonError"}static{t(this,"UsecaseJsonError")}},En=t((e,s,n,i)=>{let r=n,o=i,h=Math.min(Math.max(s,0),e.length);for(let u=0;u<h;u++){let c=e[u];if(c==="\r")r++,o=1;else if(c===`
|
|
113
|
+
`||i==="\r")return!0;if(i!==" "&&i!=="\t")return!1}return!0},"isIndentedLineStart"),Ji=t((e,s,n)=>{if(!qi(e,s))return null;let i=n.exec(e.slice(s));return i?Qe(e,s,i[0]):null},"matchAccessibilityLine"),Ao=t((e,s)=>{if(!qi(e,s))return null;let n=/^accDescr[\t ]*{/.exec(e.slice(s));if(!n)return null;let i=e.indexOf("}",s+n[0].length);return i===-1?null:Qe(e,s,e.slice(s,i+1))},"matchAccDescrBlock"),So=t((e,s)=>{if(e[s]!=="{")return null;let n=0,i=!1,r=!1;for(let o=s;o<e.length;o++){let h=e[o];if(i){if(r)r=!1;else if(h==="\\")r=!0;else if(h==='"')i=!1;continue}if(h==='"')i=!0;else if(h==="{")n++;else if(h==="}"&&--n===0)return Qe(e,s,e.slice(s,o+1))}return null},"matchJsonObject"),Ro=t((e,s)=>{let n=e.indexOf(">>",s);if(n===-1||/[\n\r]/.test(e.slice(s,n)))return null;let i=e.slice(s,n);return i.trim()?Qe(e,s,i):null},"matchStereotypeText"),re=k({name:"LABEL_TEXT",pattern:z.NA}),dt=k({name:"WORD",pattern:z.NA,categories:re}),gn=k({name:"NUMBER",pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:re}),Y=k({name:"IDENTIFIER",pattern:/\w+/,longer_alt:gn,categories:dt}),yo=k({name:"HWS",pattern:/[\t ]+/,group:z.SKIPPED}),Be=k({name:"MARKDOWN_STRING",pattern:To,start_chars_hint:['"'],line_breaks:!0}),Oo=k({name:"UNCLOSED_MARKDOWN_STRING",pattern:/"`[^]*/,line_breaks:!0}),un=k({name:"COMMENT",pattern:go,start_chars_hint:["%"],line_breaks:!1}),Fe=k({name:"NEWLINE",pattern:/\r\n|\n|\r/,line_breaks:!0}),Zi=k({name:"ACC_DESCR_BLOCK",pattern:Ao,start_chars_hint:["a"],line_breaks:!0}),Lo=/^accTitle[\t ]*:[^\n\r]*/,No=/^accDescr[\t ]*:[^\n\r]*/,Qi=k({name:"ACC_TITLE_LINE",pattern:t((e,s)=>Ji(e,s,Lo),"pattern"),start_chars_hint:["a"],line_breaks:!1}),er=k({name:"ACC_DESCR_LINE",pattern:t((e,s)=>Ji(e,s,No),"pattern"),start_chars_hint:["a"],line_breaks:!1}),tr=k({name:"JSON_DECLARATION_START",pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:"jsonBody"}),An=k({name:"JSON_OBJECT_LITERAL",pattern:So,start_chars_hint:["{"],line_breaks:!0,pop_mode:!0}),sr=k({name:"UNCLOSED_JSON_OBJECT_LITERAL",pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),ee=t((e,s)=>k({name:e,pattern:s,longer_alt:Y,categories:dt}),"keyword"),nr=ee("USECASE",/usecase-beta/),dn=ee("ACTOR",/actor/),ir=ee("SYSTEM_BOUNDARY",/systemBoundary/),rr=ee("END",/end/),ar=ee("DIRECTION",/direction/),or=ee("TD",/TD/),lr=ee("TB",/TB/),cr=ee("BT",/BT/),hr=ee("LR",/LR/),ur=ee("RL",/RL/),dr=ee("NOTE",/note/),pr=ee("FOR",/for/),Io=ee("JSON",/json/),fr=ee("CLASS_DEF",/classDef/),mr=ee("CLASS",/class/),Er=ee("STYLE",/style/),Tr=ee("INCLUDE",/include/i),gr=ee("EXTEND",/extend/i),Ar=ee("TRUE",/true/),Sr=ee("FALSE",/false/),Rr=k({name:"GENERALIZATION",pattern:/--\|>/}),yr=k({name:"DEPENDENCY_ARROW",pattern:/\.\.>/}),Or=k({name:"STEREOTYPE_START",pattern:/<</,push_mode:"stereotype"}),Sn=k({name:"STEREOTYPE_END",pattern:/>>/,pop_mode:!0}),Rn=k({name:"STEREOTYPE_TEXT",pattern:Ro,line_breaks:!1}),Lr=k({name:"UNCLOSED_STEREOTYPE_TEXT",pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),Nr=k({name:"CLASS_SEPARATOR",pattern:/:::/}),As=k({name:"FORWARD_SOLID",pattern:/--+>/}),Ir=k({name:"BACKWARD_SOLID",pattern:/<--+/}),Ss=k({name:"FORWARD_CIRCLE",pattern:/--o/}),kr=k({name:"BACKWARD_CIRCLE",pattern:/o--/}),Rs=k({name:"FORWARD_CROSS",pattern:/--x/}),Cr=k({name:"BACKWARD_CROSS",pattern:/x--/}),Ie=k({name:"MARKERLESS_SOLID",pattern:/--+/}),pn=k({name:"METADATA_START",pattern:/@{/}),ys=k({name:"AT",pattern:/@/,categories:re}),br=k({name:"LBRACE",pattern:/{/}),fn=k({name:"RBRACE",pattern:/}/}),Os=k({name:"LBRACKET",pattern:/\[/}),Ls=k({name:"RBRACKET",pattern:/]/}),Ft=k({name:"LPAREN",pattern:/\(/}),Bt=k({name:"RPAREN",pattern:/\)/}),be=k({name:"COMMA",pattern:/,/,categories:re}),$t=k({name:"COLON",pattern:/:/,categories:re}),_r=k({name:"HASH_COLOR",pattern:/#[\dA-Fa-f]+/,categories:re}),ke=k({name:"PLAIN_STRING",pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),mn=k({name:"CSS_IDENTIFIER",pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:re}),xr=k({name:"CSS_ESCAPED_COMMA",pattern:/\\,/,categories:re}),vr=k({name:"DASH",pattern:/-/,categories:re}),Mr=k({name:"DOT",pattern:/\./,categories:re}),wr=k({name:"PERCENT",pattern:/%/,categories:re}),Ur=k({name:"CSS_PUNCTUATION",pattern:/[!#$&*+/=?^_|~]/,categories:re}),ko=k({name:"LABEL_PUNCTUATION",pattern:/[;<>\\`]/,categories:re}),Co=k({name:"LABEL_SYMBOL",pattern:/[^\t\n\r !-~]+/,categories:re}),Pr=[re,dt,yo,Be,Oo,un,Fe,Zi,Qi,er,tr,nr,dn,ir,rr,ar,or,lr,cr,hr,ur,dr,pr,Io,fr,mr,Er,Tr,gr,Ar,Sr,Rr,yr,Or,Nr,As,Ir,Ss,kr,Rs,Cr,Ie,pn,ys,br,fn,Os,Ls,Ft,Bt,be,$t,_r,ke,mn,Y,gn,xr,vr,Mr,wr,Ur,ko,Co],bo={defaultMode:"defaultMode",modes:{defaultMode:[...Pr],jsonBody:[An,sr],stereotype:[Sn,Rn,Lr]}},_o=[...Pr,An,sr,Sn,Rn,Lr],xo=new z(bo),Gi=t((e)=>It(e,re)||e.tokenType===ke||e.tokenType===Be,"isLabelToken"),vo={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},Mo=class extends gs{static{t(this,"UsecaseParser")}constructor(){super(_o,{nodeLocationTracking:"full"});this.RULE("start",()=>{this.CONSUME(nr),this.SUBRULE(this.lineEnd),this.MANY(()=>this.SUBRULE(this.line))}),this.RULE("line",()=>{this.OR([{ALT:t(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:t(()=>this.SUBRULE(this.commentLine),"ALT")},{GATE:t(()=>this.isStatementStart(),"GATE"),ALT:t(()=>this.SUBRULE(this.statement),"ALT")}])}),this.RULE("statement",()=>{this.OR([{ALT:t(()=>this.SUBRULE(this.accTitleStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.accDescrStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.directionStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.actorStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.systemBoundaryStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.noteStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.jsonStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.classDefStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.classStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.styleStatement),"ALT")},{GATE:t(()=>this.isMetadataAssignment(),"GATE"),ALT:t(()=>this.SUBRULE(this.metadataAssignmentStatement),"ALT")},{GATE:t(()=>!this.isForbiddenPlantUmlStatement(),"GATE"),ALT:t(()=>this.SUBRULE(this.entityStatement),"ALT")}])}),this.RULE("lineEnd",()=>{this.OR([{ALT:t(()=>this.CONSUME(Fe),"ALT")},{ALT:t(()=>this.CONSUME(Re),"ALT")}])}),this.RULE("blankLine",()=>{this.CONSUME(Fe)}),this.RULE("commentLine",()=>{this.CONSUME(un),this.SUBRULE(this.lineEnd)}),this.RULE("accTitleStatement",()=>{this.CONSUME(Qi),this.SUBRULE(this.lineEnd)}),this.RULE("accDescrStatement",()=>{this.OR([{ALT:t(()=>this.CONSUME(er),"ALT")},{ALT:t(()=>this.CONSUME(Zi),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("actorStatement",()=>{this.CONSUME(dn),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:t(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(be),this.SUBRULE2(this.actorItem)}),"ALT")},{ALT:t(()=>this.SUBRULE(this.relationTail),"ALT")}])}),this.SUBRULE(this.lineEnd)}),this.RULE("actorItem",()=>{this.SUBRULE(this.actorName),this.OPTION(()=>this.SUBRULE(this.metadata)),this.OPTION2(()=>this.SUBRULE(this.stereotype)),this.OPTION3(()=>this.SUBRULE(this.classSuffix))}),this.RULE("actorName",()=>{this.OR([{ALT:t(()=>{this.CONSUME(Y),this.OPTION(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)})},"ALT")},{ALT:t(()=>this.CONSUME(ke),"ALT")},{ALT:t(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("actorDeclarationOnly",()=>{this.CONSUME(dn),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(be),this.SUBRULE2(this.actorItem)}),this.SUBRULE(this.lineEnd)}),this.RULE("entityStatement",()=>{this.SUBRULE(this.entityName),this.OPTION(()=>this.SUBRULE(this.relationTail)),this.SUBRULE(this.lineEnd)}),this.RULE("entityName",()=>{this.OR([{ALT:t(()=>{this.CONSUME(Y),this.OPTION(()=>{this.OR2([{ALT:t(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)},"ALT")},{ALT:t(()=>{this.CONSUME(Os),this.SUBRULE2(this.nodeLabel),this.CONSUME(Ls)},"ALT")}])})},"ALT")},{ALT:t(()=>this.CONSUME(ke),"ALT")},{ALT:t(()=>this.CONSUME(Be),"ALT")}]),this.OPTION2(()=>this.SUBRULE(this.useCaseMetadata)),this.OPTION3(()=>this.SUBRULE(this.stereotype)),this.OPTION4(()=>this.SUBRULE(this.classSuffix))}),this.RULE("nodeLabel",()=>{this.OR([{ALT:t(()=>this.CONSUME(ke),"ALT")},{ALT:t(()=>this.CONSUME(Be),"ALT")},{ALT:t(()=>this.AT_LEAST_ONE(()=>this.CONSUME(re)),"ALT")}])}),this.RULE("useCaseMetadata",()=>{this.SUBRULE(this.metadata)}),this.RULE("relationTail",()=>{this.OPTION({GATE:t(()=>this.LA(1).tokenType===Y&&this.LA(2).tokenType===ys,"GATE"),DEF:t(()=>{this.CONSUME(Y),this.CONSUME(ys)},"DEF")}),this.SUBRULE(this.arrow),this.SUBRULE(this.entityName)}),this.RULE("arrow",()=>{this.OR([{ALT:t(()=>this.SUBRULE(this.semanticRelation),"ALT")},{ALT:t(()=>this.SUBRULE(this.forwardSolidOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.backwardSolidOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.markerlessSolidOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.forwardCircleOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.backwardCircleOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.forwardCrossOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.backwardCrossOperator),"ALT")}])}),this.RULE("forwardSolidOperator",()=>{this.CONSUME(As)}),this.RULE("backwardSolidOperator",()=>{this.CONSUME(Ir),this.OPTION({GATE:t(()=>this.LA(0).image==="<--"&&this.hasLabeledRight([Ie]),"GATE"),DEF:t(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Ie)},"DEF")})}),this.RULE("markerlessSolidOperator",()=>{this.CONSUME(Ie),this.OPTION({GATE:t(()=>this.LA(0).image==="--"&&this.hasLabeledRight([As,Ie,Ss,Rs]),"GATE"),DEF:t(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:t(()=>this.CONSUME(As),"ALT")},{ALT:t(()=>this.CONSUME2(Ie),"ALT")},{ALT:t(()=>this.CONSUME(Ss),"ALT")},{ALT:t(()=>this.CONSUME(Rs),"ALT")}])},"DEF")})}),this.RULE("forwardCircleOperator",()=>{this.CONSUME(Ss)}),this.RULE("backwardCircleOperator",()=>{this.CONSUME(kr),this.OPTION({GATE:t(()=>this.hasLabeledRight([Ie]),"GATE"),DEF:t(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Ie)},"DEF")})}),this.RULE("forwardCrossOperator",()=>{this.CONSUME(Rs)}),this.RULE("backwardCrossOperator",()=>{this.CONSUME(Cr),this.OPTION({GATE:t(()=>this.hasLabeledRight([Ie]),"GATE"),DEF:t(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Ie)},"DEF")})}),this.RULE("edgeLabel",()=>{this.OR([{ALT:t(()=>this.CONSUME(ke),"ALT")},{ALT:t(()=>this.CONSUME(Be),"ALT")},{ALT:t(()=>this.AT_LEAST_ONE(()=>this.CONSUME(re)),"ALT")}])}),this.RULE("semanticRelation",()=>{this.OR([{ALT:t(()=>{this.CONSUME(yr),this.CONSUME($t),this.OR2([{ALT:t(()=>this.CONSUME(Tr),"ALT")},{ALT:t(()=>this.CONSUME(gr),"ALT")}])},"ALT")},{ALT:t(()=>this.CONSUME(Rr),"ALT")}])}),this.RULE("metadata",()=>{this.CONSUME(pn),this.MANY(()=>this.CONSUME(Fe)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(be)),this.MANY3(()=>this.CONSUME2(Fe))}),this.CONSUME(fn)}),this.RULE("metadataProperty",()=>{this.OR([{ALT:t(()=>this.CONSUME(Y),"ALT")},{ALT:t(()=>this.CONSUME(ke),"ALT")}]),this.CONSUME($t),this.OR2([{ALT:t(()=>this.CONSUME2(Y),"ALT")},{ALT:t(()=>this.CONSUME2(ke),"ALT")},{ALT:t(()=>this.CONSUME(Ar),"ALT")},{ALT:t(()=>this.CONSUME(Sr),"ALT")}])}),this.RULE("metadataSeparator",()=>{this.OR([{ALT:t(()=>{this.CONSUME(be),this.MANY(()=>this.CONSUME(Fe))},"ALT")},{ALT:t(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(Fe)),this.OPTION(()=>this.CONSUME2(be)),this.MANY2(()=>this.CONSUME3(Fe))},"ALT")}])}),this.RULE("systemBoundaryStatement",()=>{this.CONSUME(ir),this.SUBRULE(this.systemBoundaryName),this.OPTION(()=>this.SUBRULE(this.metadata)),this.OPTION2(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd),this.SUBRULE(this.systemBoundaryContent),this.CONSUME(rr),this.SUBRULE2(this.lineEnd)}),this.RULE("systemBoundaryName",()=>{this.OR([{ALT:t(()=>{this.CONSUME(Y),this.OPTION(()=>{this.OR2([{ALT:t(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)},"ALT")},{ALT:t(()=>{this.CONSUME(Os),this.SUBRULE2(this.nodeLabel),this.CONSUME(Ls)},"ALT")}])})},"ALT")},{ALT:t(()=>this.CONSUME(ke),"ALT")},{ALT:t(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("systemBoundaryContent",()=>{this.MANY(()=>{this.OR([{ALT:t(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:t(()=>this.SUBRULE(this.commentLine),"ALT")},{ALT:t(()=>this.SUBRULE(this.boundaryElement),"ALT")}])})}),this.RULE("boundaryElement",()=>{this.OR([{ALT:t(()=>this.SUBRULE(this.actorDeclarationOnly),"ALT")},{ALT:t(()=>{this.SUBRULE(this.entityName),this.SUBRULE(this.lineEnd)},"ALT")}])}),this.RULE("metadataAssignmentStatement",()=>{this.SUBRULE(this.metadataAssignmentTarget),this.SUBRULE(this.metadata),this.SUBRULE(this.lineEnd)}),this.RULE("metadataAssignmentTarget",()=>{this.OR([{ALT:t(()=>this.CONSUME(Y),"ALT")},{ALT:t(()=>this.CONSUME(ke),"ALT")},{ALT:t(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("noteStatement",()=>{this.CONSUME(dr),this.CONSUME(pr),this.CONSUME(Y),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE("stereotype",()=>{this.CONSUME(Or),this.CONSUME(Rn),this.CONSUME(Sn)}),this.RULE("classSuffix",()=>{this.CONSUME(Nr),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(be),this.CONSUME2(Y)})}),this.RULE("jsonStatement",()=>{this.CONSUME(tr),this.CONSUME(An),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE("directionStatement",()=>{this.CONSUME(ar),this.OR([{ALT:t(()=>this.CONSUME(or),"ALT")},{ALT:t(()=>this.CONSUME(lr),"ALT")},{ALT:t(()=>this.CONSUME(cr),"ALT")},{ALT:t(()=>this.CONSUME(hr),"ALT")},{ALT:t(()=>this.CONSUME(ur),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("classDefStatement",()=>{this.CONSUME(fr),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(be),this.CONSUME2(Y)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("classStatement",()=>{this.CONSUME(mr),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(be),this.CONSUME2(Y)}),this.CONSUME3(Y),this.MANY2(()=>{this.CONSUME2(be),this.CONSUME4(Y)}),this.SUBRULE(this.lineEnd)}),this.RULE("styleStatement",()=>{this.CONSUME(Er),this.CONSUME(Y),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("styles",()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(be),this.SUBRULE2(this.styleValue)})}),this.RULE("styleValue",()=>{this.OR([{ALT:t(()=>this.CONSUME(dt),"ALT")},{ALT:t(()=>this.CONSUME(mn),"ALT")},{ALT:t(()=>{this.CONSUME(Ie),this.CONSUME2(dt)},"ALT")}]),this.CONSUME($t),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE("styleComponent",()=>{this.OR([{ALT:t(()=>this.CONSUME(dt),"ALT")},{ALT:t(()=>this.CONSUME(ke),"ALT")},{ALT:t(()=>this.CONSUME(gn),"ALT")},{ALT:t(()=>this.CONSUME(_r),"ALT")},{ALT:t(()=>this.CONSUME(mn),"ALT")},{ALT:t(()=>this.CONSUME(xr),"ALT")},{ALT:t(()=>this.CONSUME(vr),"ALT")},{ALT:t(()=>this.CONSUME(Mr),"ALT")},{ALT:t(()=>this.CONSUME(wr),"ALT")},{ALT:t(()=>this.CONSUME(Ur),"ALT")},{ALT:t(()=>this.CONSUME($t),"ALT")},{ALT:t(()=>this.CONSUME(Ft),"ALT")},{ALT:t(()=>this.CONSUME(Bt),"ALT")},{ALT:t(()=>this.CONSUME(Os),"ALT")},{ALT:t(()=>this.CONSUME(Ls),"ALT")},{ALT:t(()=>this.CONSUME(br),"ALT")},{ALT:t(()=>this.CONSUME(fn),"ALT")},{ALT:t(()=>this.CONSUME(ys),"ALT")},{ALT:t(()=>this.CONSUME(Ie),"ALT")}])}),this.performSelfAnalysis()}isMetadataAssignment(){let e=this.LA(1).tokenType;return(e===Y||e===ke||e===Be)&&this.LA(2).tokenType===pn}isStatementStart(){let e=this.LA(1).tokenType;return e!==Re&&e!==Fe&&e!==un}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===Y&&vo[this.LA(1).image.toLowerCase()]===!0}hasLabeledRight(e){if(!Gi(this.LA(1)))return!1;for(let s=2;;s++){let n=this.LA(s);if(e.includes(n.tokenType))return!0;if(!Gi(n))return!1}}},Gt=new Mo,Wi=class extends Error{constructor(e,s,n){super(`${e} (line ${s}, column ${n})`);this.line=s,this.column=n,this.name="UsecaseJsonError"}static{t(this,"UsecaseJsonError")}},En=t((e,s,n,i)=>{let r=n,o=i,h=Math.min(Math.max(s,0),e.length);for(let u=0;u<h;u++){let c=e[u];if(c==="\r")r++,o=1;else if(c===`
|
|
114
114
|
`){if(u===0||e[u-1]!=="\r")r++,o=1}else o++}return{line:r,column:o}},"locationAtOffset"),wo=t((e,s,n,i)=>{let r=/\bposition (\d+)\b/u.exec(e);if(r)return En(s,Number.parseInt(r[1],10),n,i);let o=/\bline (\d+) column (\d+)\b/u.exec(e);if(o){let h=Number.parseInt(o[1],10),u=Number.parseInt(o[2],10);return{line:n+h-1,column:h===1?i+u-1:u}}if(/unexpected end|end of json input/iu.test(e))return En(s,s.length,n,i);return},"locationFromErrorMessage"),oe=class extends Error{constructor(e){super("Invalid JSON token");this.offset=e}static{t(this,"JsonWalkError")}},ji=class{constructor(e){this.text=e,this.offset=0,this.propertyOrder={}}static{t(this,"PropertyOrderCollector")}collect(){if(this.skipWhitespace(),this.collectValue(""),this.skipWhitespace(),this.offset!==this.text.length)throw new oe(this.offset);return this.propertyOrder}collectValue(e){this.skipWhitespace();let s=this.text[this.offset];if(s==="{")this.collectObject(e);else if(s==="[")this.collectArray(e);else if(s==='"')this.readString(!1);else if(s==="t")this.consumeLiteral("true");else if(s==="f")this.consumeLiteral("false");else if(s==="n")this.consumeLiteral("null");else if(s==="-"||s>="0"&&s<="9")this.consumeNumber();else throw new oe(this.offset)}collectObject(e){this.offset++;let s=[],n=new Set;if(this.propertyOrder[e]=s,this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}while(this.offset<this.text.length){if(this.text[this.offset]!=='"')throw new oe(this.offset);let i=this.readString(!0),r=`${e}/${i.replaceAll("~","~0").replaceAll("/","~1")}`;if(n.has(i))this.deletePointerSubtree(r);else n.add(i),s.push(i);if(this.skipWhitespace(),this.text[this.offset]!==":")throw new oe(this.offset);if(this.offset++,this.collectValue(r),this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}if(this.text[this.offset]!==",")throw new oe(this.offset);this.offset++,this.skipWhitespace()}throw new oe(this.offset)}collectArray(e){if(this.offset++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}let s=0;while(this.offset<this.text.length){if(this.collectValue(`${e}/${s}`),s++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}if(this.text[this.offset]!==",")throw new oe(this.offset);this.offset++,this.skipWhitespace()}throw new oe(this.offset)}readString(e){this.offset++;let s="";while(this.offset<this.text.length){let n=this.offset,i=this.text[this.offset++];if(i==='"')return s;if(i.charCodeAt(0)<32)throw new oe(n);if(i!=="\\"){if(e)s+=i;continue}let r=this.offset,o=this.text[this.offset++];switch(o){case'"':case"\\":case"/":if(e)s+=o;break;case"b":if(e)s+="\b";break;case"f":if(e)s+="\f";break;case"n":if(e)s+=`
|
|
115
115
|
`;break;case"r":if(e)s+="\r";break;case"t":if(e)s+="\t";break;case"u":{let h=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(h))throw new oe(this.offset);if(e)s+=String.fromCharCode(Number.parseInt(h,16));this.offset+=4;break}default:throw new oe(r)}}throw new oe(this.offset)}consumeLiteral(e){let s=0;for(let n of e){if(this.text[this.offset+s]!==n)throw new oe(this.offset+s);s++}this.offset+=e.length}consumeNumber(){if(this.text[this.offset]==="-")this.offset++;if(this.text[this.offset]==="0")this.offset++;else if(this.text[this.offset]>="1"&&this.text[this.offset]<="9")while(this.text[this.offset]>="0"&&this.text[this.offset]<="9")this.offset++;else throw new oe(this.offset);if(this.text[this.offset]==="."){if(this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new oe(this.offset);while(this.text[this.offset]>="0"&&this.text[this.offset]<="9")this.offset++}if(this.text[this.offset]==="e"||this.text[this.offset]==="E"){if(this.offset++,this.text[this.offset]==="+"||this.text[this.offset]==="-")this.offset++;if(this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new oe(this.offset);while(this.text[this.offset]>="0"&&this.text[this.offset]<="9")this.offset++}}skipWhitespace(){while(this.offset<this.text.length){let e=this.text[this.offset];if(e!==" "&&e!=="\t"&&e!==`
|
|
116
116
|
`&&e!=="\r")return;this.offset++}}deletePointerSubtree(e){let s=`${e}/`;for(let n of Object.keys(this.propertyOrder))if(n===e||n.startsWith(s))delete this.propertyOrder[n]}};function Dr(e,s,n){let i;try{i=JSON.parse(e)}catch(r){let o=r instanceof Error?r.message:String(r),h=wo(o,e,s,n);if(!h){let u=0;try{new ji(e).collect()}catch(c){if(c instanceof oe)u=c.offset}h=En(e,u,s,n)}throw new Wi(`Invalid JSON: ${o}`,h.line,h.column)}if(typeof i!=="object"||i===null||Array.isArray(i))throw new Wi("JSON value must have an object root",s,n);return{value:i,propertyOrder:new ji(e).collect()}}t(Dr,"parseOrderedJsonObject");var Uo=t((e)=>({shape:e.type==="normal"?"actor":e.type==="hollow"?"actor-hollow":e.type==="awesome"?"actor-awesome":"actor-icon",...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"actor",actorType:e.type,business:e.business,labelType:e.labelType,...e.icon?{icon:e.icon}:{},...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),"actorNode"),Po=t((e)=>({shape:e.shape,...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"usecase",useCaseShape:e.shape,business:e.business,labelType:e.labelType,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),"useCaseNode"),Do=t((e)=>({label:e.label,shape:"note",attrs:{kind:"note",target:e.target,labelType:e.labelType}}),"noteNode"),Fo=t((e)=>({label:e.id,shape:"json-table",...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"json",value:e.value,propertyOrder:e.propertyOrder,labelType:"text"}}),"jsonNode"),Bo=t((e)=>({id:e.id,source:e.source,target:e.target,...e.label?{label:e.label}:{},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{relationshipType:e.type,arrowType:e.arrowType,minlen:e.minlen,explicitId:e.explicitId,animate:e.animate,...e.animation?{animation:e.animation}:{},...e.labelType?{labelType:e.labelType}:{}}}),"relationshipEdge"),$o=t((e)=>({id:`${e.id}-edge`,source:e.id,target:e.target,attrs:{relationshipType:"note",arrowType:X.LINE_SOLID,pattern:"dotted",minlen:1,explicitId:!1,animate:!1,internal:!0}}),"noteEdge"),Go=t((e,s,n,i)=>{let r={};for(let c of e.getActors().values())r[c.id]=Uo(c);for(let c of e.getUseCases().values())r[c.id]=Po(c);for(let c of e.getNotes().values())r[c.id]=Do(c);for(let c of e.getJsonNodes().values())r[c.id]=Fo(c);let o={};for(let c of e.getSystemBoundaries().values())o[c.id]={...c.label===c.id?{}:{title:c.label},nodes:[...c.members],...c.classes.length?{classes:[...c.classes]}:{},...c.styles.length?{styles:[...c.styles]}:{},attrs:{kind:"systemBoundary",boundaryType:c.type,labelType:c.labelType}};let h={};for(let c of e.getClassDefs().values())h[c.id]={styles:[...c.styles]};let u=e.getDirection();return{version:1,diagramType:"usecase",source:s,header:{keyword:"usecase",direction:u==="TD"?"TB":u,span:n},...e.getAccTitle()?{accTitle:e.getAccTitle()}:{},...e.getAccDescription()?{accDescr:e.getAccDescription()}:{},nodes:r,edges:[...e.getRelationships().map(Bo),...[...e.getNotes().values()].map($o)],groups:o,classDefs:h,statements:i}},"buildUsecaseGraphAST"),de=t((e)=>`line ${e.line}, column ${e.column} [${e.span[0]},${e.span[1]})`,"locationText"),Ki=t((e)=>e===void 0?"":` (label "${e}")`,"labelSuffix"),Ze=t((e)=>e.generated?e.label:void 0,"generatedFrom"),hn=t((e,s)=>{for(let n of s)if(!e.includes(n))e.push(n)},"pushUnique"),Wo=class{constructor(e){this.db=e,this.source="",this.statements=[],this.elements=[],this.boundaries=[],this.jsonDrafts=[],this.relationshipDrafts=[],this.noteDrafts=[],this.metadataAssignments=[],this.classAssignments=[],this.styleAssignments=[],this.classDefinitions=[],this.directions=[],this.model=e.createModel()}static{t(this,"UsecaseModelBuilder")}reset(e){this.model=this.db.createModel(),this.source=e,this.statements=[],this.elements.length=0,this.boundaries.length=0,this.jsonDrafts.length=0,this.relationshipDrafts.length=0,this.noteDrafts.length=0,this.metadataAssignments.length=0,this.classAssignments.length=0,this.styleAssignments.length=0,this.classDefinitions.length=0,this.directions.length=0}addElement(e){this.elements.push(e)}addBoundary(e){this.boundaries.push(e)}addJson(e){this.jsonDrafts.push(e)}addRelationship(e){this.relationshipDrafts.push(e)}addNote(e){this.noteDrafts.push(e)}addMetadataAssignment(e,s,n,i){this.metadataAssignments.push({target:e,targetLocation:s,metadata:n,statement:i})}addClassDef(e,s){this.classDefinitions.push({ids:e,styles:s})}addClassAssignment(e,s){this.classAssignments.push({targets:e,classes:s})}addStyleAssignment(e,s,n){this.styleAssignments.push({target:e,location:s,styles:n})}setDirection(e){this.directions.push(e==="TD"?"TB":e)}setAccTitle(e){this.model.accTitle=e}setAccDescription(e){this.model.accDescription=e}setStatements(e){this.statements=e}getActors(){return this.model.actors}getUseCases(){return this.model.useCases}getSystemBoundaries(){return this.model.systemBoundaries}getRelationships(){return this.model.relationships}getNotes(){return this.model.notes}getJsonNodes(){return this.model.jsonNodes}getClassDefs(){return this.model.classDefs}getDirection(){return this.model.direction}getAccTitle(){return this.model.accTitle}getAccDescription(){return this.model.accDescription}finalize(e){let s=new Map,n=new Map,i=new Map,r=new Map;for(let c of this.relationshipDrafts)this.recordFirst(r,c.source.id,c.source.location.span[0]),this.recordFirst(r,c.target.id,c.target.location.span[0]);for(let c of this.elements)this.recordFirst(r,c.id,c.location.span[0]);for(let c of this.boundaries)this.recordFirst(r,c.id,c.location.span[0]);for(let c of this.jsonDrafts)this.recordFirst(r,c.id,c.location.span[0]);let o=[...this.elements.map((c)=>({offset:c.location.span[0],type:"element",value:c})),...this.boundaries.map((c)=>({offset:c.location.span[0],type:"boundary",value:c})),...this.jsonDrafts.map((c)=>({offset:c.location.span[0],type:"json",value:c})),...this.relationshipDrafts.filter((c)=>c.explicitId).map((c)=>({offset:c.explicitIdLocation.span[0],type:"edge",value:c}))].sort((c,d)=>c.offset-d.offset);for(let c of o)if(c.type==="element")this.collectElement(c.value,s,n);else if(c.type==="boundary")this.collectBoundary(c.value,s,i);else if(c.type==="json")this.registerUnique(s,c.value.id,"json",c.value.location,!1);else this.registerUnique(s,c.value.explicitId,"edge",c.value.explicitIdLocation,!1);this.materializeElements(n,r),this.materializeBoundaries(i,r),this.materializeJson(r);let h=this.materializeRelationships(s,n,r);this.reorderElements(n,r),this.applyMetadataAssignments(s,n,i,h),this.validateAndRefreshElements(n),this.refreshBoundaries(i,n),this.materializeNotes(s),this.applyClassDefinitions(),this.applyClassesAndStyles(s,h),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...s].map(([c,d])=>[c,d.kind]));let u=Go(this,this.source,e,this.statements);return this.model.ast=u,this.db.commit(this.model),u}collectElement(e,s,n){let i=s.get(e.id),r=Ze({generated:e.generated,label:e.label.text});if(i&&i.kind!==e.kind)this.conflict(`ID '${e.id}' is declared as both ${i.kind} and ${e.kind}`,e.location,i.location,r,Ze(i));if(i&&(i.generated||e.generated))this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,i.location,r,Ze(i));let o=n.get(e.id);if(!o){let h={kind:e.kind,id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],...e.parentId?{parentId:e.parentId,parentLocation:e.parentLocation}:{},...e.shape?{shape:e.shape}:{},...e.stereotype?{stereotype:e.stereotype,stereotypeLocation:e.location}:{}};this.applyDeclarationMetadata(h,e.metadata),n.set(e.id,h),s.set(e.id,{kind:e.kind,location:e.location,generated:e.generated,label:e.label.text});return}if(o.label.text!==e.label.text||o.label.type!==e.label.type)this.conflict(`ID '${e.id}' has conflicting labels`,e.location,o.location);if(e.shape&&o.shape&&e.shape!==o.shape)this.conflict(`Use case '${e.id}' has conflicting shapes`,e.location,o.location);if(e.parentId&&o.parentId&&e.parentId!==o.parentId)this.conflict(`Element '${e.id}' belongs to more than one system boundary`,e.parentLocation??e.location,o.parentLocation??o.location);if(e.stereotype&&o.stereotype&&e.stereotype!==o.stereotype)this.conflict(`Element '${e.id}' has conflicting stereotypes`,e.location,o.stereotypeLocation??o.location);o.shape??=e.shape,o.parentId??=e.parentId,o.parentLocation??=e.parentLocation,o.stereotype??=e.stereotype,o.stereotypeLocation??=e.stereotype?e.location:void 0,hn(o.classes,e.classes),this.applyDeclarationMetadata(o,e.metadata)}collectBoundary(e,s,n){let i=s.get(e.id),r=Ze({generated:e.generated,label:e.label.text});if(i&&i.kind!=="boundary")this.conflict(`ID '${e.id}' is declared as both ${i.kind} and boundary`,e.location,i.location,r,Ze(i));if(i&&(i.generated||e.generated))this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,i.location,r,Ze(i));let o=n.get(e.id);if(o){if(o.label.text!==e.label.text||o.label.type!==e.label.type)this.conflict(`Boundary '${e.id}' has conflicting titles`,e.location,o.location);hn(o.classes,e.classes);return}n.set(e.id,{id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],styles:[],members:[]}),s.set(e.id,{kind:"boundary",location:e.location,generated:e.generated,label:e.label.text})}materializeElements(e,s){for(let n of[...e.values()].sort((i,r)=>(s.get(i.id)??0)-(s.get(r.id)??0)))this.setElementModel(n)}materializeBoundaries(e,s){for(let n of[...e.values()].sort((i,r)=>(s.get(i.id)??0)-(s.get(r.id)??0)))this.model.systemBoundaries.set(n.id,{id:n.id,label:n.label.text,labelType:n.label.type,type:n.type??"rect",members:[],classes:[...n.classes],styles:[...n.styles]})}materializeJson(e){for(let s of[...this.jsonDrafts].sort((n,i)=>(e.get(n.id)??0)-(e.get(i.id)??0)))this.model.jsonNodes.set(s.id,{id:s.id,value:s.value,propertyOrder:s.propertyOrder,classes:[...s.classes],styles:[]})}materializeRelationships(e,s,n){let i=new Map,r=0;for(let o of this.relationshipDrafts){let h=this.resolveEndpoint(o.source,e,s,n),u=this.resolveEndpoint(o.target,e,s,n);this.validateRelationship(o,h,u,e);let c=o.explicitId??`edge-${r++}`,d={id:c,explicitId:Boolean(o.explicitId),source:o.source.id,target:o.target.id,type:o.type,arrowType:o.arrowType,...o.label?{label:o.label.text,labelType:o.label.type}:{},minlen:o.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(d),i.set(c,{draft:o,relationship:d})}return this.model.relationshipCounter=r,i}resolveEndpoint(e,s,n,i){if(e.classesOnReference&&!e.declaration)throw Error(`Relationship endpoint '${e.id}' uses ::: without declaring the node at ${de(e.location)}`);let r=s.get(e.id);if(r)return r.kind;return n.set(e.id,{kind:"usecase",id:e.id,label:e.label,location:e.location,generated:e.generated,shape:"ellipse",classes:[]}),s.set(e.id,{kind:"usecase",location:e.location,generated:e.generated,label:e.label.text}),this.recordFirst(i,e.id,e.location.span[0]),"usecase"}reorderElements(e,s){let n=new Map(this.model.actors),i=new Map(this.model.useCases);this.model.actors.clear(),this.model.useCases.clear();for(let r of[...e.values()].sort((o,h)=>(s.get(o.id)??0)-(s.get(h.id)??0))){if(!n.has(r.id)&&!i.has(r.id))this.setElementModel(r);let o=n.get(r.id)??this.model.actors.get(r.id),h=i.get(r.id)??this.model.useCases.get(r.id);if(o)this.model.actors.set(r.id,o);else if(h)this.model.useCases.set(r.id,h)}}applyMetadataAssignments(e,s,n,i){for(let r of this.metadataAssignments){let o=e.get(r.target);if(!o){let h=this.inferMetadataKind(r.metadata);throw Error(`Metadata target '${r.target}' is unresolved${h?` (metadata implies ${h})`:""} at ${de(r.targetLocation)}`)}if(o.kind==="actor"||o.kind==="usecase")this.applyStandaloneElementMetadata(s.get(r.target),r.metadata);else if(o.kind==="boundary"){let h=n.get(r.target);for(let u of r.metadata.properties){if(u.key!=="type"||u.value!=="rect"&&u.value!=="package")this.invalidMetadata(r.target,o.kind,u);h.type=u.value}}else if(o.kind==="edge"){let h=i.get(r.target);if(!h)throw Error(`Metadata target '${r.target}' is not an explicit edge at ${de(r.targetLocation)}`);r.statement.kind="edgeMetadata",r.statement.edges=[{id:r.target,span:r.statement.span,idSpan:r.targetLocation.span,...r.statement.metadata?{metadata:r.statement.metadata}:{}}],delete r.statement.nodes;for(let u of r.metadata.properties)if(u.key==="animate"&&typeof u.value==="boolean")h.relationship.animate=u.value;else if(u.key==="animation"&&(u.value==="fast"||u.value==="slow"))h.relationship.animation=u.value,h.relationship.animate=!0;else this.invalidMetadata(r.target,o.kind,u)}else for(let h of r.metadata.properties)this.invalidMetadata(r.target,o.kind,h)}for(let{relationship:r}of i.values())if(r.animation)r.animate=!0}applyStandaloneElementMetadata(e,s){for(let n of s.properties)if(e.kind==="actor")this.applyActorProperty(e,n,!0);else if(n.key==="business"&&typeof n.value==="boolean")e.business=n.value;else this.invalidMetadata(e.id,e.kind,n)}applyDeclarationMetadata(e,s){if(!s)return;for(let n of s.properties)if(e.kind==="actor")this.applyActorProperty(e,n,!1);else if(n.key==="business"&&typeof n.value==="boolean"){if(e.business!==void 0&&e.business!==n.value)this.conflict(`Use case '${e.id}' has conflicting business metadata`,n.location,e.location);e.business=n.value}else this.invalidMetadata(e.id,e.kind,n)}applyActorProperty(e,s,n){if(s.key==="type"&&(s.value==="normal"||s.value==="hollow"||s.value==="awesome")){if(!n&&e.actorType!==void 0&&e.actorType!==s.value)this.conflict(`Actor '${e.id}' has conflicting type metadata`,s.location,e.location);e.actorType=s.value}else if(s.key==="icon"&&typeof s.value==="string"){if(!n&&e.icon!==void 0&&e.icon!==s.value)this.conflict(`Actor '${e.id}' has conflicting icon metadata`,s.location,e.location);e.icon=s.value}else if(s.key==="business"&&typeof s.value==="boolean"){if(!n&&e.business!==void 0&&e.business!==s.value)this.conflict(`Actor '${e.id}' has conflicting business metadata`,s.location,e.location);e.business=s.value}else this.invalidMetadata(e.id,e.kind,s)}validateAndRefreshElements(e){for(let s of e.values()){let n=s.icon?"icon":s.actorType??"normal";if(s.kind==="actor"){if(s.icon&&s.actorType&&s.actorType!=="normal")throw Error(`Actor '${s.id}' cannot combine icon with type '${s.actorType}' at ${de(s.location)}`);if(s.business&&(n==="icon"||n==="awesome"))throw Error(`Business actor '${s.id}' must use normal or hollow geometry at ${de(s.location)}`)}else if((s.shape??"ellipse")==="rect"&&s.business)throw Error(`Rectangular use case '${s.id}' cannot be a business use case at ${de(s.location)}`);this.setElementModel(s)}}refreshBoundaries(e,s){for(let n of e.values())n.members.length=0;for(let n of[...this.elements].sort((i,r)=>i.location.span[0]-r.location.span[0])){if(!n.parentId)continue;let i=e.get(n.parentId);if(!i)throw Error(`Parent boundary '${n.parentId}' for '${n.id}' is unresolved at ${de(n.parentLocation??n.location)}`);if(!i.members.includes(n.id))i.members.push(n.id)}for(let n of s.values())if(n.parentId&&!e.has(n.parentId))throw Error(`Parent boundary '${n.parentId}' for '${n.id}' is unresolved at ${de(n.parentLocation??n.location)}`);for(let n of e.values()){let i=this.model.systemBoundaries.get(n.id);i.type=n.type??"rect",i.members=[...n.members],i.classes=[...n.classes],i.styles=[...n.styles]}}materializeNotes(e){let s=0;for(let n of this.noteDrafts){let i=e.get(n.target);if(!i)throw Error(`Note target '${n.target}' is unresolved at ${de(n.targetLocation)}`);if(i.kind!=="actor"&&i.kind!=="usecase")this.conflict(`Note target '${n.target}' must be an actor or use case, not ${i.kind}`,n.targetLocation,i.location);let r=`note-${s++}`;this.model.notes.set(r,{id:r,target:n.target,label:n.label.text,labelType:n.label.type})}this.model.noteCounter=s}applyClassDefinitions(){for(let e of this.classDefinitions)for(let s of e.ids)this.model.classDefs.set(s,{id:s,styles:[...e.styles]})}applyClassesAndStyles(e,s){for(let n of this.classAssignments)for(let i of n.targets)hn(this.getStylable(i.id,e,s,i.location).classes,n.classes);for(let n of this.styleAssignments)this.getStylable(n.target,e,s,n.location).styles.push(...n.styles)}getStylable(e,s,n,i){let r=s.get(e)?.kind,o=r==="actor"?this.model.actors.get(e):r==="usecase"?this.model.useCases.get(e):r==="boundary"?this.model.systemBoundaries.get(e):r==="json"?this.model.jsonNodes.get(e):r==="edge"?n.get(e)?.relationship:void 0;if(!o)throw Error(`Class/style target '${e}' is unresolved or anonymous at ${de(i)}`);return o}validateRelationship(e,s,n,i){let r=t((o)=>o==="actor"||o==="usecase"||o==="json","allowed");if(!r(s))this.conflict(`Relationship source '${e.source.id}' cannot be ${s}`,e.source.location,i.get(e.source.id).location);if(!r(n))this.conflict(`Relationship target '${e.target.id}' cannot be ${n}`,e.target.location,i.get(e.target.id).location);if((e.type==="include"||e.type==="extend")&&(s!=="usecase"||n!=="usecase"))throw Error(`${e.type} relationship requires use-case endpoints at ${de(e.location)}`);if(e.type==="generalization"&&(s!=="actor"&&s!=="usecase"||s!==n))throw Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${de(e.location)}`);if(e.type==="association"&&(s==="json"||n==="json")&&![0,1,2].includes(e.arrowType))throw Error(`JSON relationship '${e.source.id}' to '${e.target.id}' permits only point, reversed-point, or markerless solid association at ${de(e.location)}`)}setElementModel(e){if(e.kind==="actor"){let s=e.icon?"icon":e.actorType??"normal";this.model.useCases.delete(e.id),this.model.actors.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,type:s,...e.icon?{icon:e.icon}:{},business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.actors.get(e.id)?.styles??[]})}else this.model.actors.delete(e.id),this.model.useCases.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,shape:e.shape??"ellipse",business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.useCases.get(e.id)?.styles??[]})}inferMetadataKind(e){let s=new Set(["actor","usecase","boundary","edge"]);for(let n of e.properties)if(n.key==="icon")s.clear(),s.add("actor");else if(n.key==="animate"||n.key==="animation")s.clear(),s.add("edge");else if(n.key==="type"){if(s.clear(),n.value==="rect"||n.value==="package")s.add("boundary");else if(n.value==="normal"||n.value==="hollow"||n.value==="awesome")s.add("actor")}else if(n.key==="business")s.delete("boundary"),s.delete("edge");else return;return s.size===1?[...s][0]:void 0}invalidMetadata(e,s,n){throw Error(`Metadata property '${n.key}' is invalid for ${s} '${e}' at ${de(n.location)}`)}registerUnique(e,s,n,i,r){let o=e.get(s);if(o)this.conflict(`ID '${s}' is declared more than once (${o.kind} and ${n})`,i,o.location,void 0,Ze(o));e.set(s,{kind:n,location:i,generated:r})}recordFirst(e,s,n){let i=e.get(s);if(i===void 0||n<i)e.set(s,n)}conflict(e,s,n,i,r){throw Error(`${e} at ${de(s)}${Ki(i)}; previous declaration at ${de(n)}${Ki(r)}`)}},jo=Gt.getBaseCstVisitorConstructor(),Ko=class extends jo{constructor(){super();this.builder=new Wo(Ns),this.source="",this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}static{t(this,"UsecaseVisitor")}build(e,s){this.source=s,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(s),this.visit(e)}start(e){let s=this.tokens(e,"USECASE")[0],n=[];for(let i of this.nodes(e,"line"))n.push(this.visit(i));this.builder.setStatements(n),this.builder.finalize(this.tokenSpan(s))}line(e){let s=this.firstNode(e,"blankLine","commentLine","statement");return this.wrap(s,this.visit(s))}statement(e){return this.visit(this.firstNode(e,"accTitleStatement","accDescrStatement","directionStatement","actorStatement","systemBoundaryStatement","noteStatement","jsonStatement","classDefStatement","classStatement","styleStatement","metadataAssignmentStatement","entityStatement"))}lineEnd(e){return}blankLine(e){return{kind:"blank",span:this.tokenSpan(this.tokens(e,"NEWLINE")[0])}}commentLine(e){return{kind:"comment",span:this.tokenSpan(this.tokens(e,"COMMENT")[0])}}accTitleStatement(e){let s=this.tokens(e,"ACC_TITLE_LINE")[0].image;return this.builder.setAccTitle(s.slice(s.indexOf(":")+1).trim()),{kind:"accTitle",span:[0,0]}}accDescrStatement(e){let s=this.tokens(e,"ACC_DESCR_LINE")[0],n=this.tokens(e,"ACC_DESCR_BLOCK")[0],i=s?s.image.slice(s.image.indexOf(":")+1).trim():n.image.slice(n.image.indexOf("{")+1,n.image.lastIndexOf("}")).trim();return this.builder.setAccDescription(i),{kind:"accDescr",span:[0,0]}}actorStatement(e){let s=this.nodes(e,"actorItem"),n=s.map((c)=>this.visit(c)),i=this.nodes(e,"relationTail")[0],r=n.map((c,d)=>this.actorOccurrence(s[d],c,!0));for(let c of n)this.builder.addElement(this.actorDraft(c));if(!i)return{kind:"node",span:[0,0],nodes:r};let o=this.visit(i);if(o.target.explicitDeclaration)this.builder.addElement(this.entityDraft(o.target));let h=this.relationshipDraft(n[0],o,this.nodeLocation(i));this.builder.addRelationship(h);let u=h.explicitId??`edge-${this.anonymousEdge++}`;return r.push(this.entityOccurrence(this.nodes(i.children,"entityName")[0],o.target,o.target.explicitDeclaration)),{kind:"edge",span:[0,0],nodes:r,edges:[{id:u,span:[0,0],...h.explicitIdLocation?{idSpan:h.explicitIdLocation.span}:{},...h.label?{labelSpan:h.label.span}:{}}]}}actorItem(e){let s=this.visit(this.nodes(e,"actorName")[0]),n=this.nodes(e,"metadata")[0],i=this.nodes(e,"stereotype")[0],r=this.nodes(e,"classSuffix")[0],o=r?this.visit(r):{classes:[],spans:[]};return{...s,...n?{metadata:this.visit(n)}:{},...i?{stereotype:this.visit(i)}:{},classes:o.classes,classSpans:o.spans}}actorName(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0];if(s){let r=this.nodes(e,"nodeLabel")[0],o=r?this.visit(r):this.tokenLabel(s);return{id:s.image,label:o,location:this.tokenLocation(s),generated:!1,classes:[],classSpans:[]}}let i=this.tokenLabel(n);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(n),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(e){let s=this.nodes(e,"actorItem"),n=s.map((i)=>this.visit(i));for(let i of n)this.builder.addElement(this.actorDraft(i));return{kind:"node",span:[0,0],nodes:n.map((i,r)=>this.actorOccurrence(s[r],i,!0))}}entityStatement(e){let s=this.nodes(e,"entityName"),n=this.visit(s[0]),i=this.nodes(e,"relationTail")[0];if(!i)return n.explicitDeclaration=!0,n.shape??="ellipse",this.builder.addElement(this.entityDraft(n)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(s[0],n,!0)]};if(n.explicitDeclaration)this.builder.addElement(this.entityDraft(n));let r=this.visit(i);if(r.target.explicitDeclaration)this.builder.addElement(this.entityDraft(r.target));let o={source:this.endpoint(n),target:this.endpoint(r.target),location:this.nodeLocation(i),...r.explicitId?{explicitId:r.explicitId,explicitIdLocation:r.explicitIdLocation}:{},...r.arrow};this.builder.addRelationship(o);let h=o.explicitId??`edge-${this.anonymousEdge++}`;return{kind:"edge",span:[0,0],nodes:[this.entityOccurrence(s[0],n,n.explicitDeclaration),this.entityOccurrence(this.nodes(i.children,"entityName")[0],r.target,r.target.explicitDeclaration)],edges:[{id:h,span:[0,0],...o.explicitIdLocation?{idSpan:o.explicitIdLocation.span}:{},...o.label?{labelSpan:o.label.span}:{}}]}}entityName(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],i=this.nodes(e,"nodeLabel")[0],r=this.nodes(e,"useCaseMetadata")[0],o=this.nodes(e,"stereotype")[0],h=this.nodes(e,"classSuffix")[0],u=h?this.visit(h):{classes:[],spans:[]};if(s){let d=i?this.visit(i):this.tokenLabel(s),f=i?this.tokens(e,"LBRACKET").length?"rect":"ellipse":void 0;return{id:s.image,label:d,location:this.tokenLocation(s),generated:!1,...f?{shape:f}:{},...r?{metadata:this.visit(r)}:{},...o?{stereotype:this.visit(o)}:{},classes:u.classes,classSpans:u.spans,explicitDeclaration:Boolean(f||r||o)}}let c=this.tokenLabel(n);return{id:this.generateId(c.text),label:c,location:this.tokenLocation(n),generated:!0,...r?{metadata:this.visit(r)}:{},...o?{stereotype:this.visit(o)}:{},classes:u.classes,classSpans:u.spans,explicitDeclaration:Boolean(r||o)}}nodeLabel(e){let s=this.allTokens(e);if(s.length===1&&(s[0].tokenType.name==="PLAIN_STRING"||s[0].tokenType.name==="MARKDOWN_STRING"))return this.tokenLabel(s[0]);let n=[s[0].startOffset,(s.at(-1).endOffset??s.at(-1).startOffset)+1];return{text:this.source.slice(n[0],n[1]),type:"text",span:n}}useCaseMetadata(e){return this.visit(this.nodes(e,"metadata")[0])}relationTail(e){let s=this.tokens(e,"IDENTIFIER")[0];return{...s?{explicitId:s.image,explicitIdLocation:this.tokenLocation(s)}:{},arrow:this.visit(this.nodes(e,"arrow")[0]),target:this.visit(this.nodes(e,"entityName")[0])}}arrow(e){return this.visit(this.firstNode(e,"semanticRelation","forwardSolidOperator","backwardSolidOperator","markerlessSolidOperator","forwardCircleOperator","backwardCircleOperator","forwardCrossOperator","backwardCrossOperator"))}edgeLabel(e){return this.nodeLabel(e)}semanticRelation(e){if(this.tokens(e,"GENERALIZATION").length)return{type:"generalization",arrowType:X.SOLID_ARROW,minlen:1};let s=this.tokens(e,"INCLUDE").length?"include":"extend",n=this.tokens(e,s==="include"?"INCLUDE":"EXTEND")[0];return{type:s,arrowType:X.SOLID_ARROW,label:{text:s,type:"text",span:this.tokenSpan(n)},minlen:1}}metadata(e){return{properties:this.nodes(e,"metadataProperty").map((s)=>this.visit(s)),location:this.ctxLocation(e)}}metadataProperty(e){let s=this.allTokens(e).filter((h)=>h.tokenType.name!=="COLON"),n=s[0],i=s[1],r=i.tokenType.name==="TRUE"?!0:i.tokenType.name==="FALSE"?!1:this.decodePlain(i),o=[n.startOffset,(i.endOffset??i.startOffset)+1];return{key:this.decodePlain(n),value:r,span:o,keySpan:this.contentSpan(n),valueSpan:this.contentSpan(i),location:this.tokenLocation(n)}}metadataSeparator(e){return}systemBoundaryStatement(e){let s=this.visit(this.nodes(e,"systemBoundaryName")[0]),n=this.nodes(e,"classSuffix")[0],i=n?this.visit(n):{classes:[],spans:[]};s.classes=i.classes,this.builder.addBoundary(s);let r=this.parentBoundary;this.parentBoundary={id:s.id,location:s.location};let o=this.nodes(e,"systemBoundaryContent")[0],h=o?this.visit(o):[];this.parentBoundary=r;let u=this.tokens(e,"END")[0],c=this.nodes(e,"metadata")[0],d=c?this.visit(c):void 0,f={kind:"group",span:[0,0],group:s.id,idSpan:s.location.span,titleSpan:s.label.span,endSpan:this.tokenSpan(u),classSpans:i.spans,...d?{metadata:d.properties.map(({key:m,span:y,keySpan:I,valueSpan:P})=>({key:m,span:y,keySpan:I,valueSpan:P}))}:{},...h.length?{children:h}:{}};if(d)this.builder.addMetadataAssignment(s.id,s.location,d,f);return f}systemBoundaryName(e){let s=this.tokens(e,"IDENTIFIER")[0];if(s){let r=this.nodes(e,"nodeLabel")[0];return{id:s.image,label:r?this.visit(r):this.tokenLabel(s),location:this.tokenLocation(s),generated:!1,classes:[]}}let n=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],i=this.tokenLabel(n);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(n),generated:!0,classes:[]}}systemBoundaryContent(e){return[...this.nodes(e,"blankLine"),...this.nodes(e,"commentLine"),...this.nodes(e,"boundaryElement")].sort((n,i)=>(n.location?.startOffset??0)-(i.location?.startOffset??0)).map((n)=>this.wrap(n,this.visit(n)))}boundaryElement(e){let s=this.nodes(e,"actorDeclarationOnly")[0];if(s)return this.visit(s);let n=this.nodes(e,"entityName")[0],i=this.visit(n);return i.explicitDeclaration=!0,i.shape??="ellipse",this.builder.addElement(this.entityDraft(i)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(n,i,!0)]}}metadataAssignmentStatement(e){let s=this.visit(this.nodes(e,"metadataAssignmentTarget")[0]),n=this.visit(this.nodes(e,"metadata")[0]),i={kind:"metadata",span:[0,0],nodes:[{id:s.id,span:s.location.span,idSpan:s.location.span}],metadata:n.properties.map(({key:r,span:o,keySpan:h,valueSpan:u})=>({key:r,span:o,keySpan:h,valueSpan:u}))};return this.builder.addMetadataAssignment(s.id,s.location,n,i),i}metadataAssignmentTarget(e){let s=this.allTokens(e)[0],n=this.tokenLabel(s);return{id:s.tokenType.name==="IDENTIFIER"?s.image:this.generateId(n.text),location:this.tokenLocation(s)}}noteStatement(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.visit(this.nodes(e,"nodeLabel")[0]);return this.builder.addNote({target:s.image,targetLocation:this.tokenLocation(s),label:n,location:this.ctxLocation(e)}),{kind:"note",span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:n.span,nodes:[{id:s.image,span:this.tokenSpan(s),idSpan:this.tokenSpan(s)}]}}stereotype(e){let s=this.tokens(e,"STEREOTYPE_TEXT")[0];return{value:s.image.trim(),span:this.tokenSpan(s)}}classSuffix(e){let s=this.tokens(e,"IDENTIFIER");return{classes:s.map((n)=>n.image),spans:s.map((n)=>this.tokenSpan(n))}}jsonStatement(e){let s=this.tokens(e,"JSON_DECLARATION_START")[0],n=this.tokens(e,"JSON_OBJECT_LITERAL")[0],i=/^json[\t ]+(\w+)/.exec(s.image),r=i[1],o=i[0].length-r.length,h={span:[s.startOffset+o,s.startOffset+o+r.length],line:s.startLine??1,column:(s.startColumn??1)+o},u=Dr(n.image,n.startLine??1,n.startColumn??1),c=this.nodes(e,"classSuffix")[0],d=c?this.visit(c):{classes:[],spans:[]},f={id:r,value:u.value,propertyOrder:u.propertyOrder,location:h,classes:d.classes};return this.builder.addJson(f),{kind:"json",span:[0,0],nodes:[{id:r,span:h.span,idSpan:h.span,defines:!0,classSpans:d.spans}],classSpans:d.spans}}directionStatement(e){let s=this.allTokens(e).find((n)=>["TD","TB","BT","RL","LR"].includes(n.tokenType.name));return this.builder.setDirection(s.image),{kind:"direction",span:[0,0]}}classDefStatement(e){let s=this.tokens(e,"IDENTIFIER"),n=this.visit(this.nodes(e,"styles")[0]);return this.builder.addClassDef(s.map((i)=>i.image),n),{kind:"classDef",span:[0,0],ref:s[0].image,refSpan:this.tokenSpan(s[0])}}classStatement(e){let s=this.tokens(e,"IDENTIFIER"),n=1;for(;n<s.length;n++)if(!this.source.slice((s[n-1].endOffset??s[n-1].startOffset)+1,s[n].startOffset).includes(","))break;let i=s.slice(0,n).map((o)=>({id:o.image,location:this.tokenLocation(o)})),r=s.slice(n).map((o)=>o.image);return this.builder.addClassAssignment(i,r),{kind:"classAssign",span:[0,0],ref:r[0],refSpan:this.tokenSpan(s[n]),nodes:i.map(({id:o,location:h})=>({id:o,span:h.span,idSpan:h.span}))}}styleStatement(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.visit(this.nodes(e,"styles")[0]);return this.builder.addStyleAssignment(s.image,this.tokenLocation(s),n),{kind:"style",span:[0,0],nodes:[{id:s.image,span:this.tokenSpan(s),idSpan:this.tokenSpan(s)}]}}styles(e){return this.nodes(e,"styleValue").map((s)=>this.visit(s))}styleValue(e){let s=this.allTokens(e),n=[s[0].startOffset,(s.at(-1).endOffset??s.at(-1).startOffset)+1];return this.source.slice(n[0],n[1]).replaceAll("\\,",",")}styleComponent(e){return this.allTokens(e).map((s)=>s.image).join("")}forwardSolidOperator(e){let s=this.tokens(e,"FORWARD_SOLID")[0];return{type:"association",arrowType:X.SOLID_ARROW,minlen:this.solidMinlen(s)}}backwardSolidOperator(e){let s=this.tokens(e,"BACKWARD_SOLID")[0],n=this.nodes(e,"edgeLabel")[0],i=n?this.tokens(e,"MARKERLESS_SOLID").at(-1):s;return{type:"association",arrowType:X.BACK_ARROW,minlen:this.solidMinlen(i),...n?{label:this.visit(n)}:{}}}markerlessSolidOperator(e){let s=this.nodes(e,"edgeLabel")[0],n=this.allTokens(e);if(!s)return{type:"association",arrowType:X.LINE_SOLID,minlen:this.solidMinlen(this.tokens(e,"MARKERLESS_SOLID")[0])};let i=n.at(-1),r=i.tokenType.name==="FORWARD_SOLID"?X.SOLID_ARROW:i.tokenType.name==="FORWARD_CIRCLE"?X.CIRCLE_ARROW:i.tokenType.name==="FORWARD_CROSS"?X.CROSS_ARROW:X.LINE_SOLID;return{type:"association",arrowType:r,label:this.visit(s),minlen:r===X.SOLID_ARROW||r===X.LINE_SOLID?this.solidMinlen(i):1}}forwardCircleOperator(e){return{type:"association",arrowType:X.CIRCLE_ARROW,minlen:1}}backwardCircleOperator(e){let s=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:X.CIRCLE_ARROW_REVERSED,minlen:1,...s?{label:this.visit(s)}:{}}}forwardCrossOperator(e){return{type:"association",arrowType:X.CROSS_ARROW,minlen:1}}backwardCrossOperator(e){let s=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:X.CROSS_ARROW_REVERSED,minlen:1,...s?{label:this.visit(s)}:{}}}actorDraft(e){return{id:e.id,kind:"actor",label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}entityDraft(e){return{id:e.id,kind:"usecase",label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.shape?{shape:e.shape}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}endpoint(e,s=e.explicitDeclaration??!0){return{id:e.id,label:e.label,location:e.location,generated:e.generated,declaration:s,classesOnReference:e.classes.length>0}}relationshipDraft(e,s,n){return{source:this.endpoint(e,!0),target:this.endpoint(s.target),location:n,...s.explicitId?{explicitId:s.explicitId,explicitIdLocation:s.explicitIdLocation}:{},...s.arrow}}actorOccurrence(e,s,n){return{id:s.id,span:this.nodeSpan(e),idSpan:s.location.span,labelSpan:s.label.span,...n?{defines:!0}:{},...s.stereotype?{stereotypeSpan:s.stereotype.span}:{},...s.metadata?{metadata:s.metadata.properties.map(({key:i,span:r,keySpan:o,valueSpan:h})=>({key:i,span:r,keySpan:o,valueSpan:h}))}:{},...s.classSpans.length?{classSpans:s.classSpans}:{}}}entityOccurrence(e,s,n){return this.actorOccurrence(e,s,n)}wrap(e,s){if(s.kind==="blank"||s.kind==="comment")return s;s.span=this.nodeSpan(e);for(let n of s.edges??[])n.span=s.span;return s}tokenLabel(e){let s=e.tokenType.name==="MARKDOWN_STRING"?"markdown":"text",n=s==="markdown"?2:e.tokenType.name==="PLAIN_STRING"?1:0,i=this.tokenSpan(e,n);return{text:this.source.slice(i[0],i[1]),type:s,span:i}}decodePlain(e){return e.tokenType.name==="PLAIN_STRING"?e.image.slice(1,-1):e.image}contentSpan(e){return this.tokenSpan(e,e.tokenType.name==="PLAIN_STRING"?1:e.tokenType.name==="MARKDOWN_STRING"?2:0)}generateId(e){return e.replace(/\W/g,"_")}solidMinlen(e){return Math.max(1,(e.image.match(/-/g)?.length??2)-1)}nodeLocation(e){let s=this.allTokens(e.children)[0];return{span:this.nodeSpan(e),line:s.startLine??1,column:s.startColumn??1}}ctxLocation(e){let s=this.allTokens(e).filter((r)=>r.tokenType.name!=="NEWLINE"&&r.tokenType.name!=="EOF"),n=s[0],i=s.at(-1);return{span:[n.startOffset,Math.min(this.source.length,(i.endOffset??i.startOffset+i.image.length-1)+1)],line:n.startLine??1,column:n.startColumn??1}}tokenLocation(e){let s=e.tokenType.name==="PLAIN_STRING"?1:e.tokenType.name==="MARKDOWN_STRING"?2:0;return{span:this.tokenSpan(e,s),line:e.startLine??1,column:(e.startColumn??1)+s}}nodeSpan(e){let s=this.allTokens(e.children).filter((r)=>r.tokenType.name!=="NEWLINE"&&r.tokenType.name!=="EOF"),n=s[0],i=s.at(-1);if(!n||!i)throw Error("Usecase CST node has no source token");return[n.startOffset,Math.min(this.source.length,(i.endOffset??i.startOffset+i.image.length-1)+1)]}tokenSpan(e,s=0){return[e.startOffset+s,Math.min(this.source.length,(e.endOffset??e.startOffset+e.image.length-1)+1-s)]}nodes(e,s){return(e[s]??[]).filter((n)=>("children"in n))}tokens(e,s){return(e[s]??[]).filter((n)=>("tokenTypeIdx"in n))}firstNode(e,...s){for(let n of s){let i=this.nodes(e,n)[0];if(i)return i}throw Error(`Usecase CST is missing one of: ${s.join(", ")}`)}allTokens(e){let s=[];for(let n of Object.values(e))for(let i of n)if("tokenTypeIdx"in i)s.push(i);else s.push(...this.allTokens(i.children));return s.sort((n,i)=>n.startOffset-i.startOffset)}},Vo=new Ko,zo={parse:t(async(e)=>{Ns.clear(),Gt.input=[];try{Xi({diagramType:"usecase",lexer:xo,parser:Gt,entry:t(()=>Gt.start(),"entry"),visit:t((s)=>Vo.build(s,e),"visit")},e)}catch(s){Ns.clear();let n=Gt.errors[0];if(n){let{token:i}=n,r=ut(i.startOffset)?i.startOffset:e.length,o=ut(i.endOffset)?i.endOffset+1:r,h=ut(i.startLine)?i.startLine:e.slice(0,r).split(/\r\n|\r|\n/).length,u=Math.max(e.lastIndexOf(`
|
|
117
|
-
`,r-1),e.lastIndexOf("\r",r-1)),c=ut(i.startColumn)?i.startColumn:r-u,d=s instanceof Error?s.message:String(s);throw Error(`${d} at line ${h}, column ${c} [${r},${o})`)}throw s}},"parse")},Ho=["point","circle","cross","extension"],Fr={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},Vi=t((e,s)=>{let[n,i]=[e,s].map((r)=>r.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element");return`usecase-${n}-${i}`},"usecaseDomId"),Xo=t((e)=>`usecase-${e.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element"}`,"usecaseNodeDomId"),Is=t((e,s)=>{if(s!=="markdown")return e;return
|
|
118
|
-
`)},"getAccessibleLabel"),Yo=t((e)=>{let s=Is(e.label??e.id,e.labelType);if(Fr[e.shape]){let i=e.actorType&&e.actorType!=="normal"?`${e.actorType} `:"",r=e.business?"business ":"",o=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${r}${i}actor ${s}${o}`}if(e.shape==="note")return`Note for ${e.noteTargetLabel??e.noteTarget??""}: ${s}`;if(e.shape==="usecaseJsonTable"){let i=(e.jsonRows??[]).map((r)=>`${r.accessibleKey}: ${r.value}`).join("; ");return i?`${s}: ${i}`:s}let n=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${e.business?"business ":""}use case ${s}${n}`},"getUsecaseNodeAccessibleName"),qo=t((e)=>`${e.boundaryType} system boundary ${Is(e.label??e.id,e.labelType)}`,"getUsecaseBoundaryAccessibleName"),Jo=t((e)=>{if(e.relationshipType==="note")return"";return`${e.relationshipType==="association"&&e.label?`association ${Is(e.label,e.labelType)}`:e.relationshipType} from ${e.sourceLabel} to ${e.targetLabel}`},"getUsecaseEdgeAccessibleName"),ht=t((e)=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"escapePlainLabel"),zi=t((e)=>e.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),Zo=t((e,s)=>{e.diagramId=s,e.markers=[...Ho];for(let n of e.nodes){let i=n;if(i.domId=Xo(n.id),n.label!==void 0&&n.labelType==="text")n.label=ht(n.label);if(n.stereotype)n.stereotype=ht(n.stereotype);if(!n.isGroup&&n.shape==="usecaseJsonTable")n.jsonRows=n.jsonRows?.map((r)=>({...r,key:ht(r.key),value:ht(r.value)}));if(!n.isGroup&&(n.shape==="usecaseEllipse"||n.shape==="rect")&&n.stereotype){let r=n.label??ht(n.id);n.label=`«${zi(n.stereotype)}»<br/>${n.labelType==="text"?zi(r):r}`,n.labelType="markdown",i.hasFoldedStereotype=!0,delete n.stereotype}}for(let n of e.edges)if(n.label!==void 0&&n.labelType==="text")n.label=ht(n.label);return e},"prepareUsecaseLayoutData"),Qo=t((e,s,n)=>{for(let r of s.nodes){let o=typeof r.domId==="string"?r.domId:Vi(s.diagramId,r.id),h=e.select(`#${o}`),u=r.isGroup?"boundary":Fr[r.shape]?"actor":r.shape==="note"?"note":r.shape==="usecaseJsonTable"?"json":"usecase",c=n.nodes.get(r.id)??r.id;if(h.attr("data-usecase-id",r.id).attr("data-usecase-kind",u).attr("role","img").attr("aria-label",c),!r.isGroup&&(r.shape==="usecaseEllipse"||r.shape==="rect")&&"hasFoldedStereotype"in r&&r.hasFoldedStereotype===!0){let d=h.node(),f=d?.querySelector(".nodeLabel"),m=f?.querySelector("p")??f,y=m?.firstChild;if(m&&y?.nodeType===3){let I=m.ownerDocument.createElement("span");I.className="usecase-stereotype",m.insertBefore(I,y),I.appendChild(y)}else d?.querySelector(".label tspan tspan, .label tspan")?.classList.add("usecase-stereotype")}}let i=new Map(s.edges.map((r)=>[r.id,r]));e.selectAll('path[data-et="edge"]').each(function(){let r=i.get(this.getAttribute("data-id")??"");if(!r)return;let o=p(this);if(o.attr("id",Vi(s.diagramId,r.id)).attr("data-usecase-id",r.id).attr("data-usecase-kind",r.internal?"note-connector":"relationship"),r.internal)o.attr("aria-hidden","true");else o.attr("role","img").attr("aria-label",n.edges.get(r.id)??r.id)})},"annotateUsecaseElements"),Hi=t((e,s)=>{e.style("--mermaid-usecase-actor-font-size",`${s.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",s.actorFontFamily).style("--mermaid-usecase-actor-font-weight",s.actorFontWeight).style("--mermaid-usecase-font-size",`${s.usecaseFontSize}px`).style("--mermaid-usecase-font-family",s.usecaseFontFamily).style("--mermaid-usecase-font-weight",s.usecaseFontWeight)},"applyUsecaseFonts"),el=t(async(e,s,n,i)=>{a.info("Drawing usecase diagram (unified)",s);let{layout:r}=l(),o=i.db,h=o.getData(),u=new Map(h.nodes.map((m)=>[m.id,Is(m.label??m.id,m.labelType)])),c={nodes:new Map(h.nodes.map((m)=>[m.id,m.isGroup?qo(m):Yo(m.shape==="note"?{...m,noteTargetLabel:u.get(m.noteTarget??"")}:m)])),edges:new Map(h.edges.map((m)=>[m.id,Jo({...m,sourceLabel:u.get(m.source)??m.sourceLabel,targetLabel:u.get(m.target)??m.targetLabel})]))},d=he(s,h.config.securityLevel);h.layoutAlgorithm=ye(r),Zo(h,s),Hi(d,h),await ge(h,d),Qo(d,h,c);let f=h.diagramPadding;
|
|
117
|
+
`,r-1),e.lastIndexOf("\r",r-1)),c=ut(i.startColumn)?i.startColumn:r-u,d=s instanceof Error?s.message:String(s);throw Error(`${d} at line ${h}, column ${c} [${r},${o})`)}throw s}},"parse")},Ho=["point","circle","cross","extension"],Fr={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},Vi=t((e,s)=>{let[n,i]=[e,s].map((r)=>r.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element");return`usecase-${n}-${i}`},"usecaseDomId"),Xo=t((e)=>`usecase-${e.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element"}`,"usecaseNodeDomId"),Is=t((e,s)=>{if(s!=="markdown")return e;return si(e).map((n)=>n.map((i)=>i.content).join(" ")).join(`
|
|
118
|
+
`)},"getAccessibleLabel"),Yo=t((e)=>{let s=Is(e.label??e.id,e.labelType);if(Fr[e.shape]){let i=e.actorType&&e.actorType!=="normal"?`${e.actorType} `:"",r=e.business?"business ":"",o=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${r}${i}actor ${s}${o}`}if(e.shape==="note")return`Note for ${e.noteTargetLabel??e.noteTarget??""}: ${s}`;if(e.shape==="usecaseJsonTable"){let i=(e.jsonRows??[]).map((r)=>`${r.accessibleKey}: ${r.value}`).join("; ");return i?`${s}: ${i}`:s}let n=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${e.business?"business ":""}use case ${s}${n}`},"getUsecaseNodeAccessibleName"),qo=t((e)=>`${e.boundaryType} system boundary ${Is(e.label??e.id,e.labelType)}`,"getUsecaseBoundaryAccessibleName"),Jo=t((e)=>{if(e.relationshipType==="note")return"";return`${e.relationshipType==="association"&&e.label?`association ${Is(e.label,e.labelType)}`:e.relationshipType} from ${e.sourceLabel} to ${e.targetLabel}`},"getUsecaseEdgeAccessibleName"),ht=t((e)=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"escapePlainLabel"),zi=t((e)=>e.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),Zo=t((e,s)=>{e.diagramId=s,e.markers=[...Ho];for(let n of e.nodes){let i=n;if(i.domId=Xo(n.id),n.label!==void 0&&n.labelType==="text")n.label=ht(n.label);if(n.stereotype)n.stereotype=ht(n.stereotype);if(!n.isGroup&&n.shape==="usecaseJsonTable")n.jsonRows=n.jsonRows?.map((r)=>({...r,key:ht(r.key),value:ht(r.value)}));if(!n.isGroup&&(n.shape==="usecaseEllipse"||n.shape==="rect")&&n.stereotype){let r=n.label??ht(n.id);n.label=`«${zi(n.stereotype)}»<br/>${n.labelType==="text"?zi(r):r}`,n.labelType="markdown",i.hasFoldedStereotype=!0,delete n.stereotype}}for(let n of e.edges)if(n.label!==void 0&&n.labelType==="text")n.label=ht(n.label);return e},"prepareUsecaseLayoutData"),Qo=t((e,s,n)=>{for(let r of s.nodes){let o=typeof r.domId==="string"?r.domId:Vi(s.diagramId,r.id),h=e.select(`#${o}`),u=r.isGroup?"boundary":Fr[r.shape]?"actor":r.shape==="note"?"note":r.shape==="usecaseJsonTable"?"json":"usecase",c=n.nodes.get(r.id)??r.id;if(h.attr("data-usecase-id",r.id).attr("data-usecase-kind",u).attr("role","img").attr("aria-label",c),!r.isGroup&&(r.shape==="usecaseEllipse"||r.shape==="rect")&&"hasFoldedStereotype"in r&&r.hasFoldedStereotype===!0){let d=h.node(),f=d?.querySelector(".nodeLabel"),m=f?.querySelector("p")??f,y=m?.firstChild;if(m&&y?.nodeType===3){let I=m.ownerDocument.createElement("span");I.className="usecase-stereotype",m.insertBefore(I,y),I.appendChild(y)}else d?.querySelector(".label tspan tspan, .label tspan")?.classList.add("usecase-stereotype")}}let i=new Map(s.edges.map((r)=>[r.id,r]));e.selectAll('path[data-et="edge"]').each(function(){let r=i.get(this.getAttribute("data-id")??"");if(!r)return;let o=p(this);if(o.attr("id",Vi(s.diagramId,r.id)).attr("data-usecase-id",r.id).attr("data-usecase-kind",r.internal?"note-connector":"relationship"),r.internal)o.attr("aria-hidden","true");else o.attr("role","img").attr("aria-label",n.edges.get(r.id)??r.id)})},"annotateUsecaseElements"),Hi=t((e,s)=>{e.style("--mermaid-usecase-actor-font-size",`${s.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",s.actorFontFamily).style("--mermaid-usecase-actor-font-weight",s.actorFontWeight).style("--mermaid-usecase-font-size",`${s.usecaseFontSize}px`).style("--mermaid-usecase-font-family",s.usecaseFontFamily).style("--mermaid-usecase-font-weight",s.usecaseFontWeight)},"applyUsecaseFonts"),el=t(async(e,s,n,i)=>{a.info("Drawing usecase diagram (unified)",s);let{layout:r}=l(),o=i.db,h=o.getData(),u=new Map(h.nodes.map((m)=>[m.id,Is(m.label??m.id,m.labelType)])),c={nodes:new Map(h.nodes.map((m)=>[m.id,m.isGroup?qo(m):Yo(m.shape==="note"?{...m,noteTargetLabel:u.get(m.noteTarget??"")}:m)])),edges:new Map(h.edges.map((m)=>[m.id,Jo({...m,sourceLabel:u.get(m.source)??m.sourceLabel,targetLabel:u.get(m.target)??m.targetLabel})]))},d=he(s,h.config.securityLevel);h.layoutAlgorithm=ye(r),Zo(h,s),Hi(d,h),await ge(h,d),Qo(d,h,c);let f=h.diagramPadding;N.insertTitle(d,"usecaseDiagramTitleText",0,o.getDiagramTitle?.()??""),ue(d,f,"usecaseDiagram",h.useMaxWidth),Hi(d,h)},"draw"),tl={draw:el},sl=t((e)=>({actorBkg:e.usecaseActorBkg??e.actorBkg??e.mainBkg,actorBorder:e.usecaseActorBorder??e.actorBorder??e.primaryColor,bkg:e.usecaseBkg??e.mainBkg,border:e.usecaseBorder??e.nodeBorder??e.primaryColor,boundaryBkg:e.usecaseBoundaryBkg??e.clusterBkg,boundaryBorder:e.usecaseBoundaryBorder??e.clusterBorder,includeLine:e.usecaseIncludeLine??e.lineColor,extendLine:e.usecaseExtendLine??e.lineColor}),"roleColors"),nl=t((e)=>{let{theme:s,bkgColorArray:n,borderColorArray:i}=e;if(!se(s,i))return"";let r=x().usecase?.colorScheme==="rotate",o=le(e.look),h=o==="handDrawn",u=pe(n),c="";for(let d=0;d<vt(i);d++){let f=i[d],m=u?`fill: ${n[d%n.length]};`:"",y=`[data-look="${o}"][data-color-id="color-${d}"]`;if(c+=`
|
|
119
119
|
|
|
120
120
|
& ${y}.system-boundary rect.boundary-body,
|
|
121
121
|
& ${y}.system-boundary rect.boundary-tab,
|