import{Parser,NodeSet,NodeType,DefaultBufferLength,NodeProp,Tree,IterMode}from"@lezer/common";class Stack{constructor(p,stack,state,reducePos,pos,score,buffer,bufferBase,curContext,lookAhead=0,parent){this.p=p;this.stack=stack;this.state=state;this.reducePos=reducePos;this.pos=pos;this.score=score;this.buffer=buffer;this.bufferBase=bufferBase;this.curContext=curContext;this.lookAhead=lookAhead;this.parent=parent}toString(){return`[${this.stack.filter((_,i)=>i%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(p,state,pos=0){let cx=p.parser.context;return new Stack(p,[],state,pos,pos,0,[],0,cx?new StackContext(cx,cx.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(state,start){this.stack.push(this.state,start,this.bufferBase+this.buffer.length);this.state=state}reduce(action){let depth=action>>19,type=action&65535;let{parser}=this.p;let dPrec=parser.dynamicPrecedence(type);if(dPrec)this.score+=dPrec;if(depth==0){this.pushState(parser.getGoto(this.state,type,true),this.reducePos);if(typebase)this.stack.pop();this.reduceContext(type,start)}storeNode(term,start,end,size=4,isReduce=false){if(term==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&cur.buffer[top-4]==0&&cur.buffer[top-1]>-1){if(start==end)return;if(cur.buffer[top-2]>=start){cur.buffer[top-2]=end;return}}}if(!isReduce||this.pos==end){this.buffer.push(term,start,end,size)}else{let index=this.buffer.length;if(index>0&&this.buffer[index-4]!=0)while(index>0&&this.buffer[index-2]>end){this.buffer[index]=this.buffer[index-4];this.buffer[index+1]=this.buffer[index-3];this.buffer[index+2]=this.buffer[index-2];this.buffer[index+3]=this.buffer[index-1];index-=4;if(size>4)size-=4}this.buffer[index]=term;this.buffer[index+1]=start;this.buffer[index+2]=end;this.buffer[index+3]=size}}shift(action,next,nextEnd){let start=this.pos;if(action&131072){this.pushState(action&65535,this.pos)}else if((action&262144)==0){let nextState=action,{parser}=this.p;if(nextEnd>this.pos||next<=parser.maxNode){this.pos=nextEnd;if(!parser.stateFlag(nextState,1))this.reducePos=nextEnd}this.pushState(nextState,start);this.shiftContext(next,start);if(next<=parser.maxNode)this.buffer.push(next,start,nextEnd,4)}else{this.pos=nextEnd;this.shiftContext(next,start);if(next<=this.p.parser.maxNode)this.buffer.push(next,start,nextEnd,4)}}apply(action,next,nextEnd){if(action&65536)this.reduce(action);else this.shift(action,next,nextEnd)}useNode(value,next){let index=this.p.reused.length-1;if(index<0||this.p.reused[index]!=value){this.p.reused.push(value);index++}let start=this.pos;this.reducePos=this.pos=start+value.length;this.pushState(next,start);this.buffer.push(index,start,this.reducePos,-1);if(this.curContext)this.updateContext(this.curContext.tracker.reuse(this.curContext.context,value,this,this.p.stream.reset(this.pos-value.length)))}split(){let parent=this;let off=parent.buffer.length;while(off>0&&parent.buffer[off-2]>parent.reducePos)off-=4;let buffer=parent.buffer.slice(off),base=parent.bufferBase+off;while(parent&&base==parent.bufferBase)parent=parent.parent;return new Stack(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,buffer,base,this.curContext,this.lookAhead,parent)}recoverByDelete(next,nextEnd){let isNode=next<=this.p.parser.maxNode;if(isNode)this.storeNode(next,this.pos,nextEnd,4);this.storeNode(0,this.pos,nextEnd,isNode?8:4);this.pos=this.reducePos=nextEnd;this.score-=190}canShift(term){for(let sim=new SimulatedStack(this);;){let action=this.p.parser.stateSlot(sim.state,4)||this.p.parser.hasAction(sim.state,term);if((action&65536)==0)return true;if(action==0)return false;sim.reduce(action)}}recoverByInsert(next){if(this.stack.length>=300)return[];let nextStates=this.p.parser.nextStates(this.state);if(nextStates.length>4<<1||this.stack.length>=120){let best=[];for(let i=0,s;ii&1&&v==s))best.push(nextStates[i],s)}nextStates=best}let result=[];for(let i=0;i>19,term=reduce&65535;let target=this.stack.length-depth*3;if(target<0||parser.getGoto(this.stack[target],term,false)<0)return false;this.storeNode(0,this.reducePos,this.reducePos,4,true);this.score-=100}this.reducePos=this.pos;this.reduce(reduce);return true}forceAll(){while(!this.p.parser.stateFlag(this.state,2)){if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,true);break}}return this}get deadEnd(){if(this.stack.length!=3)return false;let{parser}=this.p;return parser.data[parser.stateSlot(this.state,1)]==65535&&!parser.stateSlot(this.state,4)}restart(){this.state=this.stack[0];this.stack.length=0}sameState(other){if(this.state!=other.state||this.stack.length!=other.stack.length)return false;for(let i=0;ithis.lookAhead){this.emitLookAhead();this.lookAhead=lookAhead}}close(){if(this.curContext&&this.curContext.tracker.strict)this.emitContext();if(this.lookAhead>0)this.emitLookAhead()}}class StackContext{constructor(tracker,context){this.tracker=tracker;this.context=context;this.hash=tracker.strict?tracker.hash(context):0}}var Recover;(function(Recover){Recover[Recover["Insert"]=200]="Insert";Recover[Recover["Delete"]=190]="Delete";Recover[Recover["Reduce"]=100]="Reduce";Recover[Recover["MaxNext"]=4]="MaxNext";Recover[Recover["MaxInsertStackDepth"]=300]="MaxInsertStackDepth";Recover[Recover["DampenInsertStackDepth"]=120]="DampenInsertStackDepth"})(Recover||(Recover={}));class SimulatedStack{constructor(start){this.start=start;this.state=start.state;this.stack=start.stack;this.base=this.stack.length}reduce(action){let term=action&65535,depth=action>>19;if(depth==0){if(this.stack==this.start.stack)this.stack=this.stack.slice();this.stack.push(this.state,0,0);this.base+=3}else{this.base-=(depth-1)*3}let goto=this.start.p.parser.getGoto(this.stack[this.base-3],term,true);this.state=goto}}class StackBufferCursor{constructor(stack,pos,index){this.stack=stack;this.pos=pos;this.index=index;this.buffer=stack.buffer;if(this.index==0)this.maybeNext()}static create(stack,pos=stack.bufferBase+stack.buffer.length){return new StackBufferCursor(stack,pos,pos-stack.bufferBase)}maybeNext(){let next=this.stack.parent;if(next!=null){this.index=this.stack.bufferBase-next.bufferBase;this.stack=next;this.buffer=next.buffer}}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4;this.pos-=4;if(this.index==0)this.maybeNext()}fork(){return new StackBufferCursor(this.stack,this.pos,this.index)}}class CachedToken{constructor(){this.start=-1;this.value=-1;this.end=-1;this.extended=-1;this.lookAhead=0;this.mask=0;this.context=0}}const nullToken=new CachedToken;class InputStream{constructor(input,ranges){this.input=input;this.ranges=ranges;this.chunk="";this.chunkOff=0;this.chunk2="";this.chunk2Pos=0;this.next=-1;this.token=nullToken;this.rangeIndex=0;this.pos=this.chunkPos=ranges[0].from;this.range=ranges[0];this.end=ranges[ranges.length-1].to;this.readNext()}resolveOffset(offset,assoc){let range=this.range,index=this.rangeIndex;let pos=this.pos+offset;while(posrange.to:pos>=range.to){if(index==this.ranges.length-1)return null;let next=this.ranges[++index];pos+=next.from-range.to;range=next}return pos}clipPos(pos){if(pos>=this.range.from&&pospos)return Math.max(pos,range.from);return this.end}peek(offset){let idx=this.chunkOff+offset,pos,result;if(idx>=0&&idx=this.chunk2Pos&&posrange.to)this.chunk2=this.chunk2.slice(0,range.to-pos);result=this.chunk2.charCodeAt(0)}}if(pos>=this.token.lookAhead)this.token.lookAhead=pos+1;return result}acceptToken(token,endOffset=0){let end=endOffset?this.resolveOffset(endOffset,-1):this.pos;if(end==null||end=this.chunk2Pos&&this.posthis.range.to?nextChunk.slice(0,this.range.to-this.pos):nextChunk;this.chunkPos=this.pos;this.chunkOff=0}}readNext(){if(this.chunkOff>=this.chunk.length){this.getChunk();if(this.chunkOff==this.chunk.length)return this.next=-1}return this.next=this.chunk.charCodeAt(this.chunkOff)}advance(n=1){this.chunkOff+=n;while(this.pos+n>=this.range.to){if(this.rangeIndex==this.ranges.length-1)return this.setDone();n-=this.range.to-this.pos;this.range=this.ranges[++this.rangeIndex];this.pos=this.range.from}this.pos+=n;if(this.pos>=this.token.lookAhead)this.token.lookAhead=this.pos+1;return this.readNext()}setDone(){this.pos=this.chunkPos=this.end;this.range=this.ranges[this.rangeIndex=this.ranges.length-1];this.chunk="";return this.next=-1}reset(pos,token){if(token){this.token=token;token.start=pos;token.lookAhead=pos+1;token.value=token.extended=-1}else{this.token=nullToken}if(this.pos!=pos){this.pos=pos;if(pos==this.end){this.setDone();return this}while(pos=this.range.to)this.range=this.ranges[++this.rangeIndex];if(pos>=this.chunkPos&&pos=this.chunkPos&&to<=this.chunkPos+this.chunk.length)return this.chunk.slice(from-this.chunkPos,to-this.chunkPos);if(from>=this.chunk2Pos&&to<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(from-this.chunk2Pos,to-this.chunk2Pos);if(from>=this.range.from&&to<=this.range.to)return this.input.read(from,to);let result="";for(let r of this.ranges){if(r.from>=to)break;if(r.to>from)result+=this.input.read(Math.max(r.from,from),Math.min(r.to,to))}return result}}class TokenGroup{constructor(data,id){this.data=data;this.id=id}token(input,stack){readToken(this.data,input,stack,this.id)}}TokenGroup.prototype.contextual=TokenGroup.prototype.fallback=TokenGroup.prototype.extend=false;class ExternalTokenizer{constructor(token,options={}){this.token=token;this.contextual=!!options.contextual;this.fallback=!!options.fallback;this.extend=!!options.extend}}function readToken(data,input,stack,group){let state=0,groupMask=1<0){let term=data[i];if(dialect.allows(term)&&(input.token.value==-1||input.token.value==term||parser.overrides(term,input.token.value))){input.acceptToken(term);break}}let next=input.next,low=0,high=data[state+2];if(input.next<0&&high>low&&data[accEnd+high*3-3]==65535){state=data[accEnd+high*3-1];continue scan}for(;low>1;let index=accEnd+mid+(mid<<1);let from=data[index],to=data[index+1];if(next=to)low=mid+1;else{state=data[index+2];input.advance();continue scan}}break}}function decodeArray(input,Type=Uint16Array){if(typeof input!="string")return input;let array=null;for(let pos=0,out=0;pos=92)next--;if(next>=34)next--;let digit=next-32;if(digit>=46){digit-=46;stop=true}value+=digit;if(stop)break;value*=46}if(array)array[out++]=value;else array=new Type(value)}return array}const verbose=typeof process!="undefined"&&process.env&&/\bparse\b/.test(process.env.LOG);let stackIDs=null;var Safety;(function(Safety){Safety[Safety["Margin"]=25]="Margin"})(Safety||(Safety={}));function cutAt(tree,pos,side){let cursor=tree.cursor(IterMode.IncludeAnonymous);cursor.moveTo(pos);for(;;){if(!(side<0?cursor.childBefore(pos):cursor.childAfter(pos)))for(;;){if((side<0?cursor.topos)&&!cursor.type.isError)return side<0?Math.max(0,Math.min(cursor.to-1,pos-25)):Math.min(tree.length,Math.max(cursor.from+1,pos+25));if(side<0?cursor.prevSibling():cursor.nextSibling())break;if(!cursor.parent())return side<0?0:tree.length}}}class FragmentCursor{constructor(fragments,nodeSet){this.fragments=fragments;this.nodeSet=nodeSet;this.i=0;this.fragment=null;this.safeFrom=-1;this.safeTo=-1;this.trees=[];this.start=[];this.index=[];this.nextFragment()}nextFragment(){let fr=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(fr){this.safeFrom=fr.openStart?cutAt(fr.tree,fr.from+fr.offset,1)-fr.offset:fr.from;this.safeTo=fr.openEnd?cutAt(fr.tree,fr.to+fr.offset,-1)-fr.offset:fr.to;while(this.trees.length){this.trees.pop();this.start.pop();this.index.pop()}this.trees.push(fr.tree);this.start.push(-fr.offset);this.index.push(0);this.nextStart=this.safeFrom}else{this.nextStart=1e9}}nodeAt(pos){if(pospos){this.nextStart=start;return null}if(next instanceof Tree){if(start==pos){if(start=Math.max(this.safeFrom,pos)){this.trees.push(next);this.start.push(start);this.index.push(0)}}else{this.index[last]++;this.nextStart=start+next.length}}}}class TokenCache{constructor(parser,stream){this.stream=stream;this.tokens=[];this.mainToken=null;this.actions=[];this.tokens=parser.tokenizers.map(_=>new CachedToken)}getActions(stack){let actionIndex=0;let main=null;let{parser}=stack.p,{tokenizers}=parser;let mask=parser.stateSlot(stack.state,3);let context=stack.curContext?stack.curContext.hash:0;let lookAhead=0;for(let i=0;itoken.end+25)lookAhead=Math.max(token.lookAhead,lookAhead);if(token.value!=0){let startIndex=actionIndex;if(token.extended>-1)actionIndex=this.addActions(stack,token.extended,token.end,actionIndex);actionIndex=this.addActions(stack,token.value,token.end,actionIndex);if(!tokenizer.extend){main=token;if(actionIndex>startIndex)break}}}while(this.actions.length>actionIndex)this.actions.pop();if(lookAhead)stack.setLookAhead(lookAhead);if(!main&&stack.pos==this.stream.end){main=new CachedToken;main.value=stack.p.parser.eofTerm;main.start=main.end=stack.pos;actionIndex=this.addActions(stack,main.value,main.end,actionIndex)}this.mainToken=main;return this.actions}getMainToken(stack){if(this.mainToken)return this.mainToken;let main=new CachedToken,{pos,p}=stack;main.start=pos;main.end=Math.min(pos+1,p.stream.end);main.value=pos==p.stream.end?p.parser.eofTerm:0;return main}updateCachedToken(token,tokenizer,stack){let start=this.stream.clipPos(stack.pos);tokenizer.token(this.stream.reset(start,token),stack);if(token.value>-1){let{parser}=stack.p;for(let i=0;i=0&&stack.p.parser.dialect.allows(result>>1)){if((result&1)==0)token.value=result>>1;else token.extended=result>>1;break}}}else{token.value=0;token.end=this.stream.clipPos(start+1)}}putAction(action,token,end,index){for(let i=0;iparser.bufferLength*4?new FragmentCursor(fragments,parser.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let stacks=this.stacks,pos=this.minStackPos;let newStacks=this.stacks=[];let stopped,stoppedTokens;for(let i=0;ipos){newStacks.push(stack)}else if(this.advanceStack(stack,newStacks,stacks)){continue}else{if(!stopped){stopped=[];stoppedTokens=[]}stopped.push(stack);let tok=this.tokens.getMainToken(stack);stoppedTokens.push(tok.value,tok.end)}break}}if(!newStacks.length){let finished=stopped&&findFinished(stopped);if(finished)return this.stackToTree(finished);if(this.parser.strict){if(verbose&&stopped)console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none"));throw new SyntaxError("No parse at "+pos)}if(!this.recovering)this.recovering=5}if(this.recovering&&stopped){let finished=this.stoppedAt!=null&&stopped[0].pos>this.stoppedAt?stopped[0]:this.runRecovery(stopped,stoppedTokens,newStacks);if(finished)return this.stackToTree(finished.forceAll())}if(this.recovering){let maxRemaining=this.recovering==1?1:this.recovering*3;if(newStacks.length>maxRemaining){newStacks.sort((a,b)=>b.score-a.score);while(newStacks.length>maxRemaining)newStacks.pop()}if(newStacks.some(s=>s.reducePos>pos))this.recovering--}else if(newStacks.length>1){outer:for(let i=0;i500&&other.buffer.length>500){if((stack.score-other.score||stack.buffer.length-other.buffer.length)>0){newStacks.splice(j--,1)}else{newStacks.splice(i--,1);continue outer}}}}}this.minStackPos=newStacks[0].pos;for(let i=1;i ":"";if(this.stoppedAt!=null&&start>this.stoppedAt)return stack.forceReduce()?stack:null;if(this.fragments){let strictCx=stack.curContext&&stack.curContext.tracker.strict,cxHash=strictCx?stack.curContext.hash:0;for(let cached=this.fragments.nodeAt(start);cached;){let match=this.parser.nodeSet.types[cached.type.id]==cached.type?parser.getGoto(stack.state,cached.type.id):-1;if(match>-1&&cached.length&&(!strictCx||(cached.prop(NodeProp.contextHash)||0)==cxHash)){stack.useNode(cached,match);if(verbose)console.log(base+this.stackID(stack)+` (via reuse of ${parser.getName(cached.type.id)})`);return true}if(!(cached instanceof Tree)||cached.children.length==0||cached.positions[0]>0)break;let inner=cached.children[0];if(inner instanceof Tree&&cached.positions[0]==0)cached=inner;else break}}let defaultReduce=parser.stateSlot(stack.state,4);if(defaultReduce>0){stack.reduce(defaultReduce);if(verbose)console.log(base+this.stackID(stack)+` (via always-reduce ${parser.getName(defaultReduce&65535)})`);return true}if(stack.stack.length>=15e3){while(stack.stack.length>9e3&&stack.forceReduce()){}}let actions=this.tokens.getActions(stack);for(let i=0;istart)stacks.push(localStack);else split.push(localStack)}return false}advanceFully(stack,newStacks){let pos=stack.pos;for(;;){if(!this.advanceStack(stack,null,null))return false;if(stack.pos>pos){pushStackDedup(stack,newStacks);return true}}}runRecovery(stacks,tokens,newStacks){let finished=null,restarted=false;for(let i=0;i ":"";if(stack.deadEnd){if(restarted)continue;restarted=true;stack.restart();if(verbose)console.log(base+this.stackID(stack)+" (restarted)");let done=this.advanceFully(stack,newStacks);if(done)continue}let force=stack.split(),forceBase=base;for(let j=0;force.forceReduce()&&j<10;j++){if(verbose)console.log(forceBase+this.stackID(force)+" (via force-reduce)");let done=this.advanceFully(force,newStacks);if(done)break;if(verbose)forceBase=this.stackID(force)+" -> "}for(let insert of stack.recoverByInsert(token)){if(verbose)console.log(base+this.stackID(insert)+" (via recover-insert)");this.advanceFully(insert,newStacks)}if(this.stream.end>stack.pos){if(tokenEnd==stack.pos){tokenEnd++;token=0}stack.recoverByDelete(token,tokenEnd);if(verbose)console.log(base+this.stackID(stack)+` (via recover-delete ${this.parser.getName(token)})`);pushStackDedup(stack,newStacks)}else if(!finished||finished.scorex;class ContextTracker{constructor(spec){this.start=spec.start;this.shift=spec.shift||id;this.reduce=spec.reduce||id;this.reuse=spec.reuse||id;this.hash=spec.hash||(()=>0);this.strict=spec.strict!==false}}class LRParser extends Parser{constructor(spec){super();this.wrappers=[];if(spec.version!=14)throw new RangeError(`Parser version (${spec.version}) doesn't match runtime version (${14})`);let nodeNames=spec.nodeNames.split(" ");this.minRepeatTerm=nodeNames.length;for(let i=0;ispec.topRules[r][1]);let nodeProps=[];for(let i=0;i=0){setProp(next,prop,propSpec[i++])}else{let value=propSpec[i+-next];for(let j=-next;j>0;j--)setProp(propSpec[i++],prop,value);i++}}}this.nodeSet=new NodeSet(nodeNames.map((name,i)=>NodeType.define({name:i>=this.minRepeatTerm?undefined:name,id:i,props:nodeProps[i],top:topTerms.indexOf(i)>-1,error:i==0,skipped:spec.skippedNodes&&spec.skippedNodes.indexOf(i)>-1})));if(spec.propSources)this.nodeSet=this.nodeSet.extend(...spec.propSources);this.strict=false;this.bufferLength=DefaultBufferLength;let tokenArray=decodeArray(spec.tokenData);this.context=spec.context;this.specializerSpecs=spec.specialized||[];this.specialized=new Uint16Array(this.specializerSpecs.length);for(let i=0;itypeof value=="number"?new TokenGroup(tokenArray,value):value);this.topRules=spec.topRules;this.dialects=spec.dialects||{};this.dynamicPrecedences=spec.dynamicPrecedences||null;this.tokenPrecTable=spec.tokenPrec;this.termNames=spec.termNames||null;this.maxNode=this.nodeSet.types.length-1;this.dialect=this.parseDialect();this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(input,fragments,ranges){let parse=new Parse(this,input,fragments,ranges);for(let w of this.wrappers)parse=w(parse,input,fragments,ranges);return parse}getGoto(state,term,loose=false){let table=this.goto;if(term>=table[0])return-1;for(let pos=table[term+1];;){let groupTag=table[pos++],last=groupTag&1;let target=table[pos++];if(last&&loose)return target;for(let end=pos+(groupTag>>1);pos0}validAction(state,action){if(action==this.stateSlot(state,4))return true;for(let i=this.stateSlot(state,1);;i+=3){if(this.data[i]==65535){if(this.data[i+1]==1)i=pair(this.data,i+2);else return false}if(action==pair(this.data,i+1))return true}}nextStates(state){let result=[];for(let i=this.stateSlot(state,1);;i+=3){if(this.data[i]==65535){if(this.data[i+1]==1)i=pair(this.data,i+2);else break}if((this.data[i+2]&65536>>16)==0){let value=this.data[i+1];if(!result.some((v,i)=>i&1&&v==value))result.push(this.data[i],value)}}return result}overrides(token,prev){let iPrev=findOffset(this.data,this.tokenPrecTable,prev);return iPrev<0||findOffset(this.data,this.tokenPrecTable,token){let found=config.tokenizers.find(r=>r.from==t);return found?found.to:t});if(config.specializers){copy.specializers=this.specializers.slice();copy.specializerSpecs=this.specializerSpecs.map((s,i)=>{let found=config.specializers.find(r=>r.from==s.external);if(!found)return s;let spec=Object.assign(Object.assign({},s),{external:found.to});copy.specializers[i]=getSpecializer(spec);return spec})}if(config.contextTracker)copy.context=config.contextTracker;if(config.dialect)copy.dialect=this.parseDialect(config.dialect);if(config.strict!=null)copy.strict=config.strict;if(config.wrap)copy.wrappers=copy.wrappers.concat(config.wrap);if(config.bufferLength!=null)copy.bufferLength=config.bufferLength;return copy}hasWrappers(){return this.wrappers.length>0}getName(term){return this.termNames?this.termNames[term]:String(term<=this.maxNode&&this.nodeSet.types[term].name||term)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(term){let prec=this.dynamicPrecedences;return prec==null?0:prec[term]||0}parseDialect(dialect){let values=Object.keys(this.dialects),flags=values.map(()=>false);if(dialect)for(let part of dialect.split(" ")){let id=values.indexOf(part);if(id>=0)flags[id]=true}let disabled=null;for(let i=0;istopped)&&stack.p.parser.stateFlag(stack.state,2)&&(!best||best.scorespec.external(value,stack)<<1|mask}return spec.get}export{ContextTracker,ExternalTokenizer,InputStream,LRParser,Stack};