159 lines
580 KiB
JavaScript
159 lines
580 KiB
JavaScript
|
|
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,n)=>t(e,`name`,{value:n,configurable:!0}),s=(e,t)=>function(){return e&&(t=(0,e[r(e)[0]])(e=0)),t},c=(e,t)=>function(){return t||(0,e[r(e)[0]])((t={exports:{}}).exports,t),t.exports},l=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},u=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(let c of r(i))!a.call(e,c)&&c!==o&&t(e,c,{get:()=>i[c],enumerable:!(s=n(i,c))||s.enumerable});return e},d=(e,t,n)=>(u(e,t,`default`),n&&u(n,t,`default`)),f=(n,r,a)=>(a=n==null?{}:e(i(n)),u(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),p=e=>u(t({},`__esModule`,{value:!0}),e),m={};l(m,{AnnotatedTextEdit:()=>T,ChangeAnnotation:()=>de,ChangeAnnotationIdentifier:()=>w,CodeAction:()=>Ge,CodeActionContext:()=>We,CodeActionKind:()=>He,CodeActionTriggerKind:()=>Ue,CodeDescription:()=>se,CodeLens:()=>Ke,Color:()=>S,ColorInformation:()=>te,ColorPresentation:()=>ne,Command:()=>le,CompletionItem:()=>ke,CompletionItemKind:()=>Ce,CompletionItemLabelDetails:()=>Oe,CompletionItemTag:()=>Te,CompletionList:()=>Ae,CreateFile:()=>E,DeleteFile:()=>pe,Diagnostic:()=>ce,DiagnosticRelatedInformation:()=>ie,DiagnosticSeverity:()=>ae,DiagnosticTag:()=>oe,DocumentHighlight:()=>Ie,DocumentHighlightKind:()=>Fe,DocumentLink:()=>Je,DocumentSymbol:()=>Ve,DocumentUri:()=>h,EOL:()=>pt,FoldingRange:()=>re,FoldingRangeKind:()=>C,FormattingOptions:()=>qe,Hover:()=>Me,InlayHint:()=>at,InlayHintKind:()=>rt,InlayHintLabelPart:()=>it,InlineCompletionContext:()=>dt,InlineCompletionItem:()=>st,InlineCompletionList:()=>ct,InlineCompletionTriggerKind:()=>lt,InlineValueContext:()=>nt,InlineValueEvaluatableExpression:()=>tt,InlineValueText:()=>$e,InlineValueVariableLookup:()=>et,InsertReplaceEdit:()=>Ee,InsertTextFormat:()=>we,InsertTextMode:()=>De,Location:()=>x,LocationLink:()=>ee,MarkedString:()=>je,MarkupContent:()=>Se,MarkupKind:()=>xe,OptionalVersionedTextDocumentIdentifier:()=>ye,ParameterInformation:()=>Ne,Position:()=>y,Range:()=>b,RenameFile:()=>D,SelectedCompletionInfo:()=>ut,SelectionRange:()=>Ye,SemanticTokenModifiers:()=>Ze,SemanticTokenTypes:()=>Xe,SemanticTokens:()=>Qe,SignatureInformation:()=>Pe,StringValue:()=>ot,SymbolInformation:()=>ze,SymbolKind:()=>Le,SymbolTag:()=>Re,TextDocument:()=>mt,TextDocumentEdit:()=>fe,TextDocumentIdentifier:()=>_e,TextDocumentItem:()=>be,TextEdit:()=>ue,URI:()=>g,VersionedTextDocumentIdentifier:()=>ve,WorkspaceChange:()=>ge,WorkspaceEdit:()=>O,WorkspaceFolder:()=>ft,WorkspaceSymbol:()=>Be,integer:()=>_,uinteger:()=>v});var h,g,_,v,y,b,x,ee,S,te,ne,C,re,ie,ae,oe,se,ce,le,ue,de,w,T,fe,E,D,pe,O,me,he,ge,_e,ve,ye,be,xe,Se,Ce,we,Te,Ee,De,Oe,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et,tt,nt,rt,it,at,ot,st,ct,lt,ut,dt,ft,pt,mt,ht,k,gt=s({"../../node_modules/.pnpm/vscode-languageserver-types@3.17.5/node_modules/vscode-languageserver-types/lib/esm/main.js"(){(function(e){function t(e){return typeof e==`string`}o(t,`is`),e.is=t})(h||={}),(function(e){function t(e){return typeof e==`string`}o(t,`is`),e.is=t})(g||={}),(function(e){e.MIN_VALUE=-2147483648,e.MAX_VALUE=2147483647;function t(t){return typeof t==`number`&&e.MIN_VALUE<=t&&t<=e.MAX_VALUE}o(t,`is`),e.is=t})(_||={}),(function(e){e.MIN_VALUE=0,e.MAX_VALUE=2147483647;function t(t){return typeof t==`number`&&e.MIN_VALUE<=t&&t<=e.MAX_VALUE}o(t,`is`),e.is=t})(v||={}),(function(e){function t(e,t){return e===Number.MAX_VALUE&&(e=v.MAX_VALUE),t===Number.MAX_VALUE&&(t=v.MAX_VALUE),{line:e,character:t}}o(t,`create`),e.create=t;function n(e){let t=e;return k.objectLiteral(t)&&k.uinteger(t.line)&&k.uinteger(t.character)}o(n,`is`),e.is=n})(y||={}),(function(e){function t(e,t,n,r){if(k.uinteger(e)&&k.uinteger(t)&&k.uinteger(n)&&k.uinteger(r))return{start:y.create(e,t),end:y.create(n,r)};if(y.is(e)&&y.is(t))return{start:e,end:t};throw Error(`Range#create called with invalid arguments[${e}, ${t}, ${n}, ${r}]`)}o(t,`create`),e.create=t;function n(e){let t=e;return k.obj
|
|||
|
|
`,`\r
|
|||
|
|
`,`\r`],(function(e){function t(e,t,n,r){return new ht(e,t,n,r)}o(t,`create`),e.create=t;function n(e){let t=e;return!!(k.defined(t)&&k.string(t.uri)&&(k.undefined(t.languageId)||k.string(t.languageId))&&k.uinteger(t.lineCount)&&k.func(t.getText)&&k.func(t.positionAt)&&k.func(t.offsetAt))}o(n,`is`),e.is=n;function r(e,t){let n=e.getText(),r=i(t,(e,t)=>{let n=e.range.start.line-t.range.start.line;return n===0?e.range.start.character-t.range.start.character:n}),a=n.length;for(let t=r.length-1;t>=0;t--){let i=r[t],o=e.offsetAt(i.range.start),s=e.offsetAt(i.range.end);if(s<=a)n=n.substring(0,o)+i.newText+n.substring(s,n.length);else throw Error(`Overlapping edit`);a=o}return n}o(r,`applyEdits`),e.applyEdits=r;function i(e,t){if(e.length<=1)return e;let n=e.length/2|0,r=e.slice(0,n),a=e.slice(n);i(r,t),i(a,t);let o=0,s=0,c=0;for(;o<r.length&&s<a.length;)t(r[o],a[s])<=0?e[c++]=r[o++]:e[c++]=a[s++];for(;o<r.length;)e[c++]=r[o++];for(;s<a.length;)e[c++]=a[s++];return e}o(i,`mergeSort`)})(mt||={}),ht=class{static{o(this,`FullTextDocument`)}constructor(e,t,n,r){this._uri=e,this._languageId=t,this._version=n,this._content=r,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(e){if(e){let t=this.offsetAt(e.start),n=this.offsetAt(e.end);return this._content.substring(t,n)}return this._content}update(e,t){this._content=e.text,this._version=t,this._lineOffsets=void 0}getLineOffsets(){if(this._lineOffsets===void 0){let e=[],t=this._content,n=!0;for(let r=0;r<t.length;r++){n&&=(e.push(r),!1);let i=t.charAt(r);n=i===`\r`||i===`
|
|||
|
|
`,i===`\r`&&r+1<t.length&&t.charAt(r+1)===`
|
|||
|
|
`&&r++}n&&t.length>0&&e.push(t.length),this._lineOffsets=e}return this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let t=this.getLineOffsets(),n=0,r=t.length;if(r===0)return y.create(0,e);for(;n<r;){let i=Math.floor((n+r)/2);t[i]>e?r=i:n=i+1}let i=n-1;return y.create(i,e-t[i])}offsetAt(e){let t=this.getLineOffsets();if(e.line>=t.length)return this._content.length;if(e.line<0)return 0;let n=t[e.line],r=e.line+1<t.length?t[e.line+1]:this._content.length;return Math.max(Math.min(n+e.character,r),n)}get lineCount(){return this.getLineOffsets().length}},(function(e){let t=Object.prototype.toString;function n(e){return e!==void 0}o(n,`defined`),e.defined=n;function r(e){return e===void 0}o(r,`undefined`),e.undefined=r;function i(e){return e===!0||e===!1}o(i,`boolean`),e.boolean=i;function a(e){return t.call(e)===`[object String]`}o(a,`string`),e.string=a;function s(e){return t.call(e)===`[object Number]`}o(s,`number`),e.number=s;function c(e,n,r){return t.call(e)===`[object Number]`&&n<=e&&e<=r}o(c,`numberRange`),e.numberRange=c;function l(e){return t.call(e)===`[object Number]`&&-2147483648<=e&&e<=2147483647}o(l,`integer`),e.integer=l;function u(e){return t.call(e)===`[object Number]`&&0<=e&&e<=2147483647}o(u,`uinteger`),e.uinteger=u;function d(e){return t.call(e)===`[object Function]`}o(d,`func`),e.func=d;function f(e){return typeof e==`object`&&!!e}o(f,`objectLiteral`),e.objectLiteral=f;function p(e,t){return Array.isArray(e)&&e.every(t)}o(p,`typedArray`),e.typedArray=p})(k||={})}}),_t=c({"../../node_modules/.pnpm/vscode-jsonrpc@8.2.0/node_modules/vscode-jsonrpc/lib/common/ral.js"(e){Object.defineProperty(e,"__esModule",{value:!0});var t;function n(){if(t===void 0)throw Error(`No runtime abstraction layer installed`);return t}o(n,`RAL`),(function(e){function n(e){if(e===void 0)throw Error(`No runtime abstraction layer provided`);t=e}o(n,`install`),e.install=n})(n||={}),e.default=n}}),vt=c({"../../node_modules/.pnpm/vscode-jsonrpc@8.2.0/node_modules/vscode-jsonrpc/lib/common/is.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.stringArray=e.array=e.func=e.error=e.number=e.string=e.boolean=void 0;function t(e){return e===!0||e===!1}o(t,`boolean`),e.boolean=t;function n(e){return typeof e==`string`||e instanceof String}o(n,`string`),e.string=n;function r(e){return typeof e==`number`||e instanceof Number}o(r,`number`),e.number=r;function i(e){return e instanceof Error}o(i,`error`),e.error=i;function a(e){return typeof e==`function`}o(a,`func`),e.func=a;function s(e){return Array.isArray(e)}o(s,`array`),e.array=s;function c(e){return s(e)&&e.every(e=>n(e))}o(c,`stringArray`),e.stringArray=c}}),yt=c({"../../node_modules/.pnpm/vscode-jsonrpc@8.2.0/node_modules/vscode-jsonrpc/lib/common/events.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Emitter=e.Event=void 0;var t=_t(),n;(function(e){let t={dispose(){}};e.None=function(){return t}})(n||(e.Event=n={}));var r=class{static{o(this,`CallbackList`)}add(e,t=null,n){this._callbacks||(this._callbacks=[],this._contexts=[]),this._callbacks.push(e),this._contexts.push(t),Array.isArray(n)&&n.push({dispose:o(()=>this.remove(e,t),`dispose`)})}remove(e,t=null){if(!this._callbacks)return;let n=!1;for(let r=0,i=this._callbacks.length;r<i;r++)if(this._callbacks[r]===e)if(this._contexts[r]===t){this._callbacks.splice(r,1),this._contexts.splice(r,1);return}else n=!0;if(n)throw Error(`When adding a listener with a context, you should remove it with the same context`)}invoke(...e){if(!this._callbacks)return[];let n=[],r=this._callbacks.slice(0),i=this._contexts.slice(0);for(let a=0,o=r.length;a<o;a++)try{n.push(r[a].apply(i[a],e))}catch(e){(0,t.default)().console.error(e)}return n}isEmpty(){return!this._callbacks||this._callbacks.length===0}dispose(){this._callbacks=void 0,this._contexts=void 0}},i=class e{static{o(this,`Emitter`)}constructor(e){this._options=e}get event(){return this._event||=(t,n,i)=>{this._callbacks||=new r,this._options&&this._options.onFirstListenerAdd&&this._callbacks.isEmpty()&&this._options.onFirstListenerAdd(this),this._callb
|
|||
|
|
${JSON.stringify(Object.fromEntries(e))}`));return}let n=parseInt(t);if(isNaN(n)){this.fireError(Error(`Content-Length value must be a number. Got ${t}`));return}this.nextMessageLength=n}let e=this.buffer.tryReadBody(this.nextMessageLength);if(e===void 0){this.setPartialMessageTimer();return}this.clearPartialMessageTimer(),this.nextMessageLength=-1,this.readSemaphore.lock(async()=>{let t=this.options.contentDecoder===void 0?e:await this.options.contentDecoder.decode(e),n=await this.options.contentTypeDecoder.decode(t,this.options);this.callback(n)}).catch(e=>{this.fireError(e)})}}catch(e){this.fireError(e)}}clearPartialMessageTimer(){this.partialMessageTimer&&=(this.partialMessageTimer.dispose(),void 0)}setPartialMessageTimer(){this.clearPartialMessageTimer(),!(this._partialMessageTimeout<=0)&&(this.partialMessageTimer=(0,t.default)().timer.setTimeout((e,t)=>{this.partialMessageTimer=void 0,e===this.messageToken&&(this.firePartialMessage({messageToken:e,waitingTime:t}),this.setPartialMessageTimer())},this._partialMessageTimeout,this.messageToken,this._partialMessageTimeout))}}}}),Dt=c({"../../node_modules/.pnpm/vscode-jsonrpc@8.2.0/node_modules/vscode-jsonrpc/lib/common/messageWriter.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.WriteableStreamMessageWriter=e.AbstractMessageWriter=e.MessageWriter=void 0;var t=_t(),n=vt(),r=Tt(),i=yt(),a=`Content-Length: `,s=`\r
|
|||
|
|
`,c;(function(e){function t(e){let t=e;return t&&n.func(t.dispose)&&n.func(t.onClose)&&n.func(t.onError)&&n.func(t.write)}o(t,`is`),e.is=t})(c||(e.MessageWriter=c={}));var l=class{static{o(this,`AbstractMessageWriter`)}constructor(){this.errorEmitter=new i.Emitter,this.closeEmitter=new i.Emitter}dispose(){this.errorEmitter.dispose(),this.closeEmitter.dispose()}get onError(){return this.errorEmitter.event}fireError(e,t,n){this.errorEmitter.fire([this.asError(e),t,n])}get onClose(){return this.closeEmitter.event}fireClose(){this.closeEmitter.fire(void 0)}asError(e){return e instanceof Error?e:Error(`Writer received error. Reason: ${n.string(e.message)?e.message:`unknown`}`)}};e.AbstractMessageWriter=l;var u;(function(e){function n(e){return e===void 0||typeof e==`string`?{charset:e??`utf-8`,contentTypeEncoder:(0,t.default)().applicationJson.encoder}:{charset:e.charset??`utf-8`,contentEncoder:e.contentEncoder,contentTypeEncoder:e.contentTypeEncoder??(0,t.default)().applicationJson.encoder}}o(n,`fromOptions`),e.fromOptions=n})(u||={}),e.WriteableStreamMessageWriter=class extends l{static{o(this,`WriteableStreamMessageWriter`)}constructor(e,t){super(),this.writable=e,this.options=u.fromOptions(t),this.errorCount=0,this.writeSemaphore=new r.Semaphore(1),this.writable.onError(e=>this.fireError(e)),this.writable.onClose(()=>this.fireClose())}async write(e){return this.writeSemaphore.lock(async()=>this.options.contentTypeEncoder.encode(e,this.options).then(e=>this.options.contentEncoder===void 0?e:this.options.contentEncoder.encode(e)).then(t=>{let n=[];return n.push(a,t.byteLength.toString(),s),n.push(s),this.doWrite(e,n,t)},e=>{throw this.fireError(e),e}))}async doWrite(e,t,n){try{return await this.writable.write(t.join(``),`ascii`),this.writable.write(n)}catch(t){return this.handleError(t,e),Promise.reject(t)}}handleError(e,t){this.errorCount++,this.fireError(e,t,this.errorCount)}end(){this.writable.end()}}}}),Ot=c({"../../node_modules/.pnpm/vscode-jsonrpc@8.2.0/node_modules/vscode-jsonrpc/lib/common/messageBuffer.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AbstractMessageBuffer=void 0;var t=13,n=10,r=`\r
|
|||
|
|
`;e.AbstractMessageBuffer=class{static{o(this,`AbstractMessageBuffer`)}constructor(e=`utf-8`){this._encoding=e,this._chunks=[],this._totalLength=0}get encoding(){return this._encoding}append(e){let t=typeof e==`string`?this.fromString(e,this._encoding):e;this._chunks.push(t),this._totalLength+=t.byteLength}tryReadHeaders(e=!1){if(this._chunks.length===0)return;let i=0,a=0,o=0,s=0;row:for(;a<this._chunks.length;){let e=this._chunks[a];o=0;column:for(;o<e.length;){switch(e[o]){case t:switch(i){case 0:i=1;break;case 2:i=3;break;default:i=0}break;case n:switch(i){case 1:i=2;break;case 3:i=4,o++;break row;default:i=0}break;default:i=0}o++}s+=e.byteLength,a++}if(i!==4)return;let c=this._read(s+o),l=new Map,u=this.toString(c,`ascii`).split(r);if(u.length<2)return l;for(let t=0;t<u.length-2;t++){let n=u[t],r=n.indexOf(`:`);if(r===-1)throw Error(`Message header must separate key and value using ':'
|
|||
|
|
${n}`);let i=n.substr(0,r),a=n.substr(r+1).trim();l.set(e?i.toLowerCase():i,a)}return l}tryReadBody(e){if(!(this._totalLength<e))return this._read(e)}get numberOfBytes(){return this._totalLength}_read(e){if(e===0)return this.emptyBuffer();if(e>this._totalLength)throw Error(`Cannot read so many bytes!`);if(this._chunks[0].byteLength===e){let t=this._chunks[0];return this._chunks.shift(),this._totalLength-=e,this.asNative(t)}if(this._chunks[0].byteLength>e){let t=this._chunks[0],n=this.asNative(t,e);return this._chunks[0]=t.slice(e),this._totalLength-=e,n}let t=this.allocNative(e),n=0;for(;e>0;){let r=this._chunks[0];if(r.byteLength>e){let i=r.slice(0,e);t.set(i,n),n+=e,this._chunks[0]=r.slice(e),this._totalLength-=e,e-=e}else t.set(r,n),n+=r.byteLength,this._chunks.shift(),this._totalLength-=r.byteLength,e-=r.byteLength}return t}}}}),kt=c({"../../node_modules/.pnpm/vscode-jsonrpc@8.2.0/node_modules/vscode-jsonrpc/lib/common/connection.js"(e){Object.defineProperty(e,"__esModule",{value:!0}),e.createMessageConnection=e.ConnectionOptions=e.MessageStrategy=e.CancellationStrategy=e.CancellationSenderStrategy=e.CancellationReceiverStrategy=e.RequestCancellationReceiverStrategy=e.IdCancellationReceiverStrategy=e.ConnectionStrategy=e.ConnectionError=e.ConnectionErrors=e.LogTraceNotification=e.SetTraceNotification=e.TraceFormat=e.TraceValues=e.Trace=e.NullLogger=e.ProgressType=e.ProgressToken=void 0;var t=_t(),n=vt(),r=xt(),i=St(),a=yt(),s=bt(),c;(function(e){e.type=new r.NotificationType(`$/cancelRequest`)})(c||={});var l;(function(e){function t(e){return typeof e==`string`||typeof e==`number`}o(t,`is`),e.is=t})(l||(e.ProgressToken=l={}));var u;(function(e){e.type=new r.NotificationType(`$/progress`)})(u||={}),e.ProgressType=class{static{o(this,`ProgressType`)}constructor(){}};var d;(function(e){function t(e){return n.func(e)}o(t,`is`),e.is=t})(d||={}),e.NullLogger=Object.freeze({error:o(()=>{},`error`),warn:o(()=>{},`warn`),info:o(()=>{},`info`),log:o(()=>{},`log`)});var f;(function(e){e[e.Off=0]=`Off`,e[e.Messages=1]=`Messages`,e[e.Compact=2]=`Compact`,e[e.Verbose=3]=`Verbose`})(f||(e.Trace=f={}));var p;(function(e){e.Off=`off`,e.Messages=`messages`,e.Compact=`compact`,e.Verbose=`verbose`})(p||(e.TraceValues=p={})),(function(e){function t(t){if(!n.string(t))return e.Off;switch(t=t.toLowerCase(),t){case`off`:return e.Off;case`messages`:return e.Messages;case`compact`:return e.Compact;case`verbose`:return e.Verbose;default:return e.Off}}o(t,`fromString`),e.fromString=t;function r(t){switch(t){case e.Off:return`off`;case e.Messages:return`messages`;case e.Compact:return`compact`;case e.Verbose:return`verbose`;default:return`off`}}o(r,`toString`),e.toString=r})(f||(e.Trace=f={}));var m;(function(e){e.Text=`text`,e.JSON=`json`})(m||(e.TraceFormat=m={})),(function(e){function t(t){return n.string(t)?(t=t.toLowerCase(),t===`json`?e.JSON:e.Text):e.Text}o(t,`fromString`),e.fromString=t})(m||(e.TraceFormat=m={}));var h;(function(e){e.type=new r.NotificationType(`$/setTrace`)})(h||(e.SetTraceNotification=h={}));var g;(function(e){e.type=new r.NotificationType(`$/logTrace`)})(g||(e.LogTraceNotification=g={}));var _;(function(e){e[e.Closed=1]=`Closed`,e[e.Disposed=2]=`Disposed`,e[e.AlreadyListening=3]=`AlreadyListening`})(_||(e.ConnectionErrors=_={}));var v=class e extends Error{static{o(this,`ConnectionError`)}constructor(t,n){super(n),this.code=t,Object.setPrototypeOf(this,e.prototype)}};e.ConnectionError=v;var y;(function(e){function t(e){let t=e;return t&&n.func(t.cancelUndispatched)}o(t,`is`),e.is=t})(y||(e.ConnectionStrategy=y={}));var b;(function(e){function t(e){let t=e;return t&&(t.kind===void 0||t.kind===`id`)&&n.func(t.createCancellationTokenSource)&&(t.dispose===void 0||n.func(t.dispose))}o(t,`is`),e.is=t})(b||(e.IdCancellationReceiverStrategy=b={}));var x;(function(e){function t(e){let t=e;return t&&t.kind===`request`&&n.func(t.createCancellationTokenSource)&&(t.dispose===void 0||n.func(t.dispose))}o(t,`is`),e.is=t})(x||(e.RequestCancellationReceiverStrategy=x={}));var ee;(function(e){e.Message=Object.freeze({createCancellatio
|
|||
|
|
${JSON.stringify(e.error,void 0,4)}`):S.error(`Received response message without id. No further error information provided.`);else{let t=e.id,n=T.get(t);if(Ke(e,n),n!==void 0){T.delete(t);try{if(e.error){let t=e.error;n.reject(new r.ResponseError(t.code,t.message,t.data))}else if(e.result!==void 0)n.resolve(e.result);else throw Error(`Should never happen.`)}catch(e){e.message?S.error(`Response handler '${n.method}' failed with message: ${e.message}`):S.error(`Response handler '${n.method}' failed unexpectedly.`)}}}}o(Le,`handleResponse`);function Re(e){if(Oe())return;let t,n;if(e.method===c.type.method){let t=e.params.id;fe.delete(t),Ge(e);return}else{let r=le.get(e.method);r&&(n=r.handler,t=r.type)}if(n||ce)try{if(Ge(e),n)if(e.params===void 0)t!==void 0&&t.numberOfParams!==0&&t.parameterStructures!==r.ParameterStructures.byName&&S.error(`Notification ${e.method} defines ${t.numberOfParams} params but received none.`),n();else if(Array.isArray(e.params)){let i=e.params;e.method===u.type.method&&i.length===2&&l.is(i[0])?n({token:i[0],value:i[1]}):(t!==void 0&&(t.parameterStructures===r.ParameterStructures.byName&&S.error(`Notification ${e.method} defines parameters by name but received parameters by position`),t.numberOfParams!==e.params.length&&S.error(`Notification ${e.method} defines ${t.numberOfParams} params but received ${i.length} arguments`)),n(...i))}else t!==void 0&&t.parameterStructures===r.ParameterStructures.byPosition&&S.error(`Notification ${e.method} defines parameters by position but received parameters by name`),n(e.params);else ce&&ce(e.method,e.params)}catch(t){t.message?S.error(`Notification handler '${e.method}' failed with message: ${t.message}`):S.error(`Notification handler '${e.method}' failed unexpectedly.`)}else _e.fire(e)}o(Re,`handleNotification`);function ze(e){if(!e){S.error(`Received empty message.`);return}S.error(`Received message which is neither a response nor a notification message:
|
|||
|
|
${JSON.stringify(e,null,4)}`);let t=e;if(n.string(t.id)||n.number(t.id)){let e=t.id,n=T.get(e);n&&n.reject(Error(`The received response has neither a result nor an error property.`))}}o(ze,`handleInvalidMessage`);function Be(e){if(e!=null)switch(D){case f.Verbose:return JSON.stringify(e,null,4);case f.Compact:return JSON.stringify(e);default:return}}o(Be,`stringifyTrace`);function Ve(e){if(!(D===f.Off||!O))if(pe===m.Text){let t;(D===f.Verbose||D===f.Compact)&&e.params&&(t=`Params: ${Be(e.params)}
|
|||
|
|
|
|||
|
|
`),O.log(`Sending request '${e.method} - (${e.id})'.`,t)}else qe(`send-request`,e)}o(Ve,`traceSendingRequest`);function He(e){if(!(D===f.Off||!O))if(pe===m.Text){let t;(D===f.Verbose||D===f.Compact)&&(t=e.params?`Params: ${Be(e.params)}
|
|||
|
|
|
|||
|
|
`:`No parameters provided.
|
|||
|
|
|
|||
|
|
`),O.log(`Sending notification '${e.method}'.`,t)}else qe(`send-notification`,e)}o(He,`traceSendingNotification`);function Ue(e,t,n){if(!(D===f.Off||!O))if(pe===m.Text){let r;(D===f.Verbose||D===f.Compact)&&(e.error&&e.error.data?r=`Error data: ${Be(e.error.data)}
|
|||
|
|
|
|||
|
|
`:e.result?r=`Result: ${Be(e.result)}
|
|||
|
|
|
|||
|
|
`:e.error===void 0&&(r=`No result returned.
|
|||
|
|
|
|||
|
|
`)),O.log(`Sending response '${t} - (${e.id})'. Processing request took ${Date.now()-n}ms`,r)}else qe(`send-response`,e)}o(Ue,`traceSendingResponse`);function We(e){if(!(D===f.Off||!O))if(pe===m.Text){let t;(D===f.Verbose||D===f.Compact)&&e.params&&(t=`Params: ${Be(e.params)}
|
|||
|
|
|
|||
|
|
`),O.log(`Received request '${e.method} - (${e.id})'.`,t)}else qe(`receive-request`,e)}o(We,`traceReceivedRequest`);function Ge(e){if(!(D===f.Off||!O||e.method===g.type.method))if(pe===m.Text){let t;(D===f.Verbose||D===f.Compact)&&(t=e.params?`Params: ${Be(e.params)}
|
|||
|
|
|
|||
|
|
`:`No parameters provided.
|
|||
|
|
|
|||
|
|
`),O.log(`Received notification '${e.method}'.`,t)}else qe(`receive-notification`,e)}o(Ge,`traceReceivedNotification`);function Ke(e,t){if(!(D===f.Off||!O))if(pe===m.Text){let n;if((D===f.Verbose||D===f.Compact)&&(e.error&&e.error.data?n=`Error data: ${Be(e.error.data)}
|
|||
|
|
|
|||
|
|
`:e.result?n=`Result: ${Be(e.result)}
|
|||
|
|
|
|||
|
|
`:e.error===void 0&&(n=`No result returned.
|
|||
|
|
|
|||
|
|
`)),t){let r=e.error?` Request failed: ${e.error.message} (${e.error.code}).`:``;O.log(`Received response '${t.method} - (${e.id})' in ${Date.now()-t.timerStart}ms.${r}`,n)}else O.log(`Received response ${e.id} without active response promise.`,n)}else qe(`receive-response`,e)}o(Ke,`traceReceivedResponse`);function qe(e,t){if(!O||D===f.Off)return;let n={isLSPMessage:!0,type:e,message:t,timestamp:Date.now()};O.log(n)}o(qe,`logLSPMessage`);function Je(){if(De())throw new v(_.Closed,`Connection is closed.`);if(Oe())throw new v(_.Disposed,`Connection is disposed.`)}o(Je,`throwIfClosedOrDisposed`);function Ye(){if(Ee())throw new v(_.AlreadyListening,`Connection is already listening`)}o(Ye,`throwIfListening`);function Xe(){if(!Ee())throw Error(`Call listen() first.`)}o(Xe,`throwIfNotListening`);function Ze(e){return e===void 0?null:e}o(Ze,`undefinedToNull`);function Qe(e){if(e!==null)return e}o(Qe,`nullToUndefined`);function $e(e){return e!=null&&!Array.isArray(e)&&typeof e==`object`}o($e,`isNamedParam`);function et(e,t){switch(e){case r.ParameterStructures.auto:return $e(t)?Qe(t):[Ze(t)];case r.ParameterStructures.byName:if(!$e(t))throw Error(`Received parameters by name but param is not an object literal.`);return Qe(t);case r.ParameterStructures.byPosition:return[Ze(t)];default:throw Error(`Unknown parameter structure ${e.toString()}`)}}o(et,`computeSingleParam`);function tt(e,t){let n,r=e.numberOfParams;switch(r){case 0:n=void 0;break;case 1:n=et(e.parameterStructures,t[0]);break;default:n=[];for(let e=0;e<t.length&&e<r;e++)n.push(Ze(t[e]));if(t.length<r)for(let e=t.length;e<r;e++)n.push(null);break}return n}o(tt,`computeMessageParams`);let nt={sendNotification:o((e,...t)=>{Je();let i,a;if(n.string(e)){i=e;let n=t[0],o=0,s=r.ParameterStructures.auto;r.ParameterStructures.is(n)&&(o=1,s=n);let c=t.length,l=c-o;switch(l){case 0:a=void 0;break;case 1:a=et(s,t[o]);break;default:if(s===r.ParameterStructures.byName)throw Error(`Received ${l} parameters for 'by Name' notification parameter structure.`);a=t.slice(o,c).map(e=>Ze(e));break}}else{let n=t;i=e.method,a=tt(e,n)}let o={jsonrpc:`2.0`,method:i,params:a};return He(o),y.write(o).catch(e=>{throw S.error(`Sending notification failed.`),e})},`sendNotification`),onNotification:o((e,t)=>{Je();let r;return n.func(e)?ce=e:t&&(n.string(e)?(r=e,le.set(e,{type:void 0,handler:t})):(r=e.method,le.set(e.method,{type:e,handler:t}))),{dispose:o(()=>{r===void 0?ce=void 0:le.delete(r)},`dispose`)}},`onNotification`),onProgress:o((e,t,n)=>{if(ue.has(t))throw Error(`Progress handler for token ${t} already registered`);return ue.set(t,n),{dispose:o(()=>{ue.delete(t)},`dispose`)}},`onProgress`),sendProgress:o((e,t,n)=>nt.sendNotification(u.type,{token:t,value:n}),`sendProgress`),onUnhandledProgress:ve.event,sendRequest:o((e,...t)=>{Je(),Xe();let i,a,c;if(n.string(e)){i=e;let n=t[0],o=t[t.length-1],l=0,u=r.ParameterStructures.auto;r.ParameterStructures.is(n)&&(l=1,u=n);let d=t.length;s.CancellationToken.is(o)&&(--d,c=o);let f=d-l;switch(f){case 0:a=void 0;break;case 1:a=et(u,t[l]);break;default:if(u===r.ParameterStructures.byName)throw Error(`Received ${f} parameters for 'by Name' request parameter structure.`);a=t.slice(l,d).map(e=>Ze(e));break}}else{let n=t;i=e.method,a=tt(e,n);let r=e.numberOfParams;c=s.CancellationToken.is(n[r])?n[r]:void 0}let l=C++,u;c&&(u=c.onCancellationRequested(()=>{let e=be.sender.sendCancellation(nt,l);return e===void 0?(S.log(`Received no promise from cancellation strategy when cancelling id ${l}`),Promise.resolve()):e.catch(()=>{S.log(`Sending cancellation messages for id ${l} failed`)})}));let d={jsonrpc:`2.0`,id:l,method:i,params:a};return Ve(d),typeof be.sender.enableCancellation==`function`&&be.sender.enableCancellation(d),new Promise(async(e,t)=>{let n=o(t=>{e(t),be.sender.cleanup(l),u?.dispose()},`resolveWithCleanup`),a=o(e=>{t(e),be.sender.cleanup(l),u?.dispose()},`rejectWithCleanup`),s={method:i,timerStart:Date.now(),resolve:n,reject:a};try{await y.write(d),T.set(l,s)}catch(e){throw S.error(`Sending request failed.`),s.reject(new r.ResponseError(r.ErrorCodes
|
|||
|
|
`),P(`\r`),P(` `),P(`\v`),P(` `),P(`\xA0`),P(` `),P(` `),P(` `),P(` `),P(` `),P(` `),P(` `),P(` `),P(` `),P(` `),P(` `),P(` `),P(`\u2028`),P(`\u2029`),P(` `),P(` `),P(` `),P(``)],_a=/[0-9a-fA-F]/,va=/[0-9]/,ya=/[1-9]/,ba=class{static{o(this,`RegExpParser`)}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 t=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};for(;this.isRegExpFlag();)switch(this.popChar()){case`g`:ua(n,`global`);break;case`i`:ua(n,`ignoreCase`);break;case`m`:ua(n,`multiLine`);break;case`u`:ua(n,`unicode`);break;case`y`:ua(n,`sticky`);break}if(this.idx!==this.input.length)throw Error(`Redundant input: `+this.input.substring(this.idx));return{type:`Pattern`,flags:n,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()===`|`;)this.consumeChar(`|`),e.push(this.alternative());return{type:`Disjunction`,value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:`Alternative`,value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():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 t;switch(this.popChar()){case`=`:t=`Lookahead`;break;case`!`:t=`NegativeLookahead`;break;case`<`:switch(this.popChar()){case`=`:t=`Lookbehind`;break;case`!`:t=`NegativeLookbehind`}break}da(t);let n=this.disjunction();return this.consumeChar(`)`),{type:t,value:n,loc:this.loc(e)}}return fa()}quantifier(e=!1){let t,n=this.idx;switch(this.popChar()){case`*`:t={atLeast:0,atMost:1/0};break;case`+`:t={atLeast:1,atMost:1/0};break;case`?`:t={atLeast:0,atMost:1};break;case`{`:let n=this.integerIncludingZero();switch(this.popChar()){case`}`:t={atLeast:n,atMost:n};break;case`,`:let e;this.isDigit()?(e=this.integerIncludingZero(),t={atLeast:n,atMost:e}):t={atLeast:n,atMost:1/0},this.consumeChar(`}`);break}if(e===!0&&t===void 0)return;da(t);break}if(!(e===!0&&t===void 0)&&da(t))return this.peekChar(0)===`?`?(this.consumeChar(`?`),t.greedy=!1):t.greedy=!0,t.type=`Quantifier`,t.loc=this.loc(n),t}atom(){let e,t=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}return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),da(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):fa()}dotAll(){return this.consumeChar(`.`),{type:`Set`,complement:!0,value:[P(`
|
|||
|
|
`),P(`\r`),P(`\u2028`),P(`\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,t=!1;switch(this.popChar()){case`d`:e=ma;break;case`D`:e=ma,t=!0;break;case`s`:e=ga;break;case`S`:e=ga,t=!0;break;case`w`:e=ha;break;case`W`:e=ha,t=!0;break}return da(e)?{type:`Set`,value:e,complement:t}:fa()}controlEscapeAtom(){let e;switch(this.popChar()){case`f`:e=P(`\f`);break;case`n`:e=P(`
|
|||
|
|
`);break;case`r`:e=P(`\r`);break;case`t`:e=P(` `);break;case`v`:e=P(`\v`);break}return da(e)?{type:`Character`,value:e}:fa()}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:P(`\0`)}}hexEscapeSequenceAtom(){return this.consumeChar(`x`),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar(`u`),this.parseHexDigits(4)}identityEscapeAtom(){return{type:`Character`,value:P(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case`
|
|||
|
|
`:case`\r`:case`\u2028`:case`\u2029`:case`\\`:case`]`:throw Error(`TBD`);default:return{type:`Character`,value:P(this.popChar())}}}characterClass(){let e=[],t=!1;for(this.consumeChar(`[`),this.peekChar(0)===`^`&&(this.consumeChar(`^`),t=!0);this.isClassAtom();){let t=this.classAtom();if(t.type,pa(t)&&this.isRangeDash()){this.consumeChar(`-`);let n=this.classAtom();if(n.type,pa(n)){if(n.value<t.value)throw Error(`Range out of order in character class`);e.push({from:t.value,to:n.value})}else la(t.value,e),e.push(P(`-`)),la(n.value,e)}else la(t.value,e)}return this.consumeChar(`]`),{type:`Set`,complement:t,value:e}}classAtom(){switch(this.peekChar()){case`]`:case`
|
|||
|
|
`: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:P(`\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 t=this.disjunction();this.consumeChar(`)`);let n={type:`Group`,capturing:e,value:t};return e&&(n.idx=this.groupIdx),n}positiveInteger(){let e=this.popChar();if(ya.test(e)===!1)throw Error(`Expecting a positive integer`);for(;va.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(va.test(e)===!1)throw Error(`Expecting an integer`);for(;va.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case`
|
|||
|
|
`: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:P(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 va.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case`]`:case`
|
|||
|
|
`: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{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case`^`:case`$`:case`\\`:case`.`:case`*`:case`+`:case`?`:case`(`:case`)`:case`[`:case`|`:case`/`:case`
|
|||
|
|
`:case`\r`:case`\u2028`:case`\u2029`:return!1;default:return!0}}parseHexDigits(e){let t=``;for(let n=0;n<e;n++){let e=this.popChar();if(_a.test(e)===!1)throw Error(`Expecting a HexDecimal digits`);t+=e}return{type:`Character`,value:parseInt(t,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}}},xa=class{static{o(this,`BaseRegExpVisitor`)}visitChildren(e){for(let t in e){let n=e[t];e.hasOwnProperty(t)&&(n.type===void 0?Array.isArray(n)&&n.forEach(e=>{this.visit(e)},this):this.visit(n))}}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){}},Sa=/\r?\n/gm,Ca=new ba,wa=new class extends xa{static{o(this,`TerminalRegExpVisitor`)}constructor(){super(...arguments),this.isStarting=!0,this.endRegexpStack=[],this.multiline=!1}get endRegex(){return this.endRegexpStack.join(``)}reset(e){this.multiline=!1,this.regex=e,this.startRegexp=``,this.isStarting=!0,this.endRegexpStack=[]}visitGroup(e){e.quantifier&&(this.isStarting=!1,this.endRegexpStack=[])}visitCharacter(e){let t=String.fromCharCode(e.value);if(!this.multiline&&t===`
|
|||
|
|
`&&(this.multiline=!0),e.quantifier)this.isStarting=!1,this.endRegexpStack=[];else{let e=ka(t);this.endRegexpStack.push(e),this.isStarting&&(this.startRegexp+=e)}}visitSet(e){if(!this.multiline){let t=this.regex.substring(e.loc.begin,e.loc.end),n=new RegExp(t);this.multiline=!!`
|
|||
|
|
`.match(n)}if(e.quantifier)this.isStarting=!1,this.endRegexpStack=[];else{let t=this.regex.substring(e.loc.begin,e.loc.end);this.endRegexpStack.push(t),this.isStarting&&(this.startRegexp+=t)}}visitChildren(e){e.type===`Group`&&e.quantifier||super.visitChildren(e)}};function Ta(e){try{typeof e!=`string`&&(e=e.source),e=`/${e}/`;let t=Ca.pattern(e),n=[];for(let r of t.value.value)wa.reset(e),wa.visit(r),n.push({start:wa.startRegexp,end:wa.endRegex});return n}catch{return[]}}o(Ta,`getTerminalParts`);function Ea(e){try{return typeof e==`string`&&(e=new RegExp(e)),e=e.toString(),wa.reset(e),wa.visit(Ca.pattern(e)),wa.multiline}catch{return!1}}o(Ea,`isMultilineComment`);var Da=`\f
|
|||
|
|
\r \v \xA0 \u2028\u2029 `.split(``);function Oa(e){let t=typeof e==`string`?new RegExp(e):e;return Da.some(e=>t.test(e))}o(Oa,`isWhitespace`);function ka(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}o(ka,`escapeRegExp`);function Aa(e,t){let n=ja(e),r=t.match(n);return!!r&&r[0].length>0}o(Aa,`partialMatches`);function ja(e){typeof e==`string`&&(e=new RegExp(e));let t=e,n=e.source,r=0;function i(){let e=``,a;function s(t){e+=n.substr(r,t),r+=t}o(s,`appendRaw`);function c(t){e+=`(?:`+n.substr(r,t)+`|$)`,r+=t}for(o(c,`appendOptional`);r<n.length;)switch(n[r]){case`\\`:switch(n[r+1]){case`c`:c(3);break;case`x`:c(4);break;case`u`:t.unicode?n[r+2]===`{`?c(n.indexOf(`}`,r)-r+1):c(6):c(2);break;case`p`:case`P`:t.unicode?c(n.indexOf(`}`,r)-r+1):c(2);break;case`k`:c(n.indexOf(`>`,r)-r+1);break;default:c(2);break}break;case`[`:a=/\[(?:\\.|.)*?\]/g,a.lastIndex=r,a=a.exec(n)||[],c(a[0].length);break;case`|`:case`^`:case`$`:case`*`:case`+`:case`?`:s(1);break;case`{`:a=/\{\d+,?\d*\}/g,a.lastIndex=r,a=a.exec(n),a?s(a[0].length):c(1);break;case`(`:if(n[r+1]===`?`)switch(n[r+2]){case`:`:e+=`(?:`,r+=3,e+=i()+`|$)`;break;case`=`:e+=`(?=`,r+=3,e+=i()+`)`;break;case`!`:a=r,r+=3,i(),e+=n.substr(a,r-a);break;case`<`:switch(n[r+3]){case`=`:case`!`:a=r,r+=4,i(),e+=n.substr(a,r-a);break;default:s(n.indexOf(`>`,r)-r+1),e+=i()+`|$)`;break}break}else s(1),e+=i()+`|$)`;break;case`)`:return++r,e;default:c(1);break}return e}return o(i,`process`),new RegExp(i(),e.flags)}o(ja,`partialRegExp`);function Ma(e){return e.rules.find(e=>Xr(e)&&e.entry)}o(Ma,`getEntryRule`);function Na(e){return e.rules.filter(e=>gi(e)&&e.hidden)}o(Na,`getHiddenRules`);function Pa(e,t){let n=new Set,r=Ma(e);if(!r)return new Set(e.rules);let i=[r].concat(Na(e));for(let e of i)Fa(e,n,t);let a=new Set;for(let t of e.rules)(n.has(t.name)||gi(t)&&t.hidden)&&a.add(t);return a}o(Pa,`getAllReachableRules`);function Fa(e,t,n){t.add(e.name),Mn(e).forEach(e=>{if(ii(e)||n&&vi(e)){let r=e.rule.ref;r&&!t.has(r.name)&&Fa(r,t,n)}})}o(Fa,`ruleDfs`);function Ia(e){let t=new Set;return Mn(e).forEach(e=>{mr(e)&&(Xr(e.type.ref)&&t.add(e.type.ref),Er(e.type.ref)&&Xr(e.type.ref.$container)&&t.add(e.type.ref.$container))}),t}o(Ia,`getAllRulesUsedForCrossReferences`);function La(e){if(e.terminal)return e.terminal;if(e.type.ref)return Ka(e.type.ref)?.terminal}o(La,`getCrossReferenceTerminal`);function Ra(e){return e.hidden&&!Oa(so(e))}o(Ra,`isCommentTerminal`);function za(e,t){return!e||!t?[]:Va(e,t,e.astNode,!0)}o(za,`findNodesForProperty`);function Ba(e,t,n){if(!e||!t)return;let r=Va(e,t,e.astNode,!0);if(r.length!==0)return n=n===void 0?0:Math.max(0,Math.min(n,r.length-1)),r[n]}o(Ba,`findNodeForProperty`);function Va(e,t,n,r){if(!r){let n=En(e.grammarSource,ir);if(n&&n.feature===t)return[e]}return mn(e)&&e.astNode===n?e.content.flatMap(e=>Va(e,t,n,!1)):[]}o(Va,`findNodesForPropertyInternal`);function Ha(e,t){return e?Wa(e,t,e?.astNode):[]}o(Ha,`findNodesForKeyword`);function Ua(e,t,n){if(!e)return;let r=Wa(e,t,e?.astNode);if(r.length!==0)return n=n===void 0?0:Math.max(0,Math.min(n,r.length-1)),r[n]}o(Ua,`findNodeForKeyword`);function Wa(e,t,n){if(e.astNode!==n)return[];if(Ir(e.grammarSource)&&e.grammarSource.value===t)return[e];let r=Li(e).iterator(),i,a=[];do if(i=r.next(),!i.done){let e=i.value;e.astNode===n?Ir(e.grammarSource)&&e.grammarSource.value===t&&a.push(e):r.prune()}while(!i.done);return a}o(Wa,`findNodesForKeywordInternal`);function Ga(e){let t=e.astNode;for(;t===e.container?.astNode;){let t=En(e.grammarSource,ir);if(t)return t;e=e.container}}o(Ga,`findAssignment`);function Ka(e){let t=e;return Er(t)&&(Xn(t.$container)?t=t.$container.$container:Wn(t.$container)?t=t.$container:oa(t.$container)),qa(e,t,new Map)}o(Ka,`findNameAssignment`);function qa(e,t,n){function r(t,r){let i;return En(t,ir)||(i=qa(r,r,n)),n.set(e,i),i}if(o(r,`go`),n.has(e))return n.get(e);n.set(e,void 0);for(let i of Mn(t))if(ir(i)&&i.feature.toLowerCase()===`name`)return n.set(e,i),i;else if(ii(i)&&Xr(i.rule.ref))return r(i,i.rule.ref);else if(oi(i)&&i.typeRef?.ref)return
|
|||
|
|
`;function Pv(e,t=!1){try{let t=Av(e);return Fv(t.value,{},t.flags.ignoreCase)}catch(n){if(n.message===Mv)t&&Z_(`${Nv} Unable to optimize: < ${e.toString()} >
|
|||
|
|
Complement Sets cannot be automatically optimized.
|
|||
|
|
This will disable the lexer's first char optimizations.
|
|||
|
|
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n=``;t&&(n=`
|
|||
|
|
This will disable the lexer's first char optimizations.
|
|||
|
|
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),X_(`${Nv}
|
|||
|
|
Failed parsing: < ${e.toString()} >
|
|||
|
|
Using the @chevrotain/regexp-to-ast library
|
|||
|
|
Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}o(Pv,`getOptimizedStartCodesIndices`);function Fv(e,t,n){switch(e.type){case`Disjunction`:for(let r=0;r<e.value.length;r++)Fv(e.value[r],t,n);break;case`Alternative`:let r=e.value;for(let e=0;e<r.length;e++){let i=r[e];switch(i.type){case`EndAnchor`:case`GroupBackReference`:case`Lookahead`:case`NegativeLookahead`:case`Lookbehind`:case`NegativeLookbehind`:case`StartAnchor`:case`WordBoundary`:case`NonWordBoundary`:continue}let a=i;switch(a.type){case`Character`:Iv(a.value,t,n);break;case`Set`:if(a.complement===!0)throw Error(Mv);z(a.value,e=>{if(typeof e==`number`)Iv(e,t,n);else{let r=e;if(n===!0)for(let e=r.from;e<=r.to;e++)Iv(e,t,n);else{for(let e=r.from;e<=r.to&&e<Sy;e++)Iv(e,t,n);if(r.to>=Sy){let e=r.from>=Sy?r.from:Sy,n=r.to,i=wy(e),a=wy(n);for(let e=i;e<=a;e++)t[e]=e}}}});break;case`Group`:Fv(a.value,t,n);break;default:throw Error(`Non Exhaustive Match`)}let o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type===`Group`&&zv(a)===!1||a.type!==`Group`&&o===!1)break}break;default:throw Error(`non exhaustive match!`)}return H(t)}o(Fv,`firstCharOptimizedIndices`);function Iv(e,t,n){let r=wy(e);t[r]=r,n===!0&&Lv(e,t)}o(Iv,`addOptimizedIdxToResult`);function Lv(e,t){let n=String.fromCharCode(e),r=n.toUpperCase();if(r!==n){let e=wy(r.charCodeAt(0));t[e]=e}else{let e=n.toLowerCase();if(e!==n){let n=wy(e.charCodeAt(0));t[n]=n}}}o(Lv,`handleIgnoreCase`);function Rv(e,t){return Hg(e.value,e=>{if(typeof e==`number`)return u_(t,e);{let n=e;return Hg(t,e=>n.from<=e&&e<=n.to)!==void 0}})}o(Rv,`findCode`);function zv(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?F(e.value)?Ng(e.value,zv):zv(e.value):!1}o(zv,`isWholeOptional`);var Bv=class extends xa{static{o(this,`CharCodeFinder`)}constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){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){u_(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?Rv(e,this.targetCharCodes)===void 0&&(this.found=!0):Rv(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function Vv(e,t){if(t instanceof RegExp){let n=Av(t),r=new Bv(e);return r.visit(n),r.found}else return Hg(t,t=>u_(e,t.charCodeAt(0)))!==void 0}o(Vv,`canMatchCharCode`);var Hv=`PATTERN`,Uv=`defaultMode`,Wv=`modes`,Gv=typeof RegExp(`(?:)`).sticky==`boolean`;function Kv(e,t){t=ug(t,{useSticky:Gv,debug:!1,safeMode:!1,positionTracking:`full`,lineTerminatorCharacters:[`\r`,`
|
|||
|
|
`],tracer:o((e,t)=>t(),`tracer`)});let n=t.tracer;n(`initCharCodeToOptimizedIndexMap`,()=>{Ty()});let r;n(`Reject Lexer.NA`,()=>{r=z_(e,e=>e[Hv]===Uy.NA)});let i=!1,a;n(`Transform Patterns`,()=>{i=!1,a=B(r,e=>{let n=e[Hv];if(S_(n)){let e=n.source;return e.length===1&&e!==`^`&&e!==`$`&&e!==`.`&&!n.ignoreCase?e:e.length===2&&e[0]===`\\`&&!u_([`d`,`D`,`s`,`S`,`t`,`r`,`n`,`t`,`0`,`c`,`b`,`B`,`f`,`v`,`w`,`W`],e[1])?e[1]:t.useSticky?dy(n):uy(n)}else if(Cs(n))return i=!0,{exec:n};else if(typeof n==`object`)return i=!0,n;else if(typeof n==`string`){if(n.length===1)return n;{let e=n.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`),r=new RegExp(e);return t.useSticky?dy(r):uy(r)}}else throw Error(`non exhaustive match`)})});let s,c,l,u,d;n(`misc mapping`,()=>{s=B(r,e=>e.tokenTypeIdx),c=B(r,e=>{let t=e.GROUP;if(t!==Uy.SKIPPED){if(i_(t))return t;if(w_(t))return!1;throw Error(`non exhaustive match`)}}),l=B(r,e=>{let t=e.LONGER_ALT;if(t)return F(t)?B(t,e=>p_(r,e)):[p_(r,t)]}),u=B(r,e=>e.PUSH_MODE),d=B(r,e=>V(e,`POP_MODE`))});let f;n(`Line Terminator Handling`,()=>{let e=by(t.lineTerminatorCharacters);f=B(r,e=>!1),t.positionTracking!==`onlyOffset`&&(f=B(r,t=>V(t,`LINE_BREAKS`)?!!t.LINE_BREAKS:vy(t,e)===!1&&Vv(e,t.PATTERN)))});let p,m,h,g;n(`Misc Mapping #2`,()=>{p=B(r,hy),m=B(a,gy),h=L_(r,(e,t)=>{let n=t.GROUP;return i_(n)&&n!==Uy.SKIPPED&&(e[n]=[]),e},{}),g=B(a,(e,t)=>({pattern:a[t],longerAlt:l[t],canLineTerminator:f[t],isCustom:p[t],short:m[t],group:c[t],push:u[t],pop:d[t],tokenTypeIdx:s[t],tokenType:r[t]}))});let _=!0,v=[];return t.safeMode||n(`First Char Optimization`,()=>{v=L_(r,(e,n,r)=>{if(typeof n.PATTERN==`string`)xy(e,wy(n.PATTERN.charCodeAt(0)),g[r]);else if(F(n.START_CHARS_HINT)){let t;z(n.START_CHARS_HINT,n=>{let i=wy(typeof n==`string`?n.charCodeAt(0):n);t!==i&&(t=i,xy(e,i,g[r]))})}else if(S_(n.PATTERN))if(n.PATTERN.unicode)_=!1,t.ensureOptimizations&&X_(`${Nv} Unable to analyze < ${n.PATTERN.toString()} > pattern.
|
|||
|
|
The regexp unicode flag is not currently supported by the regexp-to-ast library.
|
|||
|
|
This will disable the lexer's first char optimizations.
|
|||
|
|
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let i=Pv(n.PATTERN,t.ensureOptimizations);U(i)&&(_=!1),z(i,t=>{xy(e,t,g[r])})}else t.ensureOptimizations&&X_(`${Nv} TokenType: <${n.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
|
|||
|
|
This will disable the lexer's first char optimizations.
|
|||
|
|
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),_=!1;return e},[])}),{emptyGroups:h,patternIdxToConfig:g,charCodeToPatternIdxToConfig:v,hasCustom:i,canBeOptimized:_}}o(Kv,`analyzeTokenTypes`);function qv(e,t){let n=[],r=Yv(e);n=n.concat(r.errors);let i=Xv(r.valid),a=i.valid;return n=n.concat(i.errors),n=n.concat(Jv(a)),n=n.concat(iy(a)),n=n.concat(ay(a,t)),n=n.concat(oy(a)),n}o(qv,`validatePatterns`);function Jv(e){let t=[],n=Lg(e,e=>S_(e[Hv]));return t=t.concat(Qv(n)),t=t.concat(ty(n)),t=t.concat(ny(n)),t=t.concat(ry(n)),t=t.concat($v(n)),t}o(Jv,`validateRegExpPattern`);function Yv(e){let t=Lg(e,e=>!V(e,Hv));return{errors:B(t,e=>({message:`Token Type: ->`+e.name+`<- missing static 'PATTERN' property`,type:K.MISSING_PATTERN,tokenTypes:[e]})),valid:vg(e,t)}}o(Yv,`findMissingPatterns`);function Xv(e){let t=Lg(e,e=>{let t=e[Hv];return!S_(t)&&!Cs(t)&&!V(t,`exec`)&&!i_(t)});return{errors:B(t,e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.`,type:K.INVALID_PATTERN,tokenTypes:[e]})),valid:vg(e,t)}}o(Xv,`findInvalidPatterns`);var Zv=/[^\\][$]/;function Qv(e){class t extends xa{static{o(this,`EndAnchorFinder`)}constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}return B(Lg(e,e=>{let n=e.PATTERN;try{let e=Av(n),r=new t;return r.visit(e),r.found}catch{return Zv.test(n.source)}}),e=>({message:`Unexpected RegExp Anchor Error:
|
|||
|
|
Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
|
|||
|
|
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:K.EOI_ANCHOR_FOUND,tokenTypes:[e]}))}o(Qv,`findEndOfInputAnchor`);function $v(e){return B(Lg(e,e=>e.PATTERN.test(``)),e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' must not match an empty string`,type:K.EMPTY_MATCH_PATTERN,tokenTypes:[e]}))}o($v,`findEmptyMatchRegExps`);var ey=/[^\\[][\^]|^\^/;function ty(e){class t extends xa{static{o(this,`StartAnchorFinder`)}constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}return B(Lg(e,e=>{let n=e.PATTERN;try{let e=Av(n),r=new t;return r.visit(e),r.found}catch{return ey.test(n.source)}}),e=>({message:`Unexpected RegExp Anchor Error:
|
|||
|
|
Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
|
|||
|
|
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:K.SOI_ANCHOR_FOUND,tokenTypes:[e]}))}o(ty,`findStartOfInputAnchor`);function ny(e){return B(Lg(e,e=>{let t=e[Hv];return t instanceof RegExp&&(t.multiline||t.global)}),e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' may NOT contain global('g') or multiline('m')`,type:K.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]}))}o(ny,`findUnsupportedFlags`);function ry(e){let t=[],n=B(e,n=>L_(e,(e,r)=>n.PATTERN.source===r.PATTERN.source&&!u_(t,r)&&r.PATTERN!==Uy.NA?(t.push(r),e.push(r),e):e,[]));return n=wm(n),B(Lg(n,e=>e.length>1),e=>{let t=B(e,e=>e.name);return{message:`The same RegExp pattern ->${Wg(e).PATTERN}<-has been used in all of the following Token Types: ${t.join(`, `)} <-`,type:K.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}})}o(ry,`findDuplicatePatterns`);function iy(e){return B(Lg(e,e=>{if(!V(e,`GROUP`))return!1;let t=e.GROUP;return t!==Uy.SKIPPED&&t!==Uy.NA&&!i_(t)}),e=>({message:`Token Type: ->`+e.name+`<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String`,type:K.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]}))}o(iy,`findInvalidGroupType`);function ay(e,t){return B(Lg(e,e=>e.PUSH_MODE!==void 0&&!u_(t,e.PUSH_MODE)),e=>({message:`Token Type: ->${e.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${e.PUSH_MODE}<-which does not exist`,type:K.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}))}o(ay,`findModesThatDoNotExist`);function oy(e){let t=[],n=L_(e,(e,t,n)=>{let r=t.PATTERN;return r===Uy.NA||(i_(r)?e.push({str:r,idx:n,tokenType:t}):S_(r)&&cy(r)&&e.push({str:r.source,idx:n,tokenType:t})),e},[]);return z(e,(e,r)=>{z(n,({str:n,idx:i,tokenType:a})=>{if(r<i&&sy(n,e.PATTERN)){let n=`Token: ->${a.name}<- can never be matched.
|
|||
|
|
Because it appears AFTER the Token Type ->${e.name}<-in the lexer's definition.
|
|||
|
|
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:n,type:K.UNREACHABLE_PATTERN,tokenTypes:[e,a]})}})}),t}o(oy,`findUnreachablePatterns`);function sy(e,t){if(S_(t)){if(ly(t))return!1;let n=t.exec(e);return n!==null&&n.index===0}else if(Cs(t))return t(e,0,[],{});else if(V(t,`exec`))return t.exec(e,0,[],{});else if(typeof t==`string`)return t===e;else throw Error(`non exhaustive match`)}o(sy,`tryToMatchStrToPattern`);function cy(e){return Hg([`.`,`\\`,`[`,`]`,`|`,`^`,`$`,`(`,`)`,`?`,`*`,`+`,`{`],t=>e.source.indexOf(t)!==-1)===void 0}o(cy,`noMetaChar`);function ly(e){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(e.source)}o(ly,`usesLookAheadOrBehind`);function uy(e){let t=e.ignoreCase?`i`:``;return RegExp(`^(?:${e.source})`,t)}o(uy,`addStartOfInput`);function dy(e){let t=e.ignoreCase?`iy`:`y`;return RegExp(`${e.source}`,t)}o(dy,`addStickyFlag`);function fy(e,t,n){let r=[];return V(e,Uv)||r.push({message:`A MultiMode Lexer cannot be initialized without a <`+Uv+`> property in its definition
|
|||
|
|
`,type:K.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),V(e,Wv)||r.push({message:`A MultiMode Lexer cannot be initialized without a <`+Wv+`> property in its definition
|
|||
|
|
`,type:K.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),V(e,Wv)&&V(e,Uv)&&!V(e.modes,e.defaultMode)&&r.push({message:`A MultiMode Lexer cannot be initialized with a ${Uv}: <${e.defaultMode}>which does not exist
|
|||
|
|
`,type:K.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),V(e,Wv)&&z(e.modes,(e,t)=>{z(e,(n,i)=>{w_(n)?r.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${t}> at index: <${i}>
|
|||
|
|
`,type:K.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):V(n,`LONGER_ALT`)&&z(F(n.LONGER_ALT)?n.LONGER_ALT:[n.LONGER_ALT],i=>{!w_(i)&&!u_(e,i)&&r.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${i.name}> on token <${n.name}> outside of mode <${t}>
|
|||
|
|
`,type:K.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),r}o(fy,`performRuntimeChecks`);function py(e,t,n){let r=[],i=!1,a=z_(wm(Ld(H(e.modes))),e=>e[Hv]===Uy.NA),o=by(n);return t&&z(a,e=>{let t=vy(e,o);if(t!==!1){let n={message:yy(e,t),type:t.issue,tokenType:e};r.push(n)}else V(e,`LINE_BREAKS`)?e.LINE_BREAKS===!0&&(i=!0):Vv(o,e.PATTERN)&&(i=!0)}),t&&!i&&r.push({message:`Warning: No LINE_BREAKS Found.
|
|||
|
|
This Lexer has been defined to track line and column information,
|
|||
|
|
But none of the Token Types can be identified as matching a line terminator.
|
|||
|
|
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
|
|||
|
|
for details.`,type:K.NO_LINE_BREAKS_FLAGS}),r}o(py,`performWarningRuntimeChecks`);function my(e){let t={};return z(eu(e),n=>{let r=e[n];if(F(r))t[n]=[];else throw Error(`non exhaustive match`)}),t}o(my,`cloneEmptyGroups`);function hy(e){let t=e.PATTERN;if(S_(t))return!1;if(Cs(t)||V(t,`exec`))return!0;if(i_(t))return!1;throw Error(`non exhaustive match`)}o(hy,`isCustomPattern`);function gy(e){return i_(e)&&e.length===1?e.charCodeAt(0):!1}o(gy,`isShortPattern`);var _y={test:o(function(e){let t=e.length;for(let n=this.lastIndex;n<t;n++){let t=e.charCodeAt(n);if(t===10)return this.lastIndex=n+1,!0;if(t===13)return e.charCodeAt(n+1)===10?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},`test`),lastIndex:0};function vy(e,t){if(V(e,`LINE_BREAKS`))return!1;if(S_(e.PATTERN)){try{Vv(t,e.PATTERN)}catch(e){return{issue:K.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}else if(i_(e.PATTERN))return!1;else if(hy(e))return{issue:K.CUSTOM_LINE_BREAK};else throw Error(`non exhaustive match`)}o(vy,`checkLineBreaksIssues`);function yy(e,t){if(t.issue===K.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
|
|||
|
|
The problem is in the <${e.name}> Token Type
|
|||
|
|
Root cause: ${t.errMsg}.
|
|||
|
|
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===K.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
|
|||
|
|
The problem is in the <${e.name}> Token Type
|
|||
|
|
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error(`non exhaustive match`)}o(yy,`buildLineBreakIssueMessage`);function by(e){return B(e,e=>i_(e)?e.charCodeAt(0):e)}o(by,`getCharCodes`);function xy(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}o(xy,`addToMapOfArrays`);var Sy=256,Cy=[];function wy(e){return e<Sy?e:Cy[e]}o(wy,`charCodeToOptimizedIndex`);function Ty(){if(U(Cy)){Cy=Array(65536);for(let e=0;e<65536;e++)Cy[e]=e>255?255+~~(e/255):e}}o(Ty,`initCharCodeToOptimizedIndexMap`);function Ey(e,t){let n=e.tokenTypeIdx;return n===t.tokenTypeIdx?!0:t.isParent===!0&&t.categoryMatchesMap[n]===!0}o(Ey,`tokenStructuredMatcher`);function Dy(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}o(Dy,`tokenStructuredMatcherNoCategories`);var Oy=1,ky={};function Ay(e){let t=jy(e);My(t),Py(t),Ny(t),z(t,e=>{e.isParent=e.categoryMatches.length>0})}o(Ay,`augmentTokenTypes`);function jy(e){let t=Sm(e),n=e,r=!0;for(;r;){n=wm(Ld(B(n,e=>e.CATEGORIES)));let e=vg(n,t);t=t.concat(e),U(e)?r=!1:n=e}return t}o(jy,`expandCategories`);function My(e){z(e,e=>{Iy(e)||(ky[Oy]=e,e.tokenTypeIdx=Oy++),Ly(e)&&!F(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),Ly(e)||(e.CATEGORIES=[]),Ry(e)||(e.categoryMatches=[]),zy(e)||(e.categoryMatchesMap={})})}o(My,`assignTokenDefaultProps`);function Ny(e){z(e,e=>{e.categoryMatches=[],z(e.categoryMatchesMap,(t,n)=>{e.categoryMatches.push(ky[n].tokenTypeIdx)})})}o(Ny,`assignCategoriesTokensProp`);function Py(e){z(e,e=>{Fy([],e)})}o(Py,`assignCategoriesMapProp`);function Fy(e,t){z(e,e=>{t.categoryMatchesMap[e.tokenTypeIdx]=!0}),z(t.CATEGORIES,n=>{let r=e.concat(t);u_(r,n)||Fy(r,n)})}o(Fy,`singleAssignCategoriesToksMap`);function Iy(e){return V(e,`tokenTypeIdx`)}o(Iy,`hasShortKeyProperty`);function Ly(e){return V(e,`CATEGORIES`)}o(Ly,`hasCategoriesProperty`);function Ry(e){return V(e,`categoryMatches`)}o(Ry,`hasExtendingTokensTypesProperty`);function zy(e){return V(e,`categoryMatchesMap`)}o(zy,`hasExtendingTokensTypesMapProperty`);function By(e){return V(e,`tokenTypeIdx`)}o(By,`isTokenType`);var Vy={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,n,r,i,a){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters.`}},K;(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`})(K||={});var Hy={deferDefinitionErrorsHandling:!1,positionTracking:`full`,lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
|
|||
|
|
`,`\r`],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:Vy,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Hy);var Uy=class{static{o(this,`Lexer`)}constructor(e,t=Hy){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(e,t)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=Q_(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}else return t()},typeof t==`boolean`)throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
|
|||
|
|
a boolean 2nd argument is no longer supported`);this.config=nu({},Hy,t);let n=this.config.traceInitPerf;n===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof n==`number`&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT(`Lexer Constructor`,()=>{let n,r=!0;this.TRACE_INIT(`Lexer Config handling`,()=>{if(this.config.lineTerminatorsPattern===Hy.lineTerminatorsPattern)this.config.lineTerminatorsPattern=_y;else if(this.config.lineTerminatorCharacters===Hy.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
|
|||
|
|
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error(`"safeMode" and "ensureOptimizations" flags are mutually exclusive.`);this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),F(e)?n={modes:{defaultMode:Sm(e)},defaultMode:Uv}:(r=!1,n=Sm(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT(`performRuntimeChecks`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(fy(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT(`performWarningRuntimeChecks`,()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(py(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},z(n.modes,(e,t)=>{n.modes[t]=z_(e,e=>w_(e))});let i=eu(n.modes);if(z(n.modes,(e,n)=>{this.TRACE_INIT(`Mode: <${n}> processing`,()=>{if(this.modes.push(n),this.config.skipValidations===!1&&this.TRACE_INIT(`validatePatterns`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(qv(e,i))}),U(this.lexerDefinitionErrors)){Ay(e);let r;this.TRACE_INIT(`analyzeTokenTypes`,()=>{r=Kv(e,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[n]=r.patternIdxToConfig,this.charCodeToPatternIdxToConfig[n]=r.charCodeToPatternIdxToConfig,this.emptyGroups=nu({},this.emptyGroups,r.emptyGroups),this.hasCustom=r.hasCustom||this.hasCustom,this.canModeBeOptimized[n]=r.canBeOptimized}})}),this.defaultMode=n.defaultMode,!U(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let e=B(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
|
|||
|
|
`);throw Error(`Errors detected in definition of Lexer:
|
|||
|
|
`+e)}z(this.lexerDefinitionWarning,e=>{Z_(e.message)}),this.TRACE_INIT(`Choosing sub-methods implementations`,()=>{if(Gv?(this.chopInput=_s,this.match=this.matchWithTest):(this.updateLastIndex=I,this.match=this.matchWithExec),r&&(this.handleModes=I),this.trackStartLines===!1&&(this.computeNewColumn=_s),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=I),/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}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT(`Failed Optimization Warnings`,()=>{let e=L_(this.canModeBeOptimized,(e,t,n)=>(t===!1&&e.push(n),e),[]);if(t.ensureOptimizations&&!U(e))throw Error(`Lexer Modes: < ${e.join(`, `)} > cannot be optimized.
|
|||
|
|
Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
|
|||
|
|
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT(`clearRegExpParserCache`,()=>{jv()}),this.TRACE_INIT(`toFastProperties`,()=>{$_(this)})})}tokenize(e,t=this.defaultMode){if(!U(this.lexerDefinitionErrors)){let e=B(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
|
|||
|
|
`);throw Error(`Unable to Tokenize because Errors detected in definition of Lexer:
|
|||
|
|
`+e)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,r,i,a,s,c,l,u,d,f,p,m,h,g,_,v=e,y=v.length,b=0,x=0,ee=this.hasCustom?0:Math.floor(e.length/10),S=Array(ee),te=[],ne=this.trackStartLines?1:void 0,C=this.trackStartLines?1:void 0,re=my(this.emptyGroups),ie=this.trackStartLines,ae=this.config.lineTerminatorsPattern,oe=0,se=[],ce=[],le=[],ue=[];Object.freeze(ue);let de;function w(){return se}o(w,`getPossiblePatternsSlow`);function T(e){let t=wy(e),n=ce[t];return n===void 0?ue:n}o(T,`getPossiblePatternsOptimized`);let fe=o(e=>{if(le.length===1&&e.tokenType.PUSH_MODE===void 0){let t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);te.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{le.pop();let e=bg(le);se=this.patternIdxToConfig[e],ce=this.charCodeToPatternIdxToConfig[e],oe=se.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;de=ce&&t?T:w}},`pop_mode`);function E(e){le.push(e),ce=this.charCodeToPatternIdxToConfig[e],se=this.patternIdxToConfig[e],oe=se.length,oe=se.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;de=ce&&t?T:w}o(E,`push_mode`),E.call(this,t);let D,pe=this.config.recoveryEnabled;for(;b<y;){c=null;let t=v.charCodeAt(b),o=de(t),ee=o.length;for(n=0;n<ee;n++){D=o[n];let r=D.pattern;l=null;let d=D.short;if(d===!1?D.isCustom===!0?(_=r.exec(v,b,S,re),_===null?c=null:(c=_[0],_.payload!==void 0&&(l=_.payload))):(this.updateLastIndex(r,b),c=this.match(r,e,b)):t===d&&(c=r),c!==null){if(s=D.longerAlt,s!==void 0){let t=s.length;for(i=0;i<t;i++){let t=se[s[i]],n=t.pattern;if(u=null,t.isCustom===!0?(_=n.exec(v,b,S,re),_===null?a=null:(a=_[0],_.payload!==void 0&&(u=_.payload))):(this.updateLastIndex(n,b),a=this.match(n,e,b)),a&&a.length>c.length){c=a,l=u,D=t;break}}}break}}if(c!==null){if(d=c.length,f=D.group,f!==void 0&&(p=D.tokenTypeIdx,m=this.createTokenInstance(c,b,p,D.tokenType,ne,C,d),this.handlePayload(m,l),f===!1?x=this.addToken(S,x,m):re[f].push(m)),e=this.chopInput(e,d),b+=d,C=this.computeNewColumn(C,d),ie===!0&&D.canLineTerminator===!0){let e=0,t,n;ae.lastIndex=0;do t=ae.test(c),t===!0&&(n=ae.lastIndex-1,e++);while(t===!0);e!==0&&(ne+=e,C=d-n,this.updateTokenEndLineColumnLocation(m,f,n,e,ne,C,d))}this.handleModes(D,fe,E,m)}else{let t=b,n=ne,i=C,a=pe===!1;for(;a===!1&&b<y;)for(e=this.chopInput(e,1),b++,r=0;r<oe;r++){let t=se[r],n=t.pattern,i=t.short;if(i===!1?t.isCustom===!0?a=n.exec(v,b,S,re)!==null:(this.updateLastIndex(n,b),a=n.exec(e)!==null):v.charCodeAt(b)===i&&(a=!0),a===!0)break}if(h=b-t,C=this.computeNewColumn(C,h),g=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(v,t,h,n,i,bg(le)),te.push({offset:t,line:n,column:i,length:h,message:g}),pe===!1)break}}return this.hasCustom||(S.length=x),{tokens:S,groups:re,errors:te}}handleModes(e,t,n,r){if(e.pop===!0){let i=e.push;t(r),i!==void 0&&n.call(this,i)}else e.push!==void 0&&n.call(this,e.push)}chopInput(e,t){return e.substring(t)}updateLastIndex(e,t){e.lastIndex=t}updateTokenEndLineColumnLocation(e,t,n,r,i,a,o){let s,c;t!==void 0&&(s=n===o-1,c=s?-1:0,r===1&&s===!0||(e.endLine=i+c,e.endColumn=a-1+-c))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,n,r){return{image:e,startOffset:t,tokenTypeIdx:n,tokenType:r}}createStartOnlyToken(e,t,n,r,i,a){return{image:e,startOffset:t,startLine:i,startColumn:a,tokenTypeIdx:n,tokenType:r}}createFullToken(e,t,n,r,i,a,o){return{image:e,startOffset:t,endOffset:t+o-1,startLine:i,endLine:i,startColumn:a,endColumn:a+o-1,tokenTypeIdx:n,tokenType:r}}addTokenUsingPush(e,t,n){return e.push(n),t}addTokenUsingMemberAccess(e,t,n){return e[t]=n,t++,t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){t!==null&&(e.payload=t)}matchWithTest(e,t,n){return e.test(t)===!0?t.substring(n,e.lastIndex):null}matchWithExec(e,t){let n=e.exec(t);return n===null?null:n[0]}};Uy.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.`,Uy.NA=/NOT_APPLICABLE/;functi
|
|||
|
|
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return V(e,qy)&&(n.CATEGORIES=e[qy]),Ay([n]),V(e,Jy)&&(n.LABEL=e[Jy]),V(e,Yy)&&(n.GROUP=e[Yy]),V(e,Zy)&&(n.POP_MODE=e[Zy]),V(e,Xy)&&(n.PUSH_MODE=e[Xy]),V(e,Qy)&&(n.LONGER_ALT=e[Qy]),V(e,$y)&&(n.LINE_BREAKS=e[$y]),V(e,eb)&&(n.START_CHARS_HINT=e[eb]),n}o(nb,`createTokenInternal`);var rb=tb({name:`EOF`,pattern:Uy.NA});Ay([rb]);function ib(e,t,n,r,i,a,o,s){return{image:t,startOffset:n,endOffset:r,startLine:i,endLine:a,startColumn:o,endColumn:s,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}o(ib,`createTokenInstance`);function ab(e,t){return Ey(e,t)}o(ab,`tokenMatcher`);var ob={buildMismatchTokenMessage({expected:e,actual:t,previous:n,ruleName:r}){return`Expecting ${Gy(e)?`--> ${Wy(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:t}){return`Redundant input, expecting EOF but found: `+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:n,customUserDescription:r,ruleName:i}){let a=`
|
|||
|
|
but found: '`+Wg(t).image+`'`;return r?`Expecting: `+r+a:`Expecting: one of these possible Token sequences:
|
|||
|
|
${B(B(L_(e,(e,t)=>e.concat(t),[]),e=>`[${B(e,e=>Wy(e)).join(`, `)}]`),(e,t)=>` ${t+1}. ${e}`).join(`
|
|||
|
|
`)}`+a},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:n,ruleName:r}){let i=`
|
|||
|
|
but found: '`+Wg(t).image+`'`;return n?`Expecting: `+n+i:`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::
|
|||
|
|
<${B(e,e=>`[${B(e,e=>Wy(e)).join(`,`)}]`).join(` ,`)}>`+i}};Object.freeze(ob);var sb={buildRuleNotFoundError(e,t){return`Invalid grammar, reference to a rule which is not defined: ->`+t.nonTerminalName+`<-
|
|||
|
|
inside top level rule: ->`+e.name+`<-`}},cb={buildDuplicateFoundError(e,t){function n(e){return e instanceof G?e.terminalType.name:e instanceof rv?e.nonTerminalName:``}o(n,`getExtraProductionArgument`);let r=e.name,i=Wg(t),a=i.idx,s=_v(i),c=n(i),l=`->${s}${a>0?a:``}<- ${c?`with argument: ->${c}<-`:``}
|
|||
|
|
appears more than once (${t.length} times) in the top level rule: ->${r}<-.
|
|||
|
|
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
|
|||
|
|
`;return l=l.replace(/[ \t]+/g,` `),l=l.replace(/\s\s+/g,`
|
|||
|
|
`),l},buildNamespaceConflictError(e){return`Namespace conflict found in grammar.
|
|||
|
|
The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.
|
|||
|
|
To resolve this make sure each Terminal and Non-Terminal names are unique
|
|||
|
|
This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
|
|||
|
|
and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=B(e.prefixPath,e=>Wy(e)).join(`, `),n=e.alternation.idx===0?``:e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(` ,`)}> due to common lookahead prefix
|
|||
|
|
in <OR${n}> inside <${e.topLevelRule.name}> Rule,
|
|||
|
|
<${t}> may appears as a prefix path in all these alternatives.
|
|||
|
|
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
|
|||
|
|
For Further details.`},buildAlternationAmbiguityError(e){let t=B(e.prefixPath,e=>Wy(e)).join(`, `),n=e.alternation.idx===0?``:e.alternation.idx,r=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(` ,`)}> in <OR${n}> inside <${e.topLevelRule.name}> Rule,
|
|||
|
|
<${t}> may appears as a prefix path in all these alternatives.
|
|||
|
|
`;return r+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
|
|||
|
|
For Further details.`,r},buildEmptyRepetitionError(e){let t=_v(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.
|
|||
|
|
This could lead to an infinite loop.`},buildTokenNameError(e){return`deprecated`},buildEmptyAlternationError(e){return`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.
|
|||
|
|
Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(e){return`An Alternation cannot have more than 256 alternatives:
|
|||
|
|
<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.
|
|||
|
|
has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name;return`Left Recursion found in grammar.
|
|||
|
|
rule: <${t}> can be invoked from itself (directly or indirectly)
|
|||
|
|
without consuming any Tokens. The grammar path that causes this is:
|
|||
|
|
${`${t} --> ${B(e.leftRecursionPath,e=>e.name).concat([t]).join(` --> `)}`}
|
|||
|
|
To fix this refactor your grammar to remove the left recursion.
|
|||
|
|
see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return`deprecated`},buildDuplicateRuleNameError(e){let t;return t=e.topLevelRule instanceof iv?e.topLevelRule.name:e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function lb(e,t){let n=new ub(e,t);return n.resolveRefs(),n.errors}o(lb,`resolveGrammar`);var ub=class extends pv{static{o(this,`GastRefResolverVisitor`)}constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){z(H(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let t=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:t,type:hS.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},db=class extends vv{static{o(this,`AbstractNextPossibleTokensWalker`)}constructor(e,t){super(),this.topProd=e,this.path=t,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=Sm(this.path.ruleStack).reverse(),this.occurrenceStack=Sm(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let r=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,r)}}updateExpectedNext(){U(this.ruleStack)?(this.nextProductionName=``,this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},fb=class extends db{static{o(this,`NextAfterTokenWalker`)}constructor(e,t){super(e,t),this.path=t,this.nextTerminalName=``,this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let e=new av({definition:t.concat(n)});this.possibleTokTypes=bv(e),this.found=!0}}},pb=class extends vv{static{o(this,`AbstractNextTerminalAfterProductionWalker`)}constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},mb=class extends pb{static{o(this,`NextTerminalAfterManyWalker`)}walkMany(e,t,n){if(e.idx===this.occurrence){let e=Wg(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof G&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,n)}},hb=class extends pb{static{o(this,`NextTerminalAfterManySepWalker`)}walkManySep(e,t,n){if(e.idx===this.occurrence){let e=Wg(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof G&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,n)}},gb=class extends pb{static{o(this,`NextTerminalAfterAtLeastOneWalker`)}walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){let e=Wg(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof G&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,n)}},_b=class extends pb{static{o(this,`NextTerminalAfterAtLeastOneSepWalker`)}walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){let e=Wg(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof G&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,n)}};function vb(e,t,n=[]){n=Sm(n);let r=[],i=0;function a(t){return t.concat(Sg(e,i+1))}o(a,`remainingPathWith`);function s(e){let i=vb(a(e),t,n);return r.concat(i)}for(o(s,`getAlternativesForProd`);n.le
|
|||
|
|
${t.join(`
|
|||
|
|
|
|||
|
|
`).replace(/\n/g,`
|
|||
|
|
`)}`)}},`validateVisitor`)},n.prototype.constructor=n,n._RULE_NAMES=t,n}o(Hx,`createBaseSemanticVisitorConstructor`);function Ux(e,t,n){let r=o(function(){},`derivedConstructor`);Bx(r,e+`BaseSemanticsWithDefaults`);let i=Object.create(n.prototype);return z(t,e=>{i[e]=Vx}),r.prototype=i,r.prototype.constructor=r,r}o(Ux,`createBaseVisitorConstructorWithDefaults`);var Wx;(function(e){e[e.REDUNDANT_METHOD=0]=`REDUNDANT_METHOD`,e[e.MISSING_METHOD=1]=`MISSING_METHOD`})(Wx||={});function Gx(e,t){return Kx(e,t)}o(Gx,`validateVisitor`);function Kx(e,t){return wm(B(Lg(t,t=>Cs(e[t])===!1),t=>({msg:`Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,type:Wx.MISSING_METHOD,methodName:t})))}o(Kx,`validateMissingCstMethods`);var qx=class{static{o(this,`TreeBuilder`)}initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=V(e,`nodeLocationTracking`)?e.nodeLocationTracking:pS.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=I,this.cstFinallyStateUpdate=I,this.cstPostTerminal=I,this.cstPostNonTerminal=I,this.cstPostRule=I;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Ix,this.setNodeLocationFromNode=Ix,this.cstPostRule=I,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=I,this.setNodeLocationFromNode=I,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Fx,this.setNodeLocationFromNode=Fx,this.cstPostRule=I,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=I,this.setNodeLocationFromNode=I,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=I,this.setNodeLocationFromNode=I,this.cstPostRule=I,this.setInitialNodeLocation=I;else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){let t=this.LA(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?(n.endOffset=t.endOffset,n.endLine=t.endLine,n.endColumn=t.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)}cstPostRuleOnlyOffset(e){let t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?n.endOffset=t.endOffset:n.startOffset=NaN}cstPostTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];Lx(n,t,e),this.setNodeLocationFromToken(n.location,t)}cstPostNonTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];Rx(n,t,e),this.setNodeLocationFromNode(n.location,e.location)}getBaseCstVisitorConstructor(){if(w_(this.baseCstVisitorConstructor)){let e=Hx(this.className,eu(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(w_(this.baseCstVisitorWithDefaultsConstructor)){let e=Ux(this.className,eu(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-1]}getPreviousExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-2]}getLastExplicitRuleOccurrenc
|
|||
|
|
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
|
|||
|
|
For Further details.`);if(F(e)){if(U(e))throw Error(`A Token Vocabulary cannot be empty.
|
|||
|
|
Note that the first argument for the parser constructor
|
|||
|
|
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.
|
|||
|
|
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
|
|||
|
|
For Further details.`)}if(F(e))this.tokensMap=L_(e,(e,t)=>(e[t.name]=t,e),{});else if(V(e,`modes`)&&Ng(Ld(H(e.modes)),By)){let t=Y_(Ld(H(e.modes)));this.tokensMap=L_(t,(e,t)=>(e[t.name]=t,e),{})}else if(ns(e))this.tokensMap=Sm(e);else throw Error(`<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition`);this.tokensMap.EOF=rb;let n=Ng(V(e,`modes`)?Ld(H(e.modes)):H(e),e=>U(e.categoryMatches));this.tokenMatcher=n?Dy:Ey,Ay(H(this.tokensMap))}defineRule(e,t,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'
|
|||
|
|
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let r=V(n,`resyncEnabled`)?n.resyncEnabled:mS.resyncEnabled,i=V(n,`recoveryValueFunc`)?n.recoveryValueFunc:mS.recoveryValueFunc,a=this.ruleShortNameIdx<<xx+Sx;this.ruleShortNameIdx++,this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a;let s;return s=this.outputCst===!0?o(function(...n){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n);let r=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(r),r}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}},`invokeRuleWithTry`):o(function(...n){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n)}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}},`invokeRuleWithTryCst`),Object.assign(s,{ruleName:e,originalGrammarAction:t})}invokeRuleCatch(e,t,n){let r=this.RULE_STACK.length===1,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if(ux(e)){let t=e;if(i){let r=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(r))if(t.resyncedTokens=this.reSyncTo(r),this.outputCst){let e=this.CST_STACK[this.CST_STACK.length-1];return e.recoveredNode=!0,e}else return n(e);else{if(this.outputCst){let e=this.CST_STACK[this.CST_STACK.length-1];e.recoveredNode=!0,t.partialCstResult=e}throw t}}else if(r)return this.moveToTerminatedState(),n(e);else throw t}else throw e}optionInternal(e,t){let n=this.getKeyForAutomaticLookahead(Tx,t);return this.optionInternalLogic(e,t,n)}optionInternalLogic(e,t,n){let r=this.getLaFuncFromCache(n),i;if(typeof e!=`function`){i=e.DEF;let t=e.GATE;if(t!==void 0){let e=r;r=o(()=>t.call(this)&&e.call(this),`lookAheadFunc`)}}else i=e;if(r.call(this)===!0)return i.call(this)}atLeastOneInternal(e,t){let n=this.getKeyForAutomaticLookahead(Dx,e);return this.atLeastOneInternalLogic(e,t,n)}atLeastOneInternalLogic(e,t,n){let r=this.getLaFuncFromCache(n),i;if(typeof t!=`function`){i=t.DEF;let e=t.GATE;if(e!==void 0){let t=r;r=o(()=>e.call(this)&&t.call(this),`lookAheadFunc`)}}else i=t;if(r.call(this)===!0){let e=this.doSingleRepetition(i);for(;r.call(this)===!0&&e===!0;)e=this.doSingleRepetition(i)}else throw this.raiseEarlyExitException(e,q.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],r,Dx,e,gb)}atLeastOneSepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(kx,e);this.atLeastOneSepFirstInternalLogic(e,t,n)}atLeastOneSepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){r.call(this);let t=o(()=>this.tokenMatcher(this.LA(1),i),`separatorLookAheadFunc`);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,_b],t,kx,e,_b)}else throw this.raiseEarlyExitException(e,q.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let n=this.getKeyForAutomaticLookahead(Ex,e);return this.manyInternalLogic(e,t,n)}manyInternalLogic(e,t,n){let r=this.getLaFuncFromCache(n),i;if(typeof t!=`function`){i=t.DEF;let e=t.GATE;if(e!==void 0){let t=r;r=o(()=>e.call(this)&&t.call(this),`lookaheadFunction`)}}else i=t;let a=!0;for(;r.call(this)===!0&&a===!0;)a=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],r,Ex,e,mb,a)}manySepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(Ox,e);this.manySepFirstInternalLogic(e,t,n)}manySepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){r.call(this);let t=o(()=>this.tokenMatcher(this.LA(1),i),`separatorLookAheadFunc`);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,hb],t,Ox,e,hb)}}repetitionSepSecondInternal(e,t,n,r,i){for(;n();)this.CONSUME(t),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,n,r,i],n,kx,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let n=this
|
|||
|
|
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(rS);var iS={name:`This CSTNode indicates the Parser is in Recording Phase
|
|||
|
|
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},aS=class{static{o(this,`GastRecorder`)}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 t=e>0?e:``;this[`CONSUME${t}`]=function(t,n){return this.consumeInternalRecord(t,e,n)},this[`SUBRULE${t}`]=function(t,n){return this.subruleInternalRecord(t,e,n)},this[`OPTION${t}`]=function(t){return this.optionInternalRecord(t,e)},this[`OR${t}`]=function(t){return this.orInternalRecord(t,e)},this[`MANY${t}`]=function(t){this.manyInternalRecord(e,t)},this[`MANY_SEP${t}`]=function(t){this.manySepFirstInternalRecord(e,t)},this[`AT_LEAST_ONE${t}`]=function(t){this.atLeastOneInternalRecord(e,t)},this[`AT_LEAST_ONE_SEP${t}`]=function(t){this.atLeastOneSepFirstInternalRecord(e,t)}}this.consume=function(e,t,n){return this.consumeInternalRecord(t,e,n)},this.subrule=function(e,t,n){return this.subruleInternalRecord(t,e,n)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},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 t=0;t<10;t++){let n=t>0?t:``;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,t){return()=>!0}LA_RECORD(e){return fS}topLevelRuleRecord(e,t){try{let n=new iv({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),t.call(this),this.recordingProdStack.pop(),n}catch(e){if(e.KNOWN_RECORDER_ERROR!==!0)try{e.message+=`
|
|||
|
|
This error was thrown during the "grammar recording phase" For more info see:
|
|||
|
|
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw e}throw e}}optionInternalRecord(e,t){return oS.call(this,ov,e,t)}atLeastOneInternalRecord(e,t){oS.call(this,sv,t,e)}atLeastOneSepFirstInternalRecord(e,t){oS.call(this,cv,t,e,eS)}manyInternalRecord(e,t){oS.call(this,W,t,e)}manySepFirstInternalRecord(e,t){oS.call(this,lv,t,e,eS)}orInternalRecord(e,t){return sS.call(this,e,t)}subruleInternalRecord(e,t,n){if(lS(t),!e||V(e,`ruleName`)===!1){let n=Error(`<SUBRULE${cS(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
|
|||
|
|
inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}let r=bg(this.recordingProdStack),i=e.ruleName,a=new rv({idx:t,nonTerminalName:i,label:n?.LABEL,referencedRule:void 0});return r.definition.push(a),this.outputCst?iS:$x}consumeInternalRecord(e,t,n){if(lS(t),!Iy(e)){let n=Error(`<CONSUME${cS(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>
|
|||
|
|
inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}let r=bg(this.recordingProdStack),i=new G({idx:t,terminalType:e,label:n?.LABEL});return r.definition.push(i),rS}};function oS(e,t,n,r=!1){lS(n);let i=bg(this.recordingProdStack),a=Cs(t)?t:t.DEF,o=new e({definition:[],idx:n});return r&&(o.separator=t.SEP),V(t,`MAX_LOOKAHEAD`)&&(o.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(o),a.call(this),i.definition.push(o),this.recordingProdStack.pop(),$x}o(oS,`recordProd`);function sS(e,t){lS(t);let n=bg(this.recordingProdStack),r=F(e)===!1,i=r===!1?e:e.DEF,a=new uv({definition:[],idx:t,ignoreAmbiguities:r&&e.IGNORE_AMBIGUITIES===!0});return V(e,`MAX_LOOKAHEAD`)&&(a.maxLookahead=e.MAX_LOOKAHEAD),a.hasPredicates=U_(i,e=>Cs(e.GATE)),n.definition.push(a),z(i,e=>{let t=new av({definition:[]});a.definition.push(t),V(e,`IGNORE_AMBIGUITIES`)?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:V(e,`GATE`)&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()}),$x}o(sS,`recordOrProd`);function cS(e){return e===0?``:`${e}`}o(cS,`getIdxSuffix`);function lS(e){if(e<0||e>tS){let t=Error(`Invalid DSL Method idx value: <${e}>
|
|||
|
|
Idx value must be a none negative value smaller than ${tS+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}o(lS,`assertMethodIdxIsValid`);var uS=class{static{o(this,`PerformanceTracer`)}initPerformanceTracer(e){if(V(e,`traceInitPerf`)){let t=e.traceInitPerf,n=typeof t==`number`;this.traceInitMaxIdent=n?t:1/0,this.traceInitPerf=n?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=pS.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=Q_(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}else return t()}};function dS(e,t){t.forEach(t=>{let n=t.prototype;Object.getOwnPropertyNames(n).forEach(r=>{if(r===`constructor`)return;let i=Object.getOwnPropertyDescriptor(n,r);i&&(i.get||i.set)?Object.defineProperty(e.prototype,r,i):e.prototype[r]=t.prototype[r]})})}o(dS,`applyMixins`);var fS=ib(rb,``,NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(fS);var pS=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:ob,nodeLocationTracking:`none`,traceInitPerf:!1,skipValidations:!1}),mS=Object.freeze({recoveryValueFunc:o(()=>void 0,`recoveryValueFunc`),resyncEnabled:!0}),hS;(function(e){e[e.INVALID_RULE_NAME=0]=`INVALID_RULE_NAME`,e[e.DUPLICATE_RULE_NAME=1]=`DUPLICATE_RULE_NAME`,e[e.INVALID_RULE_OVERRIDE=2]=`INVALID_RULE_OVERRIDE`,e[e.DUPLICATE_PRODUCTIONS=3]=`DUPLICATE_PRODUCTIONS`,e[e.UNRESOLVED_SUBRULE_REF=4]=`UNRESOLVED_SUBRULE_REF`,e[e.LEFT_RECURSION=5]=`LEFT_RECURSION`,e[e.NONE_LAST_EMPTY_ALT=6]=`NONE_LAST_EMPTY_ALT`,e[e.AMBIGUOUS_ALTS=7]=`AMBIGUOUS_ALTS`,e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]=`CONFLICT_TOKENS_RULES_NAMESPACE`,e[e.INVALID_TOKEN_NAME=9]=`INVALID_TOKEN_NAME`,e[e.NO_NON_EMPTY_LOOKAHEAD=10]=`NO_NON_EMPTY_LOOKAHEAD`,e[e.AMBIGUOUS_PREFIX_ALTS=11]=`AMBIGUOUS_PREFIX_ALTS`,e[e.TOO_MANY_ALTS=12]=`TOO_MANY_ALTS`,e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]=`CUSTOM_LOOKAHEAD_VALIDATION`})(hS||={});function gS(e=void 0){return function(){return e}}o(gS,`EMPTY_ALT`);var _S=class e{static{o(this,`Parser`)}static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT(`performSelfAnalysis`,()=>{let t;this.selfAnalysisDone=!0;let n=this.className;this.TRACE_INIT(`toFastProps`,()=>{$_(this)}),this.TRACE_INIT(`Grammar Recording`,()=>{try{this.enableRecording(),z(this.definedRulesNames,e=>{let t=this[e].originalGrammarAction,n;this.TRACE_INIT(`${e} Rule`,()=>{n=this.topLevelRuleRecord(e,t)}),this.gastProductionsCache[e]=n})}finally{this.disableRecording()}});let r=[];if(this.TRACE_INIT(`Grammar Resolving`,()=>{r=rx({rules:H(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(r)}),this.TRACE_INIT(`Grammar Validations`,()=>{if(U(r)&&this.skipValidations===!1){let e=ix({rules:H(this.gastProductionsCache),tokenTypes:H(this.tokensMap),errMsgProvider:cb,grammarName:n}),t=Rb({lookaheadStrategy:this.lookaheadStrategy,rules:H(this.gastProductionsCache),tokenTypes:H(this.tokensMap),grammarName:n});this.definitionErrors=this.definitionErrors.concat(e,t)}}),U(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT(`computeAllProdsFollows`,()=>{let e=Ev(H(this.gastProductionsCache));this.resyncFollows=e}),this.TRACE_INIT(`ComputeLookaheadFunctions`,()=>{var e,t;(t=(e=this.lookaheadStrategy).initialize)==null||t.call(e,{rules:H(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(H(this.gastProductionsCache))})),!e.DEFER_DEFINITION_ERRORS_HANDLING&&!U(this.definitionErrors))throw t=B(this.definitionErrors,e=>e.message),Error(`Parser Definition Errors detected:
|
|||
|
|
${t.join(`
|
|||
|
|
-------------------------------
|
|||
|
|
`)}`)})}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(t),n.initLexerAdapter(),n.initLooksAhead(t),n.initRecognizerEngine(e,t),n.initRecoverable(t),n.initTreeBuilder(t),n.initContentAssist(),n.initGastRecorder(t),n.initPerformanceTracer(t),V(t,`ignoredIssues`))throw Error(`The <ignoredIssues> IParserConfig property has been deprecated.
|
|||
|
|
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
|
|||
|
|
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
|
|||
|
|
For further details.`);this.skipValidations=V(t,`skipValidations`)?t.skipValidations:pS.skipValidations}};_S.DEFER_DEFINITION_ERRORS_HANDLING=!1,dS(_S,[yx,Mx,qx,Jx,Xx,Yx,Zx,Qx,aS,uS]);var vS=class extends _S{static{o(this,`EmbeddedActionsParser`)}constructor(e,t=pS){let n=Sm(t);n.outputCst=!1,super(e,n)}};function yS(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}o(yS,`arrayMap`);var bS=yS;function xS(){this.__data__=[],this.size=0}o(xS,`listCacheClear`);var SS=xS;function CS(e,t){return e===t||e!==e&&t!==t}o(CS,`eq`);var wS=CS;function TS(e,t){for(var n=e.length;n--;)if(wS(e[n][0],t))return n;return-1}o(TS,`assocIndexOf`);var ES=TS,DS=Array.prototype.splice;function OS(e){var t=this.__data__,n=ES(t,e);return n<0?!1:(n==t.length-1?t.pop():DS.call(t,n,1),--this.size,!0)}o(OS,`listCacheDelete`);var kS=OS;function AS(e){var t=this.__data__,n=ES(t,e);return n<0?void 0:t[n][1]}o(AS,`listCacheGet`);var jS=AS;function MS(e){return ES(this.__data__,e)>-1}o(MS,`listCacheHas`);var NS=MS;function PS(e,t){var n=this.__data__,r=ES(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}o(PS,`listCacheSet`);var FS=PS;function IS(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}o(IS,`ListCache`),IS.prototype.clear=SS,IS.prototype.delete=kS,IS.prototype.get=jS,IS.prototype.has=NS,IS.prototype.set=FS;var LS=IS;function RS(){this.__data__=new LS,this.size=0}o(RS,`stackClear`);var zS=RS;function BS(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}o(BS,`stackDelete`);var VS=BS;function HS(e){return this.__data__.get(e)}o(HS,`stackGet`);var US=HS;function WS(e){return this.__data__.has(e)}o(WS,`stackHas`);var GS=WS,KS=typeof global==`object`&&global&&global.Object===Object&&global,qS=typeof self==`object`&&self&&self.Object===Object&&self,JS=KS||qS||Function(`return this`)(),YS=JS.Symbol,XS=Object.prototype,ZS=XS.hasOwnProperty,QS=XS.toString,$S=YS?YS.toStringTag:void 0;function eC(e){var t=ZS.call(e,$S),n=e[$S];try{e[$S]=void 0;var r=!0}catch{}var i=QS.call(e);return r&&(t?e[$S]=n:delete e[$S]),i}o(eC,`getRawTag`);var tC=eC,nC=Object.prototype.toString;function rC(e){return nC.call(e)}o(rC,`objectToString`);var iC=rC,aC=`[object Null]`,oC=`[object Undefined]`,sC=YS?YS.toStringTag:void 0;function cC(e){return e==null?e===void 0?oC:aC:sC&&sC in Object(e)?tC(e):iC(e)}o(cC,`baseGetTag`);var lC=cC;function uC(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}o(uC,`isObject`);var dC=uC,fC=`[object AsyncFunction]`,pC=`[object Function]`,mC=`[object GeneratorFunction]`,hC=`[object Proxy]`;function gC(e){if(!dC(e))return!1;var t=lC(e);return t==pC||t==mC||t==fC||t==hC}o(gC,`isFunction`);var _C=gC,vC=JS[`__core-js_shared__`],yC=(function(){var e=/[^.]+$/.exec(vC&&vC.keys&&vC.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``})();function bC(e){return!!yC&&yC in e}o(bC,`isMasked`);var xC=bC,SC=Function.prototype.toString;function CC(e){if(e!=null){try{return SC.call(e)}catch{}try{return e+``}catch{}}return``}o(CC,`toSource`);var wC=CC,TC=/[\\^$.*+?()[\]{}|]/g,EC=/^\[object .+?Constructor\]$/,DC=Function.prototype,OC=Object.prototype,kC=DC.toString,AC=OC.hasOwnProperty,jC=RegExp(`^`+kC.call(AC).replace(TC,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function MC(e){return!dC(e)||xC(e)?!1:(_C(e)?jC:EC).test(wC(e))}o(MC,`baseIsNative`);var NC=MC;function PC(e,t){return e?.[t]}o(PC,`getValue`);var FC=PC;function IC(e,t){var n=FC(e,t);return NC(n)?n:void 0}o(IC,`getNative`);var LC=IC,RC=LC(JS,`Map`),zC=LC(Object,`create`);function BC(){this.__data__=zC?zC(null):{},this.size=0}o(BC,`hashClear`);var VC=BC;function HC(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}o(HC,`hashDelete`);var UC=HC,WC=`__lodash_hash_undefined__`,GC=Object.prototype.hasOwnProperty;function KC(e){var t=this.__data__;if(zC){var n=t[e];return n===WC?void 0:n}return GC.call(t,e)?t[e]:void 0}o(KC,`hashGet`);var qC=KC,JC=Object.prototype.hasOwnProperty;function YC(e){var t=this.__data__;return zC?t[e]!==void 0:JC.call(
|
|||
|
|
<${t}> may appears as a prefix path in all these alternatives.
|
|||
|
|
`;return r+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
|
|||
|
|
For Further details.`,r}o(NA,`buildAmbiguityError`);function PA(e){if(e instanceof rv)return`SUBRULE`;if(e instanceof ov)return`OPTION`;if(e instanceof uv)return`OR`;if(e instanceof sv)return`AT_LEAST_ONE`;if(e instanceof cv)return`AT_LEAST_ONE_SEP`;if(e instanceof lv)return`MANY_SEP`;if(e instanceof W)return`MANY`;if(e instanceof G)return`CONSUME`;throw Error(`non exhaustive match`)}o(PA,`getProductionDslName`);function FA(e,t,n){return{actualToken:n,possibleTokenTypes:rA(Lk(t.configs.elements,e=>e.state.transitions).filter(e=>e instanceof ZO).map(e=>e.tokenType),e=>e.tokenTypeIdx),tokenPath:e}}o(FA,`buildAdaptivePredictError`);function IA(e,t){return e.edges[t.tokenTypeIdx]}o(IA,`getExistingTargetState`);function LA(e,t,n){let r=new Ck,i=[];for(let a of e.elements){if(n.is(a.alt)===!1)continue;if(a.state.type===WO){i.push(a);continue}let e=a.state.transitions.length;for(let n=0;n<e;n++){let e=a.state.transitions[n],i=RA(e,t);i!==void 0&&r.add({state:i,alt:a.alt,stack:a.stack})}}let a;if(i.length===0&&r.size===1&&(a=r),a===void 0){a=new Ck;for(let e of r.elements)WA(e,a)}if(i.length>0&&!KA(a))for(let e of i)a.add(e);return a}o(LA,`computeReachSet`);function RA(e,t){if(e instanceof ZO&&ab(t,e.tokenType))return e.target}o(RA,`getReachableTarget`);function zA(e,t){let n;for(let r of e.elements)if(t.is(r.alt)===!0){if(n===void 0)n=r.alt;else if(n!==r.alt)return}return n}o(zA,`getUniqueAlt`);function BA(e){return{configs:e,edges:{},isAcceptState:!1,prediction:-1}}o(BA,`newDFAState`);function VA(e,t,n,r){return r=HA(e,r),t.edges[n.tokenTypeIdx]=r,r}o(VA,`addDFAEdge`);function HA(e,t){if(t===Sk)return t;let n=t.configs.key,r=e.states[n];return r===void 0?(t.configs.finalize(),e.states[n]=t,t):r}o(HA,`addDFAState`);function UA(e){let t=new Ck,n=e.transitions.length;for(let r=0;r<n;r++)WA({state:e.transitions[r].target,alt:r,stack:[]},t);return t}o(UA,`computeStartState`);function WA(e,t){let n=e.state;if(n.type===WO){if(e.stack.length>0){let n=[...e.stack];WA({state:n.pop(),alt:e.alt,stack:n},t)}else t.add(e);return}n.epsilonOnlyTransitions||t.add(e);let r=n.transitions.length;for(let i=0;i<r;i++){let r=n.transitions[i],a=GA(e,r);a!==void 0&&WA(a,t)}}o(WA,`closure`);function GA(e,t){if(t instanceof QO)return{state:t.target,alt:e.alt,stack:e.stack};if(t instanceof $O){let n=[...e.stack,t.followState];return{state:t.target,alt:e.alt,stack:n}}}o(GA,`getEpsilonTarget`);function KA(e){for(let t of e.elements)if(t.state.type===WO)return!0;return!1}o(KA,`hasConfigInRuleStopState`);function qA(e){for(let t of e.elements)if(t.state.type!==WO)return!1;return!0}o(qA,`allConfigsInRuleStopStates`);function JA(e){if(qA(e))return!0;let t=YA(e.elements);return XA(t)&&!ZA(t)}o(JA,`hasConflictTerminatingPrediction`);function YA(e){let t=new Map;for(let n of e){let e=wk(n,!1),r=t.get(e);r===void 0&&(r={},t.set(e,r)),r[n.alt]=!0}return t}o(YA,`getConflictingAltSets`);function XA(e){for(let t of Array.from(e.values()))if(Object.keys(t).length>1)return!0;return!1}o(XA,`hasConflictingAltSet`);function ZA(e){for(let t of Array.from(e.values()))if(Object.keys(t).length===1)return!0;return!1}o(ZA,`hasStateAssociatedWithOneAlt`),gt();var QA=class{static{o(this,`CstNodeBuilder`)}constructor(){this.nodeStack=[]}get current(){return this.nodeStack[this.nodeStack.length-1]??this.rootNode}buildRootNode(e){return this.rootNode=new rj(e),this.rootNode.root=this.rootNode,this.nodeStack=[this.rootNode],this.rootNode}buildCompositeNode(e){let t=new tj;return t.grammarSource=e,t.root=this.rootNode,this.current.content.push(t),this.nodeStack.push(t),t}buildLeafNode(e,t){let n=new ej(e.startOffset,e.image.length,Bi(e),e.tokenType,!t);return n.grammarSource=t,n.root=this.rootNode,this.current.content.push(n),n}removeNode(e){let t=e.container;if(t){let n=t.content.indexOf(e);n>=0&&t.content.splice(n,1)}}addHiddenNodes(e){let t=[];for(let n of e){let e=new ej(n.startOffset,n.image.length,Bi(n),n.tokenType,!0);e.root=this.rootNode,t.push(e)}let n=this.current,r=!1;if(n.content.length>0){n.content.push(...t);return}for(;n.container;){let e=n.container.content.indexOf(n);
|
|||
|
|
`;case`r`:return`\r`;case`t`:return` `;case`v`:return`\v`;case`0`:return`\0`;default:return e}}o(n,`convertEscapeCharacter`);function r(e){return e.charAt(0)===`^`?e.substring(1):e}o(r,`convertID`),e.convertID=r;function i(e){return parseInt(e)}o(i,`convertInt`),e.convertInt=i;function a(e){return BigInt(e)}o(a,`convertBigint`),e.convertBigint=a;function s(e){return new Date(e)}o(s,`convertDate`),e.convertDate=s;function c(e){return Number(e)}o(c,`convertNumber`),e.convertNumber=c;function l(e){return e.toLowerCase()===`true`}o(l,`convertBoolean`),e.convertBoolean=l})(zj||={});var Z={};d(Z,f(bt(),1));function Bj(){return new Promise(e=>{typeof setImmediate>`u`?setTimeout(e,0):setImmediate(e)})}o(Bj,`delayNextTick`);var Vj=0,Hj=10;function Uj(){return Vj=performance.now(),new Z.CancellationTokenSource}o(Uj,`startCancelableOperation`);function Wj(e){Hj=e}o(Wj,`setInterruptionPeriod`);var Gj=Symbol(`OperationCancelled`);function Kj(e){return e===Gj}o(Kj,`isOperationCancelled`);async function Q(e){if(e===Z.CancellationToken.None)return;let t=performance.now();if(t-Vj>=Hj&&(Vj=t,await Bj(),Vj=performance.now()),e.isCancellationRequested)throw Gj}o(Q,`interruptAndCheck`);var qj=class{static{o(this,`Deferred`)}constructor(){this.promise=new Promise((e,t)=>{this.resolve=t=>(e(t),this),this.reject=e=>(t(e),this)})}},Jj=class e{static{o(this,`FullTextDocument`)}constructor(e,t,n,r){this._uri=e,this._languageId=t,this._version=n,this._content=r,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(e){if(e){let t=this.offsetAt(e.start),n=this.offsetAt(e.end);return this._content.substring(t,n)}return this._content}update(t,n){for(let n of t)if(e.isIncremental(n)){let e=$j(n.range),t=this.offsetAt(e.start),r=this.offsetAt(e.end);this._content=this._content.substring(0,t)+n.text+this._content.substring(r,this._content.length);let i=Math.max(e.start.line,0),a=Math.max(e.end.line,0),o=this._lineOffsets,s=Zj(n.text,!1,t);if(a-i===s.length)for(let e=0,t=s.length;e<t;e++)o[e+i+1]=s[e];else s.length<1e4?o.splice(i+1,a-i,...s):this._lineOffsets=o=o.slice(0,i+1).concat(s,o.slice(a+1));let c=n.text.length-(r-t);if(c!==0)for(let e=i+1+s.length,t=o.length;e<t;e++)o[e]=o[e]+c}else if(e.isFull(n))this._content=n.text,this._lineOffsets=void 0;else throw Error(`Unknown change event received`);this._version=n}getLineOffsets(){return this._lineOffsets===void 0&&(this._lineOffsets=Zj(this._content,!0)),this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let t=this.getLineOffsets(),n=0,r=t.length;if(r===0)return{line:0,character:e};for(;n<r;){let i=Math.floor((n+r)/2);t[i]>e?r=i:n=i+1}let i=n-1;return e=this.ensureBeforeEOL(e,t[i]),{line:i,character:e-t[i]}}offsetAt(e){let t=this.getLineOffsets();if(e.line>=t.length)return this._content.length;if(e.line<0)return 0;let n=t[e.line];if(e.character<=0)return n;let r=e.line+1<t.length?t[e.line+1]:this._content.length,i=Math.min(n+e.character,r);return this.ensureBeforeEOL(i,n)}ensureBeforeEOL(e,t){for(;e>t&&Qj(this._content.charCodeAt(e-1));)e--;return e}get lineCount(){return this.getLineOffsets().length}static isIncremental(e){let t=e;return t!=null&&typeof t.text==`string`&&t.range!==void 0&&(t.rangeLength===void 0||typeof t.rangeLength==`number`)}static isFull(e){let t=e;return t!=null&&typeof t.text==`string`&&t.range===void 0&&t.rangeLength===void 0}},Yj;(function(e){function t(e,t,n,r){return new Jj(e,t,n,r)}o(t,`create`),e.create=t;function n(e,t,n){if(e instanceof Jj)return e.update(t,n),e;throw Error(`TextDocument.update: document must be created by TextDocument.create`)}o(n,`update`),e.update=n;function r(e,t){let n=e.getText(),r=Xj(t.map(eM),(e,t)=>{let n=e.range.start.line-t.range.start.line;return n===0?e.range.start.character-t.range.start.character:n}),i=0,a=[];for(let t of r){let r=e.offsetAt(t.range.start);if(r<i)throw Error(`Overlapping edit`);r>i&&a.push(n.substring(i,r)),t.newText.length&&a.push(t.newText),i=e.offsetAt(t.range.end)}return a.push(n.substr(i)),a.join(``)}o(r,`apply
|
|||
|
|
${t}`),this.inline?`{${e}}`:e}toMarkdown(e){return e?.renderTag?.(this)??this.toMarkdownDefault(e)}toMarkdownDefault(e){let t=this.content.toMarkdown(e);if(this.inline){let n=CN(this.name,t,e??{});if(typeof n==`string`)return n}let n=``;e?.tag===`italic`||e?.tag===void 0?n=`*`:e?.tag===`bold`?n=`**`:e?.tag===`bold-italic`&&(n=`***`);let r=`${n}@${this.name}${n}`;return this.content.inlines.length===1?r=`${r} \u2014 ${t}`:this.content.inlines.length>1&&(r=`${r}
|
|||
|
|
${t}`),this.inline?`{${r}}`:r}};function CN(e,t,n){if(e===`linkplain`||e===`linkcode`||e===`link`){let r=t.indexOf(` `),i=t;if(r>0){let e=uN(t,r);i=t.substring(e),t=t.substring(0,r)}return(e===`linkcode`||e===`link`&&n.link===`code`)&&(i=`\`${i}\``),n.renderLink?.(t,i)??wN(t,i)}}o(CN,`renderInlineTag`);function wN(e,t){try{return nM.parse(e,!0),`[${t}](${e})`}catch{return e}}o(wN,`renderLinkDefault`);var TN=class{static{o(this,`JSDocTextImpl`)}constructor(e,t){this.inlines=e,this.range=t}toString(){let e=``;for(let t=0;t<this.inlines.length;t++){let n=this.inlines[t],r=this.inlines[t+1];e+=n.toString(),r&&r.range.start.line>n.range.start.line&&(e+=`
|
|||
|
|
`)}return e}toMarkdown(e){let t=``;for(let n=0;n<this.inlines.length;n++){let r=this.inlines[n],i=this.inlines[n+1];t+=r.toMarkdown(e),i&&i.range.start.line>r.range.start.line&&(t+=`
|
|||
|
|
`)}return t}},EN=class{static{o(this,`JSDocLineImpl`)}constructor(e,t){this.text=e,this.range=t}toString(){return this.text}toMarkdown(){return this.text}};function DN(e){return e.endsWith(`
|
|||
|
|
`)?`
|
|||
|
|
`:`
|
|||
|
|
|
|||
|
|
`}o(DN,`fillNewlines`);var ON=class{static{o(this,`JSDocDocumentationProvider`)}constructor(e){this.indexManager=e.shared.workspace.IndexManager,this.commentProvider=e.documentation.CommentProvider}getDocumentation(e){let t=this.commentProvider.getComment(e);if(t&&nN(t))return tN(t).toMarkdown({renderLink:o((t,n)=>this.documentationLinkRenderer(e,t,n),`renderLink`),renderTag:o(t=>this.documentationTagRenderer(e,t),`renderTag`)})}documentationLinkRenderer(e,t,n){let r=this.findNameInLocalSymbols(e,t)??this.findNameInGlobalScope(e,t);if(r&&r.nameSegment){let e=r.nameSegment.range.start.line+1,t=r.nameSegment.range.start.character+1;return`[${n}](${r.documentUri.with({fragment:`L${e},${t}`}).toString()})`}else return}documentationTagRenderer(e,t){}findNameInLocalSymbols(e,t){let n=On(e).localSymbols;if(!n)return;let r=e;do{let e=n.getStream(r).find(e=>e.name===t);if(e)return e;r=r.$container}while(r)}findNameInGlobalScope(e,t){return this.indexManager.allElements().find(e=>e.name===t)}},kN=class{static{o(this,`DefaultCommentProvider`)}constructor(e){this.grammarConfig=()=>e.parser.GrammarConfig}getComment(e){return EM(e)?e.$comment:qi(e.$cstNode,this.grammarConfig().multilineCommentRules)?.text}},AN=class{static{o(this,`DefaultAsyncParser`)}constructor(e){this.syncParser=e.parser.LangiumParser}parse(e,t){return Promise.resolve(this.syncParser.parse(e))}},jN=class{static{o(this,`AbstractThreadedAsyncParser`)}constructor(e){this.threadCount=8,this.terminationDelay=200,this.workerPool=[],this.queue=[],this.hydrator=e.serializer.Hydrator}initializeWorkers(){for(;this.workerPool.length<this.threadCount;){let e=this.createWorker();e.onReady(()=>{if(this.queue.length>0){let t=this.queue.shift();t&&(e.lock(),t.resolve(e))}}),this.workerPool.push(e)}}async parse(e,t){let n=await this.acquireParserWorker(t),r=new qj,i,a=t.onCancellationRequested(()=>{i=setTimeout(()=>{this.terminateWorker(n)},this.terminationDelay)});return n.parse(e).then(e=>{let t=this.hydrator.hydrate(e);r.resolve(t)}).catch(e=>{r.reject(e)}).finally(()=>{a.dispose(),clearTimeout(i)}),r.promise}terminateWorker(e){e.terminate();let t=this.workerPool.indexOf(e);t>=0&&this.workerPool.splice(t,1)}async acquireParserWorker(e){this.initializeWorkers();for(let e of this.workerPool)if(e.ready)return e.lock(),e;let t=new qj;return e.onCancellationRequested(()=>{let e=this.queue.indexOf(t);e>=0&&this.queue.splice(e,1),t.reject(Gj)}),this.queue.push(t),t.promise}},MN=class{static{o(this,`ParserWorker`)}get ready(){return this._ready}get onReady(){return this.onReadyEmitter.event}constructor(e,t,n,r){this.onReadyEmitter=new HM.Emitter,this.deferred=new qj,this._ready=!0,this._parsing=!1,this.sendMessage=e,this._terminate=r,t(e=>{let t=e;this.deferred.resolve(t),this.unlock()}),n(e=>{this.deferred.reject(e),this.unlock()})}terminate(){this.deferred.reject(Gj),this._terminate()}lock(){this._ready=!1}unlock(){this._parsing=!1,this._ready=!0,this.onReadyEmitter.fire()}parse(e){if(this._parsing)throw Error(`Parser worker is busy`);return this._parsing=!0,this.deferred=new qj,this.sendMessage(e),this.deferred.promise}},NN=class{static{o(this,`DefaultWorkspaceLock`)}constructor(){this.previousTokenSource=new Z.CancellationTokenSource,this.writeQueue=[],this.readQueue=[],this.done=!0}write(e){this.cancelWrite();let t=Uj();return this.previousTokenSource=t,this.enqueue(this.writeQueue,e,t.token)}read(e){return this.enqueue(this.readQueue,e)}enqueue(e,t,n=Z.CancellationToken.None){let r=new qj,i={action:t,deferred:r,cancellationToken:n};return e.push(i),this.performNextOperation(),r.promise}async performNextOperation(){if(!this.done)return;let e=[];if(this.writeQueue.length>0)e.push(this.writeQueue.shift());else if(this.readQueue.length>0)e.push(...this.readQueue.splice(0,this.readQueue.length));else return;this.done=!1,await Promise.all(e.map(async({action:e,deferred:t,cancellationToken:n})=>{try{let r=await Promise.resolve().then(()=>e(n));t.resolve(r)}catch(e){Kj(e)?t.resolve(void 0):t.reject(e)}})),this.done=!0,this.performNextOperation()}cancelWrite(){this.previousTokenSource.can
|
|||
|
|
`.includes(e[t-1])}matchWhitespace(e,t,n,r){this.whitespaceRegExp.lastIndex=t;let i=this.whitespaceRegExp.exec(e);return{currIndentLevel:i?.[0].length??0,prevIndentLevel:this.indentationStack.at(-1),match:i}}createIndentationTokenInstance(e,t,n,r){let i=this.getLineNumber(t,r);return ib(e,n,r,r+n.length,i,i,1,n.length)}getLineNumber(e,t){return e.substring(0,t).split(/\r\n|\r|\n/).length}indentMatcher(e,t,n,r){if(!this.isStartOfLine(e,t))return null;let{currIndentLevel:i,prevIndentLevel:a,match:o}=this.matchWhitespace(e,t,n,r);return i<=a?null:(this.indentationStack.push(i),o)}dedentMatcher(e,t,n,r){if(!this.isStartOfLine(e,t))return null;let{currIndentLevel:i,prevIndentLevel:a,match:o}=this.matchWhitespace(e,t,n,r);if(i>=a)return null;let s=this.indentationStack.lastIndexOf(i);if(s===-1)return this.diagnostics.push({severity:`error`,message:`Invalid dedent level ${i} at offset: ${t}. Current indentation stack: ${this.indentationStack}`,offset:t,length:o?.[0]?.length??0,line:this.getLineNumber(e,t),column:1}),null;let c=this.indentationStack.length-s-1,l=e.substring(0,t).match(/[\r\n]+$/)?.[0].length??1;for(let r=0;r<c;r++){let r=this.createIndentationTokenInstance(this.dedentTokenType,e,``,t-(l-1));n.push(r),this.indentationStack.pop()}return null}buildTerminalToken(e){let t=super.buildTerminalToken(e),{indentTokenName:n,dedentTokenName:r,whitespaceTokenName:i}=this.options;return t.name===n?this.indentTokenType:t.name===r?this.dedentTokenType:t.name===i?tb({name:i,pattern:this.whitespaceRegExp,group:Uy.SKIPPED}):t}flushRemainingDedents(e){let t=[];for(;this.indentationStack.length>1;)t.push(this.createIndentationTokenInstance(this.dedentTokenType,e,``,e.length)),this.indentationStack.pop();return this.indentationStack=[0],t}},JN=class extends ZM{static{o(this,`IndentationAwareLexer`)}constructor(e){if(super(e),e.parser.TokenBuilder instanceof qN)this.indentationTokenBuilder=e.parser.TokenBuilder;else throw Error(`IndentationAwareLexer requires an accompanying IndentationAwareTokenBuilder`)}tokenize(e,t=XM){let n=super.tokenize(e),r=n.report;t?.mode===`full`&&n.tokens.push(...r.remainingDedents),r.remainingDedents=[];let{indentTokenType:i,dedentTokenType:a}=this.indentationTokenBuilder,o=i.tokenTypeIdx,s=a.tokenTypeIdx,c=[],l=n.tokens.length-1;for(let e=0;e<l;e++){let t=n.tokens[e],r=n.tokens[e+1];if(t.tokenTypeIdx===o&&r.tokenTypeIdx===s){e++;continue}c.push(t)}return l>=0&&c.push(n.tokens[l]),n.tokens=c,n}},YN={};l(YN,{AstUtils:()=>wn,BiMap:()=>mM,Cancellation:()=>Z,ContextCache:()=>SM,CstUtils:()=>cn,DONE_RESULT:()=>xn,Deferred:()=>qj,Disposable:()=>GM,DisposableCache:()=>bM,DocumentCache:()=>CM,EMPTY_STREAM:()=>bn,ErrorWithLocation:()=>aa,GrammarUtils:()=>ia,MultiMap:()=>pM,OperationCancelled:()=>Gj,Reduction:()=>Cn,RegExpUtils:()=>ca,SimpleCache:()=>xM,StreamImpl:()=>_n,TreeStreamImpl:()=>Sn,URI:()=>nM,UriTrie:()=>aM,UriUtils:()=>iM,WorkspaceCache:()=>wM,assertCondition:()=>sa,assertUnreachable:()=>oa,delayNextTick:()=>Bj,interruptAndCheck:()=>Q,isOperationCancelled:()=>Kj,loadGrammarFromJson:()=>tP,setInterruptionPeriod:()=>Wj,startCancelableOperation:()=>Uj,stream:()=>M}),d(YN,HM);var XN=class{static{o(this,`EmptyFileSystemProvider`)}stat(e){throw Error(`No file system is available.`)}statSync(e){throw Error(`No file system is available.`)}async exists(){return!1}existsSync(){return!1}readBinary(){throw Error(`No file system is available.`)}readBinarySync(){throw Error(`No file system is available.`)}readFile(){throw Error(`No file system is available.`)}readFileSync(){throw Error(`No file system is available.`)}async readDirectory(){return[]}readDirectorySync(){return[]}},ZN={fileSystemProvider:o(()=>new XN,`fileSystemProvider`)},QN={Grammar:o(()=>void 0,`Grammar`),LanguageMetaData:o(()=>({caseInsensitive:!1,fileExtensions:[`.langium`],languageId:`langium`}),`LanguageMetaData`)},$N={AstReflection:o(()=>new Fi,`AstReflection`)};function eP(){let e=RN(IN(ZN),$N),t=RN(FN({shared:e}),QN);return e.ServiceRegistry.register(t),t}o(eP,`createMinimalGrammarServices`);function tP(e){let t=eP(),n=t.serializer.JsonSerializ
|
|||
|
|
`)}}},CI=class extends SI{static{o(this,`CommonValueConverter`)}runCustomConverter(e,t,n){}},wI=class extends Lj{static{o(this,`AbstractMermaidTokenBuilder`)}constructor(e){super(),this.keywords=new Set(e)}buildKeywordTokens(e,t,n){let r=super.buildKeywordTokens(e,t,n);return r.forEach(e=>{this.keywords.has(e.name)&&e.PATTERN!==void 0&&(e.PATTERN=RegExp(e.PATTERN.toString()+`(?:(?=%%)|(?!\\S))`))}),r}};(class extends wI{static{o(this,`CommonTokenBuilder`)}});export{FN as _,ZN as a,UP as b,mI as c,gI as d,_I as f,o as g,bI as h,CI as i,uI as l,vI as m,SI as n,fI as o,yI as p,dI as r,pI as s,wI as t,hI as u,IN as v,RN as y};
|