/** * Bundled by jsDelivr using Rollup v4.62.2 and esbuild v0.28.1. * Original file: /npm/nearley@2.20.1/lib/nearley.js * * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files */ var g={exports:{}},N=g.exports,k;function O(){return k||(k=1,(function(b){(function(c,u){b.exports?b.exports=u():c.nearley=u()})(N,function(){function c(t,e,r){return this.id=++c.highestId,this.name=t,this.symbols=e,this.postprocess=r,this}c.highestId=0,c.prototype.toString=function(t){var e=typeof t>"u"?this.symbols.map(S).join(" "):this.symbols.slice(0,t).map(S).join(" ")+" \u25CF "+this.symbols.slice(t).map(S).join(" ");return this.name+" \u2192 "+e};function u(t,e,r,i){this.rule=t,this.dot=e,this.reference=r,this.data=[],this.wantedBy=i,this.isComplete=this.dot===t.symbols.length}u.prototype.toString=function(){return"{"+this.rule.toString(this.dot)+"}, from: "+(this.reference||0)},u.prototype.nextState=function(t){var e=new u(this.rule,this.dot+1,this.reference,this.wantedBy);return e.left=this,e.right=t,e.isComplete&&(e.data=e.build(),e.right=void 0),e},u.prototype.build=function(){var t=[],e=this;do t.push(e.right.data),e=e.left;while(e.left);return t.reverse(),t},u.prototype.finish=function(){this.rule.postprocess&&(this.data=this.rule.postprocess(this.data,this.reference,l.fail))};function v(t,e){this.grammar=t,this.index=e,this.states=[],this.wants={},this.scannable=[],this.completed={}}v.prototype.process=function(t){for(var e=this.states,r=this.wants,i=this.completed,s=0;s0&&e.push(" ^ "+i+" more lines identical to this"),i=0,e.push(" "+h)),r=h}},l.prototype.getSymbolDisplay=function(t){return E(t)},l.prototype.buildFirstStateStack=function(t,e){if(e.indexOf(t)!==-1)return null;if(t.wantedBy.length===0)return[t];var r=t.wantedBy[0],i=[t].concat(e),s=this.buildFirstStateStack(r,i);return s===null?null:[t].concat(s)},l.prototype.save=function(){var t=this.table[this.current];return t.lexerState=this.lexerState,t},l.prototype.restore=function(t){var e=t.index;this.current=e,this.table[e]=t,this.table.splice(e+1),this.lexerState=t.lexerState,this.results=this.finish()},l.prototype.rewind=function(t){if(!this.options.keepHistory)throw new Error("set option `keepHistory` to enable rewinding");this.restore(this.table[t])},l.prototype.finish=function(){var t=[],e=this.grammar.start,r=this.table[this.table.length-1];return r.states.forEach(function(i){i.rule.name===e&&i.dot===i.rule.symbols.length&&i.reference===0&&i.data!==l.fail&&t.push(i)}),t.map(function(i){return i.data})};function E(t){var e=typeof t;if(e==="string")return t;if(e==="object"){if(t.literal)return JSON.stringify(t.literal);if(t instanceof RegExp)return"character matching "+t;if(t.type)return t.type+" token";if(t.test)return"token matching "+String(t.test);throw new Error("Unknown symbol type: "+t)}}function S(t){var e=typeof t;if(e==="string")return t;if(e==="object"){if(t.literal)return JSON.stringify(t.literal);if(t instanceof RegExp)return t.toString();if(t.type)return"%"+t.type;if(t.test)return"<"+String(t.test)+">";throw new Error("Unknown symbol type: "+t)}}return{Parser:l,Grammar:y,Rule:c}})})(g)),g.exports}var B=O();export{B as default};