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

Method toString

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

Source from the content-addressed store, hash-verified

145 Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
146 See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
147 For further details.`);this.skipValidations=q(n,"skipValidations")?n.skipValidations:wt.skipValidations}}return t.DEFER_DEFINITION_ERRORS_HANDLING=!1,t})();mg(gg,[wc,bc,Dc,Mc,Gc,Fc,Uc,qc,zc,Wc]);var Ia=class extends gg{constructor(e,r=wt){let n=Ne(r);n.outputCst=!1,super(e,n)}};function ei(t,e,r){return`${t.name}_${e}_${r}`}var yn=1,VE=2,yg=4,Tg=5;var Qi=7,KE=8,HE=9,YE=10,XE=11,Rg=12,_a=class{constructor(e){this.target=e}isEpsilon(){return!1}},Xi=class extends _a{constructor(e,r){super(e),this.tokenType=r}},ba=class extends _a{constructor(e){super(e)}isEpsilon(){return!0}},Ji=class extends _a{constructor(e,r,n){super(e),this.rule=r,this.followState=n}isEpsilon(){return!0}};function xg(t){let e={decisionMap:{},decisionStates:[],ruleToStartState:new Map,ruleToStopState:new Map,states:[]};JE(e,t);let r=t.length;for(let n=0;n<r;n++){let i=t[n],s=ti(e,i,i);s!==void 0&&cA(e,i,s)}return e}function JE(t,e){let r=e.length;for(let n=0;n<r;n++){let i=e[n],s=st(t,i,void 0,{type:VE}),a=st(t,i,void 0,{type:Qi});s.stop=a,t.ruleToStartState.set(i,s),t.ruleToStopState.set(i,a)}}function vg(t,e,r){return r instanceof te?Pf(t,e,r.terminalType,r):r instanceof pe?oA(t,e,r):r instanceof xe?rA(t,e,r):r instanceof he?nA(t,e,r):r instanceof se?QE(t,e,r):r instanceof Re?ZE(t,e,r):r instanceof Ae?eA(t,e,r):r instanceof $e?tA(t,e,r):ti(t,e,r)}function QE(t,e,r){let n=st(t,e,r,{type:Tg});Tn(t,n);let i=Zi(t,e,n,r,ti(t,e,r));return Ag(t,e,r,i)}function ZE(t,e,r){let n=st(t,e,r,{type:Tg});Tn(t,n);let i=Zi(t,e,n,r,ti(t,e,r)),s=Pf(t,e,r.separator,r);return Ag(t,e,r,i,s)}function eA(t,e,r){let n=st(t,e,r,{type:yg});Tn(t,n);let i=Zi(t,e,n,r,ti(t,e,r));return Eg(t,e,r,i)}function tA(t,e,r){let n=st(t,e,r,{type:yg});Tn(t,n);let i=Zi(t,e,n,r,ti(t,e,r)),s=Pf(t,e,r.separator,r);return Eg(t,e,r,i,s)}function rA(t,e,r){let n=st(t,e,r,{type:yn});Tn(t,n);let i=I(r.definition,a=>vg(t,e,a));return Zi(t,e,n,r,...i)}function nA(t,e,r){let n=st(t,e,r,{type:yn});Tn(t,n);let i=Zi(t,e,n,r,ti(t,e,r));return iA(t,e,r,i)}function ti(t,e,r){let n=ct(I(r.definition,i=>vg(t,e,i)),i=>i!==void 0);return n.length===1?n[0]:n.length===0?void 0:aA(t,n)}function Eg(t,e,r,n,i){let s=n.left,a=n.right,o=st(t,e,r,{type:XE});Tn(t,o);let c=st(t,e,r,{type:Rg});return s.loopback=o,c.loopback=o,t.decisionMap[ei(e,i?"RepetitionMandatoryWithSeparator":"RepetitionMandatory",r.idx)]=o,Ye(a,o),i===void 0?(Ye(o,s),Ye(o,c)):(Ye(o,c),Ye(o,i.left),Ye(i.right,s)),{left:s,right:c}}function Ag(t,e,r,n,i){let s=n.left,a=n.right,o=st(t,e,r,{type:YE});Tn(t,o);let c=st(t,e,r,{type:Rg}),l=st(t,e,r,{type:HE});return o.loopback=l,c.loopback=l,Ye(o,s),Ye(o,c),Ye(a,l),i!==void 0?(Ye(l,c),Ye(l,i.left),Ye(i.right,s)):Ye(l,o),t.decisionMap[ei(e,i?"RepetitionWithSeparator":"Repetition",r.idx)]=o,{left:o,right:c}}function iA(t,e,r,n){let i=n.left,s=n.right;return Ye(i,s),t.decisionMap[ei(e,"Option",r.idx)]=i,n}function Tn(t,e){return t.decisionStates.push(e),e.decision=t.decisionStates.length-1,e.decision}function Zi(t,e,r,n,...i){let s=st(t,e,n,{type:KE,start:r});r.end=s;for(let o of i)o!==void 0?(Ye(r,o.left),Ye(o.right,s)):Ye(r,s);let a={left:r,right:s};return t.decisionMap[ei(e,sA(n),n.idx)]=r,a}function sA(t){if(t instanceof xe)return"Alternation";if(t instanceof he)return"Option";if(t instanceof se)return"Repetition";if(t instanceof Re)return"RepetitionWithSeparator";if(t instanceof Ae)return"RepetitionMandatory";if(t instanceof $e)return"RepetitionMandatoryWithSeparator";throw new Error("Invalid production type encountered")}function aA(t,e){let r=e.length;for(let s=0;s<r-1;s++){let a=e[s],o;a.left.transitions.length===1&&(o=a.left.transitions[0]);let c=o instanceof Ji,l=o,u=e[s+1].left;a.left.type===yn&&a.right.type===yn&&o!==void 0&&(c&&l.followState===a.right||o.target===a.right)?(c?l.followState=u:o.target=u,lA(t,a.right)):Ye(a.right,u)}let n=e[0],i=e[r-1];return{left:n.left,right:i.right}}function Pf(t,e,r,n){let i=st(t,e,n,{type:yn}),s=st(t,e,n,{type:yn});return Of(i,new Xi(s,r)),{left:i,right:s}}function oA(t,e,r){let n=r.referencedRule,i=t.ruleToStartState.get(n),s=st(t,e,r,{type:yn}),a=st(t,e,r,{type:yn}),o=new Ji(i,n,a);return Of(s,o),{left:s,right:a}}function cA(t,e,r){let n=t.ruleToStartState.get(e);Ye(n,r.left);let i=t.ruleToStopState.get(e);return Ye(r.right,i),{left:n,right:i}}function Ye(t,e){let r=new ba(e);Of(t,r)}function st(t,e,r,n){let i=Object.assign({atn:t,production:r,epsilonOnlyTransitions:!1,rule:e,transitions:[],nextTokenWithinRule:[],stateNumber:t.states.length},n);return t.states.push(i),i}function Of(t,e){t.transitions.length===0&&(t.epsilonOnlyTransitions=e.isEpsilon()),t.transitions.push(e)}function lA(t,e){t.states.splice(t.states.indexOf(e),1)}var Pa={},es=class{constructor(){this.map={},this.configs=[]}get size(){return this.configs.length}finalize(){this.map={}}add(e){let r=Lf(e);r in this.map||(this.map[r]=this.configs.length,this.configs.push(e))}get elements(){return this.configs}get alts(){return I(this.configs,e=>e.alt)}get key(){let e="";for(let r in this.map)e+=r+":";return e}};function Lf(t,e=!0){return`${e?`a${t.alt}`:""}s${t.state.stateNumber}:${t.stack.map(r=>r.stateNumber.toString()).join("_")}`}function uA(t,e){let r={};return n=>{let i=n.toString(),s=r[i];return s!==void 0||(s={atnStartState:t,decision:e,states:{}},r[i]=s),s}}var Kc=class{constructor(){this.predicates=[]}is(e){return e>=this.predicates.length||this.predicates[e]}set(e,r){this.predicates[e]=r}toString(){let e="",r=this.predicates.length;for(let n=0;n<r;n++)e+=this.predicates[n]===!0?"1":"0";return e}},$g=new Kc,Oa=class extends Yr{constructor(e){var r;super(),this.logging=(r=e?.logging)!==null&&r!==void 0?r:n=>console.log(n)}initialize(e){this.atn=xg(e.rules),this.dfas=fA(this.atn)}validateAmbiguousAlternationAlternatives(){return[]}validateEmptyOrAlternatives(){return[]}buildLookaheadForAlternation(e){let{prodOccurrence:r,rule:n,hasPredicates:i,dynamicTokensEnabled:s}=e,a=this.dfas,o=this.logging,c=ei(n,"Alternation",r),u=this.atn.decisionMap[c].decision,p=I(kc({maxLookahead:1,occurrence:r,prodType:"Alternation",rule:n}),h=>I(h,g=>g[0]));if(Sg(p,!1)&&!s){let h=Ue(p,(g,C,k)=>(D(C,G=>{G&&(g[G.tokenTypeIdx]=k,D(G.categoryMatches,M=>{g[M]=k}))}),g),{});return i?function(g){var C;let k=this.LA(1),G=h[k.tokenTypeIdx];if(g!==void 0&&G!==void 0){let M=(C=g[G])===null||C===void 0?void 0:C.GATE;if(M!==void 0&&M.call(this)===!1)return}return G}:function(){let g=this.LA(1);return h[g.tokenTypeIdx]}}else return i?function(h){let g=new Kc,C=h===void 0?0:h.length;for(let G=0;G<C;G++){let M=h?.[G].GATE;g.set(G,M===void 0||M.call(this))}let k=Df.call(this,a,u,g,o);return typeof k=="number"?k:void 0}:function(){let h=Df.call(this,a,u,$g,o);return typeof h=="number"?h:void 0}}buildLookaheadForOptional(e){let{prodOccurrence:r,rule:n,prodType:i,dynamicTokensEnabled:s}=e,a=this.dfas,o=this.logging,c=ei(n,i,r),u=this.atn.decisionMap[c].decision,p=I(kc({maxLookahead:1,occurrence:r,prodType:i,rule:n}),h=>I(h,g=>g[0]));if(Sg(p)&&p[0][0]&&!s){let h=p[0],g=Ve(h);if(g.length===1&&Z(g[0].categoryMatches)){let k=g[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===k}}else{let C=Ue(g,(k,G)=>(G!==void 0&&(k[G.tokenTypeIdx]=!0,D(G.categoryMatches,M=>{k[M]=!0})),k),{});return function(){let k=this.LA(1);return C[k.tokenTypeIdx]===!0}}}return function(){let h=Df.call(this,a,u,$g,o);return typeof h=="object"?!1:h===0}}};function Sg(t,e=!0){let r=new Set;for(let n of t){let i=new Set;for(let s of n){if(s===void 0){if(e)break;return!1}let a=[s.tokenTypeIdx].concat(s.categoryMatches);for(let o of a)if(r.has(o)){if(!i.has(o))return!1}else r.add(o),i.add(o)}}return!0}function fA(t){let e=t.decisionStates.length,r=Array(e);for(let n=0;n<e;n++)r[n]=uA(t.decisionStates[n],n);return r}function Df(t,e,r,n){let i=t[e](r),s=i.start;if(s===void 0){let o=EA(i.atnStartState);s=Cg(i,Ng(o)),i.start=s}return dA.apply(this,[i,s,r,n])}function dA(t,e,r,n){let i=e,s=1,a=[],o=this.LA(s++);for(;;){let c=TA(i,o);if(c===void 0&&(c=pA.apply(this,[t,i,o,s,r,n])),c===Pa)return yA(a,i,o);if(c.isAcceptState===!0)return c.prediction;i=c,a.push(o),o=this.LA(s++)}}function pA(t,e,r,n,i,s){let a=RA(e.configs,r,i);if(a.size===0)return kg(t,e,r,Pa),Pa;let o=Ng(a),c=vA(a,i);if(c!==void 0)o.isAcceptState=!0,o.prediction=c,o.configs.uniqueAlt=c;else if(kA(a)){let l=qh(a.alts);o.isAcceptState=!0,o.prediction=l,o.configs.uniqueAlt=l,hA.apply(this,[t,n,a.alts,s])}return o=kg(t,e,r,o),o}function hA(t,e,r,n){let i=[];for(let l=1;l<=e;l++)i.push(this.LA(l).tokenType);let s=t.atnStartState,a=s.rule,o=s.production,c=mA({topLevelRule:a,ambiguityIndices:r,production:o,prefixPath:i});n(c)}function mA(t){let e=I(t.prefixPath,i=>Vr(i)).join(", "),r=t.production.idx===0?"":t.production.idx,n=`Ambiguous Alternatives Detected: <${t.ambiguityIndices.join(", ")}> in <${gA(t.production)}${r}> inside <${t.topLevelRule.name}> Rule,
148<${e}> may appears as a prefix path in all these alternatives.
149`;return n=n+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
150For Further details.`,n}function gA(t){if(t instanceof pe)return"SUBRULE";if(t instanceof he)return"OPTION";if(t instanceof xe)return"OR";if(t instanceof Ae)return"AT_LEAST_ONE";if(t instanceof $e)return"AT_LEAST_ONE_SEP";if(t instanceof Re)return"MANY_SEP";if(t instanceof se)return"MANY";if(t instanceof te)return"CONSUME";throw Error("non exhaustive match")}function yA(t,e,r){let n=ht(e.configs.elements,s=>s.state.transitions),i=zh(n.filter(s=>s instanceof Xi).map(s=>s.tokenType),s=>s.tokenTypeIdx);return{actualToken:r,possibleTokenTypes:i,tokenPath:t}}function TA(t,e){return t.edges[e.tokenTypeIdx]}function RA(t,e,r){let n=new es,i=[];for(let a of t.elements){if(r.is(a.alt)===!1)continue;if(a.state.type===Qi){i.push(a);continue}let o=a.state.transitions.length;for(let c=0;c<o;c++){let l=a.state.transitions[c],u=xA(l,e);u!==void 0&&n.add({state:u,alt:a.alt,stack:a.stack})}}let s;if(i.length===0&&n.size===1&&(s=n),s===void 0){s=new es;for(let a of n.elements)Hc(a,s)}if(i.length>0&&!$A(s))for(let a of i)s.add(a);return s}function xA(t,e){if(t instanceof Xi&&xa(e,t.tokenType))return t.target}function vA(t,e){let r;for(let n of t.elements)if(e.is(n.alt)===!0){if(r===void 0)r=n.alt;else if(r!==n.alt)return}return r}function Ng(t){return{configs:t,edges:{},isAcceptState:!1,prediction:-1}}function kg(t,e,r,n){return n=Cg(t,n),e.edges[r.tokenTypeIdx]=n,n}function Cg(t,e){if(e===Pa)return e;let r=e.configs.key,n=t.states[r];return n!==void 0?n:(e.configs.finalize(),t.states[r]=e,e)}function EA(t){let e=new es,r=t.transitions.length;for(let n=0;n<r;n++){let s={state:t.transitions[n].target,alt:n,stack:[]};Hc(s,e)}return e}function Hc(t,e){let r=t.state;if(r.type===Qi){if(t.stack.length>0){let i=[...t.stack],a={state:i.pop(),alt:t.alt,stack:i};Hc(a,e)}else e.add(t);return}r.epsilonOnlyTransitions||e.add(t);let n=r.transitions.length;for(let i=0;i<n;i++){let s=r.transitions[i],a=AA(t,s);a!==void 0&&Hc(a,e)}}function AA(t,e){if(e instanceof ba)return{state:e.target,alt:t.alt,stack:t.stack};if(e instanceof Ji){let r=[...t.stack,e.followState];return{state:e.target,alt:t.alt,stack:r}}}function $A(t){for(let e of t.elements)if(e.state.type===Qi)return!0;return!1}function SA(t){for(let e of t.elements)if(e.state.type!==Qi)return!1;return!0}function kA(t){if(SA(t))return!0;let e=NA(t.elements);return CA(e)&&!wA(e)}function NA(t){let e=new Map;for(let r of t){let n=Lf(r,!1),i=e.get(n);i===void 0&&(i={},e.set(n,i)),i[r.alt]=!0}return e}function CA(t){for(let e of Array.from(t.values()))if(Object.keys(e).length>1)return!0;return!1}function wA(t){for(let e of Array.from(t.values()))if(Object.keys(e).length===1)return!0;return!1}as();var qa=class{constructor(){this.nodeStack=[]}get current(){return this.nodeStack[this.nodeStack.length-1]??this.rootNode}buildRootNode(e){return this.rootNode=new os(e),this.rootNode.root=this.rootNode,this.nodeStack=[this.rootNode],this.rootNode}buildCompositeNode(e){let r=new si;return r.grammarSource=e,r.root=this.rootNode,this.current.content.push(r),this.nodeStack.push(r),r}buildLeafNode(e,r){let n=new ii(e.startOffset,e.image.length,Pi(e),e.tokenType,!r);return n.grammarSource=r,n.root=this.rootNode,this.current.content.push(n),n}removeNode(e){let r=e.container;if(r){let n=r.content.indexOf(e);n>=0&&r.content.splice(n,1)}}addHiddenNodes(e){let r=[];for(let s of e){let a=new ii(s.startOffset,s.image.length,Pi(s),s.tokenType,!0);a.root=this.rootNode,r.push(a)}let n=this.current,i=!1;if(n.content.length>0){n.content.push(...r);return}for(;n.container;){let s=n.container.content.indexOf(n);if(s>0){n.container.content.splice(s,0,...r),i=!0;break}n=n.container}i||this.rootNode.content.unshift(...r)}construct(e){let r=this.current;typeof e.$type=="string"&&!e.$infixName&&(this.current.astNode=e),e.$cstNode=r;let n=this.nodeStack.pop();n?.content.length===0&&this.removeNode(n)}},za=class{get hidden(){return!1}get astNode(){let e=typeof this._astNode?.$type=="string"?this._astNode:this.container?.astNode;if(!e)throw new Error("This node has no associated AST element");return e}set astNode(e){this._astNode=e}get text(){return this.root.fullText.substring(this.offset,this.end)}},ii=class extends za{get offset(){return this._offset}get length(){return this._length}get end(){return this._offset+this._length}get hidden(){return this._hidden}get tokenType(){return this._tokenType}get range(){return this._range}constructor(e,r,n,i,s=!1){super(),this._hidden=s,this._offset=e,this._tokenType=i,this._length=r,this._range=n}},si=class extends za{constructor(){super(...arguments),this.content=new Sd(this)}get offset(){return this.firstNonHiddenNode?.offset??0}get length(){return this.end-this.offset}get end(){return this.lastNonHiddenNode?.end??0}get range(){let e=this.firstNonHiddenNode,r=this.lastNonHiddenNode;if(e&&r){if(this._rangeCache===void 0){let{range:n}=e,{range:i}=r;this._rangeCache={start:n.start,end:i.end.line<n.start.line?n.start:i.end}}return this._rangeCache}else return{start:ce.create(0,0),end:ce.create(0,0)}}get firstNonHiddenNode(){for(let e of this.content)if(!e.hidden)return e;return this.content[0]}get lastNonHiddenNode(){for(let e=this.content.length-1;e>=0;e--){let r=this.content[e];if(!r.hidden)return r}return this.content[this.content.length-1]}},Sd=class t extends Array{constructor(e){super(),this.parent=e,Object.setPrototypeOf(this,t.prototype)}push(...e){return this.addParents(e),super.push(...e)}unshift(...e){return this.addParents(e),super.unshift(...e)}splice(e,r,...n){return this.addParents(n),super.splice(e,r,...n)}addParents(e){for(let r of e)r.container=this.parent}},os=class extends si{get text(){return this._text.substring(this.offset,this.end)}get fullText(){return this._text}constructor(e){super(),this._text="",this._text=e??""}};var sl=Symbol("Datatype");function kd(t){return t.$type===sl}var jg="\u200B",Bg=t=>t.endsWith(jg)?t:t+jg,ja=class{constructor(e){this._unorderedGroups=new Map,this.allRules=new Map,this.lexer=e.parser.Lexer;let r=this.lexer.definition,n=e.LanguageMetaData.mode==="production";e.shared.profilers.LangiumProfiler?.isActive("parsing")?this.wrapper=new Nd(r,er(ge({},e.parser.ParserConfig),{skipValidations:n,errorMessageProvider:e.parser.ParserErrorMessageProvider}),e.shared.profilers.LangiumProfiler.createTask("parsing",e.LanguageMetaData.languageId)):this.wrapper=new ol(r,er(ge({},e.parser.ParserConfig),{skipValidations:n,errorMessageProvider:e.parser.ParserErrorMessageProvider}))}alternatives(e,r){this.wrapper.wrapOr(e,r)}optional(e,r){this.wrapper.wrapOption(e,r)}many(e,r){this.wrapper.wrapMany(e,r)}atLeastOne(e,r){this.wrapper.wrapAtLeastOne(e,r)}getRule(e){return this.allRules.get(e)}isRecording(){return this.wrapper.IS_RECORDING}get unorderedGroups(){return this._unorderedGroups}getRuleStack(){return this.wrapper.RULE_STACK}finalize(){this.wrapper.wrapSelfAnalysis()}},Ba=class extends ja{get current(){return this.stack[this.stack.length-1]}constructor(e){super(e),this.nodeBuilder=new qa,this.stack=[],this.assignmentMap=new Map,this.operatorPrecedence=new Map,this.linker=e.references.Linker,this.converter=e.parser.ValueConverter,this.astReflection=e.shared.AstReflection}rule(e,r){let n=this.computeRuleType(e),i;dn(e)&&(i=e.name,this.registerPrecedenceMap(e));let s=this.wrapper.DEFINE_RULE(Bg(e.name),this.startImplementation(n,i,r).bind(this));return this.allRules.set(e.name,s),nt(e)&&e.entry&&(this.mainRule=s),s}registerPrecedenceMap(e){let r=e.name,n=new Map;for(let i=0;i<e.operators.precedences.length;i++){let s=e.operators.precedences[i];for(let a of s.operators)n.set(a.value,{precedence:i,rightAssoc:s.associativity==="right"})}this.operatorPrecedence.set(r,n)}computeRuleType(e){return dn(e)?hn(e):e.fragment?void 0:ha(e)?sl:hn(e)}parse(e,r={}){this.nodeBuilder.buildRootNode(e);let n=this.lexerResult=this.lexer.tokenize(e);this.wrapper.input=n.tokens;let i=r.rule?this.allRules.get(r.rule):this.mainRule;if(!i)throw new Error(r.rule?`No rule found with name '${r.rule}'`:"No main rule available.");let s=this.doParse(i);return this.nodeBuilder.addHiddenNodes(n.hidden),this.unorderedGroups.clear(),this.lexerResult=void 0,Ai(s,{deep:!0}),{value:s,lexerErrors:n.errors,lexerReport:n.report,parserErrors:this.wrapper.errors}}doParse(e){let r=this.wrapper.rule(e);if(this.stack.length>0&&(r=this.construct()),r===void 0)throw new Error("No result from parser");if(this.stack.length>0)throw new Error("Parser stack is not empty after parsing");return r}startImplementation(e,r,n){return i=>{let s=!this.isRecording()&&e!==void 0;if(s){let a={$type:e};this.stack.push(a),e===sl?a.value="":r!==void 0&&(a.$infixName=r)}return n(i),s?this.construct():void 0}}extractHiddenTokens(e){let r=this.lexerResult.hidden;if(!r.length)return[];let n=e.startOffset;for(let i=0;i<r.length;i++)if(r[i].startOffset>n)return r.splice(0,i);return r.splice(0,r.length)}consume(e,r,n){let i=this.wrapper.wrapConsume(e,r);if(!this.isRecording()&&this.isValidToken(i)){let s=this.extractHiddenTokens(i);this.nodeBuilder.addHiddenNodes(s);let a=this.nodeBuilder.buildLeafNode(i,n),{assignment:o,crossRef:c}=this.getAssignment(n),l=this.current;if(o){let u=Ht(n)?i.image:this.converter.convert(i.image,a);this.assign(o.operator,o.feature,u,a,c)}else if(kd(l)){let u=i.image;Ht(n)||(u=this.converter.convert(u,a).toString()),l.value+=u}}}isValidToken(e){return!e.isInsertedInRecovery&&!isNaN(e.startOffset)&&typeof e.endOffset=="number"&&!isNaN(e.endOffset)}subrule(e,r,n,i,s){let a;!this.isRecording()&&!n&&(a=this.nodeBuilder.buildCompositeNode(i));let o;try{o=this.wrapper.wrapSubrule(e,r,s)}finally{this.isRecording()||(o===void 0&&!n&&(o=this.construct()),o!==void 0&&a&&a.length>0&&this.performSubruleAssignment(o,i,a))}}performSubruleAssignment(e,r,n){let{assignment:i,crossRef:s}=this.getAssignment(r);if(i)this.assign(i.operator,i.feature,e,n,s);else if(!i){let a=this.current;if(kd(a))a.value+=e.toString();else if(typeof e=="object"&&e){let c=this.assignWithoutOverride(e,a);this.stack.pop(),this.stack.push(c)}}}action(e,r){if(!this.isRecording()){let n=this.current;if(r.feature&&r.operator){n=this.construct(),this.nodeBuilder.removeNode(n.$cstNode),this.nodeBuilder.buildCompositeNode(r).content.push(n.$cstNode);let s={$type:e};this.stack.push(s),this.assign(r.operator,r.feature,n,n.$cstNode)}else n.$type=e}}construct(){if(this.isRecording())return;let e=this.stack.pop();return this.nodeBuilder.construct(e),"$infixName"in e?this.constructInfix(e,this.operatorPrecedence.get(e.$infixName)):kd(e)?this.converter.convert(e.value,e.$cstNode):(Tu(this.astReflection,e),e)}constructInfix(e,r){let n=e.parts;if(!Array.isArray(n)||n.length===0)return;let i=e.operators;if(!Array.isArray(i)||n.length<2)return n[0];let s=0,a=-1;for(let k=0;k<i.length;k++){let G=i[k],M=r.get(G)??{precedence:1/0,rightAssoc:!1};M.precedence>a?(a=M.precedence,s=k):M.precedence===a&&(M.rightAssoc||(s=k))}let o=i.slice(0,s),c=i.slice(s+1),l=n.slice(0,s+1),u=n.slice(s+1),p={$infixName:e.$infixName,$type:e.$type,$cstNode:e.$cstNode,parts:l,operators:o},h={$infixName:e.$infixName,$type:e.$type,$cstNode:e.$cstNode,parts:u,operators:c},g=this.constructInfix(p,r),C=this.constructInfix(h,r);return{$type:e.$type,$cstNode:e.$cstNode,left:g,operator:i[s],right:C}}getAssignment(e){if(!this.assignmentMap.has(e)){let r=Dr(e,sr);this.assignmentMap.set(e,{assignment:r,crossRef:r&&ar(r.terminal)?r.terminal.isMulti?"multi":"single":void 0})}return this.assignmentMap.get(e)}assign(e,r,n,i,s){let a=this.current,o;switch(s==="single"&&typeof n=="string"?o=this.linker.buildReference(a,r,i,n):s==="multi"&&typeof n=="string"?o=this.linker.buildMultiReference(a,r,i,n):o=n,e){case"=":{a[r]=o;break}case"?=":{a[r]=!0;break}case"+=":Array.isArray(a[r])||(a[r]=[]),a[r].push(o)}}assignWithoutOverride(e,r){for(let[i,s]of Object.entries(r)){let a=e[i];a===void 0?e[i]=s:Array.isArray(a)&&Array.isArray(s)&&(s.push(...a),e[i]=s)}let n=e.$cstNode;return n&&(n.astNode=void 0,e.$cstNode=void 0),e}get definitionErrors(){return this.wrapper.definitionErrors}},al=class{buildMismatchTokenMessage(e){return Hr.buildMismatchTokenMessage(e)}buildNotAllInputParsedMessage(e){return Hr.buildNotAllInputParsedMessage(e)}buildNoViableAltMessage(e){return Hr.buildNoViableAltMessage(e)}buildEarlyExitMessage(e){return Hr.buildEarlyExitMessage(e)}},cs=class extends al{buildMismatchTokenMessage({expected:e,actual:r}){return`Expecting ${e.LABEL?"`"+e.LABEL+"`":e.name.endsWith(":KW")?`keyword '${e.name.substring(0,e.name.length-3)}'`:`token of type '${e.name}'`} but found \`${r.image}\`.`}buildNotAllInputParsedMessage({firstRedundant:e}){return`Expecting end of file but found \`${e.image}\`.`}},Wa=class extends ja{constructor(){super(...arguments),this.tokens=[],this.elementStack=[],this.lastElementStack=[],this.nextTokenIndex=0,this.stackSize=0}action(){}construct(){}parse(e){this.resetState();let r=this.lexer.tokenize(e,{mode:"partial"});return this.tokens=r.tokens,this.wrapper.input=[...this.tokens],this.mainRule.call(this.wrapper,{}),this.unorderedGroups.clear(),{tokens:this.tokens,elementStack:[...this.lastElementStack],tokenIndex:this.nextTokenIndex}}rule(e,r){let n=this.wrapper.DEFINE_RULE(Bg(e.name),this.startImplementation(r).bind(this));return this.allRules.set(e.name,n),e.entry&&(this.mainRule=n),n}resetState(){this.elementStack=[],this.lastElementStack=[],this.nextTokenIndex=0,this.stackSize=0}startImplementation(e){return r=>{let n=this.keepStackSize();try{e(r)}finally{this.resetStackSize(n)}}}removeUnexpectedElements(){this.elementStack.splice(this.stackSize)}keepStackSize(){let e=this.elementStack.length;return this.stackSize=e,e}resetStackSize(e){this.removeUnexpectedElements(),this.stackSize=e}consume(e,r,n){this.wrapper.wrapConsume(e,r),this.isRecording()||(this.lastElementStack=[...this.elementStack,n],this.nextTokenIndex=this.currIdx+1)}subrule(e,r,n,i,s){this.before(i),this.wrapper.wrapSubrule(e,r,s),this.after(i)}before(e){this.isRecording()||this.elementStack.push(e)}after(e){if(!this.isRecording()){let r=this.elementStack.lastIndexOf(e);r>=0&&this.elementStack.splice(r)}}get currIdx(){return this.wrapper.currIdx}},_A={recoveryEnabled:!0,nodeLocationTracking:"full",skipValidations:!0,errorMessageProvider:new cs},ol=class extends Ia{constructor(e,r){let n=r&&"maxLookahead"in r;super(e,ge(er(ge({},_A),{lookaheadStrategy:n?new Yr({maxLookahead:r.maxLookahead}):new Oa({logging:r.skipValidations?()=>{}:void 0})}),r))}get IS_RECORDING(){return this.RECORDING_PHASE}DEFINE_RULE(e,r,n){return this.RULE(e,r,n)}wrapSelfAnalysis(){this.performSelfAnalysis()}wrapConsume(e,r){return this.consume(e,r,void 0)}wrapSubrule(e,r,n){return this.subrule(e,r,{ARGS:[n]})}wrapOr(e,r){this.or(e,r)}wrapOption(e,r){this.option(e,r)}wrapMany(e,r){this.many(e,r)}wrapAtLeastOne(e,r){this.atLeastOne(e,r)}rule(e){return e.call(this,{})}},Nd=class extends ol{constructor(e,r,n){super(e,r),this.task=n}rule(e){this.task.start(),this.task.startSubTask(this.ruleName(e));try{return super.rule(e)}finally{this.task.stopSubTask(this.ruleName(e)),this.task.stop()}}ruleName(e){return e.ruleName}subrule(e,r,n){this.task.startSubTask(this.ruleName(r));try{return super.subrule(e,r,n)}finally{this.task.stopSubTask(this.ruleName(r))}}};function Va(t,e,r){return bA({parser:e,tokens:r,ruleNames:new Map},t),e}function bA(t,e){let r=da(e,!1),n=ee(e.rules).filter(nt).filter(s=>r.has(s));for(let s of n){let a=er(ge({},t),{consume:1,optional:1,subrule:1,many:1,or:1});t.parser.rule(s,ai(a,s.definition))}let i=ee(e.rules).filter(dn).filter(s=>r.has(s));for(let s of i)t.parser.rule(s,PA(t,s))}function PA(t,e){let r=e.call.rule.ref;if(!r)throw new Error("Could not resolve reference to infix operator rule: "+e.call.rule.$refText);if(kt(r))throw new Error("Cannot use terminal rule in infix expression");let n=e.operators.precedences.flatMap(g=>g.operators),i={$type:"Group",elements:[]},s={$container:i,$type:"Assignment",feature:"parts",operator:"+=",terminal:e.call},a={$container:i,$type:"Group",elements:[],cardinality:"*"};i.elements.push(s,a);let c={$container:a,$type:"Assignment",feature:"operators",operator:"+=",terminal:{$type:"Alternatives",elements:n}},l=er(ge({},s),{$container:a});a.elements.push(c,l);let p=n.map(g=>t.tokens[g.value]).map((g,C)=>({ALT:()=>t.parser.consume(C,g,c)})),h;return g=>{h??(h=wd(t,r)),t.parser.subrule(0,h,!1,s,g),t.parser.many(0,{DEF:()=>{t.parser.alternatives(0,p),t.parser.subrule(1,h,!1,l,g)}})}}function ai(t,e,r=!1){let n;if(Ht(e))n=UA(t,e);else if(Ur(e))n=OA(t,e);else if(sr(e))n=ai(t,e.terminal);else if(ar(e))n=Wg(t,e);else if(or(e))n=LA(t,e);else if(ec(e))n=MA(t,e);else if(ic(e))n=FA(t,e);else if(fn(e))n=GA(t,e);else if(Su(e)){let i=t.consume++;n=()=>t.parser.consume(i,Bt,e)}else throw new Vn(e.$cstNode,`Unexpected element type: ${e.$type}`);return Vg(t,r?void 0:cl(e),n,e.cardinality)}function OA(t,e){let r=hn(e);return()=>t.parser.action(r,e)}function LA(t,e){let r=e.rule.ref;if(Gr(r)){let n=t.subrule++,i=nt(r)&&r.fragment,s=e.arguments.length>0?DA(r,e.arguments):()=>({}),a;return o=>{a??(a=wd(t,r)),t.parser.subrule(n,a,i,e,s(o))}}else if(kt(r)){let n=t.consume++,i=Cd(t,r.name);return()=>t.parser.consume(n,i,e)}else if(r)Rr(r);else throw new Vn(e.$cstNode,`Undefined rule: ${e.rule.$refText}`)}function DA(t,e){if(e.some(n=>n.calledByName)){let n=e.map(i=>({parameterName:i.parameter?.ref?.name,predicate:Ar(i.value)}));return i=>{let s={};for(let{parameterName:a,predicate:o}of n)a&&(s[a]=o(i));return s}}else{let n=e.map(i=>Ar(i.value));return i=>{let s={};for(let a=0;a<n.length;a++)if(a<t.parameters.length){let o=t.parameters[a].name,c=n[a];s[o]=c(i)}return s}}}function Ar(t){if($u(t)){let e=Ar(t.left),r=Ar(t.right);return n=>e(n)||r(n)}else if(Au(t)){let e=Ar(t.left),r=Ar(t.right);return n=>e(n)&&r(n)}else if(Cu(t)){let e=Ar(t.value);return r=>!e(r)}else if(wu(t)){let e=t.parameter.ref.name;return r=>r!==void 0&&r[e]===!0}else if(vu(t)){let e=!!t.true;return()=>e}Rr(t)}function MA(t,e){if(e.elements.length===1)return ai(t,e.elements[0]);{let r=[];for(let i of e.elements){let s={ALT:ai(t,i,!0)},a=cl(i);a&&(s.GATE=Ar(a)),r.push(s)}let n=t.or++;return i=>t.parser.alternatives(n,r.map(s=>{let a={ALT:()=>s.ALT(i)},o=s.GATE;return o&&(a.GATE=()=>o(i)),a}))}}function FA(t,e){if(e.elements.length===1)return ai(t,e.elements[0]);let r=[];for(let o of e.elements){let c={ALT:ai(t,o,!0)},l=cl(o);l&&(c.GATE=Ar(l)),r.push(c)}let n=t.or++,i=(o,c)=>{let l=c.getRuleStack().join("-");return`uGroup_${o}_${l}`},s=o=>t.parser.alternatives(n,r.map((c,l)=>{let u={ALT:()=>!0},p=t.parser;u.ALT=()=>{if(c.ALT(o),!p.isRecording()){let g=i(n,p);p.unorderedGroups.get(g)||p.unorderedGroups.set(g,[]);let C=p.unorderedGroups.get(g);typeof C?.[l]>"u"&&(C[l]=!0)}};let h=c.GATE;return h?u.GATE=()=>h(o):u.GATE=()=>!p.unorderedGroups.get(i(n,p))?.[l],u})),a=Vg(t,cl(e),s,"*");return o=>{a(o),t.parser.isRecording()||t.parser.unorderedGroups.delete(i(n,t.parser))}}function GA(t,e){let r=e.elements.map(n=>ai(t,n));return n=>r.forEach(i=>i(n))}function cl(t){if(fn(t))return t.guardCondition}function Wg(t,e,r=e.terminal){if(r)if(or(r)&&nt(r.rule.ref)){let n=r.rule.ref,i=t.subrule++,s;return a=>{s??(s=wd(t,n)),t.parser.subrule(i,s,!1,e,a)}}else if(or(r)&&kt(r.rule.ref)){let n=t.consume++,i=Cd(t,r.rule.ref.name);return()=>t.parser.consume(n,i,e)}else if(Ht(r)){let n=t.consume++,i=Cd(t,r.value);return()=>t.parser.consume(n,i,e)}else throw new Error("Could not build cross reference parser");else{if(!e.type.ref)throw new Error("Could not resolve reference to type: "+e.type.$refText);let i=uc(e.type.ref)?.terminal;if(!i)throw new Error("Could not find name assignment for type: "+hn(e.type.ref));return Wg(t,e,i)}}function UA(t,e){let r=t.consume++,n=t.tokens[e.value];if(!n)throw new Error("Could not find token for keyword: "+e.value);return()=>t.parser.consume(r,n,e)}function Vg(t,e,r,n){let i=e&&Ar(e);if(!n)if(i){let s=t.or++;return a=>t.parser.alternatives(s,[{ALT:()=>r(a),GATE:()=>i(a)},{ALT:Vc(),GATE:()=>!i(a)}])}else return r;if(n==="*"){let s=t.many++;return a=>t.parser.many(s,{DEF:()=>r(a),GATE:i?()=>i(a):void 0})}else if(n==="+"){let s=t.many++;if(i){let a=t.or++;return o=>t.parser.alternatives(a,[{ALT:()=>t.parser.atLeastOne(s,{DEF:()=>r(o)}),GATE:()=>i(o)},{ALT:Vc(),GATE:()=>!i(o)}])}else return a=>t.parser.atLeastOne(s,{DEF:()=>r(a)})}else if(n==="?"){let s=t.optional++;return a=>t.parser.optional(s,{DEF:()=>r(a),GATE:i?()=>i(a):void 0})}else Rr(n)}function wd(t,e){let r=qA(t,e),n=t.parser.getRule(r);if(!n)throw new Error(`Rule "${r}" not found."`);return n}function qA(t,e){if(Gr(e))return e.name;if(t.ruleNames.has(e))return t.ruleNames.get(e);{let r=e,n=r.$container,i=e.$type;for(;!nt(n);)(fn(n)||ec(n)||ic(n))&&(i=n.elements.indexOf(r).toString()+":"+i),r=n,n=n.$container;return i=n.name+":"+i,t.ruleNames.set(e,i),i}}function Cd(t,e){let r=t.tokens[e];if(!r)throw new Error(`Token "${e}" not found."`);return r}function Id(t){let e=t.Grammar,r=t.parser.Lexer,n=new Wa(t);return Va(e,n,r.definition),n.finalize(),n}function _d(t){let e=Kg(t);return e.finalize(),e}function Kg(t){let e=t.Grammar,r=t.parser.Lexer,n=new Ba(t);return Va(e,n,r.definition)}var Jr=class{constructor(){this.diagnostics=[]}buildTokens(e,r){let n=ee(da(e,!1)),i=this.buildTerminalTokens(n),s=this.buildKeywordTokens(n,i,r);return s.push(...i),s}flushLexingReport(e){return{diagnostics:this.popDiagnostics()}}popDiagnostics(){let e=[...this.diagnostics];return this.diagnostics=[],e}buildTerminalTokens(e){return e.filter(kt).filter(r=>!r.fragment).map(r=>this.buildTerminalToken(r)).toArray()}buildTerminalToken(e){let r=Li(e),n=this.requiresCustomPattern(r)?this.regexPatternFunction(r):r,i={name:e.name,PATTERN:n};return typeof n=="function"&&(i.LINE_BREAKS=!0),e.hidden&&(i.GROUP=fa(r)?He.SKIPPED:"hidden"),i}requiresCustomPattern(e){return!!(e.flags.includes("u")||e.flags.includes("s"))}regexPatternFunction(e){let r=new RegExp(e,e.flags+"y");return(n,i)=>(r.lastIndex=i,r.exec(n))}buildKeywordTokens(e,r,n){return e.filter(Gr).flatMap(i=>nr(i).filter(Ht)).distinct(i=>i.value).toArray().sort((i,s)=>s.value.length-i.value.length).map(i=>this.buildKeywordToken(i,r,!!n?.caseInsensitive))}buildKeywordToken(e,r,n){let i=this.buildKeywordPattern(e,n),s={name:e.value,PATTERN:i,LONGER_ALT:this.findLongerAlt(e,r)};return typeof i=="function"&&(s.LINE_BREAKS=!0),s}buildKeywordPattern(e,r){return r?new RegExp(pn(e.value),"i"):e.value}findLongerAlt(e,r){return r.reduce((n,i)=>{let s=i?.PATTERN;return s?.source&&Ku("^"+s.source+"$",e.value)&&n.push(i),n},[])}};var oi=class{convert(e,r){let n=r.grammarSource;if(ar(n)&&(n=Xu(n)),or(n)){let i=n.rule.ref;if(!i)throw new Error("This cst node was not parsed by a rule.");return this.runConverter(i,e,r)}return e}runConverter(e,r,n){switch(e.name.toUpperCase()){case"INT":return $r.convertInt(r);case"STRING":return $r.convertString(r);case"ID":return $r.convertID(r)}switch(nf(e)?.toLowerCase()){case"number":return $r.convertNumber(r);case"boolean":return $r.convertBoolean(r);case"bigint":return $r.convertBigint(r);case"date":return $r.convertDate(r);default:return r}}},$r;(function(t){function e(l){let u="";for(let p=1;p<l.length-1;p++){let h=l.charAt(p);if(h==="\\"){let g=l.charAt(++p);u+=r(g)}else u+=h}return u}t.convertString=e;function r(l){switch(l){case"b":return"\b";case"f":return"\f";case"n":return`

Callers 15

nextIdMethod · 0.45
writeMethod · 0.45
tryReadHeadersMethod · 0.45
LFunction · 0.45
OFunction · 0.45
TFunction · 0.45
fuFunction · 0.45
o$Function · 0.45
svFunction · 0.45
VuFunction · 0.45
GiFunction · 0.45
fmFunction · 0.45

Calls 2

trimMethod · 0.80
bxFunction · 0.70

Tested by

no test coverage detected