likec4 1.49.0 → 1.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__app__/src/likec4.js +17 -40
- package/__app__/src/routes/single.js +27 -20
- package/__app__/src/style.css +1 -1
- package/__app__/src/vendors.js +1152 -1013
- package/config/schema.json +16 -0
- package/dist/THIRD-PARTY-LICENSES.md +31 -1
- package/dist/_chunks/LikeC4.mjs +1154 -0
- package/dist/_chunks/binary.mjs +72 -0
- package/dist/_chunks/index.d.mts +11 -12
- package/dist/_chunks/index2.d.mts +166 -76
- package/dist/_chunks/libs/@chevrotain/cst-dts-gen.mjs +30 -0
- package/dist/_chunks/libs/@chevrotain/regexp-to-ast.mjs +8 -8
- package/dist/_chunks/libs/@chevrotain/types.d.mts +1 -0
- package/dist/_chunks/libs/@chevrotain/utils.mjs +1 -1
- package/dist/_chunks/libs/@hono/mcp.mjs +8 -8
- package/dist/_chunks/libs/@hono/node-server.mjs +1 -1
- package/dist/_chunks/libs/@logtape/logtape.mjs +3 -3
- package/dist/_chunks/libs/@lume/kiwi.mjs +1 -1
- package/dist/_chunks/libs/@modelcontextprotocol/sdk.d.mts +114 -14
- package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +7 -7
- package/dist/_chunks/libs/@msgpack/msgpack.mjs +1 -1
- package/dist/_chunks/libs/@nanostores/react.d.mts +61 -1
- package/dist/_chunks/libs/@nanostores/react.mjs +1 -1
- package/dist/_chunks/libs/@smithy/is-array-buffer.mjs +1 -0
- package/dist/_chunks/libs/@smithy/util-base64.mjs +1 -1
- package/dist/_chunks/libs/ajv.mjs +1 -1
- package/dist/_chunks/libs/atomically.mjs +1 -1
- package/dist/_chunks/libs/birpc.mjs +1 -1
- package/dist/_chunks/libs/chevrotain-allstar.mjs +2 -2
- package/dist/_chunks/libs/chevrotain.mjs +35 -35
- package/dist/_chunks/libs/conf.mjs +1 -1
- package/dist/_chunks/libs/defu.mjs +1 -1
- package/dist/_chunks/libs/esm-env.mjs +1 -1
- package/dist/_chunks/libs/eventemitter3.mjs +1 -1
- package/dist/_chunks/libs/fast-equals.mjs +1 -1
- package/dist/_chunks/libs/find-up-simple.mjs +1 -1
- package/dist/_chunks/libs/get-port.mjs +1 -1
- package/dist/_chunks/libs/is-docker.mjs +1 -1
- package/dist/_chunks/libs/is-error-instance.mjs +1 -1
- package/dist/_chunks/libs/is-inside-container.mjs +1 -1
- package/dist/_chunks/libs/is-plain-obj.mjs +1 -1
- package/dist/_chunks/libs/isexe.mjs +1 -1
- package/dist/_chunks/libs/json5.mjs +10 -10
- package/dist/_chunks/libs/khroma.mjs +1 -1
- package/dist/_chunks/libs/ky.mjs +2 -2
- package/dist/_chunks/libs/langium.d.mts +4 -3
- package/dist/_chunks/libs/langium.mjs +20 -19
- package/dist/_chunks/libs/merge-error-cause.mjs +2 -2
- package/dist/_chunks/libs/p-limit.mjs +1 -1
- package/dist/_chunks/libs/p-queue.mjs +1 -1
- package/dist/_chunks/libs/package-manager-detector.mjs +1 -1
- package/dist/_chunks/libs/package-up.mjs +1 -1
- package/dist/_chunks/libs/pako.mjs +1 -0
- package/dist/_chunks/libs/parse-ms.mjs +1 -1
- package/dist/_chunks/libs/pathe.mjs +1 -1
- package/dist/_chunks/libs/picomatch.mjs +1 -1
- package/dist/_chunks/libs/pretty-ms.mjs +1 -1
- package/dist/_chunks/libs/remeda.mjs +2 -1
- package/dist/_chunks/libs/safe-stringify.mjs +1 -1
- package/dist/_chunks/libs/strip-indent.mjs +1 -1
- package/dist/_chunks/libs/tinyrainbow.mjs +1 -1
- package/dist/_chunks/libs/ts-graphviz.mjs +3 -3
- package/dist/_chunks/libs/ufo.mjs +1 -1
- package/dist/_chunks/libs/which.mjs +1 -1
- package/dist/_chunks/libs/word-wrap.mjs +2 -2
- package/dist/_chunks/rolldown-runtime.mjs +1 -1
- package/dist/_chunks/sequence.mjs +1 -0
- package/dist/_chunks/src.mjs +15 -0
- package/dist/_chunks/src2.mjs +499 -0
- package/dist/cli/index.mjs +75 -231
- package/dist/config/index.mjs +1 -1
- package/dist/index.d.mts +5 -3
- package/dist/index.mjs +1 -1
- package/dist/model/index.mjs +1 -1
- package/dist/vite-plugin/index.d.mts +3 -0
- package/dist/vite-plugin/index.mjs +1 -1
- package/dist/vite-plugin/internal.d.mts +1 -2
- package/dist/vite-plugin/internal.mjs +1 -1
- package/package.json +26 -26
- package/react/index.d.mts +2 -2
- package/react/index.mjs +36 -54
- package/vite-plugin-modules.d.ts +5 -0
- package/dist/_chunks/GraphvizBinaryAdapter.mjs +0 -72
- package/dist/_chunks/filenames.mjs +0 -14
- package/dist/_chunks/libs/@chevrotain/gast.mjs +0 -1
- package/dist/_chunks/libs/nanostores.d.mts +0 -63
- package/dist/_chunks/libs/nanostores.mjs +0 -1
- package/dist/_chunks/node.mjs +0 -481
- package/dist/_chunks/plugin.mjs +0 -322
- package/dist/_chunks/sequence-view.mjs +0 -1
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import{n as RegExpParser,t as BaseRegExpVisitor}from"./@chevrotain/regexp-to-ast.mjs";import{$ as isIterateeCall,A as cacheHas,B as Stack,C as map,D as baseIteratee,E as baseEach,F as getAllKeysIn,G as keys,H as arrayPush,I as getAllKeys,J as nodeUtil,K as baseKeys,L as getSymbolsIn,M as Uint8Array,N as _getTag_default,O as hasPath,P as Set,Q as isPrototype,R as getSymbols,S as isString,T as forEach,U as keysIn,V as getPrototype,W as assign,X as isBuffer,Y as baseUnary,Z as isArguments,_ as some,_t as Symbol,a as GAstVisitor,at as baseAssignValue,b as includes,c as NonTerminal,ct as arrayEach,d as RepetitionMandatory,dt as toInteger,et as isArrayLike,f as RepetitionMandatoryWithSeparator,ft as isObject,g as serializeGrammar,gt as isObjectLike,h as Terminal,i as isSequenceProd,it as eq,j as SetCache,k as setToArray,l as Option,lt as isFunction,m as Rule,mt as arrayMap,n as isBranchingProd,nt as copyObject,o as Alternation,ot as baseIndexOf,p as RepetitionWithSeparator,pt as isArray,q as isTypedArray,r as isOptionalProd,rt as assignValue,s as Alternative,st as baseFindIndex,t as getProductionDslName,tt as baseRest,u as Repetition,ut as identity,v as pickBy,vt as root,w as every,x as values,y as isRegExp,z as arrayFilter}from"./@chevrotain/gast.mjs";import{i as PRINT_WARNING,n as timer,r as PRINT_ERROR,t as toFastProperties}from"./@chevrotain/utils.mjs";var objectCreate=Object.create,baseCreate=function(){function e(){}return function(t){if(!isObject(t))return{};if(objectCreate)return objectCreate(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function noop(){}function copyArray(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}function arrayIncludes(e,t){return!!(e!=null&&e.length)&&baseIndexOf(e,t,0)>-1}var spreadableSymbol=Symbol?Symbol.isConcatSpreadable:void 0;function isFlattenable(e){return isArray(e)||isArguments(e)||!!(spreadableSymbol&&e&&e[spreadableSymbol])}function baseFlatten(e,t,n,r,i){var a=-1,o=e.length;for(n||=isFlattenable,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?baseFlatten(s,t-1,n,r,i):arrayPush(i,s):r||(i[i.length]=s)}return i}function flatten(e){return e!=null&&e.length?baseFlatten(e,1):[]}function baseSlice(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=Array(i);++r<i;)a[r]=e[r+t];return a}function arrayReduce(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function baseAssign(e,t){return e&©Object(t,keys(t),e)}function baseAssignIn(e,t){return e&©Object(t,keysIn(t),e)}var freeExports=typeof exports==`object`&&exports&&!exports.nodeType&&exports,freeModule=freeExports&&typeof module==`object`&&module&&!module.nodeType&&module,Buffer=freeModule&&freeModule.exports===freeExports?root.Buffer:void 0,allocUnsafe=Buffer?Buffer.allocUnsafe:void 0;function cloneBuffer(e,t){if(t)return e.slice();var n=e.length,r=allocUnsafe?allocUnsafe(n):new e.constructor(n);return e.copy(r),r}function copySymbols(e,t){return copyObject(e,getSymbols(e),t)}function copySymbolsIn(e,t){return copyObject(e,getSymbolsIn(e),t)}var hasOwnProperty$4=Object.prototype.hasOwnProperty;function initCloneArray(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&hasOwnProperty$4.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}function cloneArrayBuffer(e){var t=new e.constructor(e.byteLength);return new Uint8Array(t).set(new Uint8Array(e)),t}function cloneDataView(e,t){var n=t?cloneArrayBuffer(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}var reFlags=/\w*$/;function cloneRegExp(e){var t=new e.constructor(e.source,reFlags.exec(e));return t.lastIndex=e.lastIndex,t}var symbolProto=Symbol?Symbol.prototype:void 0,symbolValueOf=symbolProto?symbolProto.valueOf:void 0;function cloneSymbol(e){return symbolValueOf?Object(symbolValueOf.call(e)):{}}function cloneTypedArray(e,t){var n=t?cloneArrayBuffer(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var boolTag$1=`[object Boolean]`,dateTag$1=`[object Date]`,mapTag$3=`[object Map]`,numberTag$1=`[object Number]`,regexpTag$1=`[object RegExp]`,setTag$3=`[object Set]`,stringTag$1=`[object String]`,symbolTag$1=`[object Symbol]`,arrayBufferTag$1=`[object ArrayBuffer]`,dataViewTag$1=`[object DataView]`,float32Tag$1=`[object Float32Array]`,float64Tag$1=`[object Float64Array]`,int8Tag$1=`[object Int8Array]`,int16Tag$1=`[object Int16Array]`,int32Tag$1=`[object Int32Array]`,uint8Tag$1=`[object Uint8Array]`,uint8ClampedTag$1=`[object Uint8ClampedArray]`,uint16Tag$1=`[object Uint16Array]`,uint32Tag$1=`[object Uint32Array]`;function initCloneByTag(e,t,n){var r=e.constructor;switch(t){case arrayBufferTag$1:return cloneArrayBuffer(e);case boolTag$1:case dateTag$1:return new r(+e);case dataViewTag$1:return cloneDataView(e,n);case float32Tag$1:case float64Tag$1:case int8Tag$1:case int16Tag$1:case int32Tag$1:case uint8Tag$1:case uint8ClampedTag$1:case uint16Tag$1:case uint32Tag$1:return cloneTypedArray(e,n);case mapTag$3:return new r;case numberTag$1:case stringTag$1:return new r(e);case regexpTag$1:return cloneRegExp(e);case setTag$3:return new r;case symbolTag$1:return cloneSymbol(e)}}function initCloneObject(e){return typeof e.constructor==`function`&&!isPrototype(e)?baseCreate(getPrototype(e)):{}}var mapTag$2=`[object Map]`;function baseIsMap(e){return isObjectLike(e)&&_getTag_default(e)==mapTag$2}var nodeIsMap=nodeUtil&&nodeUtil.isMap,isMap=nodeIsMap?baseUnary(nodeIsMap):baseIsMap,setTag$2=`[object Set]`;function baseIsSet(e){return isObjectLike(e)&&_getTag_default(e)==setTag$2}var nodeIsSet=nodeUtil&&nodeUtil.isSet,isSet=nodeIsSet?baseUnary(nodeIsSet):baseIsSet,CLONE_DEEP_FLAG=1,CLONE_FLAT_FLAG=2,CLONE_SYMBOLS_FLAG$1=4,argsTag=`[object Arguments]`,arrayTag=`[object Array]`,boolTag=`[object Boolean]`,dateTag=`[object Date]`,errorTag=`[object Error]`,funcTag=`[object Function]`,genTag=`[object GeneratorFunction]`,mapTag$1=`[object Map]`,numberTag=`[object Number]`,objectTag=`[object Object]`,regexpTag=`[object RegExp]`,setTag$1=`[object Set]`,stringTag=`[object String]`,symbolTag=`[object Symbol]`,weakMapTag=`[object WeakMap]`,arrayBufferTag=`[object ArrayBuffer]`,dataViewTag=`[object DataView]`,float32Tag=`[object Float32Array]`,float64Tag=`[object Float64Array]`,int8Tag=`[object Int8Array]`,int16Tag=`[object Int16Array]`,int32Tag=`[object Int32Array]`,uint8Tag=`[object Uint8Array]`,uint8ClampedTag=`[object Uint8ClampedArray]`,uint16Tag=`[object Uint16Array]`,uint32Tag=`[object Uint32Array]`,cloneableTags={};cloneableTags[argsTag]=cloneableTags[arrayTag]=cloneableTags[arrayBufferTag]=cloneableTags[dataViewTag]=cloneableTags[boolTag]=cloneableTags[dateTag]=cloneableTags[float32Tag]=cloneableTags[float64Tag]=cloneableTags[int8Tag]=cloneableTags[int16Tag]=cloneableTags[int32Tag]=cloneableTags[mapTag$1]=cloneableTags[numberTag]=cloneableTags[objectTag]=cloneableTags[regexpTag]=cloneableTags[setTag$1]=cloneableTags[stringTag]=cloneableTags[symbolTag]=cloneableTags[uint8Tag]=cloneableTags[uint8ClampedTag]=cloneableTags[uint16Tag]=cloneableTags[uint32Tag]=!0,cloneableTags[errorTag]=cloneableTags[funcTag]=cloneableTags[weakMapTag]=!1;function baseClone(e,t,n,r,a,o){var s,u=t&CLONE_DEEP_FLAG,f=t&CLONE_FLAT_FLAG,p=t&CLONE_SYMBOLS_FLAG$1;if(n&&(s=a?n(e,r,a,o):n(e)),s!==void 0)return s;if(!isObject(e))return e;var m=isArray(e);if(m){if(s=initCloneArray(e),!u)return copyArray(e,s)}else{var h=_getTag_default(e),_=h==funcTag||h==genTag;if(isBuffer(e))return cloneBuffer(e,u);if(h==objectTag||h==argsTag||_&&!a){if(s=f||_?{}:initCloneObject(e),!u)return f?copySymbolsIn(e,baseAssignIn(s,e)):copySymbols(e,baseAssign(s,e))}else{if(!cloneableTags[h])return a?e:{};s=initCloneByTag(e,h,u)}}o||=new Stack;var v=o.get(e);if(v)return v;o.set(e,s),isSet(e)?e.forEach(function(r){s.add(baseClone(r,t,n,r,e,o))}):isMap(e)&&e.forEach(function(r,i){s.set(i,baseClone(r,t,n,i,e,o))});var y=m?void 0:(p?f?getAllKeysIn:getAllKeys:f?keysIn:keys)(e);return arrayEach(y||e,function(r,i){y&&(i=r,r=e[i]),assignValue(s,i,baseClone(r,t,n,i,e,o))}),s}var CLONE_SYMBOLS_FLAG=4;function clone(e){return baseClone(e,CLONE_SYMBOLS_FLAG)}function compact(e){for(var t=-1,n=e==null?0:e.length,r=0,i=[];++t<n;){var a=e[t];a&&(i[r++]=a)}return i}function arrayAggregator(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}function baseAggregator(e,t,n,r){return baseEach(e,function(e,i,a){t(r,e,n(e),a)}),r}function createAggregator(e,t){return function(n,r){var i=isArray(n)?arrayAggregator:baseAggregator,a=t?t():{};return i(n,e,baseIteratee(r,2),a)}}var objectProto=Object.prototype,hasOwnProperty$3=objectProto.hasOwnProperty,defaults=baseRest(function(e,t){e=Object(e);var r=-1,i=t.length,a=i>2?t[2]:void 0;for(a&&isIterateeCall(t[0],t[1],a)&&(i=1);++r<i;)for(var o=t[r],s=keysIn(o),c=-1,l=s.length;++c<l;){var u=s[c],d=e[u];(d===void 0||eq(d,objectProto[u])&&!hasOwnProperty$3.call(e,u))&&(e[u]=o[u])}return e});function isArrayLikeObject(e){return isObjectLike(e)&&isArrayLike(e)}function arrayIncludesWith(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}var LARGE_ARRAY_SIZE$1=200;function baseDifference(e,t,n,i){var a=-1,o=arrayIncludes,s=!0,c=e.length,l=[],u=t.length;if(!c)return l;n&&(t=arrayMap(t,baseUnary(n))),i?(o=arrayIncludesWith,s=!1):t.length>=LARGE_ARRAY_SIZE$1&&(o=cacheHas,s=!1,t=new SetCache(t));outer:for(;++a<c;){var d=e[a],f=n==null?d:n(d);if(d=i||d!==0?d:0,s&&f===f){for(var p=u;p--;)if(t[p]===f)continue outer;l.push(d)}else o(t,f,i)||l.push(d)}return l}var difference=baseRest(function(e,t){return isArrayLikeObject(e)?baseDifference(e,baseFlatten(t,1,isArrayLikeObject,!0)):[]});function last(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}function drop(e,t,n){var r=e==null?0:e.length;return r?(t=n||t===void 0?1:toInteger(t),baseSlice(e,t<0?0:t,r)):[]}function dropRight(e,t,n){var r=e==null?0:e.length;return r?(t=n||t===void 0?1:toInteger(t),t=r-t,baseSlice(e,0,t<0?0:t)):[]}function baseFilter(e,t){var n=[];return baseEach(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function filter(e,t){return(isArray(e)?arrayFilter:baseFilter)(e,baseIteratee(t,3))}function createFind(e){return function(t,n,r){var i=Object(t);if(!isArrayLike(t)){var a=baseIteratee(n,3);t=keys(t),n=function(e){return a(i[e],e,i)}}var s=e(t,n,r);return s>-1?i[a?t[s]:s]:void 0}}var nativeMax$1=Math.max;function findIndex(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:toInteger(n);return i<0&&(i=nativeMax$1(r+i,0)),baseFindIndex(e,baseIteratee(t,3),i)}var find=createFind(findIndex);function head(e){return e&&e.length?e[0]:void 0}function flatMap(e,t){return baseFlatten(map(e,t),1)}var hasOwnProperty$2=Object.prototype.hasOwnProperty,groupBy=createAggregator(function(e,t,n){hasOwnProperty$2.call(e,n)?e[n].push(t):baseAssignValue(e,n,[t])}),hasOwnProperty$1=Object.prototype.hasOwnProperty;function baseHas(e,t){return e!=null&&hasOwnProperty$1.call(e,t)}function has(e,t){return e!=null&&hasPath(e,t,baseHas)}var nativeMax=Math.max;function indexOf(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:toInteger(n);return i<0&&(i=nativeMax(r+i,0)),baseIndexOf(e,t,i)}var mapTag=`[object Map]`,setTag=`[object Set]`,hasOwnProperty=Object.prototype.hasOwnProperty;function isEmpty(e){if(e==null)return!0;if(isArrayLike(e)&&(isArray(e)||typeof e==`string`||typeof e.splice==`function`||isBuffer(e)||isTypedArray(e)||isArguments(e)))return!e.length;var t=_getTag_default(e);if(t==mapTag||t==setTag)return!e.size;if(isPrototype(e))return!baseKeys(e).length;for(var n in e)if(hasOwnProperty.call(e,n))return!1;return!0}function isUndefined(e){return e===void 0}var FUNC_ERROR_TEXT=`Expected a function`;function negate(e){if(typeof e!=`function`)throw TypeError(FUNC_ERROR_TEXT);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function baseReduce(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}function reduce(e,t,n){var r=isArray(e)?arrayReduce:baseReduce,i=arguments.length<3;return r(e,baseIteratee(t,4),n,i,baseEach)}function reject(e,t){return(isArray(e)?arrayFilter:baseFilter)(e,negate(baseIteratee(t,3)))}var createSet=Set&&1/setToArray(new Set([,-0]))[1]==1/0?function(e){return new Set(e)}:noop,LARGE_ARRAY_SIZE=200;function baseUniq(e,t,n){var i=-1,a=arrayIncludes,o=e.length,s=!0,c=[],l=c;if(n)s=!1,a=arrayIncludesWith;else if(o>=LARGE_ARRAY_SIZE){var u=t?null:createSet(e);if(u)return setToArray(u);s=!1,a=cacheHas,l=new SetCache}else l=t?[]:c;outer:for(;++i<o;){var d=e[i],f=t?t(d):d;if(d=n||d!==0?d:0,s&&f===f){for(var p=l.length;p--;)if(l[p]===f)continue outer;t&&l.push(f),c.push(d)}else a(l,f,n)||(l!==c&&l.push(f),c.push(d))}return c}function uniq(e){return e&&e.length?baseUniq(e):[]}var RestWalker=class{walk(e,t=[]){forEach(e.definition,(n,r)=>{let i=drop(e.definition,r+1);if(n instanceof NonTerminal)this.walkProdRef(n,i,t);else if(n instanceof Terminal)this.walkTerminal(n,i,t);else if(n instanceof Alternative)this.walkFlat(n,i,t);else if(n instanceof Option)this.walkOption(n,i,t);else if(n instanceof RepetitionMandatory)this.walkAtLeastOne(n,i,t);else if(n instanceof RepetitionMandatoryWithSeparator)this.walkAtLeastOneSep(n,i,t);else if(n instanceof RepetitionWithSeparator)this.walkManySep(n,i,t);else if(n instanceof Repetition)this.walkMany(n,i,t);else if(n instanceof Alternation)this.walkOr(n,i,t);else throw Error(`non exhaustive match`)})}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){let r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){let r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){let r=[new Option({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){let r=restForRepetitionWithSeparator(e,t,n);this.walk(e,r)}walkMany(e,t,n){let r=[new Option({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){let r=restForRepetitionWithSeparator(e,t,n);this.walk(e,r)}walkOr(e,t,n){let r=t.concat(n);forEach(e.definition,e=>{let t=new Alternative({definition:[e]});this.walk(t,r)})}};function restForRepetitionWithSeparator(e,t,n){return[new Option({definition:[new Terminal({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function first(e){if(e instanceof NonTerminal)return first(e.referencedRule);if(e instanceof Terminal)return firstForTerminal(e);if(isSequenceProd(e))return firstForSequence(e);if(isBranchingProd(e))return firstForBranching(e);throw Error(`non exhaustive match`)}function firstForSequence(e){let t=[],n=e.definition,r=0,i=n.length>r,a,o=!0;for(;i&&o;)a=n[r],o=isOptionalProd(a),t=t.concat(first(a)),r+=1,i=n.length>r;return uniq(t)}function firstForBranching(e){return uniq(flatten(map(e.definition,e=>first(e))))}function firstForTerminal(e){return[e.terminalType]}const IN=`_~IN~_`;var ResyncFollowsWalker=class extends RestWalker{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){let r=buildBetweenProdsFollowPrefix(e.referencedRule,e.idx)+this.topProd.name,i=first(new Alternative({definition:t.concat(n)}));this.follows[r]=i}};function computeAllProdsFollows(e){let t={};return forEach(e,e=>{assign(t,new ResyncFollowsWalker(e).startWalking())}),t}function buildBetweenProdsFollowPrefix(e,t){return e.name+t+IN}let regExpAstCache={};const regExpParser=new RegExpParser;function getRegExpAst(e){let t=e.toString();if(regExpAstCache.hasOwnProperty(t))return regExpAstCache[t];{let e=regExpParser.pattern(t);return regExpAstCache[t]=e,e}}function clearRegExpParserCache(){regExpAstCache={}}const complementErrorMessage=`Complement Sets are not supported for first char optimization`,failedOptimizationPrefixMsg=`Unable to use "first char" lexer optimizations:
|
|
2
|
-
`;function
|
|
1
|
+
import{n as e,t}from"./@chevrotain/regexp-to-ast.mjs";import{$ as n,A as r,B as i,D as a,E as o,F as s,G as c,H as l,I as u,J as d,K as f,L as p,M as m,N as h,O as g,P as _,Q as v,R as y,S as b,T as x,U as S,V as C,W as ee,X as w,Y as T,Z as E,a as D,b as O,c as k,d as A,et as j,f as M,g as te,h as N,i as ne,j as P,k as F,l as I,m as L,n as re,o as ie,p as ae,q as R,r as oe,s as z,t as B,u as V,v as se,w as H,x as U,y as ce,z as W}from"./@chevrotain/cst-dts-gen.mjs";import{i as le,n as ue,r as de,t as fe}from"./@chevrotain/utils.mjs";var pe=class{walk(e,t=[]){W(e.definition,(n,r)=>{let i=C(e.definition,r+1);if(n instanceof k)this.walkProdRef(n,i,t);else if(n instanceof N)this.walkTerminal(n,i,t);else if(n instanceof z)this.walkFlat(n,i,t);else if(n instanceof I)this.walkOption(n,i,t);else if(n instanceof A)this.walkAtLeastOne(n,i,t);else if(n instanceof M)this.walkAtLeastOneSep(n,i,t);else if(n instanceof ae)this.walkManySep(n,i,t);else if(n instanceof V)this.walkMany(n,i,t);else if(n instanceof ie)this.walkOr(n,i,t);else throw Error(`non exhaustive match`)})}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){let r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){let r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){let r=[new I({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){let r=me(e,t,n);this.walk(e,r)}walkMany(e,t,n){let r=[new I({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){let r=me(e,t,n);this.walk(e,r)}walkOr(e,t,n){let r=t.concat(n);W(e.definition,e=>{let t=new z({definition:[e]});this.walk(t,r)})}};function me(e,t,n){return[new I({definition:[new N({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function he(e){if(e instanceof k)return he(e.referencedRule);if(e instanceof N)return ve(e);if(ne(e))return ge(e);if(re(e))return _e(e);throw Error(`non exhaustive match`)}function ge(e){let t=[],n=e.definition,r=0,i=n.length>r,a,o=!0;for(;i&&o;)a=n[r],o=oe(a),t=t.concat(he(a)),r+=1,i=n.length>r;return se(t)}function _e(e){return se(R(_(e.definition,e=>he(e))))}function ve(e){return[e.terminalType]}const ye=`_~IN~_`;var be=class extends pe{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){let r=Se(e.referencedRule,e.idx)+this.topProd.name,i=he(new z({definition:t.concat(n)}));this.follows[r]=i}};function xe(e){let t={};return W(e,e=>{d(t,new be(e).startWalking())}),t}function Se(e,t){return e.name+t+ye}let Ce={};const we=new e;function Te(e){let t=e.toString();if(Ce.hasOwnProperty(t))return Ce[t];{let e=we.pattern(t);return Ce[t]=e,e}}function Ee(){Ce={}}const De=`Complement Sets are not supported for first char optimization`,Oe=`Unable to use "first char" lexer optimizations:
|
|
2
|
+
`;function ke(e,t=!1){try{let t=Te(e);return Ae(t.value,{},t.flags.ignoreCase)}catch(n){if(n.message===De)t&&le(`${Oe}\tUnable to optimize: < ${e.toString()} >\n Complement Sets cannot be automatically optimized.
|
|
3
3
|
This will disable the lexer's first char optimizations.
|
|
4
4
|
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n=``;t&&(n=`
|
|
5
5
|
This will disable the lexer's first char optimizations.
|
|
6
|
-
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),
|
|
7
|
-
`],tracer:(e,t)=>t()});let n=t.tracer;n(`initCharCodeToOptimizedIndexMap`,()=>{
|
|
6
|
+
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),de(`${Oe}\n\tFailed parsing: < ${e.toString()} >\n\tUsing the @chevrotain/regexp-to-ast library\n Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function Ae(e,t,n){switch(e.type){case`Disjunction`:for(let r=0;r<e.value.length;r++)Ae(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`StartAnchor`:case`WordBoundary`:case`NonWordBoundary`:continue}let a=i;switch(a.type){case`Character`:je(a.value,t,n);break;case`Set`:if(a.complement===!0)throw Error(De);W(a.value,e=>{if(typeof e==`number`)je(e,t,n);else{let r=e;if(n===!0)for(let e=r.from;e<=r.to;e++)je(e,t,n);else{for(let e=r.from;e<=r.to&&e<ht;e++)je(e,t,n);if(r.to>=ht){let e=r.from>=ht?r.from:ht,n=r.to,i=K(e),a=K(n);for(let e=i;e<=a;e++)t[e]=e}}}});break;case`Group`:Ae(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`&&Pe(a)===!1||a.type!==`Group`&&o===!1)break}break;default:throw Error(`non exhaustive match!`)}return F(t)}function je(e,t,n){let r=K(e);t[r]=r,n===!0&&Me(e,t)}function Me(e,t){let n=String.fromCharCode(e),r=n.toUpperCase();if(r!==n){let e=K(r.charCodeAt(0));t[e]=e}else{let e=n.toLowerCase();if(e!==n){let n=K(e.charCodeAt(0));t[n]=n}}}function Ne(e,t){return u(e.value,e=>{if(typeof e==`number`)return g(t,e);{let n=e;return u(t,e=>n.from<=e&&e<=n.to)!==void 0}})}function Pe(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?j(e.value)?y(e.value,Pe):Pe(e.value):!1}var Fe=class extends t{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}super.visitChildren(e)}}visitCharacter(e){g(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?Ne(e,this.targetCharCodes)===void 0&&(this.found=!0):Ne(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function Ie(e,t){if(t instanceof RegExp){let n=Te(t),r=new Fe(e);return r.visit(n),r.found}else return u(t,t=>g(e,t.charCodeAt(0)))!==void 0}const G=`PATTERN`,Le=`defaultMode`,Re=`modes`;let ze=typeof RegExp(`(?:)`).sticky==`boolean`;function Be(e,t){t=ee(t,{useSticky:ze,debug:!1,safeMode:!1,positionTracking:`full`,lineTerminatorCharacters:[`\r`,`
|
|
7
|
+
`],tracer:(e,t)=>t()});let n=t.tracer;n(`initCharCodeToOptimizedIndexMap`,()=>{_t()});let i;n(`Reject Lexer.NA`,()=>{i=O(e,e=>e[G]===J.NA)});let s=!1,c;n(`Transform Patterns`,()=>{s=!1,c=_(i,e=>{let n=e[G];if(x(n)){let e=n.source;return e.length===1&&e!==`^`&&e!==`$`&&e!==`.`&&!n.ignoreCase?e:e.length===2&&e[0]===`\\`&&!g([`d`,`D`,`s`,`S`,`t`,`r`,`n`,`t`,`0`,`c`,`b`,`B`,`f`,`v`,`w`,`W`],e[1])?e[1]:t.useSticky?it(n):rt(n)}else if(E(n))return s=!0,{exec:n};else if(typeof n==`object`)return s=!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?it(r):rt(r)}}else throw Error(`non exhaustive match`)})});let l,u,d,f,p;n(`misc mapping`,()=>{l=_(i,e=>e.tokenTypeIdx),u=_(i,e=>{let t=e.GROUP;if(t!==J.SKIPPED){if(r(t))return t;if(H(t))return!1;throw Error(`non exhaustive match`)}}),d=_(i,e=>{let t=e.LONGER_ALT;if(t)return j(t)?_(t,e=>a(i,e)):[a(i,t)]}),f=_(i,e=>e.PUSH_MODE),p=_(i,e=>P(e,`POP_MODE`))});let m;n(`Line Terminator Handling`,()=>{let e=pt(t.lineTerminatorCharacters);m=_(i,e=>!1),t.positionTracking!==`onlyOffset`&&(m=_(i,t=>P(t,`LINE_BREAKS`)?!!t.LINE_BREAKS:dt(t,e)===!1&&Ie(e,t.PATTERN)))});let h,v,y,b;n(`Misc Mapping #2`,()=>{h=_(i,ct),v=_(c,lt),y=U(i,(e,t)=>{let n=t.GROUP;return r(n)&&n!==J.SKIPPED&&(e[n]=[]),e},{}),b=_(c,(e,t)=>({pattern:c[t],longerAlt:d[t],canLineTerminator:m[t],isCustom:h[t],short:v[t],group:u[t],push:f[t],pop:p[t],tokenTypeIdx:l[t],tokenType:i[t]}))});let S=!0,C=[];return t.safeMode||n(`First Char Optimization`,()=>{C=U(i,(e,n,r)=>{if(typeof n.PATTERN==`string`)mt(e,K(n.PATTERN.charCodeAt(0)),b[r]);else if(j(n.START_CHARS_HINT)){let t;W(n.START_CHARS_HINT,n=>{let i=K(typeof n==`string`?n.charCodeAt(0):n);t!==i&&(t=i,mt(e,i,b[r]))})}else if(x(n.PATTERN))if(n.PATTERN.unicode)S=!1,t.ensureOptimizations&&de(`${Oe}\tUnable to analyze < ${n.PATTERN.toString()} > pattern.\n The regexp unicode flag is not currently supported by the regexp-to-ast library.
|
|
8
8
|
This will disable the lexer's first char optimizations.
|
|
9
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let i=
|
|
10
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),
|
|
9
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let i=ke(n.PATTERN,t.ensureOptimizations);o(i)&&(S=!1),W(i,t=>{mt(e,t,b[r])})}else t.ensureOptimizations&&de(`${Oe}\tTokenType: <${n.name}> is using a custom token pattern without providing <start_chars_hint> parameter.\n This will disable the lexer's first char optimizations.
|
|
10
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),S=!1;return e},[])}),{emptyGroups:y,patternIdxToConfig:b,charCodeToPatternIdxToConfig:C,hasCustom:s,canBeOptimized:S}}function Ve(e,t){let n=[],r=Ue(e);n=n.concat(r.errors);let i=We(r.valid),a=i.valid;return n=n.concat(i.errors),n=n.concat(He(a)),n=n.concat(Qe(a)),n=n.concat($e(a,t)),n=n.concat(et(a)),n}function He(e){let t=[],n=p(e,e=>x(e[G]));return t=t.concat(Ke(n)),t=t.concat(Ye(n)),t=t.concat(Xe(n)),t=t.concat(Ze(n)),t=t.concat(qe(n)),t}function Ue(e){let t=p(e,e=>!P(e,G));return{errors:_(t,e=>({message:`Token Type: ->`+e.name+`<- missing static 'PATTERN' property`,type:q.MISSING_PATTERN,tokenTypes:[e]})),valid:S(e,t)}}function We(e){let t=p(e,e=>{let t=e[G];return!x(t)&&!E(t)&&!P(t,`exec`)&&!r(t)});return{errors:_(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:q.INVALID_PATTERN,tokenTypes:[e]})),valid:S(e,t)}}const Ge=/[^\\][$]/;function Ke(e){class n extends t{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}return _(p(e,e=>{let t=e.PATTERN;try{let e=Te(t),r=new n;return r.visit(e),r.found}catch{return Ge.test(t.source)}}),e=>({message:`Unexpected RegExp Anchor Error:
|
|
11
11
|
Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
|
|
12
|
-
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:
|
|
12
|
+
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:q.EOI_ANCHOR_FOUND,tokenTypes:[e]}))}function qe(e){return _(p(e,e=>e.PATTERN.test(``)),e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' must not match an empty string`,type:q.EMPTY_MATCH_PATTERN,tokenTypes:[e]}))}const Je=/[^\\[][\^]|^\^/;function Ye(e){class n extends t{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}return _(p(e,e=>{let t=e.PATTERN;try{let e=Te(t),r=new n;return r.visit(e),r.found}catch{return Je.test(t.source)}}),e=>({message:`Unexpected RegExp Anchor Error:
|
|
13
13
|
Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
|
|
14
|
-
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:
|
|
15
|
-
`,type:
|
|
16
|
-
`,type:
|
|
14
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:q.SOI_ANCHOR_FOUND,tokenTypes:[e]}))}function Xe(e){return _(p(e,e=>{let t=e[G];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:q.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]}))}function Ze(e){let t=[],n=_(e,n=>U(e,(e,r)=>n.PATTERN.source===r.PATTERN.source&&!g(t,r)&&r.PATTERN!==J.NA?(t.push(r),e.push(r),e):e,[]));return n=c(n),_(p(n,e=>e.length>1),e=>{let t=_(e,e=>e.name);return{message:`The same RegExp pattern ->${s(e).PATTERN}<-has been used in all of the following Token Types: ${t.join(`, `)} <-`,type:q.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}})}function Qe(e){return _(p(e,e=>{if(!P(e,`GROUP`))return!1;let t=e.GROUP;return t!==J.SKIPPED&&t!==J.NA&&!r(t)}),e=>({message:`Token Type: ->`+e.name+`<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String`,type:q.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]}))}function $e(e,t){return _(p(e,e=>e.PUSH_MODE!==void 0&&!g(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:q.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}))}function et(e){let t=[],n=U(e,(e,t,n)=>{let i=t.PATTERN;return i===J.NA||(r(i)?e.push({str:i,idx:n,tokenType:t}):x(i)&&nt(i)&&e.push({str:i.source,idx:n,tokenType:t})),e},[]);return W(e,(e,r)=>{W(n,({str:n,idx:i,tokenType:a})=>{if(r<i&&tt(n,e.PATTERN)){let n=`Token: ->${a.name}<- can never be matched.\nBecause it appears AFTER the Token Type ->${e.name}<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:n,type:q.UNREACHABLE_PATTERN,tokenTypes:[e,a]})}})}),t}function tt(e,t){if(x(t)){let n=t.exec(e);return n!==null&&n.index===0}else if(E(t))return t(e,0,[],{});else if(P(t,`exec`))return t.exec(e,0,[],{});else if(typeof t==`string`)return t===e;else throw Error(`non exhaustive match`)}function nt(e){return u([`.`,`\\`,`[`,`]`,`|`,`^`,`$`,`(`,`)`,`?`,`*`,`+`,`{`],t=>e.source.indexOf(t)!==-1)===void 0}function rt(e){let t=e.ignoreCase?`i`:``;return RegExp(`^(?:${e.source})`,t)}function it(e){let t=e.ignoreCase?`iy`:`y`;return RegExp(`${e.source}`,t)}function at(e,t,n){let r=[];return P(e,Le)||r.push({message:`A MultiMode Lexer cannot be initialized without a <`+Le+`> property in its definition
|
|
15
|
+
`,type:q.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),P(e,Re)||r.push({message:`A MultiMode Lexer cannot be initialized without a <`+Re+`> property in its definition
|
|
16
|
+
`,type:q.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),P(e,Re)&&P(e,Le)&&!P(e.modes,e.defaultMode)&&r.push({message:`A MultiMode Lexer cannot be initialized with a ${Le}: <${e.defaultMode}>which does not exist\n`,type:q.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),P(e,Re)&&W(e.modes,(e,t)=>{W(e,(n,i)=>{H(n)?r.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${t}> at index: <${i}>\n`,type:q.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):P(n,`LONGER_ALT`)&&W(j(n.LONGER_ALT)?n.LONGER_ALT:[n.LONGER_ALT],i=>{!H(i)&&!g(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}>\n`,type:q.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),r}function ot(e,t,n){let r=[],i=!1,a=O(c(R(F(e.modes))),e=>e[G]===J.NA),o=pt(n);return t&&W(a,e=>{let t=dt(e,o);if(t!==!1){let n={message:ft(e,t),type:t.issue,tokenType:e};r.push(n)}else P(e,`LINE_BREAKS`)?e.LINE_BREAKS===!0&&(i=!0):Ie(o,e.PATTERN)&&(i=!0)}),t&&!i&&r.push({message:`Warning: No LINE_BREAKS Found.
|
|
17
17
|
This Lexer has been defined to track line and column information,
|
|
18
18
|
But none of the Token Types can be identified as matching a line terminator.
|
|
19
19
|
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
|
|
20
|
-
for details.`,type:
|
|
21
|
-
\tThe problem is in the <${e.name}> Token Type\n\t Root cause: ${t.errMsg}.\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===
|
|
22
|
-
\tThe problem is in the <${e.name}> Token Type\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error(`non exhaustive match`)}function
|
|
23
|
-
`,`\r`],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:
|
|
24
|
-
a boolean 2nd argument is no longer supported`);this.config=
|
|
25
|
-
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),
|
|
20
|
+
for details.`,type:q.NO_LINE_BREAKS_FLAGS}),r}function st(e){let t={};return W(T(e),n=>{let r=e[n];if(j(r))t[n]=[];else throw Error(`non exhaustive match`)}),t}function ct(e){let t=e.PATTERN;if(x(t))return!1;if(E(t)||P(t,`exec`))return!0;if(r(t))return!1;throw Error(`non exhaustive match`)}function lt(e){return r(e)&&e.length===1?e.charCodeAt(0):!1}const ut={test: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},lastIndex:0};function dt(e,t){if(P(e,`LINE_BREAKS`))return!1;if(x(e.PATTERN)){try{Ie(t,e.PATTERN)}catch(e){return{issue:q.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}else if(r(e.PATTERN))return!1;else if(ct(e))return{issue:q.CUSTOM_LINE_BREAK};else throw Error(`non exhaustive match`)}function ft(e,t){if(t.issue===q.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
|
|
21
|
+
\tThe problem is in the <${e.name}> Token Type\n\t Root cause: ${t.errMsg}.\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===q.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
|
|
22
|
+
\tThe problem is in the <${e.name}> Token Type\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error(`non exhaustive match`)}function pt(e){return _(e,e=>r(e)?e.charCodeAt(0):e)}function mt(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}const ht=256;let gt=[];function K(e){return e<256?e:gt[e]}function _t(){if(o(gt)){gt=Array(65536);for(let e=0;e<65536;e++)gt[e]=e>255?255+~~(e/255):e}}function vt(e,t){let n=e.tokenTypeIdx;return n===t.tokenTypeIdx?!0:t.isParent===!0&&t.categoryMatchesMap[n]===!0}function yt(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}let bt=1;const xt={};function St(e){let t=Ct(e);wt(t),Et(t),Tt(t),W(t,e=>{e.isParent=e.categoryMatches.length>0})}function Ct(e){let t=f(e),n=e,r=!0;for(;r;){n=c(R(_(n,e=>e.CATEGORIES)));let e=S(n,t);t=t.concat(e),o(e)?r=!1:n=e}return t}function wt(e){W(e,e=>{Ot(e)||(xt[bt]=e,e.tokenTypeIdx=bt++),kt(e)&&!j(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),kt(e)||(e.CATEGORIES=[]),At(e)||(e.categoryMatches=[]),jt(e)||(e.categoryMatchesMap={})})}function Tt(e){W(e,e=>{e.categoryMatches=[],W(e.categoryMatchesMap,(t,n)=>{e.categoryMatches.push(xt[n].tokenTypeIdx)})})}function Et(e){W(e,e=>{Dt([],e)})}function Dt(e,t){W(e,e=>{t.categoryMatchesMap[e.tokenTypeIdx]=!0}),W(t.CATEGORIES,n=>{let r=e.concat(t);g(r,n)||Dt(r,n)})}function Ot(e){return P(e,`tokenTypeIdx`)}function kt(e){return P(e,`CATEGORIES`)}function At(e){return P(e,`categoryMatches`)}function jt(e){return P(e,`categoryMatchesMap`)}function Mt(e){return P(e,`tokenTypeIdx`)}const Nt={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,n,r,i){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters.`}};var q;(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`})(q||={});const Pt={deferDefinitionErrorsHandling:!1,positionTracking:`full`,lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
|
|
23
|
+
`,`\r`],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:Nt,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Pt);var J=class{constructor(e,t=Pt){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}=ue(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.
|
|
24
|
+
a boolean 2nd argument is no longer supported`);this.config=d({},Pt,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===Pt.lineTerminatorsPattern)this.config.lineTerminatorsPattern=ut;else if(this.config.lineTerminatorCharacters===Pt.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
|
|
25
|
+
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),j(e)?n={modes:{defaultMode:f(e)},defaultMode:Le}:(r=!1,n=f(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT(`performRuntimeChecks`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(at(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT(`performWarningRuntimeChecks`,()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(ot(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},W(n.modes,(e,t)=>{n.modes[t]=O(e,e=>H(e))});let i=T(n.modes);if(W(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(Ve(e,i))}),o(this.lexerDefinitionErrors)){St(e);let r;this.TRACE_INIT(`analyzeTokenTypes`,()=>{r=Be(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=d({},this.emptyGroups,r.emptyGroups),this.hasCustom=r.hasCustom||this.hasCustom,this.canModeBeOptimized[n]=r.canBeOptimized}})}),this.defaultMode=n.defaultMode,!o(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let e=_(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
|
|
26
26
|
`);throw Error(`Errors detected in definition of Lexer:
|
|
27
|
-
`+e)}
|
|
28
|
-
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT(`clearRegExpParserCache`,()=>{
|
|
27
|
+
`+e)}W(this.lexerDefinitionWarning,e=>{le(e.message)}),this.TRACE_INIT(`Choosing sub-methods implementations`,()=>{if(ze?(this.chopInput=v,this.match=this.matchWithTest):(this.updateLastIndex=w,this.match=this.matchWithExec),r&&(this.handleModes=w),this.trackStartLines===!1&&(this.computeNewColumn=v),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=w),/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=U(this.canModeBeOptimized,(e,t,n)=>(t===!1&&e.push(n),e),[]);if(t.ensureOptimizations&&!o(e))throw Error(`Lexer Modes: < ${e.join(`, `)} > cannot be optimized.\n Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
|
|
28
|
+
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT(`clearRegExpParserCache`,()=>{Ee()}),this.TRACE_INIT(`toFastProperties`,()=>{fe(this)})})}tokenize(e,t=this.defaultMode){if(!o(this.lexerDefinitionErrors)){let e=_(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
|
|
29
29
|
`);throw Error(`Unable to Tokenize because Errors detected in definition of Lexer:
|
|
30
|
-
`+e)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,r,i,a,o,s,c,
|
|
31
|
-
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return
|
|
32
|
-
but found: '`+
|
|
33
|
-
`)}`+
|
|
34
|
-
but found: '`+
|
|
35
|
-
inside top level rule: ->`+e.name+`<-`}},
|
|
30
|
+
`+e)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,r,i,a,o,s,c,u,d,f,p,m,h,g,_,v=e,y=v.length,b=0,x=0,S=this.hasCustom?0:Math.floor(e.length/10),C=Array(S),ee=[],w=this.trackStartLines?1:void 0,T=this.trackStartLines?1:void 0,E=st(this.emptyGroups),D=this.trackStartLines,O=this.config.lineTerminatorsPattern,k=0,A=[],j=[],M=[],te=[];Object.freeze(te);let N;function ne(){return A}function P(e){let t=K(e),n=j[t];return n===void 0?te:n}let F=e=>{if(M.length===1&&e.tokenType.PUSH_MODE===void 0){let t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);ee.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{M.pop();let e=l(M);A=this.patternIdxToConfig[e],j=this.charCodeToPatternIdxToConfig[e],k=A.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;N=j&&t?P:ne}};function I(e){M.push(e),j=this.charCodeToPatternIdxToConfig[e],A=this.patternIdxToConfig[e],k=A.length,k=A.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;N=j&&t?P:ne}I.call(this,t);let L,re=this.config.recoveryEnabled;for(;b<y;){s=null;let t=v.charCodeAt(b),l=N(t),S=l.length;for(n=0;n<S;n++){L=l[n];let r=L.pattern;c=null;let d=L.short;if(d===!1?L.isCustom===!0?(_=r.exec(v,b,C,E),_===null?s=null:(s=_[0],_.payload!==void 0&&(c=_.payload))):(this.updateLastIndex(r,b),s=this.match(r,e,b)):t===d&&(s=r),s!==null){if(o=L.longerAlt,o!==void 0){let t=o.length;for(i=0;i<t;i++){let t=A[o[i]],n=t.pattern;if(u=null,t.isCustom===!0?(_=n.exec(v,b,C,E),_===null?a=null:(a=_[0],_.payload!==void 0&&(u=_.payload))):(this.updateLastIndex(n,b),a=this.match(n,e,b)),a&&a.length>s.length){s=a,c=u,L=t;break}}}break}}if(s!==null){if(d=s.length,f=L.group,f!==void 0&&(p=L.tokenTypeIdx,m=this.createTokenInstance(s,b,p,L.tokenType,w,T,d),this.handlePayload(m,c),f===!1?x=this.addToken(C,x,m):E[f].push(m)),e=this.chopInput(e,d),b+=d,T=this.computeNewColumn(T,d),D===!0&&L.canLineTerminator===!0){let e=0,t,n;O.lastIndex=0;do t=O.test(s),t===!0&&(n=O.lastIndex-1,e++);while(t===!0);e!==0&&(w+=e,T=d-n,this.updateTokenEndLineColumnLocation(m,f,n,e,w,T,d))}this.handleModes(L,F,I,m)}else{let t=b,n=w,i=T,a=re===!1;for(;a===!1&&b<y;)for(e=this.chopInput(e,1),b++,r=0;r<k;r++){let t=A[r],n=t.pattern,i=t.short;if(i===!1?t.isCustom===!0?a=n.exec(v,b,C,E)!==null:(this.updateLastIndex(n,b),a=n.exec(e)!==null):v.charCodeAt(b)===i&&(a=!0),a===!0)break}if(h=b-t,T=this.computeNewColumn(T,h),g=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(v,t,h,n,i),ee.push({offset:t,line:n,column:i,length:h,message:g}),re===!1)break}}return this.hasCustom||(C.length=x),{tokens:C,groups:E,errors:ee}}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]}};J.SKIPPED=`This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.`,J.NA=/NOT_APPLICABLE/;function Ft(e){return It(e)?e.LABEL:e.name}function It(e){return r(e.LABEL)&&e.LABEL!==``}const Lt=`categories`,Rt=`label`,zt=`group`,Bt=`push_mode`,Vt=`pop_mode`,Ht=`longer_alt`,Ut=`line_breaks`,Wt=`start_chars_hint`;function Gt(e){return Kt(e)}function Kt(e){let t=e.pattern,n={};if(n.name=e.name,H(t)||(n.PATTERN=t),P(e,`parent`))throw`The parent property is no longer supported.
|
|
31
|
+
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return P(e,Lt)&&(n.CATEGORIES=e[Lt]),St([n]),P(e,Rt)&&(n.LABEL=e[Rt]),P(e,zt)&&(n.GROUP=e[zt]),P(e,Vt)&&(n.POP_MODE=e[Vt]),P(e,Bt)&&(n.PUSH_MODE=e[Bt]),P(e,Ht)&&(n.LONGER_ALT=e[Ht]),P(e,Ut)&&(n.LINE_BREAKS=e[Ut]),P(e,Wt)&&(n.START_CHARS_HINT=e[Wt]),n}const Y=Gt({name:`EOF`,pattern:J.NA});St([Y]);function qt(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}}function Jt(e,t){return vt(e,t)}const Yt={buildMismatchTokenMessage({expected:e,actual:t,previous:n,ruleName:r}){return`Expecting ${It(e)?`--> ${Ft(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=`
|
|
32
|
+
but found: '`+s(t).image+`'`;return r?`Expecting: `+r+a:`Expecting: one of these possible Token sequences:\n${_(_(U(e,(e,t)=>e.concat(t),[]),e=>`[${_(e,e=>Ft(e)).join(`, `)}]`),(e,t)=>` ${t+1}. ${e}`).join(`
|
|
33
|
+
`)}`+a},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:n,ruleName:r}){let i=`
|
|
34
|
+
but found: '`+s(t).image+`'`;return n?`Expecting: `+n+i:`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::\n <${_(e,e=>`[${_(e,e=>Ft(e)).join(`,`)}]`).join(` ,`)}>`+i}};Object.freeze(Yt);const Xt={buildRuleNotFoundError(e,t){return`Invalid grammar, reference to a rule which is not defined: ->`+t.nonTerminalName+`<-
|
|
35
|
+
inside top level rule: ->`+e.name+`<-`}},X={buildDuplicateFoundError(e,t){function n(e){return e instanceof N?e.terminalType.name:e instanceof k?e.nonTerminalName:``}let r=e.name,i=s(t),a=i.idx,o=B(i),c=n(i),l=`->${o}${a>0?a:``}<- ${c?`with argument: ->${c}<-`:``}
|
|
36
36
|
appears more than once (${t.length} times) in the top level rule: ->${r}<-.
|
|
37
37
|
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
|
|
38
|
-
`;return
|
|
39
|
-
`),
|
|
40
|
-
For Further details.`,r},buildEmptyRepetitionError(e){let t=getProductionDslName(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis 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.\nOnly the last alternative may be an empty alternative.`},buildTooManyAlternativesError(e){return`An Alternation cannot have more than 256 alternatives:\n<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\n has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name;return`Left Recursion found in grammar.\nrule: <${t}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${`${t} --> ${map(e.leftRecursionPath,e=>e.name).concat([t]).join(` --> `)}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return`deprecated`},buildDuplicateRuleNameError(e){let t;return t=e.topLevelRule instanceof Rule?e.topLevelRule.name:e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function resolveGrammar$1(e,t){let n=new GastRefResolverVisitor(e,t);return n.resolveRefs(),n.errors}var GastRefResolverVisitor=class extends GAstVisitor{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){forEach(values(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:ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},AbstractNextPossibleTokensWalker=class extends RestWalker{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=clone(this.path.ruleStack).reverse(),this.occurrenceStack=clone(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(){isEmpty(this.ruleStack)?(this.nextProductionName=``,this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},NextAfterTokenWalker=class extends AbstractNextPossibleTokensWalker{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){this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found&&(this.possibleTokTypes=first(new Alternative({definition:t.concat(n)})),this.found=!0)}},AbstractNextTerminalAfterProductionWalker=class extends RestWalker{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}},NextTerminalAfterManyWalker=class extends AbstractNextTerminalAfterProductionWalker{walkMany(e,t,n){if(e.idx===this.occurrence){let e=head(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof Terminal&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,n)}},NextTerminalAfterManySepWalker=class extends AbstractNextTerminalAfterProductionWalker{walkManySep(e,t,n){if(e.idx===this.occurrence){let e=head(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof Terminal&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,n)}},NextTerminalAfterAtLeastOneWalker=class extends AbstractNextTerminalAfterProductionWalker{walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){let e=head(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof Terminal&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,n)}},NextTerminalAfterAtLeastOneSepWalker=class extends AbstractNextTerminalAfterProductionWalker{walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){let e=head(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof Terminal&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,n)}};function possiblePathsFrom(e,t,n=[]){n=clone(n);let r=[],i=0;function a(t){return t.concat(drop(e,i+1))}function o(e){let i=possiblePathsFrom(a(e),t,n);return r.concat(i)}for(;n.length<t&&i<e.length;){let t=e[i];if(t instanceof Alternative||t instanceof NonTerminal)return o(t.definition);if(t instanceof Option)r=o(t.definition);else if(t instanceof RepetitionMandatory)return o(t.definition.concat([new Repetition({definition:t.definition})]));else if(t instanceof RepetitionMandatoryWithSeparator)return o([new Alternative({definition:t.definition}),new Repetition({definition:[new Terminal({terminalType:t.separator})].concat(t.definition)})]);else if(t instanceof RepetitionWithSeparator)r=o(t.definition.concat([new Repetition({definition:[new Terminal({terminalType:t.separator})].concat(t.definition)})]));else if(t instanceof Repetition)r=o(t.definition.concat([new Repetition({definition:t.definition})]));else if(t instanceof Alternation)return forEach(t.definition,e=>{isEmpty(e.definition)===!1&&(r=o(e.definition))}),r;else if(t instanceof Terminal)n.push(t.terminalType);else throw Error(`non exhaustive match`);i++}return r.push({partialPath:n,suffixDef:drop(e,i)}),r}function nextPossibleTokensAfter(e,t,n,r){let i=`EXIT_NONE_TERMINAL`,a=[i],o=`EXIT_ALTERNATIVE`,s=!1,c=t.length,l=c-r-1,u=[],d=[];for(d.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!isEmpty(d);){let e=d.pop();if(e===o){s&&last(d).idx<=l&&d.pop();continue}let r=e.def,f=e.idx,p=e.ruleStack,m=e.occurrenceStack;if(isEmpty(r))continue;let h=r[0];if(h===i){let e={idx:f,def:drop(r),ruleStack:dropRight(p),occurrenceStack:dropRight(m)};d.push(e)}else if(h instanceof Terminal)if(f<c-1){let e=f+1,i=t[e];if(n(i,h.terminalType)){let t={idx:e,def:drop(r),ruleStack:p,occurrenceStack:m};d.push(t)}}else if(f===c-1)u.push({nextTokenType:h.terminalType,nextTokenOccurrence:h.idx,ruleStack:p,occurrenceStack:m}),s=!0;else throw Error(`non exhaustive match`);else if(h instanceof NonTerminal){let e=clone(p);e.push(h.nonTerminalName);let t=clone(m);t.push(h.idx);let n={idx:f,def:h.definition.concat(a,drop(r)),ruleStack:e,occurrenceStack:t};d.push(n)}else if(h instanceof Option){let e={idx:f,def:drop(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t={idx:f,def:h.definition.concat(drop(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof RepetitionMandatory){let e=new Repetition({definition:h.definition,idx:h.idx}),t={idx:f,def:h.definition.concat([e],drop(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof RepetitionMandatoryWithSeparator){let e=new Repetition({definition:[new Terminal({terminalType:h.separator})].concat(h.definition),idx:h.idx}),t={idx:f,def:h.definition.concat([e],drop(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof RepetitionWithSeparator){let e={idx:f,def:drop(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new Repetition({definition:[new Terminal({terminalType:h.separator})].concat(h.definition),idx:h.idx}),n={idx:f,def:h.definition.concat([t],drop(r)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof Repetition){let e={idx:f,def:drop(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new Repetition({definition:h.definition,idx:h.idx}),n={idx:f,def:h.definition.concat([t],drop(r)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof Alternation)for(let e=h.definition.length-1;e>=0;e--){let t={idx:f,def:h.definition[e].definition.concat(drop(r)),ruleStack:p,occurrenceStack:m};d.push(t),d.push(o)}else if(h instanceof Alternative)d.push({idx:f,def:h.definition.concat(drop(r)),ruleStack:p,occurrenceStack:m});else if(h instanceof Rule)d.push(expandTopLevelRule(h,f,p,m));else throw Error(`non exhaustive match`)}return u}function expandTopLevelRule(e,t,n,r){let i=clone(n);i.push(e.name);let a=clone(r);return a.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:a}}var PROD_TYPE;(function(e){e[e.OPTION=0]=`OPTION`,e[e.REPETITION=1]=`REPETITION`,e[e.REPETITION_MANDATORY=2]=`REPETITION_MANDATORY`,e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]=`REPETITION_MANDATORY_WITH_SEPARATOR`,e[e.REPETITION_WITH_SEPARATOR=4]=`REPETITION_WITH_SEPARATOR`,e[e.ALTERNATION=5]=`ALTERNATION`})(PROD_TYPE||={});function getProdType(e){if(e instanceof Option||e===`Option`)return PROD_TYPE.OPTION;if(e instanceof Repetition||e===`Repetition`)return PROD_TYPE.REPETITION;if(e instanceof RepetitionMandatory||e===`RepetitionMandatory`)return PROD_TYPE.REPETITION_MANDATORY;if(e instanceof RepetitionMandatoryWithSeparator||e===`RepetitionMandatoryWithSeparator`)return PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof RepetitionWithSeparator||e===`RepetitionWithSeparator`)return PROD_TYPE.REPETITION_WITH_SEPARATOR;if(e instanceof Alternation||e===`Alternation`)return PROD_TYPE.ALTERNATION;throw Error(`non exhaustive match`)}function getLookaheadPaths(e){let{occurrence:t,rule:n,prodType:r,maxLookahead:i}=e,a=getProdType(r);return a===PROD_TYPE.ALTERNATION?getLookaheadPathsForOr(t,n,i):getLookaheadPathsForOptionalProd(t,n,a,i)}function buildLookaheadFuncForOr(e,t,n,r,i,a){let o=getLookaheadPathsForOr(e,t,n);return a(o,r,areTokenCategoriesNotUsed(o)?tokenStructuredMatcherNoCategories:tokenStructuredMatcher,i)}function buildLookaheadFuncForOptionalProd(e,t,n,r,i,a){let o=getLookaheadPathsForOptionalProd(e,t,i,n),s=areTokenCategoriesNotUsed(o)?tokenStructuredMatcherNoCategories:tokenStructuredMatcher;return a(o[0],s,r)}function buildAlternativesLookAheadFunc(e,t,n,r){let i=e.length,o=every(e,e=>every(e,e=>e.length===1));if(t)return function(t){let r=map(t,e=>e.GATE);for(let t=0;t<i;t++){let i=e[t],a=i.length,o=r[t];if(!(o!==void 0&&o.call(this)===!1))nextPath:for(let e=0;e<a;e++){let r=i[e],a=r.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),r[e])===!1)continue nextPath;return t}}};if(o&&!r){let t=reduce(map(e,e=>flatten(e)),(e,t,n)=>(forEach(t,t=>{has(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=n),forEach(t.categoryMatches,t=>{has(e,t)||(e[t]=n)})}),e),{});return function(){return t[this.LA(1).tokenTypeIdx]}}else return function(){for(let t=0;t<i;t++){let r=e[t],i=r.length;nextPath:for(let e=0;e<i;e++){let i=r[e],a=i.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),i[e])===!1)continue nextPath;return t}}}}function buildSingleAlternativeLookaheadFunction(e,t,n){let r=every(e,e=>e.length===1),i=e.length;if(r&&!n){let t=flatten(e);if(t.length===1&&isEmpty(t[0].categoryMatches)){let e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}else{let e=reduce(t,(e,t,n)=>(e[t.tokenTypeIdx]=!0,forEach(t.categoryMatches,t=>{e[t]=!0}),e),[]);return function(){return e[this.LA(1).tokenTypeIdx]===!0}}}else return function(){nextPath:for(let n=0;n<i;n++){let r=e[n],i=r.length;for(let e=0;e<i;e++)if(t(this.LA(e+1),r[e])===!1)continue nextPath;return!0}return!1}}var RestDefinitionFinderWalker=class extends RestWalker{constructor(e,t,n){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,n,r){return e.idx===this.targetOccurrence&&this.targetProdType===t?(this.restDef=n.concat(r),!0):!1}walkOption(e,t,n){this.checkIsTarget(e,PROD_TYPE.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,PROD_TYPE.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,PROD_TYPE.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,PROD_TYPE.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}},InsideDefinitionFinderVisitor=class extends GAstVisitor{constructor(e,t,n){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=n,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,PROD_TYPE.OPTION)}visitRepetition(e){this.checkIsTarget(e,PROD_TYPE.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,PROD_TYPE.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,PROD_TYPE.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,PROD_TYPE.ALTERNATION)}};function initializeArrayOfArrays(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=[];return t}function pathToHashKeys(e){let t=[``];for(let n=0;n<e.length;n++){let r=e[n],i=[];for(let e=0;e<t.length;e++){let n=t[e];i.push(n+`_`+r.tokenTypeIdx);for(let e=0;e<r.categoryMatches.length;e++){let t=`_`+r.categoryMatches[e];i.push(n+t)}}t=i}return t}function isUniquePrefixHash(e,t,n){for(let r=0;r<e.length;r++){if(r===n)continue;let i=e[r];for(let e=0;e<t.length;e++)if(i[t[e]]===!0)return!1}return!0}function lookAheadSequenceFromAlternatives(e,t){let n=map(e,e=>possiblePathsFrom([e],1)),r=initializeArrayOfArrays(n.length),i=map(n,e=>{let t={};return forEach(e,e=>{forEach(pathToHashKeys(e.partialPath),e=>{t[e]=!0})}),t}),o=n;for(let e=1;e<=t;e++){let n=o;o=initializeArrayOfArrays(n.length);for(let a=0;a<n.length;a++){let s=n[a];for(let n=0;n<s.length;n++){let c=s[n].partialPath,l=s[n].suffixDef,u=pathToHashKeys(c);if(isUniquePrefixHash(i,u,a)||isEmpty(l)||c.length===t){let e=r[a];if(containsPath(e,c)===!1){e.push(c);for(let e=0;e<u.length;e++){let t=u[e];i[a][t]=!0}}}else{let t=possiblePathsFrom(l,e+1,c);o[a]=o[a].concat(t),forEach(t,e=>{forEach(pathToHashKeys(e.partialPath),e=>{i[a][e]=!0})})}}}}return r}function getLookaheadPathsForOr(e,t,n,r){let i=new InsideDefinitionFinderVisitor(e,PROD_TYPE.ALTERNATION,r);return t.accept(i),lookAheadSequenceFromAlternatives(i.result,n)}function getLookaheadPathsForOptionalProd(e,t,n,r){let i=new InsideDefinitionFinderVisitor(e,n);t.accept(i);let a=i.result,o=new RestDefinitionFinderWalker(t,e,n).startWalking();return lookAheadSequenceFromAlternatives([new Alternative({definition:a}),new Alternative({definition:o})],r)}function containsPath(e,t){compareOtherPath:for(let n=0;n<e.length;n++){let r=e[n];if(r.length===t.length){for(let e=0;e<r.length;e++){let n=t[e],i=r[e];if(!(n===i||i.categoryMatchesMap[n.tokenTypeIdx]!==void 0))continue compareOtherPath}return!0}}return!1}function isStrictPrefixOfPath(e,t){return e.length<t.length&&every(e,(e,n)=>{let r=t[n];return e===r||r.categoryMatchesMap[e.tokenTypeIdx]})}function areTokenCategoriesNotUsed(e){return every(e,e=>every(e,e=>every(e,e=>isEmpty(e.categoryMatches))))}function validateLookahead(e){return map(e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}),e=>Object.assign({type:ParserDefinitionErrorType.CUSTOM_LOOKAHEAD_VALIDATION},e))}function validateGrammar$1(e,t,n,r){let i=flatMap(e,e=>validateDuplicateProductions(e,n)),a=checkTerminalAndNoneTerminalsNameSpace(e,t,n),o=flatMap(e,e=>validateTooManyAlts(e,n)),s=flatMap(e,t=>validateRuleDoesNotAlreadyExist(t,e,r,n));return i.concat(a,o,s)}function validateDuplicateProductions(e,t){let n=new OccurrenceValidationCollector;e.accept(n);let r=n.allProductions;return map(values(pickBy(groupBy(r,identifyProductionForDuplicates),e=>e.length>1)),n=>{let r=head(n),i=t.buildDuplicateFoundError(e,n),a=getProductionDslName(r),o={message:i,type:ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:a,occurrence:r.idx},s=getExtraProductionArgument(r);return s&&(o.parameter=s),o})}function identifyProductionForDuplicates(e){return`${getProductionDslName(e)}_#_${e.idx}_#_${getExtraProductionArgument(e)}`}function getExtraProductionArgument(e){return e instanceof Terminal?e.terminalType.name:e instanceof NonTerminal?e.nonTerminalName:``}var OccurrenceValidationCollector=class extends GAstVisitor{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}};function validateRuleDoesNotAlreadyExist(e,t,n,r){let i=[];if(reduce(t,(t,n)=>n.name===e.name?t+1:t,0)>1){let t=r.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});i.push({message:t,type:ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function validateRuleIsOverridden(e,t,n){let r=[],i;return includes(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,r.push({message:i,type:ParserDefinitionErrorType.INVALID_RULE_OVERRIDE,ruleName:e})),r}function validateNoLeftRecursion(e,t,n,r=[]){let i=[],a=getFirstNoneTerminal(t.definition);if(isEmpty(a))return[];{let t=e.name;includes(a,e)&&i.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:r}),type:ParserDefinitionErrorType.LEFT_RECURSION,ruleName:t});let o=flatMap(difference(a,r.concat([e])),t=>{let i=clone(r);return i.push(t),validateNoLeftRecursion(e,t,n,i)});return i.concat(o)}}function getFirstNoneTerminal(e){let t=[];if(isEmpty(e))return t;let n=head(e);if(n instanceof NonTerminal)t.push(n.referencedRule);else if(n instanceof Alternative||n instanceof Option||n instanceof RepetitionMandatory||n instanceof RepetitionMandatoryWithSeparator||n instanceof RepetitionWithSeparator||n instanceof Repetition)t=t.concat(getFirstNoneTerminal(n.definition));else if(n instanceof Alternation)t=flatten(map(n.definition,e=>getFirstNoneTerminal(e.definition)));else if(!(n instanceof Terminal))throw Error(`non exhaustive match`);let r=isOptionalProd(n),i=e.length>1;if(r&&i){let n=drop(e);return t.concat(getFirstNoneTerminal(n))}else return t}var OrCollector=class extends GAstVisitor{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function validateEmptyOrAlternative(e,t){let n=new OrCollector;e.accept(n);let r=n.alternations;return flatMap(r,n=>flatMap(dropRight(n.definition),(r,i)=>isEmpty(nextPossibleTokensAfter([r],[],tokenStructuredMatcher,1))?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:n,emptyChoiceIdx:i}),type:ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:n.idx,alternative:i+1}]:[]))}function validateAmbiguousAlternationAlternatives(e,t,n){let r=new OrCollector;e.accept(r);let i=r.alternations;return i=reject(i,e=>e.ignoreAmbiguities===!0),flatMap(i,r=>{let i=r.idx,a=getLookaheadPathsForOr(i,e,r.maxLookahead||t,r),o=checkAlternativesAmbiguities(a,r,e,n),s=checkPrefixAlternativesAmbiguities(a,r,e,n);return o.concat(s)})}var RepetitionCollector=class extends GAstVisitor{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}};function validateTooManyAlts(e,t){let n=new OrCollector;e.accept(n);let r=n.alternations;return flatMap(r,n=>n.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:n}),type:ParserDefinitionErrorType.TOO_MANY_ALTS,ruleName:e.name,occurrence:n.idx}]:[])}function validateSomeNonEmptyLookaheadPath(e,t,n){let r=[];return forEach(e,e=>{let i=new RepetitionCollector;e.accept(i);let a=i.allProductions;forEach(a,i=>{let a=getProdType(i),o=i.maxLookahead||t,s=i.idx,c=getLookaheadPathsForOptionalProd(s,e,a,o)[0];if(isEmpty(flatten(c))){let t=n.buildEmptyRepetitionError({topLevelRule:e,repetition:i});r.push({message:t,type:ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),r}function checkAlternativesAmbiguities(e,t,n,r){let i=[];return map(reduce(e,(n,r,a)=>(t.definition[a].ignoreAmbiguities===!0||forEach(r,r=>{let o=[a];forEach(e,(e,n)=>{a!==n&&containsPath(e,r)&&t.definition[n].ignoreAmbiguities!==!0&&o.push(n)}),o.length>1&&!containsPath(i,r)&&(i.push(r),n.push({alts:o,path:r}))}),n),[]),e=>{let i=map(e.alts,e=>e+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:ParserDefinitionErrorType.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:t.idx,alternatives:e.alts}})}function checkPrefixAlternativesAmbiguities(e,t,n,r){let i=reduce(e,(e,t,n)=>{let r=map(t,e=>({idx:n,path:e}));return e.concat(r)},[]);return compact(flatMap(i,e=>{if(t.definition[e.idx].ignoreAmbiguities===!0)return[];let o=e.idx,s=e.path;return map(filter(i,e=>t.definition[e.idx].ignoreAmbiguities!==!0&&e.idx<o&&isStrictPrefixOfPath(e.path,s)),e=>{let i=[e.idx+1,o+1],a=t.idx===0?``:t.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:a,alternatives:i}})}))}function checkTerminalAndNoneTerminalsNameSpace(e,t,n){let r=[],i=map(t,e=>e.name);return forEach(e,e=>{let t=e.name;if(includes(i,t)){let i=n.buildNamespaceConflictError(e);r.push({message:i,type:ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),r}function resolveGrammar(e){let t=defaults(e,{errMsgProvider:defaultGrammarResolverErrorProvider}),n={};return forEach(e.rules,e=>{n[e.name]=e}),resolveGrammar$1(n,t.errMsgProvider)}function validateGrammar(e){return e=defaults(e,{errMsgProvider:defaultGrammarValidatorErrorProvider}),validateGrammar$1(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}const MISMATCHED_TOKEN_EXCEPTION=`MismatchedTokenException`,NO_VIABLE_ALT_EXCEPTION=`NoViableAltException`,EARLY_EXIT_EXCEPTION=`EarlyExitException`,NOT_ALL_INPUT_PARSED_EXCEPTION=`NotAllInputParsedException`,RECOGNITION_EXCEPTION_NAMES=[MISMATCHED_TOKEN_EXCEPTION,NO_VIABLE_ALT_EXCEPTION,EARLY_EXIT_EXCEPTION,NOT_ALL_INPUT_PARSED_EXCEPTION];Object.freeze(RECOGNITION_EXCEPTION_NAMES);function isRecognitionException(e){return includes(RECOGNITION_EXCEPTION_NAMES,e.name)}var RecognitionException=class extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},MismatchedTokenException=class extends RecognitionException{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=MISMATCHED_TOKEN_EXCEPTION}},NoViableAltException=class extends RecognitionException{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=NO_VIABLE_ALT_EXCEPTION}},NotAllInputParsedException=class extends RecognitionException{constructor(e,t){super(e,t),this.name=NOT_ALL_INPUT_PARSED_EXCEPTION}},EarlyExitException=class extends RecognitionException{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=EARLY_EXIT_EXCEPTION}};const EOF_FOLLOW_KEY={},IN_RULE_RECOVERY_EXCEPTION=`InRuleRecoveryException`;var InRuleRecoveryException=class extends Error{constructor(e){super(e),this.name=IN_RULE_RECOVERY_EXCEPTION}},Recoverable=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=has(e,`recoveryEnabled`)?e.recoveryEnabled:DEFAULT_PARSER_CONFIG.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=attemptInRepetitionRecovery)}getTokenToInsert(e){let t=createTokenInstance(e,``,NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,n,r){let i=this.findReSyncTokenType(),a=this.exportLexerState(),o=[],s=!1,c=this.LA(1),l=this.LA(1),u=()=>{let e=this.LA(0),t=new MismatchedTokenException(this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:c,previous:e,ruleName:this.getCurrRuleFullName()}),c,this.LA(0));t.resyncedTokens=dropRight(o),this.SAVE_ERROR(t)};for(;!s;)if(this.tokenMatcher(l,r)){u();return}else if(n.call(this)){u(),e.apply(this,t);return}else this.tokenMatcher(l,i)?s=!0:(l=this.SKIP_TOKEN(),this.addToResyncTokens(l,o));this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,t,n){return!(n===!1||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){let n=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new InRuleRecoveryException(`sad sad panda`)}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||isEmpty(t))return!1;let n=this.LA(1);return find(t,e=>this.tokenMatcher(n,e))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey();return includes(this.getFollowSetFromFollowKey(t),e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA(1),n=2;for(;;){let r=find(e,e=>tokenMatcher(t,e));if(r!==void 0)return r;t=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return EOF_FOLLOW_KEY;let e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK;return map(e,(n,r)=>r===0?EOF_FOLLOW_KEY:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:t[r],inRule:this.shortRuleNameToFullName(e[r-1])})}flattenFollowSet(){return flatten(map(this.buildFullFollowKeyStack(),e=>this.getFollowSetFromFollowKey(e)))}getFollowSetFromFollowKey(e){if(e===EOF_FOLLOW_KEY)return[EOF];let t=e.ruleName+e.idxInCallingRule+IN+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,EOF)||t.push(e),t}reSyncTo(e){let t=[],n=this.LA(1);for(;this.tokenMatcher(n,e)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,t);return dropRight(t)}attemptInRepetitionRecovery(e,t,n,r,i,a,o){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:clone(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return map(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}};function attemptInRepetitionRecovery(e,t,n,r,i,a,o){let s=this.getKeyForAutomaticLookahead(r,i),c=this.firstAfterRepMap[s];if(c===void 0){let e=this.getCurrRuleFullName(),t=this.getGAstProductions()[e];c=new a(t,i).startWalking(),this.firstAfterRepMap[s]=c}let l=c.token,u=c.occurrence,d=c.isEndOfRule;this.RULE_STACK.length===1&&d&&l===void 0&&(l=EOF,u=1),!(l===void 0||u===void 0)&&this.shouldInRepetitionRecoveryBeTried(l,u,o)&&this.tryInRepetitionRecovery(e,t,n,l)}const AT_LEAST_ONE_IDX=1024,MANY_SEP_IDX=1280,AT_LEAST_ONE_SEP_IDX=1536;function getKeyForAutomaticLookahead(e,t,n){return n|t|e}var LLkLookaheadStrategy=class{constructor(e){this.maxLookahead=e?.maxLookahead??DEFAULT_PARSER_CONFIG.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);if(isEmpty(t)){let n=this.validateEmptyOrAlternatives(e.rules),r=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...n,...r,...i]}return t}validateNoLeftRecursion(e){return flatMap(e,e=>validateNoLeftRecursion(e,e,defaultGrammarValidatorErrorProvider))}validateEmptyOrAlternatives(e){return flatMap(e,e=>validateEmptyOrAlternative(e,defaultGrammarValidatorErrorProvider))}validateAmbiguousAlternationAlternatives(e,t){return flatMap(e,e=>validateAmbiguousAlternationAlternatives(e,t,defaultGrammarValidatorErrorProvider))}validateSomeNonEmptyLookaheadPath(e,t){return validateSomeNonEmptyLookaheadPath(e,t,defaultGrammarValidatorErrorProvider)}buildLookaheadForAlternation(e){return buildLookaheadFuncForOr(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,buildAlternativesLookAheadFunc)}buildLookaheadForOptional(e){return buildLookaheadFuncForOptionalProd(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,getProdType(e.prodType),buildSingleAlternativeLookaheadFunction)}},LooksAhead=class{initLooksAhead(e){this.dynamicTokensEnabled=has(e,`dynamicTokensEnabled`)?e.dynamicTokensEnabled:DEFAULT_PARSER_CONFIG.dynamicTokensEnabled,this.maxLookahead=has(e,`maxLookahead`)?e.maxLookahead:DEFAULT_PARSER_CONFIG.maxLookahead,this.lookaheadStrategy=has(e,`lookaheadStrategy`)?e.lookaheadStrategy:new LLkLookaheadStrategy({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){forEach(e,e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{let{alternation:t,repetition:n,option:r,repetitionMandatory:i,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:o}=collectMethods(e);forEach(t,t=>{let n=t.idx===0?``:t.idx;this.TRACE_INIT(`${getProductionDslName(t)}${n}`,()=>{let n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),r=getKeyForAutomaticLookahead(this.fullRuleNameToShort[e.name],256,t.idx);this.setLaFuncCache(r,n)})}),forEach(n,t=>{this.computeLookaheadFunc(e,t.idx,768,`Repetition`,t.maxLookahead,getProductionDslName(t))}),forEach(r,t=>{this.computeLookaheadFunc(e,t.idx,512,`Option`,t.maxLookahead,getProductionDslName(t))}),forEach(i,t=>{this.computeLookaheadFunc(e,t.idx,AT_LEAST_ONE_IDX,`RepetitionMandatory`,t.maxLookahead,getProductionDslName(t))}),forEach(a,t=>{this.computeLookaheadFunc(e,t.idx,AT_LEAST_ONE_SEP_IDX,`RepetitionMandatoryWithSeparator`,t.maxLookahead,getProductionDslName(t))}),forEach(o,t=>{this.computeLookaheadFunc(e,t.idx,MANY_SEP_IDX,`RepetitionWithSeparator`,t.maxLookahead,getProductionDslName(t))})})})}computeLookaheadFunc(e,t,n,r,i,a){this.TRACE_INIT(`${a}${t===0?``:t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r}),o=getKeyForAutomaticLookahead(this.fullRuleNameToShort[e.name],n,t);this.setLaFuncCache(o,a)})}getKeyForAutomaticLookahead(e,t){return getKeyForAutomaticLookahead(this.getLastExplicitRuleShortName(),e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},DslMethodsCollectorVisitor=class extends GAstVisitor{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}};const collectorVisitor=new DslMethodsCollectorVisitor;function collectMethods(e){collectorVisitor.reset(),e.accept(collectorVisitor);let t=collectorVisitor.dslMethods;return collectorVisitor.reset(),t}function setNodeLocationOnlyOffset(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function setNodeLocationFull(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function addTerminalToCst(e,t,n){e.children[n]===void 0?e.children[n]=[t]:e.children[n].push(t)}function addNoneTerminalToCst(e,t,n){e.children[t]===void 0?e.children[t]=[n]:e.children[t].push(n)}function defineNameProp(e,t){Object.defineProperty(e,`name`,{enumerable:!1,configurable:!0,writable:!1,value:t})}function defaultVisit(e,t){let n=keys(e),r=n.length;for(let i=0;i<r;i++){let r=e[n[i]],a=r.length;for(let e=0;e<a;e++){let n=r[e];n.tokenTypeIdx===void 0&&this[n.name](n.children,t)}}}function createBaseSemanticVisitorConstructor(e,t){let n=function(){};return defineNameProp(n,e+`BaseSemantics`),n.prototype={visit:function(e,t){if(isArray(e)&&(e=e[0]),!isUndefined(e))return this[e.name](e.children,t)},validateVisitor:function(){let e=validateVisitor(this,t);if(!isEmpty(e)){let t=map(e,e=>e.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${t.join(`
|
|
38
|
+
`;return l=l.replace(/[ \t]+/g,` `),l=l.replace(/\s\s+/g,`
|
|
39
|
+
`),l},buildNamespaceConflictError(e){return`Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=_(e.prefixPath,e=>Ft(e)).join(`, `),n=e.alternation.idx===0?``:e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(` ,`)}> due to common lookahead prefix\nin <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details.`},buildAlternationAmbiguityError(e){let t=_(e.prefixPath,e=>Ft(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,\n<${t}> may appears as a prefix path in all these alternatives.\n`;return r+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
|
|
40
|
+
For Further details.`,r},buildEmptyRepetitionError(e){let t=B(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis 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.\nOnly the last alternative may be an empty alternative.`},buildTooManyAlternativesError(e){return`An Alternation cannot have more than 256 alternatives:\n<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\n has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name;return`Left Recursion found in grammar.\nrule: <${t}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${`${t} --> ${_(e.leftRecursionPath,e=>e.name).concat([t]).join(` --> `)}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return`deprecated`},buildDuplicateRuleNameError(e){let t;return t=e.topLevelRule instanceof L?e.topLevelRule.name:e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function Zt(e,t){let n=new Qt(e,t);return n.resolveRefs(),n.errors}var Qt=class extends D{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){W(F(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:$.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},$t=class extends pe{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=f(this.path.ruleStack).reverse(),this.occurrenceStack=f(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(){o(this.ruleStack)?(this.nextProductionName=``,this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},en=class extends $t{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){this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found&&(this.possibleTokTypes=he(new z({definition:t.concat(n)})),this.found=!0)}},tn=class extends pe{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}},nn=class extends tn{walkMany(e,t,n){if(e.idx===this.occurrence){let e=s(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof N&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,n)}},rn=class extends tn{walkManySep(e,t,n){if(e.idx===this.occurrence){let e=s(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof N&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,n)}},an=class extends tn{walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){let e=s(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof N&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,n)}},on=class extends tn{walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){let e=s(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof N&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,n)}};function sn(e,t,n=[]){n=f(n);let r=[],i=0;function a(t){return t.concat(C(e,i+1))}function s(e){let i=sn(a(e),t,n);return r.concat(i)}for(;n.length<t&&i<e.length;){let t=e[i];if(t instanceof z||t instanceof k)return s(t.definition);if(t instanceof I)r=s(t.definition);else if(t instanceof A)return s(t.definition.concat([new V({definition:t.definition})]));else if(t instanceof M)return s([new z({definition:t.definition}),new V({definition:[new N({terminalType:t.separator})].concat(t.definition)})]);else if(t instanceof ae)r=s(t.definition.concat([new V({definition:[new N({terminalType:t.separator})].concat(t.definition)})]));else if(t instanceof V)r=s(t.definition.concat([new V({definition:t.definition})]));else if(t instanceof ie)return W(t.definition,e=>{o(e.definition)===!1&&(r=s(e.definition))}),r;else if(t instanceof N)n.push(t.terminalType);else throw Error(`non exhaustive match`);i++}return r.push({partialPath:n,suffixDef:C(e,i)}),r}function cn(e,t,n,r){let a=`EXIT_NONE_TERMINAL`,s=[a],c=`EXIT_ALTERNATIVE`,u=!1,d=t.length,p=d-r-1,m=[],h=[];for(h.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!o(h);){let e=h.pop();if(e===c){u&&l(h).idx<=p&&h.pop();continue}let r=e.def,g=e.idx,_=e.ruleStack,v=e.occurrenceStack;if(o(r))continue;let y=r[0];if(y===a){let e={idx:g,def:C(r),ruleStack:i(_),occurrenceStack:i(v)};h.push(e)}else if(y instanceof N)if(g<d-1){let e=g+1,i=t[e];if(n(i,y.terminalType)){let t={idx:e,def:C(r),ruleStack:_,occurrenceStack:v};h.push(t)}}else if(g===d-1)m.push({nextTokenType:y.terminalType,nextTokenOccurrence:y.idx,ruleStack:_,occurrenceStack:v}),u=!0;else throw Error(`non exhaustive match`);else if(y instanceof k){let e=f(_);e.push(y.nonTerminalName);let t=f(v);t.push(y.idx);let n={idx:g,def:y.definition.concat(s,C(r)),ruleStack:e,occurrenceStack:t};h.push(n)}else if(y instanceof I){let e={idx:g,def:C(r),ruleStack:_,occurrenceStack:v};h.push(e),h.push(c);let t={idx:g,def:y.definition.concat(C(r)),ruleStack:_,occurrenceStack:v};h.push(t)}else if(y instanceof A){let e=new V({definition:y.definition,idx:y.idx}),t={idx:g,def:y.definition.concat([e],C(r)),ruleStack:_,occurrenceStack:v};h.push(t)}else if(y instanceof M){let e=new V({definition:[new N({terminalType:y.separator})].concat(y.definition),idx:y.idx}),t={idx:g,def:y.definition.concat([e],C(r)),ruleStack:_,occurrenceStack:v};h.push(t)}else if(y instanceof ae){let e={idx:g,def:C(r),ruleStack:_,occurrenceStack:v};h.push(e),h.push(c);let t=new V({definition:[new N({terminalType:y.separator})].concat(y.definition),idx:y.idx}),n={idx:g,def:y.definition.concat([t],C(r)),ruleStack:_,occurrenceStack:v};h.push(n)}else if(y instanceof V){let e={idx:g,def:C(r),ruleStack:_,occurrenceStack:v};h.push(e),h.push(c);let t=new V({definition:y.definition,idx:y.idx}),n={idx:g,def:y.definition.concat([t],C(r)),ruleStack:_,occurrenceStack:v};h.push(n)}else if(y instanceof ie)for(let e=y.definition.length-1;e>=0;e--){let t={idx:g,def:y.definition[e].definition.concat(C(r)),ruleStack:_,occurrenceStack:v};h.push(t),h.push(c)}else if(y instanceof z)h.push({idx:g,def:y.definition.concat(C(r)),ruleStack:_,occurrenceStack:v});else if(y instanceof L)h.push(ln(y,g,_,v));else throw Error(`non exhaustive match`)}return m}function ln(e,t,n,r){let i=f(n);i.push(e.name);let a=f(r);return a.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:a}}var Z;(function(e){e[e.OPTION=0]=`OPTION`,e[e.REPETITION=1]=`REPETITION`,e[e.REPETITION_MANDATORY=2]=`REPETITION_MANDATORY`,e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]=`REPETITION_MANDATORY_WITH_SEPARATOR`,e[e.REPETITION_WITH_SEPARATOR=4]=`REPETITION_WITH_SEPARATOR`,e[e.ALTERNATION=5]=`ALTERNATION`})(Z||={});function un(e){if(e instanceof I||e===`Option`)return Z.OPTION;if(e instanceof V||e===`Repetition`)return Z.REPETITION;if(e instanceof A||e===`RepetitionMandatory`)return Z.REPETITION_MANDATORY;if(e instanceof M||e===`RepetitionMandatoryWithSeparator`)return Z.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof ae||e===`RepetitionWithSeparator`)return Z.REPETITION_WITH_SEPARATOR;if(e instanceof ie||e===`Alternation`)return Z.ALTERNATION;throw Error(`non exhaustive match`)}function dn(e){let{occurrence:t,rule:n,prodType:r,maxLookahead:i}=e,a=un(r);return a===Z.ALTERNATION?Sn(t,n,i):Cn(t,n,a,i)}function fn(e,t,n,r,i,a){let o=Sn(e,t,n);return a(o,r,En(o)?yt:vt,i)}function pn(e,t,n,r,i,a){let o=Cn(e,t,i,n),s=En(o)?yt:vt;return a(o[0],s,r)}function mn(e,t,n,r){let i=e.length,a=y(e,e=>y(e,e=>e.length===1));if(t)return function(t){let r=_(t,e=>e.GATE);for(let t=0;t<i;t++){let i=e[t],a=i.length,o=r[t];if(!(o!==void 0&&o.call(this)===!1))nextPath:for(let e=0;e<a;e++){let r=i[e],a=r.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),r[e])===!1)continue nextPath;return t}}};if(a&&!r){let t=U(_(e,e=>R(e)),(e,t,n)=>(W(t,t=>{P(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=n),W(t.categoryMatches,t=>{P(e,t)||(e[t]=n)})}),e),{});return function(){return t[this.LA(1).tokenTypeIdx]}}else return function(){for(let t=0;t<i;t++){let r=e[t],i=r.length;nextPath:for(let e=0;e<i;e++){let i=r[e],a=i.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),i[e])===!1)continue nextPath;return t}}}}function hn(e,t,n){let r=y(e,e=>e.length===1),i=e.length;if(r&&!n){let t=R(e);if(t.length===1&&o(t[0].categoryMatches)){let e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}else{let e=U(t,(e,t,n)=>(e[t.tokenTypeIdx]=!0,W(t.categoryMatches,t=>{e[t]=!0}),e),[]);return function(){return e[this.LA(1).tokenTypeIdx]===!0}}}else return function(){nextPath:for(let n=0;n<i;n++){let r=e[n],i=r.length;for(let e=0;e<i;e++)if(t(this.LA(e+1),r[e])===!1)continue nextPath;return!0}return!1}}var gn=class extends pe{constructor(e,t,n){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,n,r){return e.idx===this.targetOccurrence&&this.targetProdType===t?(this.restDef=n.concat(r),!0):!1}walkOption(e,t,n){this.checkIsTarget(e,Z.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,Z.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,Z.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,Z.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}},_n=class extends D{constructor(e,t,n){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=n,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,Z.OPTION)}visitRepetition(e){this.checkIsTarget(e,Z.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,Z.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,Z.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,Z.ALTERNATION)}};function vn(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=[];return t}function yn(e){let t=[``];for(let n=0;n<e.length;n++){let r=e[n],i=[];for(let e=0;e<t.length;e++){let n=t[e];i.push(n+`_`+r.tokenTypeIdx);for(let e=0;e<r.categoryMatches.length;e++){let t=`_`+r.categoryMatches[e];i.push(n+t)}}t=i}return t}function bn(e,t,n){for(let r=0;r<e.length;r++){if(r===n)continue;let i=e[r];for(let e=0;e<t.length;e++)if(i[t[e]]===!0)return!1}return!0}function xn(e,t){let n=_(e,e=>sn([e],1)),r=vn(n.length),i=_(n,e=>{let t={};return W(e,e=>{W(yn(e.partialPath),e=>{t[e]=!0})}),t}),a=n;for(let e=1;e<=t;e++){let n=a;a=vn(n.length);for(let s=0;s<n.length;s++){let c=n[s];for(let n=0;n<c.length;n++){let l=c[n].partialPath,u=c[n].suffixDef,d=yn(l);if(bn(i,d,s)||o(u)||l.length===t){let e=r[s];if(wn(e,l)===!1){e.push(l);for(let e=0;e<d.length;e++){let t=d[e];i[s][t]=!0}}}else{let t=sn(u,e+1,l);a[s]=a[s].concat(t),W(t,e=>{W(yn(e.partialPath),e=>{i[s][e]=!0})})}}}}return r}function Sn(e,t,n,r){let i=new _n(e,Z.ALTERNATION,r);return t.accept(i),xn(i.result,n)}function Cn(e,t,n,r){let i=new _n(e,n);t.accept(i);let a=i.result,o=new gn(t,e,n).startWalking();return xn([new z({definition:a}),new z({definition:o})],r)}function wn(e,t){compareOtherPath:for(let n=0;n<e.length;n++){let r=e[n];if(r.length===t.length){for(let e=0;e<r.length;e++){let n=t[e],i=r[e];if(!(n===i||i.categoryMatchesMap[n.tokenTypeIdx]!==void 0))continue compareOtherPath}return!0}}return!1}function Tn(e,t){return e.length<t.length&&y(e,(e,n)=>{let r=t[n];return e===r||r.categoryMatchesMap[e.tokenTypeIdx]})}function En(e){return y(e,e=>y(e,e=>y(e,e=>o(e.categoryMatches))))}function Dn(e){return _(e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}),e=>Object.assign({type:$.CUSTOM_LOOKAHEAD_VALIDATION},e))}function On(e,t,n,r){let i=h(e,e=>kn(e,n)),a=Gn(e,t,n),o=h(e,e=>Vn(e,n)),s=h(e,t=>Nn(t,e,r,n));return i.concat(a,o,s)}function kn(e,t){let n=new Mn;e.accept(n);let r=n.allProductions;return _(F(b(m(r,An),e=>e.length>1)),n=>{let r=s(n),i=t.buildDuplicateFoundError(e,n),a=B(r),o={message:i,type:$.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:a,occurrence:r.idx},c=jn(r);return c&&(o.parameter=c),o})}function An(e){return`${B(e)}_#_${e.idx}_#_${jn(e)}`}function jn(e){return e instanceof N?e.terminalType.name:e instanceof k?e.nonTerminalName:``}var Mn=class extends D{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}};function Nn(e,t,n,r){let i=[];if(U(t,(t,n)=>n.name===e.name?t+1:t,0)>1){let t=r.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});i.push({message:t,type:$.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function Pn(e,t,n){let r=[],i;return g(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,r.push({message:i,type:$.INVALID_RULE_OVERRIDE,ruleName:e})),r}function Fn(e,t,n,r=[]){let i=[],a=In(t.definition);if(o(a))return[];{let t=e.name;g(a,e)&&i.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:r}),type:$.LEFT_RECURSION,ruleName:t});let o=h(S(a,r.concat([e])),t=>{let i=f(r);return i.push(t),Fn(e,t,n,i)});return i.concat(o)}}function In(e){let t=[];if(o(e))return t;let n=s(e);if(n instanceof k)t.push(n.referencedRule);else if(n instanceof z||n instanceof I||n instanceof A||n instanceof M||n instanceof ae||n instanceof V)t=t.concat(In(n.definition));else if(n instanceof ie)t=R(_(n.definition,e=>In(e.definition)));else if(!(n instanceof N))throw Error(`non exhaustive match`);let r=oe(n),i=e.length>1;if(r&&i){let n=C(e);return t.concat(In(n))}else return t}var Ln=class extends D{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function Rn(e,t){let n=new Ln;e.accept(n);let r=n.alternations;return h(r,n=>h(i(n.definition),(r,i)=>o(cn([r],[],vt,1))?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:n,emptyChoiceIdx:i}),type:$.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:n.idx,alternative:i+1}]:[]))}function zn(e,t,n){let r=new Ln;e.accept(r);let i=r.alternations;return i=O(i,e=>e.ignoreAmbiguities===!0),h(i,r=>{let i=r.idx,a=Sn(i,e,r.maxLookahead||t,r),o=Un(a,r,e,n),s=Wn(a,r,e,n);return o.concat(s)})}var Bn=class extends D{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}};function Vn(e,t){let n=new Ln;e.accept(n);let r=n.alternations;return h(r,n=>n.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:n}),type:$.TOO_MANY_ALTS,ruleName:e.name,occurrence:n.idx}]:[])}function Hn(e,t,n){let r=[];return W(e,e=>{let i=new Bn;e.accept(i);let a=i.allProductions;W(a,i=>{let a=un(i),s=i.maxLookahead||t,c=i.idx,l=Cn(c,e,a,s)[0];if(o(R(l))){let t=n.buildEmptyRepetitionError({topLevelRule:e,repetition:i});r.push({message:t,type:$.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),r}function Un(e,t,n,r){let i=[];return _(U(e,(n,r,a)=>(t.definition[a].ignoreAmbiguities===!0||W(r,r=>{let o=[a];W(e,(e,n)=>{a!==n&&wn(e,r)&&t.definition[n].ignoreAmbiguities!==!0&&o.push(n)}),o.length>1&&!wn(i,r)&&(i.push(r),n.push({alts:o,path:r}))}),n),[]),e=>{let i=_(e.alts,e=>e+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:$.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:t.idx,alternatives:e.alts}})}function Wn(e,t,n,r){let i=U(e,(e,t,n)=>{let r=_(t,e=>({idx:n,path:e}));return e.concat(r)},[]);return c(h(i,e=>{if(t.definition[e.idx].ignoreAmbiguities===!0)return[];let a=e.idx,o=e.path;return _(p(i,e=>t.definition[e.idx].ignoreAmbiguities!==!0&&e.idx<a&&Tn(e.path,o)),e=>{let i=[e.idx+1,a+1],o=t.idx===0?``:t.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:$.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:o,alternatives:i}})}))}function Gn(e,t,n){let r=[],i=_(t,e=>e.name);return W(e,e=>{let t=e.name;if(g(i,t)){let i=n.buildNamespaceConflictError(e);r.push({message:i,type:$.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),r}function Kn(e){let t=ee(e,{errMsgProvider:Xt}),n={};return W(e.rules,e=>{n[e.name]=e}),Zt(n,t.errMsgProvider)}function qn(e){return e=ee(e,{errMsgProvider:X}),On(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}const Jn=`MismatchedTokenException`,Yn=`NoViableAltException`,Xn=`EarlyExitException`,Zn=`NotAllInputParsedException`,Qn=[Jn,Yn,Xn,Zn];Object.freeze(Qn);function $n(e){return g(Qn,e.name)}var er=class extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},tr=class extends er{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Jn}},nr=class extends er{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Yn}},rr=class extends er{constructor(e,t){super(e,t),this.name=Zn}},ir=class extends er{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Xn}};const ar={},or=`InRuleRecoveryException`;var sr=class extends Error{constructor(e){super(e),this.name=or}},cr=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=P(e,`recoveryEnabled`)?e.recoveryEnabled:Q.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=lr)}getTokenToInsert(e){let t=qt(e,``,NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,n,r){let a=this.findReSyncTokenType(),o=this.exportLexerState(),s=[],c=!1,l=this.LA(1),u=this.LA(1),d=()=>{let e=this.LA(0),t=new tr(this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:l,previous:e,ruleName:this.getCurrRuleFullName()}),l,this.LA(0));t.resyncedTokens=i(s),this.SAVE_ERROR(t)};for(;!c;)if(this.tokenMatcher(u,r)){d();return}else if(n.call(this)){d(),e.apply(this,t);return}else this.tokenMatcher(u,a)?c=!0:(u=this.SKIP_TOKEN(),this.addToResyncTokens(u,s));this.importLexerState(o)}shouldInRepetitionRecoveryBeTried(e,t,n){return!(n===!1||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){let n=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new sr(`sad sad panda`)}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||o(t))return!1;let n=this.LA(1);return u(t,e=>this.tokenMatcher(n,e))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey();return g(this.getFollowSetFromFollowKey(t),e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA(1),n=2;for(;;){let r=u(e,e=>Jt(t,e));if(r!==void 0)return r;t=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return ar;let e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK;return _(e,(n,r)=>r===0?ar:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:t[r],inRule:this.shortRuleNameToFullName(e[r-1])})}flattenFollowSet(){return R(_(this.buildFullFollowKeyStack(),e=>this.getFollowSetFromFollowKey(e)))}getFollowSetFromFollowKey(e){if(e===ar)return[Y];let t=e.ruleName+e.idxInCallingRule+ye+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,Y)||t.push(e),t}reSyncTo(e){let t=[],n=this.LA(1);for(;this.tokenMatcher(n,e)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,t);return i(t)}attemptInRepetitionRecovery(e,t,n,r,i,a,o){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:f(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return _(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}};function lr(e,t,n,r,i,a,o){let s=this.getKeyForAutomaticLookahead(r,i),c=this.firstAfterRepMap[s];if(c===void 0){let e=this.getCurrRuleFullName(),t=this.getGAstProductions()[e];c=new a(t,i).startWalking(),this.firstAfterRepMap[s]=c}let l=c.token,u=c.occurrence,d=c.isEndOfRule;this.RULE_STACK.length===1&&d&&l===void 0&&(l=Y,u=1),!(l===void 0||u===void 0)&&this.shouldInRepetitionRecoveryBeTried(l,u,o)&&this.tryInRepetitionRecovery(e,t,n,l)}const ur=1024,dr=1280,fr=1536;function pr(e,t,n){return n|t|e}var mr=class{constructor(e){this.maxLookahead=e?.maxLookahead??Q.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);if(o(t)){let n=this.validateEmptyOrAlternatives(e.rules),r=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...n,...r,...i]}return t}validateNoLeftRecursion(e){return h(e,e=>Fn(e,e,X))}validateEmptyOrAlternatives(e){return h(e,e=>Rn(e,X))}validateAmbiguousAlternationAlternatives(e,t){return h(e,e=>zn(e,t,X))}validateSomeNonEmptyLookaheadPath(e,t){return Hn(e,t,X)}buildLookaheadForAlternation(e){return fn(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,mn)}buildLookaheadForOptional(e){return pn(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,un(e.prodType),hn)}},hr=class{initLooksAhead(e){this.dynamicTokensEnabled=P(e,`dynamicTokensEnabled`)?e.dynamicTokensEnabled:Q.dynamicTokensEnabled,this.maxLookahead=P(e,`maxLookahead`)?e.maxLookahead:Q.maxLookahead,this.lookaheadStrategy=P(e,`lookaheadStrategy`)?e.lookaheadStrategy:new mr({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){W(e,e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{let{alternation:t,repetition:n,option:r,repetitionMandatory:i,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:o}=vr(e);W(t,t=>{let n=t.idx===0?``:t.idx;this.TRACE_INIT(`${B(t)}${n}`,()=>{let n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),r=pr(this.fullRuleNameToShort[e.name],256,t.idx);this.setLaFuncCache(r,n)})}),W(n,t=>{this.computeLookaheadFunc(e,t.idx,768,`Repetition`,t.maxLookahead,B(t))}),W(r,t=>{this.computeLookaheadFunc(e,t.idx,512,`Option`,t.maxLookahead,B(t))}),W(i,t=>{this.computeLookaheadFunc(e,t.idx,ur,`RepetitionMandatory`,t.maxLookahead,B(t))}),W(a,t=>{this.computeLookaheadFunc(e,t.idx,fr,`RepetitionMandatoryWithSeparator`,t.maxLookahead,B(t))}),W(o,t=>{this.computeLookaheadFunc(e,t.idx,dr,`RepetitionWithSeparator`,t.maxLookahead,B(t))})})})}computeLookaheadFunc(e,t,n,r,i,a){this.TRACE_INIT(`${a}${t===0?``:t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r}),o=pr(this.fullRuleNameToShort[e.name],n,t);this.setLaFuncCache(o,a)})}getKeyForAutomaticLookahead(e,t){return pr(this.getLastExplicitRuleShortName(),e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},gr=class extends D{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}};const _r=new gr;function vr(e){_r.reset(),e.accept(_r);let t=_r.dslMethods;return _r.reset(),t}function yr(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function br(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function xr(e,t,n){e.children[n]===void 0?e.children[n]=[t]:e.children[n].push(t)}function Sr(e,t,n){e.children[t]===void 0?e.children[t]=[n]:e.children[t].push(n)}function Cr(e,t){Object.defineProperty(e,`name`,{enumerable:!1,configurable:!0,writable:!1,value:t})}function wr(e,t){let n=T(e),r=n.length;for(let i=0;i<r;i++){let r=e[n[i]],a=r.length;for(let e=0;e<a;e++){let n=r[e];n.tokenTypeIdx===void 0&&this[n.name](n.children,t)}}}function Tr(e,t){let n=function(){};return Cr(n,e+`BaseSemantics`),n.prototype={visit:function(e,t){if(j(e)&&(e=e[0]),!H(e))return this[e.name](e.children,t)},validateVisitor:function(){let e=Or(this,t);if(!o(e)){let t=_(e,e=>e.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${t.join(`
|
|
41
41
|
|
|
42
42
|
`).replace(/\n/g,`
|
|
43
|
-
`)}`)}}},n.prototype.constructor=n,n._RULE_NAMES=t,n}function createBaseVisitorConstructorWithDefaults(e,t,n){let r=function(){};defineNameProp(r,e+`BaseSemanticsWithDefaults`);let i=Object.create(n.prototype);return forEach(t,e=>{i[e]=defaultVisit}),r.prototype=i,r.prototype.constructor=r,r}var CstVisitorDefinitionError;(function(e){e[e.REDUNDANT_METHOD=0]=`REDUNDANT_METHOD`,e[e.MISSING_METHOD=1]=`MISSING_METHOD`})(CstVisitorDefinitionError||={});function validateVisitor(e,t){return validateMissingCstMethods(e,t)}function validateMissingCstMethods(e,t){return compact(map(filter(t,t=>isFunction(e[t])===!1),t=>({msg:`Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,type:CstVisitorDefinitionError.MISSING_METHOD,methodName:t})))}var TreeBuilder=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=has(e,`nodeLocationTracking`)?e.nodeLocationTracking:DEFAULT_PARSER_CONFIG.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=noop,this.cstFinallyStateUpdate=noop,this.cstPostTerminal=noop,this.cstPostNonTerminal=noop,this.cstPostRule=noop;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=setNodeLocationFull,this.setNodeLocationFromNode=setNodeLocationFull,this.cstPostRule=noop,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=noop,this.setNodeLocationFromNode=noop,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=setNodeLocationOnlyOffset,this.setNodeLocationFromNode=setNodeLocationOnlyOffset,this.cstPostRule=noop,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=noop,this.setNodeLocationFromNode=noop,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=noop,this.setNodeLocationFromNode=noop,this.cstPostRule=noop,this.setInitialNodeLocation=noop;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];addTerminalToCst(n,t,e),this.setNodeLocationFromToken(n.location,t)}cstPostNonTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];addNoneTerminalToCst(n,t,e),this.setNodeLocationFromNode(n.location,e.location)}getBaseCstVisitorConstructor(){if(isUndefined(this.baseCstVisitorConstructor)){let e=createBaseSemanticVisitorConstructor(this.className,keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(isUndefined(this.baseCstVisitorWithDefaultsConstructor)){let e=createBaseVisitorConstructorWithDefaults(this.className,keys(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]}getLastExplicitRuleOccurrenceIndex(){let e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]}},LexerAdapter=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error(`Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.`);this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):END_OF_FILE}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?END_OF_FILE:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}},RecognizerApi=class{ACTION(e){return e.call(this)}consume(e,t,n){return this.consumeInternal(t,e,n)}subrule(e,t,n){return this.subruleInternal(t,e,n)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,n=DEFAULT_RULE_CONFIG){if(includes(this.definedRulesNames,e)){let t={message:defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);let r=this.defineRule(e,t,n);return this[e]=r,r}OVERRIDE_RULE(e,t,n=DEFAULT_RULE_CONFIG){let r=validateRuleIsOverridden(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);let i=this.defineRule(e,t,n);return this[e]=i,i}BACKTRACK(e,t){return function(){this.isBackTrackingStack.push(1);let n=this.saveRecogState();try{return e.apply(this,t),!0}catch(e){if(isRecognitionException(e))return!1;throw e}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return serializeGrammar(values(this.gastProductionsCache))}},RecognizerEngine=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=tokenStructuredMatcherNoCategories,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},has(t,`serializedGrammar`))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
|
|
43
|
+
`)}`)}}},n.prototype.constructor=n,n._RULE_NAMES=t,n}function Er(e,t,n){let r=function(){};Cr(r,e+`BaseSemanticsWithDefaults`);let i=Object.create(n.prototype);return W(t,e=>{i[e]=wr}),r.prototype=i,r.prototype.constructor=r,r}var Dr;(function(e){e[e.REDUNDANT_METHOD=0]=`REDUNDANT_METHOD`,e[e.MISSING_METHOD=1]=`MISSING_METHOD`})(Dr||={});function Or(e,t){return kr(e,t)}function kr(e,t){return c(_(p(t,t=>E(e[t])===!1),t=>({msg:`Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,type:Dr.MISSING_METHOD,methodName:t})))}var Ar=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=P(e,`nodeLocationTracking`)?e.nodeLocationTracking:Q.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=w,this.cstFinallyStateUpdate=w,this.cstPostTerminal=w,this.cstPostNonTerminal=w,this.cstPostRule=w;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=br,this.setNodeLocationFromNode=br,this.cstPostRule=w,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=w,this.setNodeLocationFromNode=w,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=yr,this.setNodeLocationFromNode=yr,this.cstPostRule=w,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=w,this.setNodeLocationFromNode=w,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=w,this.setNodeLocationFromNode=w,this.cstPostRule=w,this.setInitialNodeLocation=w;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];xr(n,t,e),this.setNodeLocationFromToken(n.location,t)}cstPostNonTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];Sr(n,t,e),this.setNodeLocationFromNode(n.location,e.location)}getBaseCstVisitorConstructor(){if(H(this.baseCstVisitorConstructor)){let e=Tr(this.className,T(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(H(this.baseCstVisitorWithDefaultsConstructor)){let e=Er(this.className,T(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]}getLastExplicitRuleOccurrenceIndex(){let e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]}},jr=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error(`Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.`);this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):qr}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?qr:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}},Mr=class{ACTION(e){return e.call(this)}consume(e,t,n){return this.consumeInternal(t,e,n)}subrule(e,t,n){return this.subruleInternal(t,e,n)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,n=Jr){if(g(this.definedRulesNames,e)){let t={message:X.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:$.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);let r=this.defineRule(e,t,n);return this[e]=r,r}OVERRIDE_RULE(e,t,n=Jr){let r=Pn(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);let i=this.defineRule(e,t,n);return this[e]=i,i}BACKTRACK(e,t){return function(){this.isBackTrackingStack.push(1);let n=this.saveRecogState();try{return e.apply(this,t),!0}catch(e){if($n(e))return!1;throw e}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return te(F(this.gastProductionsCache))}},Nr=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=yt,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},P(t,`serializedGrammar`))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
|
|
44
44
|
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
|
|
45
|
-
For Further details.`);if(
|
|
45
|
+
For Further details.`);if(j(e)){if(o(e))throw Error(`A Token Vocabulary cannot be empty.
|
|
46
46
|
Note that the first argument for the parser constructor
|
|
47
47
|
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.
|
|
48
48
|
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
|
|
49
|
-
For Further details.`)}if(
|
|
50
|
-
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(
|
|
51
|
-
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};var
|
|
49
|
+
For Further details.`)}if(j(e))this.tokensMap=U(e,(e,t)=>(e[t.name]=t,e),{});else if(P(e,`modes`)&&y(R(F(e.modes)),Mt))this.tokensMap=U(se(R(F(e.modes))),(e,t)=>(e[t.name]=t,e),{});else if(n(e))this.tokensMap=f(e);else throw Error(`<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition`);this.tokensMap.EOF=Y,this.tokenMatcher=y(P(e,`modes`)?R(F(e.modes)):F(e),e=>o(e.categoryMatches))?yt:vt,St(F(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'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let r=P(n,`resyncEnabled`)?n.resyncEnabled:Jr.resyncEnabled,i=P(n,`recoveryValueFunc`)?n.recoveryValueFunc:Jr.recoveryValueFunc,a=this.ruleShortNameIdx<<12;this.ruleShortNameIdx++,this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a;let o;return o=this.outputCst===!0?function n(...o){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,o);let n=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(n),n}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}}:function n(...o){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,o)}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(o,{ruleName:e,originalGrammarAction:t})}invokeRuleCatch(e,t,n){let r=this.RULE_STACK.length===1,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if($n(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(512,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=()=>t.call(this)&&e.call(this)}}else i=e;if(r.call(this)===!0)return i.call(this)}atLeastOneInternal(e,t){let n=this.getKeyForAutomaticLookahead(ur,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=()=>e.call(this)&&t.call(this)}}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,Z.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],r,ur,e,an)}atLeastOneSepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(fr,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=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,on],t,fr,e,on)}else throw this.raiseEarlyExitException(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let n=this.getKeyForAutomaticLookahead(768,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=()=>e.call(this)&&t.call(this)}}else i=t;let a=!0;for(;r.call(this)===!0&&a===!0;)a=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],r,768,e,nn,a)}manySepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(dr,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=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,rn],t,dr,e,rn)}}repetitionSepSecondInternal(e,t,n,r,i){for(;n();)this.CONSUME(t),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,n,r,i],n,fr,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let n=this.getKeyForAutomaticLookahead(256,t),r=j(e)?e:e.DEF,i=this.getLaFuncFromCache(n).call(this,r);if(i!==void 0)return r[i].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){let e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new rr(t,e))}}subruleInternal(e,t,n){let r;try{let i=n===void 0?void 0:n.ARGS;return this.subruleIdx=t,r=e.apply(this,i),this.cstPostNonTerminal(r,n!==void 0&&n.LABEL!==void 0?n.LABEL:e.ruleName),r}catch(t){throw this.subruleInternalError(t,n,e.ruleName)}}subruleInternalError(e,t,n){throw $n(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:n),delete e.partialCstResult),e}consumeInternal(e,t,n){let r;try{let t=this.LA(1);this.tokenMatcher(t,e)===!0?(this.consumeToken(),r=t):this.consumeInternalError(e,t,n)}catch(n){r=this.consumeInternalRecovery(e,t,n)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:e.name,r),r}consumeInternalError(e,t,n){let r,i=this.LA(0);throw r=n!==void 0&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new tr(r,t,i))}consumeInternalRecovery(e,t,n){if(this.recoveryEnabled&&n.name===`MismatchedTokenException`&&!this.isBackTracking()){let r=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,r)}catch(e){throw e.name===or?n:e}}else throw n}saveRecogState(){let e=this.errors,t=f(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState),this.RULE_STACK=e.RULE_STACK}ruleInvocationStateUpdate(e,t,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(t)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Y)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}},Pr=class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=P(e,`errorMessageProvider`)?e.errorMessageProvider:Q.errorMessageProvider}SAVE_ERROR(e){if($n(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:f(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error(`Trying to save an Error which is not a RecognitionException`)}get errors(){return f(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,t,n){let r=this.getCurrRuleFullName(),i=this.getGAstProductions()[r],a=Cn(e,i,t,this.maxLookahead)[0],o=[];for(let e=1;e<=this.maxLookahead;e++)o.push(this.LA(e));let s=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:a,actual:o,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new ir(s,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){let n=this.getCurrRuleFullName(),r=this.getGAstProductions()[n],i=Sn(e,r,this.maxLookahead),a=[];for(let e=1;e<=this.maxLookahead;e++)a.push(this.LA(e));let o=this.LA(0),s=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:i,actual:a,previous:o,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new nr(s,this.LA(1),o))}},Fr=class{initContentAssist(){}computeContentAssist(e,t){let n=this.gastProductionsCache[e];if(H(n))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return cn([n],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let t=s(e.ruleStack),n=this.getGAstProductions()[t];return new en(n,e).startWalking()}};const Ir={description:`This Object indicates the Parser is during Recording Phase`};Object.freeze(Ir);const Lr=Gt({name:`RECORDING_PHASE_TOKEN`,pattern:J.NA});St([Lr]);const Rr=qt(Lr,`This IToken indicates the Parser is in Recording Phase
|
|
50
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Rr);const zr={name:`This CSTNode indicates the Parser is in Recording Phase
|
|
51
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};var Br=class{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 qr}topLevelRuleRecord(e,t){try{let n=new L({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+=`
|
|
52
52
|
This error was thrown during the "grammar recording phase" For more info see:
|
|
53
|
-
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw e}throw e}}optionInternalRecord(e,t){return
|
|
53
|
+
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw e}throw e}}optionInternalRecord(e,t){return Vr.call(this,I,e,t)}atLeastOneInternalRecord(e,t){Vr.call(this,A,t,e)}atLeastOneSepFirstInternalRecord(e,t){Vr.call(this,M,t,e,!0)}manyInternalRecord(e,t){Vr.call(this,V,t,e)}manySepFirstInternalRecord(e,t){Vr.call(this,ae,t,e,!0)}orInternalRecord(e,t){return Hr.call(this,e,t)}subruleInternalRecord(e,t,n){if(Wr(t),!e||P(e,`ruleName`)===!1){let n=Error(`<SUBRULE${Ur(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}let r=l(this.recordingProdStack),i=e.ruleName,a=new k({idx:t,nonTerminalName:i,label:n?.LABEL,referencedRule:void 0});return r.definition.push(a),this.outputCst?zr:Ir}consumeInternalRecord(e,t,n){if(Wr(t),!Ot(e)){let n=Error(`<CONSUME${Ur(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}let r=l(this.recordingProdStack),i=new N({idx:t,terminalType:e,label:n?.LABEL});return r.definition.push(i),Rr}};function Vr(e,t,n,r=!1){Wr(n);let i=l(this.recordingProdStack),a=E(t)?t:t.DEF,o=new e({definition:[],idx:n});return r&&(o.separator=t.SEP),P(t,`MAX_LOOKAHEAD`)&&(o.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(o),a.call(this),i.definition.push(o),this.recordingProdStack.pop(),Ir}function Hr(e,t){Wr(t);let n=l(this.recordingProdStack),r=j(e)===!1,i=r===!1?e:e.DEF,a=new ie({definition:[],idx:t,ignoreAmbiguities:r&&e.IGNORE_AMBIGUITIES===!0});return P(e,`MAX_LOOKAHEAD`)&&(a.maxLookahead=e.MAX_LOOKAHEAD),a.hasPredicates=ce(i,e=>E(e.GATE)),n.definition.push(a),W(i,e=>{let t=new z({definition:[]});a.definition.push(t),P(e,`IGNORE_AMBIGUITIES`)?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:P(e,`GATE`)&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()}),Ir}function Ur(e){return e===0?``:`${e}`}function Wr(e){if(e<0||e>255){let t=Error(`Invalid DSL Method idx value: <${e}>\n\tIdx value must be a none negative value smaller than 256`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var Gr=class{initPerformanceTracer(e){if(P(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=Q.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}=ue(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 Kr(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]})})}const qr=qt(Y,``,NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(qr);const Q=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:Yt,nodeLocationTracking:`none`,traceInitPerf:!1,skipValidations:!1}),Jr=Object.freeze({recoveryValueFunc:()=>void 0,resyncEnabled:!0});var $;(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`})($||={});function Yr(e=void 0){return function(){return e}}var Xr=class e{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`,()=>{fe(this)}),this.TRACE_INIT(`Grammar Recording`,()=>{try{this.enableRecording(),W(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=Kn({rules:F(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(r)}),this.TRACE_INIT(`Grammar Validations`,()=>{if(o(r)&&this.skipValidations===!1){let e=qn({rules:F(this.gastProductionsCache),tokenTypes:F(this.tokensMap),errMsgProvider:X,grammarName:n}),t=Dn({lookaheadStrategy:this.lookaheadStrategy,rules:F(this.gastProductionsCache),tokenTypes:F(this.tokensMap),grammarName:n});this.definitionErrors=this.definitionErrors.concat(e,t)}}),o(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT(`computeAllProdsFollows`,()=>{this.resyncFollows=xe(F(this.gastProductionsCache))}),this.TRACE_INIT(`ComputeLookaheadFunctions`,()=>{var e,t;(t=(e=this.lookaheadStrategy).initialize)==null||t.call(e,{rules:F(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(F(this.gastProductionsCache))})),!e.DEFER_DEFINITION_ERRORS_HANDLING&&!o(this.definitionErrors))throw t=_(this.definitionErrors,e=>e.message),Error(`Parser Definition Errors detected:\n ${t.join(`
|
|
54
54
|
-------------------------------
|
|
55
|
-
`)}`)})}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),
|
|
55
|
+
`)}`)})}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),P(t,`ignoredIssues`))throw Error(`The <ignoredIssues> IParserConfig property has been deprecated.
|
|
56
56
|
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
|
|
57
57
|
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
|
|
58
|
-
For further details.`);this.skipValidations=
|
|
58
|
+
For further details.`);this.skipValidations=P(t,`skipValidations`)?t.skipValidations:Q.skipValidations}};Xr.DEFER_DEFINITION_ERRORS_HANDLING=!1,Kr(Xr,[cr,hr,Ar,jr,Nr,Mr,Pr,Fr,Br,Gr]);var Zr=class extends Xr{constructor(e,t=Q){let n=f(t);n.outputCst=!1,super(e,n)}};export{Yt as a,qt as c,J as d,Nt as f,dn as i,Ft as l,Zr as n,Y as o,mr as r,Gt as s,Yr as t,Jt as u};
|