MCPcopy Index your code
hub / github.com/google/adk-python / Tf

Function Tf

src/google/adk/cli/browser/chunk-NALL4A3P.js:123–123  ·  view source on GitHub ↗
(t)

Source from the content-addressed store, hash-verified

121 ${n}
122 To fix this refactor your grammar to remove the left recursion.
123see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(t){return"deprecated"},buildDuplicateRuleNameError(t){let e;return t.topLevelRule instanceof Nt?e=t.topLevelRule.name:e=t.topLevelRule,`Duplicate definition, rule: ->${e}<- is already defined in the grammar: ->${t.grammarName}<-`}};function Dm(t,e){let r=new gf(t,e);return r.resolveRefs(),r.errors}var gf=class extends Ct{constructor(e,r){super(),this.nameToTopRule=e,this.errMsgProvider=r,this.errors=[]}resolveRefs(){D(Ce(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let r=this.nameToTopRule[e.nonTerminalName];if(r)e.referencedRule=r;else{let n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:n,type:it.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}};var yf=class extends jr{constructor(e,r){super(),this.topProd=e,this.path=r,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=Ne(this.path.ruleStack).reverse(),this.occurrenceStack=Ne(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,r=[]){this.found||super.walk(e,r)}walkProdRef(e,r,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let i=r.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,i)}}updateExpectedNext(){Z(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},xc=class extends yf{constructor(e,r){super(e,r),this.path=r,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,r,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let i=r.concat(n),s=new Ee({definition:i});this.possibleTokTypes=Jn(s),this.found=!0}}},Bi=class extends jr{constructor(e,r){super(),this.topRule=e,this.occurrence=r,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},vc=class extends Bi{walkMany(e,r,n){if(e.idx===this.occurrence){let i=pt(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof te&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkMany(e,r,n)}},va=class extends Bi{walkManySep(e,r,n){if(e.idx===this.occurrence){let i=pt(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof te&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkManySep(e,r,n)}},Ec=class extends Bi{walkAtLeastOne(e,r,n){if(e.idx===this.occurrence){let i=pt(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof te&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOne(e,r,n)}},Ea=class extends Bi{walkAtLeastOneSep(e,r,n){if(e.idx===this.occurrence){let i=pt(r.concat(n));this.result.isEndOfRule=i===void 0,i instanceof te&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOneSep(e,r,n)}};function Ac(t,e,r=[]){r=Ne(r);let n=[],i=0;function s(o){return o.concat(Ke(t,i+1))}function a(o){let c=Ac(s(o),e,r);return n.concat(c)}for(;r.length<e&&i<t.length;){let o=t[i];if(o instanceof Ee)return a(o.definition);if(o instanceof pe)return a(o.definition);if(o instanceof he)n=a(o.definition);else if(o instanceof Ae){let c=o.definition.concat([new se({definition:o.definition})]);return a(c)}else if(o instanceof $e){let c=[new Ee({definition:o.definition}),new se({definition:[new te({terminalType:o.separator})].concat(o.definition)})];return a(c)}else if(o instanceof Re){let c=o.definition.concat([new se({definition:[new te({terminalType:o.separator})].concat(o.definition)})]);n=a(c)}else if(o instanceof se){let c=o.definition.concat([new se({definition:o.definition})]);n=a(c)}else{if(o instanceof xe)return D(o.definition,c=>{Z(c.definition)===!1&&(n=a(c.definition))}),n;if(o instanceof te)r.push(o.terminalType);else throw Error("non exhaustive match")}i++}return n.push({partialPath:r,suffixDef:Ke(t,i)}),n}function $c(t,e,r,n){let i="EXIT_NONE_TERMINAL",s=[i],a="EXIT_ALTERNATIVE",o=!1,c=e.length,l=c-n-1,u=[],p=[];for(p.push({idx:-1,def:t,ruleStack:[],occurrenceStack:[]});!Z(p);){let h=p.pop();if(h===a){o&&gr(p).idx<=l&&p.pop();continue}let g=h.def,C=h.idx,k=h.ruleStack,G=h.occurrenceStack;if(Z(g))continue;let M=g[0];if(M===i){let b={idx:C,def:Ke(g),ruleStack:tn(k),occurrenceStack:tn(G)};p.push(b)}else if(M instanceof te)if(C<c-1){let b=C+1,E=e[b];if(r(E,M.terminalType)){let H={idx:b,def:Ke(g),ruleStack:k,occurrenceStack:G};p.push(H)}}else if(C===c-1)u.push({nextTokenType:M.terminalType,nextTokenOccurrence:M.idx,ruleStack:k,occurrenceStack:G}),o=!0;else throw Error("non exhaustive match");else if(M instanceof pe){let b=Ne(k);b.push(M.nonTerminalName);let E=Ne(G);E.push(M.idx);let H={idx:C,def:M.definition.concat(s,Ke(g)),ruleStack:b,occurrenceStack:E};p.push(H)}else if(M instanceof he){let b={idx:C,def:Ke(g),ruleStack:k,occurrenceStack:G};p.push(b),p.push(a);let E={idx:C,def:M.definition.concat(Ke(g)),ruleStack:k,occurrenceStack:G};p.push(E)}else if(M instanceof Ae){let b=new se({definition:M.definition,idx:M.idx}),E=M.definition.concat([b],Ke(g)),H={idx:C,def:E,ruleStack:k,occurrenceStack:G};p.push(H)}else if(M instanceof $e){let b=new te({terminalType:M.separator}),E=new se({definition:[b].concat(M.definition),idx:M.idx}),H=M.definition.concat([E],Ke(g)),F={idx:C,def:H,ruleStack:k,occurrenceStack:G};p.push(F)}else if(M instanceof Re){let b={idx:C,def:Ke(g),ruleStack:k,occurrenceStack:G};p.push(b),p.push(a);let E=new te({terminalType:M.separator}),H=new se({definition:[E].concat(M.definition),idx:M.idx}),F=M.definition.concat([H],Ke(g)),ye={idx:C,def:F,ruleStack:k,occurrenceStack:G};p.push(ye)}else if(M instanceof se){let b={idx:C,def:Ke(g),ruleStack:k,occurrenceStack:G};p.push(b),p.push(a);let E=new se({definition:M.definition,idx:M.idx}),H=M.definition.concat([E],Ke(g)),F={idx:C,def:H,ruleStack:k,occurrenceStack:G};p.push(F)}else if(M instanceof xe)for(let b=M.definition.length-1;b>=0;b--){let E=M.definition[b],H={idx:C,def:E.definition.concat(Ke(g)),ruleStack:k,occurrenceStack:G};p.push(H),p.push(a)}else if(M instanceof Ee)p.push({idx:C,def:M.definition.concat(Ke(g)),ruleStack:k,occurrenceStack:G});else if(M instanceof Nt)p.push(NE(M,C,k,G));else throw Error("non exhaustive match")}return u}function NE(t,e,r,n){let i=Ne(r);i.push(t.name);let s=Ne(n);return s.push(1),{idx:e,def:t.definition,ruleStack:i,occurrenceStack:s}}var De=(function(t){return t[t.OPTION=0]="OPTION",t[t.REPETITION=1]="REPETITION",t[t.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",t[t.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",t[t.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",t[t.ALTERNATION=5]="ALTERNATION",t})(De||{});function Aa(t){if(t instanceof he||t==="Option")return De.OPTION;if(t instanceof se||t==="Repetition")return De.REPETITION;if(t instanceof Ae||t==="RepetitionMandatory")return De.REPETITION_MANDATORY;if(t instanceof $e||t==="RepetitionMandatoryWithSeparator")return De.REPETITION_MANDATORY_WITH_SEPARATOR;if(t instanceof Re||t==="RepetitionWithSeparator")return De.REPETITION_WITH_SEPARATOR;if(t instanceof xe||t==="Alternation")return De.ALTERNATION;throw Error("non exhaustive match")}function kc(t){let{occurrence:e,rule:r,prodType:n,maxLookahead:i}=t,s=Aa(n);return s===De.ALTERNATION?Wi(e,r,i):Vi(e,r,s,i)}function Fm(t,e,r,n,i,s){let a=Wi(t,e,r),o=Bm(a)?zi:Br;return s(a,n,o,i)}function Gm(t,e,r,n,i,s){let a=Vi(t,e,i,r),o=Bm(a)?zi:Br;return s(a[0],o,n)}function Um(t,e,r,n){let i=t.length,s=At(t,a=>At(a,o=>o.length===1));if(e)return function(a){let o=I(a,c=>c.GATE);for(let c=0;c<i;c++){let l=t[c],u=l.length,p=o[c];if(!(p!==void 0&&p.call(this)===!1))e:for(let h=0;h<u;h++){let g=l[h],C=g.length;for(let k=0;k<C;k++){let G=this.LA(k+1);if(r(G,g[k])===!1)continue e}return c}}};if(s&&!n){let a=I(t,c=>Ve(c)),o=Ue(a,(c,l,u)=>(D(l,p=>{q(c,p.tokenTypeIdx)||(c[p.tokenTypeIdx]=u),D(p.categoryMatches,h=>{q(c,h)||(c[h]=u)})}),c),{});return function(){let c=this.LA(1);return o[c.tokenTypeIdx]}}else return function(){for(let a=0;a<i;a++){let o=t[a],c=o.length;e:for(let l=0;l<c;l++){let u=o[l],p=u.length;for(let h=0;h<p;h++){let g=this.LA(h+1);if(r(g,u[h])===!1)continue e}return a}}}}function qm(t,e,r){let n=At(t,s=>s.length===1),i=t.length;if(n&&!r){let s=Ve(t);if(s.length===1&&Z(s[0].categoryMatches)){let o=s[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===o}}else{let a=Ue(s,(o,c,l)=>(o[c.tokenTypeIdx]=!0,D(c.categoryMatches,u=>{o[u]=!0}),o),[]);return function(){let o=this.LA(1);return a[o.tokenTypeIdx]===!0}}}else return function(){e:for(let s=0;s<i;s++){let a=t[s],o=a.length;for(let c=0;c<o;c++){let l=this.LA(c+1);if(e(l,a[c])===!1)continue e}return!0}return!1}}var Rf=class extends jr{constructor(e,r,n){super(),this.topProd=e,this.targetOccurrence=r,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,r,n,i){return e.idx===this.targetOccurrence&&this.targetProdType===r?(this.restDef=n.concat(i),!0):!1}walkOption(e,r,n){this.checkIsTarget(e,De.OPTION,r,n)||super.walkOption(e,r,n)}walkAtLeastOne(e,r,n){this.checkIsTarget(e,De.REPETITION_MANDATORY,r,n)||super.walkOption(e,r,n)}walkAtLeastOneSep(e,r,n){this.checkIsTarget(e,De.REPETITION_MANDATORY_WITH_SEPARATOR,r,n)||super.walkOption(e,r,n)}walkMany(e,r,n){this.checkIsTarget(e,De.REPETITION,r,n)||super.walkOption(e,r,n)}walkManySep(e,r,n){this.checkIsTarget(e,De.REPETITION_WITH_SEPARATOR,r,n)||super.walkOption(e,r,n)}},Sc=class extends Ct{constructor(e,r,n){super(),this.targetOccurrence=e,this.targetProdType=r,this.targetRef=n,this.result=[]}checkIsTarget(e,r){e.idx===this.targetOccurrence&&this.targetProdType===r&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,De.OPTION)}visitRepetition(e){this.checkIsTarget(e,De.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,De.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,De.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,De.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,De.ALTERNATION)}};function Mm(t){let e=new Array(t);for(let r=0;r<t;r++)e[r]=[];return e}function Tf(t){let e=[""];for(let r=0;r<t.length;r++){let n=t[r],i=[];for(let s=0;s<e.length;s++){let a=e[s];i.push(a+"_"+n.tokenTypeIdx);for(let o=0;o<n.categoryMatches.length;o++){let c="_"+n.categoryMatches[o];i.push(a+c)}}e=i}return e}function CE(t,e,r){for(let n=0;n<t.length;n++){if(n===r)continue;let i=t[n];for(let s=0;s<e.length;s++){let a=e[s];if(i[a]===!0)return!1}}return!0}function zm(t,e){let r=I(t,a=>Ac([a],1)),n=Mm(r.length),i=I(r,a=>{let o={};return D(a,c=>{let l=Tf(c.partialPath);D(l,u=>{o[u]=!0})}),o}),s=r;for(let a=1;a<=e;a++){let o=s;s=Mm(o.length);for(let c=0;c<o.length;c++){let l=o[c];for(let u=0;u<l.length;u++){let p=l[u].partialPath,h=l[u].suffixDef,g=Tf(p);if(CE(i,g,c)||Z(h)||p.length===e){let k=n[c];if(Nc(k,p)===!1){k.push(p);for(let G=0;G<g.length;G++){let M=g[G];i[c][M]=!0}}}else{let k=Ac(h,a+1,p);s[c]=s[c].concat(k),D(k,G=>{let M=Tf(G.partialPath);D(M,b=>{i[c][b]=!0})})}}}}return n}function Wi(t,e,r,n){let i=new Sc(t,De.ALTERNATION,n);return e.accept(i),zm(i.result,r)}function Vi(t,e,r,n){let i=new Sc(t,r);e.accept(i);let s=i.result,o=new Rf(e,t,r).startWalking(),c=new Ee({definition:s}),l=new Ee({definition:o});return zm([c,l],n)}function Nc(t,e){e:for(let r=0;r<t.length;r++){let n=t[r];if(n.length===e.length){for(let i=0;i<n.length;i++){let s=e[i],a=n[i];if((s===a||a.categoryMatchesMap[s.tokenTypeIdx]!==void 0)===!1)continue e}return!0}}return!1}function jm(t,e){return t.length<e.length&&At(t,(r,n)=>{let i=e[n];return r===i||i.categoryMatchesMap[r.tokenTypeIdx]})}function Bm(t){return At(t,e=>At(e,r=>At(r,n=>Z(n.categoryMatches))))}function Wm(t){let e=t.lookaheadStrategy.validate({rules:t.rules,tokenTypes:t.tokenTypes,grammarName:t.grammarName});return I(e,r=>Object.assign({type:it.CUSTOM_LOOKAHEAD_VALIDATION},r))}function Vm(t,e,r,n){let i=ht(t,c=>wE(c,r)),s=LE(t,e,r),a=ht(t,c=>bE(c,r)),o=ht(t,c=>_E(c,t,n,r));return i.concat(s,a,o)}function wE(t,e){let r=new xf;t.accept(r);let n=r.allProductions,i=Uh(n,IE),s=Gt(i,o=>o.length>1);return I(Ce(s),o=>{let c=pt(o),l=e.buildDuplicateFoundError(t,o),u=Ot(c),p={message:l,type:it.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:u,occurrence:c.idx},h=Km(c);return h&&(p.parameter=h),p})}function IE(t){return`${Ot(t)}_#_${t.idx}_#_${Km(t)}`}function Km(t){return t instanceof te?t.terminalType.name:t instanceof pe?t.nonTerminalName:""}var xf=class extends Ct{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 _E(t,e,r,n){let i=[];if(Ue(e,(a,o)=>o.name===t.name?a+1:a,0)>1){let a=n.buildDuplicateRuleNameError({topLevelRule:t,grammarName:r});i.push({message:a,type:it.DUPLICATE_RULE_NAME,ruleName:t.name})}return i}function Hm(t,e,r){let n=[],i;return Pe(e,t)||(i=`Invalid rule override, rule: ->${t}<- cannot be overridden in the grammar: ->${r}<-as it is not defined in any of the super grammars `,n.push({message:i,type:it.INVALID_RULE_OVERRIDE,ruleName:t})),n}function Ef(t,e,r,n=[]){let i=[],s=Cc(e.definition);if(Z(s))return[];{let a=t.name;Pe(s,t)&&i.push({message:r.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:n}),type:it.LEFT_RECURSION,ruleName:a});let c=wn(s,n.concat([t])),l=ht(c,u=>{let p=Ne(n);return p.push(u),Ef(t,u,r,p)});return i.concat(l)}}function Cc(t){let e=[];if(Z(t))return e;let r=pt(t);if(r instanceof pe)e.push(r.referencedRule);else if(r instanceof Ee||r instanceof he||r instanceof Ae||r instanceof $e||r instanceof Re||r instanceof se)e=e.concat(Cc(r.definition));else if(r instanceof xe)e=Ve(I(r.definition,s=>Cc(s.definition)));else if(!(r instanceof te))throw Error("non exhaustive match");let n=Xn(r),i=t.length>1;if(n&&i){let s=Ke(t);return e.concat(Cc(s))}else return e}var $a=class extends Ct{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function Ym(t,e){let r=new $a;t.accept(r);let n=r.alternations;return ht(n,s=>{let a=tn(s.definition);return ht(a,(o,c)=>{let l=$c([o],[],Br,1);return Z(l)?[{message:e.buildEmptyAlternationError({topLevelRule:t,alternation:s,emptyChoiceIdx:c}),type:it.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:s.idx,alternative:c+1}]:[]})})}function Xm(t,e,r){let n=new $a;t.accept(n);let i=n.alternations;return i=In(i,a=>a.ignoreAmbiguities===!0),ht(i,a=>{let o=a.idx,c=a.maxLookahead||e,l=Wi(o,t,c,a),u=PE(l,a,t,r),p=OE(l,a,t,r);return u.concat(p)})}var vf=class extends Ct{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 bE(t,e){let r=new $a;t.accept(r);let n=r.alternations;return ht(n,s=>s.definition.length>255?[{message:e.buildTooManyAlternativesError({topLevelRule:t,alternation:s}),type:it.TOO_MANY_ALTS,ruleName:t.name,occurrence:s.idx}]:[])}function Jm(t,e,r){let n=[];return D(t,i=>{let s=new vf;i.accept(s);let a=s.allProductions;D(a,o=>{let c=Aa(o),l=o.maxLookahead||e,u=o.idx,h=Vi(u,i,c,l)[0];if(Z(Ve(h))){let g=r.buildEmptyRepetitionError({topLevelRule:i,repetition:o});n.push({message:g,type:it.NO_NON_EMPTY_LOOKAHEAD,ruleName:i.name})}})}),n}function PE(t,e,r,n){let i=[],s=Ue(t,(o,c,l)=>(e.definition[l].ignoreAmbiguities===!0||D(c,u=>{let p=[l];D(t,(h,g)=>{l!==g&&Nc(h,u)&&e.definition[g].ignoreAmbiguities!==!0&&p.push(g)}),p.length>1&&!Nc(i,u)&&(i.push(u),o.push({alts:p,path:u}))}),o),[]);return I(s,o=>{let c=I(o.alts,u=>u+1);return{message:n.buildAlternationAmbiguityError({topLevelRule:r,alternation:e,ambiguityIndices:c,prefixPath:o.path}),type:it.AMBIGUOUS_ALTS,ruleName:r.name,occurrence:e.idx,alternatives:o.alts}})}function OE(t,e,r,n){let i=Ue(t,(a,o,c)=>{let l=I(o,u=>({idx:c,path:u}));return a.concat(l)},[]);return Or(ht(i,a=>{if(e.definition[a.idx].ignoreAmbiguities===!0)return[];let c=a.idx,l=a.path,u=ct(i,h=>e.definition[h.idx].ignoreAmbiguities!==!0&&h.idx<c&&jm(h.path,l));return I(u,h=>{let g=[h.idx+1,c+1],C=e.idx===0?"":e.idx;return{message:n.buildAlternationPrefixAmbiguityError({topLevelRule:r,alternation:e,ambiguityIndices:g,prefixPath:h.path}),type:it.AMBIGUOUS_PREFIX_ALTS,ruleName:r.name,occurrence:C,alternatives:g}})}))}function LE(t,e,r){let n=[],i=I(e,s=>s.name);return D(t,s=>{let a=s.name;if(Pe(i,a)){let o=r.buildNamespaceConflictError(s);n.push({message:o,type:it.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:a})}}),n}function Qm(t){let e=Ks(t,{errMsgProvider:Lm}),r={};return D(t.rules,n=>{r[n.name]=n}),Dm(r,e.errMsgProvider)}function Zm(t){return t=Ks(t,{errMsgProvider:cr}),Vm(t.rules,t.tokenTypes,t.errMsgProvider,t.grammarName)}var eg="MismatchedTokenException",tg="NoViableAltException",rg="EarlyExitException",ng="NotAllInputParsedException",ig=[eg,tg,rg,ng];Object.freeze(ig);function gn(t){return Pe(ig,t.name)}var Ki=class extends Error{constructor(e,r){super(e),this.token=r,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Zn=class extends Ki{constructor(e,r,n){super(e,r),this.previousToken=n,this.name=eg}},Sa=class extends Ki{constructor(e,r,n){super(e,r),this.previousToken=n,this.name=tg}},ka=class extends Ki{constructor(e,r){super(e,r),this.name=ng}},Na=class extends Ki{constructor(e,r,n){super(e,r),this.previousToken=n,this.name=rg}};var Af={},Sf="InRuleRecoveryException",$f=class extends Error{constructor(e){super(e),this.name=Sf}},wc=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=q(e,"recoveryEnabled")?e.recoveryEnabled:wt.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=DE)}getTokenToInsert(e){let r=Kr(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return r.isInsertedInRecovery=!0,r}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,r,n,i){let s=this.findReSyncTokenType(),a=this.exportLexerState(),o=[],c=!1,l=this.LA(1),u=this.LA(1),p=()=>{let h=this.LA(0),g=this.errorMessageProvider.buildMismatchTokenMessage({expected:i,actual:l,previous:h,ruleName:this.getCurrRuleFullName()}),C=new Zn(g,l,this.LA(0));C.resyncedTokens=tn(o),this.SAVE_ERROR(C)};for(;!c;)if(this.tokenMatcher(u,i)){p();return}else if(n.call(this)){p(),e.apply(this,r);return}else this.tokenMatcher(u,s)?c=!0:(u=this.SKIP_TOKEN(),this.addToResyncTokens(u,o));this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,r,n){return!(n===!1||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,r)))}getFollowsForInRuleRecovery(e,r){let n=this.getCurrentGrammarPath(e,r);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,r){if(this.canRecoverWithSingleTokenInsertion(e,r))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new $f("sad sad panda")}canPerformInRuleRecovery(e,r){return this.canRecoverWithSingleTokenInsertion(e,r)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,r){if(!this.canTokenTypeBeInsertedInRecovery(e)||Z(r))return!1;let n=this.LA(1);return Lr(r,s=>this.tokenMatcher(n,s))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let r=this.getCurrFollowKey(),n=this.getFollowSetFromFollowKey(r);return Pe(n,e)}findReSyncTokenType(){let e=this.flattenFollowSet(),r=this.LA(1),n=2;for(;;){let i=Lr(e,s=>xa(r,s));if(i!==void 0)return i;r=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return Af;let e=this.getLastExplicitRuleShortName(),r=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:r,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,r=this.RULE_OCCURRENCE_STACK;return I(e,(n,i)=>i===0?Af:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:r[i],inRule:this.shortRuleNameToFullName(e[i-1])})}flattenFollowSet(){let e=I(this.buildFullFollowKeyStack(),r=>this.getFollowSetFromFollowKey(r));return Ve(e)}getFollowSetFromFollowKey(e){if(e===Af)return[Bt];let r=e.ruleName+e.idxInCallingRule+hc+e.inRule;return this.resyncFollows[r]}addToResyncTokens(e,r){return this.tokenMatcher(e,Bt)||r.push(e),r}reSyncTo(e){let r=[],n=this.LA(1);for(;this.tokenMatcher(n,e)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,r);return tn(r)}attemptInRepetitionRecovery(e,r,n,i,s,a,o){}getCurrentGrammarPath(e,r){let n=this.getHumanReadableRuleStack(),i=Ne(this.RULE_OCCURRENCE_STACK);return{ruleStack:n,occurrenceStack:i,lastTok:e,lastTokOccurrence:r}}getHumanReadableRuleStack(){return I(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}};function DE(t,e,r,n,i,s,a){let o=this.getKeyForAutomaticLookahead(n,i),c=this.firstAfterRepMap[o];if(c===void 0){let h=this.getCurrRuleFullName(),g=this.getGAstProductions()[h];c=new s(g,i).startWalking(),this.firstAfterRepMap[o]=c}let l=c.token,u=c.occurrence,p=c.isEndOfRule;this.RULE_STACK.length===1&&p&&l===void 0&&(l=Bt,u=1),!(l===void 0||u===void 0)&&this.shouldInRepetitionRecoveryBeTried(l,u,a)&&this.tryInRepetitionRecovery(t,e,r,l)}function Ic(t,e,r){return r|e|t}var Yr=class{constructor(e){var r;this.maxLookahead=(r=e?.maxLookahead)!==null&&r!==void 0?r:wt.maxLookahead}validate(e){let r=this.validateNoLeftRecursion(e.rules);if(Z(r)){let n=this.validateEmptyOrAlternatives(e.rules),i=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),s=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...r,...n,...i,...s]}return r}validateNoLeftRecursion(e){return ht(e,r=>Ef(r,r,cr))}validateEmptyOrAlternatives(e){return ht(e,r=>Ym(r,cr))}validateAmbiguousAlternationAlternatives(e,r){return ht(e,n=>Xm(n,r,cr))}validateSomeNonEmptyLookaheadPath(e,r){return Jm(e,r,cr)}buildLookaheadForAlternation(e){return Fm(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,Um)}buildLookaheadForOptional(e){return Gm(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,Aa(e.prodType),qm)}};var bc=class{initLooksAhead(e){this.dynamicTokensEnabled=q(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:wt.dynamicTokensEnabled,this.maxLookahead=q(e,"maxLookahead")?e.maxLookahead:wt.maxLookahead,this.lookaheadStrategy=q(e,"lookaheadStrategy")?e.lookaheadStrategy:new Yr({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){D(e,r=>{this.TRACE_INIT(`${r.name} Rule Lookahead`,()=>{let{alternation:n,repetition:i,option:s,repetitionMandatory:a,repetitionMandatoryWithSeparator:o,repetitionWithSeparator:c}=ME(r);D(n,l=>{let u=l.idx===0?"":l.idx;this.TRACE_INIT(`${Ot(l)}${u}`,()=>{let p=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:l.idx,rule:r,maxLookahead:l.maxLookahead||this.maxLookahead,hasPredicates:l.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),h=Ic(this.fullRuleNameToShort[r.name],256,l.idx);this.setLaFuncCache(h,p)})}),D(i,l=>{this.computeLookaheadFunc(r,l.idx,768,"Repetition",l.maxLookahead,Ot(l))}),D(s,l=>{this.computeLookaheadFunc(r,l.idx,512,"Option",l.maxLookahead,Ot(l))}),D(a,l=>{this.computeLookaheadFunc(r,l.idx,1024,"RepetitionMandatory",l.maxLookahead,Ot(l))}),D(o,l=>{this.computeLookaheadFunc(r,l.idx,1536,"RepetitionMandatoryWithSeparator",l.maxLookahead,Ot(l))}),D(c,l=>{this.computeLookaheadFunc(r,l.idx,1280,"RepetitionWithSeparator",l.maxLookahead,Ot(l))})})})}computeLookaheadFunc(e,r,n,i,s,a){this.TRACE_INIT(`${a}${r===0?"":r}`,()=>{let o=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:r,rule:e,maxLookahead:s||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:i}),c=Ic(this.fullRuleNameToShort[e.name],n,r);this.setLaFuncCache(c,o)})}getKeyForAutomaticLookahead(e,r){let n=this.getLastExplicitRuleShortName();return Ic(n,e,r)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,r){this.lookAheadFuncsCache.set(e,r)}},kf=class extends Ct{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)}},_c=new kf;function ME(t){_c.reset(),t.accept(_c);let e=_c.dslMethods;return _c.reset(),e}function wf(t,e){isNaN(t.startOffset)===!0?(t.startOffset=e.startOffset,t.endOffset=e.endOffset):t.endOffset<e.endOffset&&(t.endOffset=e.endOffset)}function If(t,e){isNaN(t.startOffset)===!0?(t.startOffset=e.startOffset,t.startColumn=e.startColumn,t.startLine=e.startLine,t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine):t.endOffset<e.endOffset&&(t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine)}function sg(t,e,r){t.children[r]===void 0?t.children[r]=[e]:t.children[r].push(e)}function ag(t,e,r){t.children[e]===void 0?t.children[e]=[r]:t.children[e].push(r)}var FE="name";function _f(t,e){Object.defineProperty(t,FE,{enumerable:!1,configurable:!0,writable:!1,value:e})}function GE(t,e){let r=Pr(t),n=r.length;for(let i=0;i<n;i++){let s=r[i],a=t[s],o=a.length;for(let c=0;c<o;c++){let l=a[c];l.tokenTypeIdx===void 0&&this[l.name](l.children,e)}}}function og(t,e){let r=function(){};_f(r,t+"BaseSemantics");let n={visit:function(i,s){if(Ze(i)&&(i=i[0]),!$t(i))return this[i.name](i.children,s)},validateVisitor:function(){let i=UE(this,e);if(!Z(i)){let s=I(i,a=>a.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
124 ${s.join(`
125
126`).replace(/\n/g,`

Callers 1

zmFunction · 0.70

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected