@gram-data/gram-parse
Advanced tools
Comparing version
@@ -9,3 +9,3 @@ interface NearleyToken { | ||
save: () => any; | ||
formatError: (token: NearleyToken) => string; | ||
formatError: (token: never) => string; | ||
has: (tokenType: string) => boolean; | ||
@@ -12,0 +12,0 @@ } |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t=t||self).gram=t.gram||{},t.gram.parse={}))}(this,(function(t){"use strict";var e=function(t){if(t)throw t},r=function(t){return null!=t&&null!=t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},n=Object.prototype.hasOwnProperty,o=Object.prototype.toString,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===o.call(t)},l=function(t){if(!t||"[object Object]"!==o.call(t))return!1;var e,r=n.call(t,"constructor"),i=t.constructor&&t.constructor.prototype&&n.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!i)return!1;for(e in t);return void 0===e||n.call(t,e)},u=function(t,e){i&&"__proto__"===e.name?i(t,e.name,{enumerable:!0,configurable:!0,value:e.newValue,writable:!0}):t[e.name]=e.newValue},c=function(t,e){if("__proto__"===e){if(!n.call(t,e))return;if(s)return s(t,e).value}return t[e]},f=function t(){var e,r,n,o,i,s,f=arguments[0],p=1,h=arguments.length,m=!1;for("boolean"==typeof f&&(m=f,f=arguments[1]||{},p=2),(null==f||"object"!=typeof f&&"function"!=typeof f)&&(f={});p<h;++p)if(null!=(e=arguments[p]))for(r in e)n=c(f,r),f!==(o=c(e,r))&&(m&&o&&(l(o)||(i=a(o)))?(i?(i=!1,s=n&&a(n)?n:[]):s=n&&l(n)?n:{},u(f,{name:r,newValue:t(m,s,o)})):void 0!==o&&u(f,{name:r,newValue:o}));return f},p=t=>{if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype},h=[].slice,m=function(t,e){var r;return function(){var e,i=h.call(arguments,0),s=t.length>i.length;s&&i.push(n);try{e=t.apply(null,i)}catch(t){if(s&&r)throw t;return n(t)}s||(e&&"function"==typeof e.then?e.then(o,n):e instanceof Error?n(e):o(e))};function n(){r||(r=!0,e.apply(null,arguments))}function o(t){n(null,t)}},y=b;b.wrap=m;var d=[].slice;function b(){var t=[],e={run:function(){var e=-1,r=d.call(arguments,0,-1),n=arguments[arguments.length-1];if("function"!=typeof n)throw new Error("Expected function as last argument, not "+n);function o(i){var s=t[++e],a=d.call(arguments,0),l=a.slice(1),u=r.length,c=-1;if(i)n(i);else{for(;++c<u;)null==l[c]&&(l[c]=r[c]);r=l,s?m(s,o).apply(null,r):n.apply(null,[null].concat(r))}}o.apply(null,[null].concat(r))},use:function(r){if("function"!=typeof r)throw new Error("Expected `fn` to be a function, not "+r);return t.push(r),e}};return e}var g={}.hasOwnProperty,v=function(t){return t&&"object"==typeof t?g.call(t,"position")||g.call(t,"type")?x(t.position):g.call(t,"start")||g.call(t,"end")?x(t):g.call(t,"line")||g.call(t,"column")?w(t):"":""};function w(t){return t&&"object"==typeof t||(t={}),S(t.line)+":"+S(t.column)}function x(t){return t&&"object"==typeof t||(t={}),w(t.start)+"-"+w(t.end)}function S(t){return t&&"number"==typeof t?t:1}var k=P;function $(){}$.prototype=Error.prototype;var E=P.prototype=new $;function P(t,e,r){var n,o,i;"string"==typeof e&&(r=e,e=null),n=function(t){var e,r=[null,null];return"string"==typeof t&&(-1===(e=t.indexOf(":"))?r[1]=t:(r[0]=t.slice(0,e),r[1]=t.slice(e+1))),r}(r),o=v(e)||"1:1",i={start:{line:null,column:null},end:{line:null,column:null}},e&&e.position&&(e=e.position),e&&(e.start?(i=e,e=e.start):i.start=e),t.stack&&(this.stack=t.stack,t=t.message),this.message=t,this.name=o,this.reason=t,this.line=e?e.line:null,this.column=e?e.column:null,this.location=i,this.source=n[0],this.ruleId=n[1]}E.file="",E.name="",E.reason="",E.message="",E.stack="",E.fatal=null,E.column=null,E.line=null;var A="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(t,e){for(var r=0,n=t.length-1;n>=0;n--){var o=t[n];"."===o?t.splice(n,1):".."===o?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}"function"==typeof A.setTimeout&&setTimeout,"function"==typeof A.clearTimeout&&clearTimeout,new Date;var O=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,j=function(t){return O.exec(t).slice(1)};function L(){for(var t="",e=!1,r=arguments.length-1;r>=-1&&!e;r--){var n=r>=0?arguments[r]:"/";if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(t=n+"/"+t,e="/"===n.charAt(0))}return(e?"/":"")+(t=_(V(t.split("/"),(function(t){return!!t})),!e).join("/"))||"."}function T(t){var e=R(t),r="/"===z(t,-1);return(t=_(V(t.split("/"),(function(t){return!!t})),!e).join("/"))||e||(t="."),t&&r&&(t+="/"),(e?"/":"")+t}function R(t){return"/"===t.charAt(0)}function C(){var t=Array.prototype.slice.call(arguments,0);return T(V(t,(function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t})).join("/"))}function N(t,e){function r(t){for(var e=0;e<t.length&&""===t[e];e++);for(var r=t.length-1;r>=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=L(t).substr(1),e=L(e).substr(1);for(var n=r(t.split("/")),o=r(e.split("/")),i=Math.min(n.length,o.length),s=i,a=0;a<i;a++)if(n[a]!==o[a]){s=a;break}var l=[];for(a=s;a<n.length;a++)l.push("..");return(l=l.concat(o.slice(s))).join("/")}function q(t){var e=j(t),r=e[0],n=e[1];return r||n?(n&&(n=n.substr(0,n.length-1)),r+n):"."}function I(t,e){var r=j(t)[2];return e&&r.substr(-1*e.length)===e&&(r=r.substr(0,r.length-e.length)),r}function G(t){return j(t)[3]}var B={extname:G,basename:I,dirname:q,sep:"/",delimiter:":",relative:N,join:C,isAbsolute:R,normalize:T,resolve:L};function V(t,e){if(t.filter)return t.filter(e);for(var r=[],n=0;n<t.length;n++)e(t[n],n,t)&&r.push(t[n]);return r}var z="b"==="ab".substr(-1)?function(t,e,r){return t.substr(e,r)}:function(t,e,r){return e<0&&(e=t.length+e),t.substr(e,r)},F="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Q(t,e){return t(e={exports:{}},e.exports),e.exports}var M,U=(M={__proto__:null,resolve:L,normalize:T,isAbsolute:R,join:C,relative:N,sep:"/",delimiter:":",dirname:q,basename:I,extname:G,default:B})&&M.default||M,J=D,Z={}.hasOwnProperty,H=D.prototype,K=["history","path","basename","stem","extname","dirname"];function D(t){var e,n,o;if(t){if("string"==typeof t||r(t))t={contents:t};else if("message"in t&&"messages"in t)return t}else t={};if(!(this instanceof D))return new D(t);for(this.data={},this.messages=[],this.history=[],this.cwd="/",n=-1,o=K.length;++n<o;)Z.call(t,e=K[n])&&(this[e]=t[e]);for(e in t)-1===K.indexOf(e)&&(this[e]=t[e])}function W(t,e){if(-1!==t.indexOf(U.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+U.sep+"`")}function X(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function Y(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}H.toString=function(t){var e=this.contents||"";return r(e)?e.toString(t):String(e)},Object.defineProperty(H,"path",{get:function(){return this.history[this.history.length-1]},set:function(t){X(t,"path"),t!==this.path&&this.history.push(t)}}),Object.defineProperty(H,"dirname",{get:function(){return"string"==typeof this.path?U.dirname(this.path):void 0},set:function(t){Y(this.path,"dirname"),this.path=U.join(t||"",this.basename)}}),Object.defineProperty(H,"basename",{get:function(){return"string"==typeof this.path?U.basename(this.path):void 0},set:function(t){X(t,"basename"),W(t,"basename"),this.path=U.join(this.dirname||"",t)}}),Object.defineProperty(H,"extname",{get:function(){return"string"==typeof this.path?U.extname(this.path):void 0},set:function(t){var e=t||"";if(W(e,"extname"),Y(this.path,"extname"),e){if("."!==e.charAt(0))throw new Error("`extname` must start with `.`");if(-1!==e.indexOf(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=function(t,e){if("string"!=typeof t)return t;if(0===t.length)return t;var r=U.basename(t,U.extname(t))+e;return U.join(U.dirname(t),r)}(this.path,e)}}),Object.defineProperty(H,"stem",{get:function(){return"string"==typeof this.path?U.basename(this.path,this.extname):void 0},set:function(t){X(t,"stem"),W(t,"stem"),this.path=U.join(this.dirname||"",t+(this.extname||""))}});var tt=J,et=J.prototype;et.message=function(t,e,r){var n=this.path,o=new k(t,e,r);return n&&(o.name=n+":"+o.name,o.file=n),o.fatal=!1,this.messages.push(o),o},et.info=function(){var t=this.message.apply(this,arguments);return t.fatal=null,t},et.fail=function(){var t=this.message.apply(this,arguments);throw t.fatal=!0,t};var rt=function t(){var r=[],n=y(),o={},i=!1,s=-1;return a.data=function(t,e){return"string"==typeof t?2===arguments.length?(ut("data",i),o[t]=e,a):ot.call(o,t)&&o[t]||null:t?(ut("data",i),o=t,a):o},a.freeze=l,a.attachers=r,a.use=function(t){var e;if(ut("use",i),null==t);else if("function"==typeof t)c.apply(null,arguments);else{if("object"!=typeof t)throw new Error("Expected usable value, not `"+t+"`");"length"in t?l(t):n(t)}return e&&(o.settings=f(o.settings||{},e)),a;function n(t){l(t.plugins),t.settings&&(e=f(e||{},t.settings))}function s(t){if("function"==typeof t)c(t);else{if("object"!=typeof t)throw new Error("Expected usable value, not `"+t+"`");"length"in t?c.apply(null,t):n(t)}}function l(t){var e,r;if(null==t);else{if("object"!=typeof t||!("length"in t))throw new Error("Expected a list of plugins, not `"+t+"`");for(e=t.length,r=-1;++r<e;)s(t[r])}}function c(t,e){var n=u(t);n?(p(n[1])&&p(e)&&(e=f(n[1],e)),n[1]=e):r.push(nt.call(arguments))}},a.parse=function(t){var e,r=tt(t);return l(),at("parse",e=a.Parser),st(e,"parse")?new e(String(r),r).parse():e(String(r),r)},a.stringify=function(t,e){var r,n=tt(e);return l(),lt("stringify",r=a.Compiler),ct(t),st(r,"compile")?new r(t,n).compile():r(t,n)},a.run=c,a.runSync=function(t,r){var n,o=!1;return c(t,r,(function(t,r){o=!0,e(t),n=r})),ft("runSync","run",o),n},a.process=h,a.processSync=function(t){var r,n=!1;return l(),at("processSync",a.Parser),lt("processSync",a.Compiler),h(r=tt(t),(function(t){n=!0,e(t)})),ft("processSync","process",n),r},a;function a(){for(var e=t(),n=r.length,i=-1;++i<n;)e.use.apply(null,r[i]);return e.data(f(!0,{},o)),e}function l(){var t,e,o,l;if(i)return a;for(;++s<r.length;)e=(t=r[s])[0],!1!==(o=t[1])&&(!0===o&&(t[1]=void 0),"function"==typeof(l=e.apply(a,t.slice(1)))&&n.use(l));return i=!0,s=Infinity,a}function u(t){for(var e,n=r.length,o=-1;++o<n;)if((e=r[o])[0]===t)return e}function c(t,e,r){if(ct(t),l(),r||"function"!=typeof e||(r=e,e=null),!r)return new Promise(o);function o(o,i){n.run(t,tt(e),(function(e,n,s){n=n||t,e?i(e):o?o(n):r(null,n,s)}))}o(null,r)}function h(t,e){if(l(),at("process",a.Parser),lt("process",a.Compiler),!e)return new Promise(r);function r(r,n){var o=tt(t);it.run(a,{file:o},(function(t){t?n(t):r?r(o):e(null,o)}))}r(null,e)}}().freeze(),nt=[].slice,ot={}.hasOwnProperty,it=y().use((function(t,e){e.tree=t.parse(e.file)})).use((function(t,e,r){t.run(e.tree,e.file,(function(t,n,o){t?r(t):(e.tree=n,e.file=o,r())}))})).use((function(t,e){var n=t.stringify(e.tree,e.file),o=e.file;null==n||("string"==typeof n||r(n)?o.contents=n:o.result=n)}));function st(t,e){return"function"==typeof t&&t.prototype&&(function(t){var e;for(e in t)return!0;return!1}(t.prototype)||e in t.prototype)}function at(t,e){if("function"!=typeof e)throw new Error("Cannot `"+t+"` without `Parser`")}function lt(t,e){if("function"!=typeof e)throw new Error("Cannot `"+t+"` without `Compiler`")}function ut(t,e){if(e)throw new Error("Cannot invoke `"+t+"` on a frozen processor.\nCreate a new processor first, by invoking it: use `processor()` instead of `processor`.")}function ct(t){if(!t||"string"!=typeof t.type)throw new Error("Expected node, got `"+t+"`")}function ft(t,e,r){if(!r)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}var pt=Q((function(t){var e,r;e=F,r=function(){function t(e,r,n){return this.id=++t.highestId,this.name=e,this.symbols=r,this.postprocess=n,this}function e(t,e,r,n){this.rule=t,this.dot=e,this.reference=r,this.data=[],this.wantedBy=n,this.isComplete=this.dot===t.symbols.length}function r(t,e){this.grammar=t,this.index=e,this.states=[],this.wants={},this.scannable=[],this.completed={}}function n(t,e){this.rules=t,this.start=e||this.rules[0].name;var r=this.byName={};this.rules.forEach((function(t){r.hasOwnProperty(t.name)||(r[t.name]=[]),r[t.name].push(t)}))}function o(){this.reset("")}function i(t,e,i){if(t instanceof n){var s=t;i=e}else s=n.fromCompiled(t,e);for(var a in this.grammar=s,this.options={keepHistory:!1,lexer:s.lexer||new o},i||{})this.options[a]=i[a];this.lexer=this.options.lexer,this.lexerState=void 0;var l=new r(s,0);this.table=[l],l.wants[s.start]=[],l.predict(s.start),l.process(),this.current=0}function s(t){var e=typeof t;if("string"===e)return t;if("object"===e){if(t.literal)return JSON.stringify(t.literal);if(t instanceof RegExp)return t.toString();if(t.type)return"%"+t.type;if(t.test)return"<"+String(t.test)+">";throw new Error("Unknown symbol type: "+t)}}return t.highestId=0,t.prototype.toString=function(t){var e=void 0===t?this.symbols.map(s).join(" "):this.symbols.slice(0,t).map(s).join(" ")+" ● "+this.symbols.slice(t).map(s).join(" ");return this.name+" → "+e},e.prototype.toString=function(){return"{"+this.rule.toString(this.dot)+"}, from: "+(this.reference||0)},e.prototype.nextState=function(t){var r=new e(this.rule,this.dot+1,this.reference,this.wantedBy);return r.left=this,r.right=t,r.isComplete&&(r.data=r.build(),r.right=void 0),r},e.prototype.build=function(){var t=[],e=this;do{t.push(e.right.data),e=e.left}while(e.left);return t.reverse(),t},e.prototype.finish=function(){this.rule.postprocess&&(this.data=this.rule.postprocess(this.data,this.reference,i.fail))},r.prototype.process=function(t){for(var e=this.states,r=this.wants,n=this.completed,o=0;o<e.length;o++){var s=e[o];if(s.isComplete){if(s.finish(),s.data!==i.fail){for(var a=s.wantedBy,l=a.length;l--;)this.complete(a[l],s);s.reference===this.index&&(this.completed[u=s.rule.name]=this.completed[u]||[]).push(s)}}else{var u;if("string"!=typeof(u=s.rule.symbols[s.dot])){this.scannable.push(s);continue}if(r[u]){if(r[u].push(s),n.hasOwnProperty(u)){var c=n[u];for(l=0;l<c.length;l++)this.complete(s,c[l])}}else r[u]=[s],this.predict(u)}}},r.prototype.predict=function(t){for(var r=this.grammar.byName[t]||[],n=0;n<r.length;n++){var o=new e(r[n],0,this.index,this.wants[t]);this.states.push(o)}},r.prototype.complete=function(t,e){var r=t.nextState(e);this.states.push(r)},n.fromCompiled=function(e,r){var o=e.Lexer;e.ParserStart&&(r=e.ParserStart,e=e.ParserRules);var i=new n(e=e.map((function(e){return new t(e.name,e.symbols,e.postprocess)})),r);return i.lexer=o,i},o.prototype.reset=function(t,e){this.buffer=t,this.index=0,this.line=e?e.line:1,this.lastLineBreak=e?-e.col:0},o.prototype.next=function(){if(this.index<this.buffer.length){var t=this.buffer[this.index++];return"\n"===t&&(this.line+=1,this.lastLineBreak=this.index),{value:t}}},o.prototype.save=function(){return{line:this.line,col:this.index-this.lastLineBreak}},o.prototype.formatError=function(t,e){var r=this.buffer;if("string"==typeof r){var n=r.split("\n").slice(Math.max(0,this.line-5),this.line),o=r.indexOf("\n",this.index);-1===o&&(o=r.length);var i=this.index-this.lastLineBreak,s=String(this.line).length;return e+=" at line "+this.line+" col "+i+":\n\n",(e+=n.map((function(t,e){return a(this.line-n.length+e+1,s)+" "+t}),this).join("\n"))+"\n"+a("",s+i)+"^\n"}return e+" at index "+(this.index-1);function a(t,e){var r=String(t);return Array(e-r.length+1).join(" ")+r}},i.fail={},i.prototype.feed=function(t){var e,n=this.lexer;for(n.reset(t,this.lexerState);;){try{if(!(e=n.next()))break}catch(t){var i=new r(this.grammar,this.current+1);throw this.table.push(i),(l=new Error(this.reportLexerError(t))).offset=this.current,l.token=t.token,l}var s=this.table[this.current];this.options.keepHistory||delete this.table[this.current-1];var a=this.current+1;i=new r(this.grammar,a),this.table.push(i);for(var l,u=void 0!==e.text?e.text:e.value,c=n.constructor===o?e.value:e,f=s.scannable,p=f.length;p--;){var h=f[p],m=h.rule.symbols[h.dot];if(m.test?m.test(c):m.type?m.type===e.type:m.literal===u){var y=h.nextState({data:c,token:e,isToken:!0,reference:a-1});i.states.push(y)}}if(i.process(),0===i.states.length)throw(l=new Error(this.reportError(e))).offset=this.current,l.token=e,l;this.options.keepHistory&&(s.lexerState=n.save()),this.current++}return s&&(this.lexerState=n.save()),this.results=this.finish(),this},i.prototype.reportLexerError=function(t){var e,r,n=t.token;return n?(e="input "+JSON.stringify(n.text[0])+" (lexer error)",r=this.lexer.formatError(n,"Syntax error")):(e="input (lexer error)",r=t.message),this.reportErrorCommon(r,e)},i.prototype.reportError=function(t){var e=(t.type?t.type+" token: ":"")+JSON.stringify(void 0!==t.value?t.value:t),r=this.lexer.formatError(t,"Syntax error");return this.reportErrorCommon(r,e)},i.prototype.reportErrorCommon=function(t,e){var r=[];r.push(t);var n=this.table[this.table.length-2],o=n.states.filter((function(t){var e=t.rule.symbols[t.dot];return e&&"string"!=typeof e}));return 0===o.length?(r.push("Unexpected "+e+". I did not expect any more input. Here is the state of my parse table:\n"),this.displayStateStack(n.states,r)):(r.push("Unexpected "+e+". Instead, I was expecting to see one of the following:\n"),o.map((function(t){return this.buildFirstStateStack(t,[])||[t]}),this).forEach((function(t){var e=t[0],n=this.getSymbolDisplay(e.rule.symbols[e.dot]);r.push("A "+n+" based on:"),this.displayStateStack(t,r)}),this)),r.push(""),r.join("\n")},i.prototype.displayStateStack=function(t,e){for(var r,n=0,o=0;o<t.length;o++){var i=t[o],s=i.rule.toString(i.dot);s===r?n++:(n>0&&e.push(" ^ "+n+" more lines identical to this"),n=0,e.push(" "+s)),r=s}},i.prototype.getSymbolDisplay=function(t){return function(t){var e=typeof t;if("string"===e)return t;if("object"===e){if(t.literal)return JSON.stringify(t.literal);if(t instanceof RegExp)return"character matching "+t;if(t.type)return t.type+" token";if(t.test)return"token matching "+String(t.test);throw new Error("Unknown symbol type: "+t)}}(t)},i.prototype.buildFirstStateStack=function(t,e){if(-1!==e.indexOf(t))return null;if(0===t.wantedBy.length)return[t];var r=t.wantedBy[0],n=[t].concat(e),o=this.buildFirstStateStack(r,n);return null===o?null:[t].concat(o)},i.prototype.save=function(){var t=this.table[this.current];return t.lexerState=this.lexerState,t},i.prototype.restore=function(t){var e=t.index;this.current=e,this.table[e]=t,this.table.splice(e+1),this.lexerState=t.lexerState,this.results=this.finish()},i.prototype.rewind=function(t){if(!this.options.keepHistory)throw new Error("set option `keepHistory` to enable rewinding");this.restore(this.table[t])},i.prototype.finish=function(){var t=[],e=this.grammar.start;return this.table[this.table.length-1].states.forEach((function(r){r.rule.name===e&&r.dot===r.rule.symbols.length&&0===r.reference&&r.data!==i.fail&&t.push(r)})),t.map((function(t){return t.data}))},{Parser:i,Grammar:n,Rule:t}},t.exports?t.exports=r():e.nearley=r()}));function ht(){return(ht=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var mt=Q((function(t){var e,r;e=F,r=function(){var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,r="boolean"==typeof(new RegExp).sticky;function n(t){return t&&"[object RegExp]"===e.call(t)}function o(t){return t&&"object"==typeof t&&!n(t)&&!Array.isArray(t)}function i(t){return t.length?"(?:"+t.map((function(t){return"(?:"+t+")"})).join("|")+")":"(?!)"}function s(t){if("string"==typeof t)return"(?:"+t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")+")";if(n(t)){if(t.ignoreCase)throw new Error("RegExp /i flag not allowed");if(t.global)throw new Error("RegExp /g flag is implied");if(t.sticky)throw new Error("RegExp /y flag is implied");if(t.multiline)throw new Error("RegExp /m flag is implied");return t.source}throw new Error("Not a pattern: "+t)}function a(e,r){if(o(r)||(r={match:r}),r.include)throw new Error("Matching rules cannot also include states");var i={defaultType:e,lineBreaks:!!r.error||!!r.fallback,pop:!1,next:null,push:null,error:!1,fallback:!1,value:null,type:null,shouldThrow:!1};for(var s in r)t.call(r,s)&&(i[s]=r[s]);if("string"==typeof i.type&&e!==i.type)throw new Error("Type transform cannot be a string (type '"+i.type+"' for token '"+e+"')");var a=i.match;return i.match=Array.isArray(a)?a:a?[a]:[],i.match.sort((function(t,e){return n(t)&&n(e)?0:n(e)?-1:n(t)?1:e.length-t.length})),i}function l(t){return Array.isArray(t)?function(t){for(var e=[],r=0;r<t.length;r++){var n=t[r];if(n.include)for(var o=[].concat(n.include),i=0;i<o.length;i++)e.push({include:o[i]});else{if(!n.type)throw new Error("Rule has no type: "+JSON.stringify(n));e.push(a(n.type,n))}}return e}(t):function(t){for(var e=Object.getOwnPropertyNames(t),r=[],n=0;n<e.length;n++){var i=e[n],s=[].concat(t[i]);if("include"!==i){var l=[];s.forEach((function(t){o(t)?(l.length&&r.push(a(i,l)),r.push(a(i,t)),l=[]):l.push(t)})),l.length&&r.push(a(i,l))}else for(var u=0;u<s.length;u++)r.push({include:s[u]})}return r}(t)}var u=a("error",{lineBreaks:!0,shouldThrow:!0});function c(t,e){for(var o=null,a=Object.create(null),l=!0,c=null,f=[],p=[],h=0;h<t.length;h++)t[h].fallback&&(l=!1);for(h=0;h<t.length;h++){var m=t[h];if(m.include)throw new Error("Inheritance is not allowed in stateless lexers");if(m.error||m.fallback){if(o)throw!m.fallback==!o.fallback?new Error("Multiple "+(m.fallback?"fallback":"error")+" rules not allowed (for token '"+m.defaultType+"')"):new Error("fallback and error are mutually exclusive (for token '"+m.defaultType+"')");o=m}var y=m.match.slice();if(l)for(;y.length&&"string"==typeof y[0]&&1===y[0].length;)a[y.shift().charCodeAt(0)]=m;if(m.pop||m.push||m.next){if(!e)throw new Error("State-switching options are not allowed in stateless lexers (for token '"+m.defaultType+"')");if(m.fallback)throw new Error("State-switching options are not allowed on fallback tokens (for token '"+m.defaultType+"')")}if(0!==y.length){l=!1,f.push(m);for(var d=0;d<y.length;d++){var b=y[d];if(n(b))if(null===c)c=b.unicode;else if(c!==b.unicode&&!1===m.fallback)throw new Error("If one rule is /u then all must be")}var g=i(y.map(s)),v=new RegExp(g);if(v.test(""))throw new Error("RegExp matches empty string: "+v);if(new RegExp("|"+g).exec("").length-1>0)throw new Error("RegExp has capture groups: "+v+"\nUse (?: … ) instead");if(!m.lineBreaks&&v.test("\n"))throw new Error("Rule should declare lineBreaks: "+v);p.push("("+g+")")}}var w=o&&o.fallback,x=r&&!w?"ym":"gm",S=r||w?"":"|";return!0===c&&(x+="u"),{regexp:new RegExp(i(p)+S,x),groups:f,fast:a,error:o||u}}function f(t,e,r){var n=t&&(t.push||t.next);if(n&&!r[n])throw new Error("Missing state '"+n+"' (in token '"+t.defaultType+"' of state '"+e+"')");if(t&&t.pop&&1!=+t.pop)throw new Error("pop must be 1 (in token '"+t.defaultType+"' of state '"+e+"')")}var p=function(t,e){this.startState=e,this.states=t,this.buffer="",this.stack=[],this.reset()};p.prototype.reset=function(t,e){return this.buffer=t||"",this.index=0,this.line=e?e.line:1,this.col=e?e.col:1,this.queuedToken=e?e.queuedToken:null,this.queuedThrow=e?e.queuedThrow:null,this.setState(e?e.state:this.startState),this.stack=e&&e.stack?e.stack.slice():[],this},p.prototype.save=function(){return{line:this.line,col:this.col,state:this.state,stack:this.stack.slice(),queuedToken:this.queuedToken,queuedThrow:this.queuedThrow}},p.prototype.setState=function(t){if(t&&this.state!==t){this.state=t;var e=this.states[t];this.groups=e.groups,this.error=e.error,this.re=e.regexp,this.fast=e.fast}},p.prototype.popState=function(){this.setState(this.stack.pop())},p.prototype.pushState=function(t){this.stack.push(this.state),this.setState(t)};var h=r?function(t,e){return t.exec(e)}:function(t,e){var r=t.exec(e);return 0===r[0].length?null:r};function m(){return this.value}if(p.prototype._getGroup=function(t){for(var e=this.groups.length,r=0;r<e;r++)if(void 0!==t[r+1])return this.groups[r];throw new Error("Cannot find token type for matched text")},p.prototype.next=function(){var t=this.index;if(this.queuedGroup){var e=this._token(this.queuedGroup,this.queuedText,t);return this.queuedGroup=null,this.queuedText="",e}var r=this.buffer;if(t!==r.length){if(s=this.fast[r.charCodeAt(t)])return this._token(s,r.charAt(t),t);var n=this.re;n.lastIndex=t;var o=h(n,r),i=this.error;if(null==o)return this._token(i,r.slice(t,r.length),t);var s=this._getGroup(o),a=o[0];return i.fallback&&o.index!==t?(this.queuedGroup=s,this.queuedText=a,this._token(i,r.slice(t,o.index),t)):this._token(s,a,t)}},p.prototype._token=function(t,e,r){var n=0;if(t.lineBreaks){var o=/\n/g,i=1;if("\n"===e)n=1;else for(;o.exec(e);)n++,i=o.lastIndex}var s={type:"function"==typeof t.type&&t.type(e)||t.defaultType,value:"function"==typeof t.value?t.value(e):e,text:e,toString:m,offset:r,lineBreaks:n,line:this.line,col:this.col},a=e.length;if(this.index+=a,this.line+=n,0!==n?this.col=a-i+1:this.col+=a,t.shouldThrow)throw new Error(this.formatError(s,"invalid syntax"));return t.pop?this.popState():t.push?this.pushState(t.push):t.next&&this.setState(t.next),s},"undefined"!=typeof Symbol&&Symbol.iterator){var y=function(t){this.lexer=t};y.prototype.next=function(){var t=this.lexer.next();return{value:t,done:!t}},y.prototype[Symbol.iterator]=function(){return this},p.prototype[Symbol.iterator]=function(){return new y(this)}}return p.prototype.formatError=function(t,e){if(null==t){var r=this.buffer.slice(this.index);t={text:r,offset:this.index,lineBreaks:-1===r.indexOf("\n")?0:1,line:this.line,col:this.col}}var n=Math.max(0,t.offset-t.col+1),o=t.lineBreaks?t.text.indexOf("\n"):t.text.length,i=this.buffer.substring(n,t.offset+o);return e+=" at line "+t.line+" col "+t.col+":\n\n",(e+=" "+i+"\n")+" "+Array(t.col).join(" ")+"^"},p.prototype.clone=function(){return new p(this.states,this.state)},p.prototype.has=function(t){return!0},{compile:function(t){var e=c(l(t));return new p({start:e},"start")},states:function(t,e){var r=t.$all?l(t.$all):[];delete t.$all;var n=Object.getOwnPropertyNames(t);e||(e=n[0]);for(var o=Object.create(null),i=0;i<n.length;i++)o[v=n[i]]=l(t[v]).concat(r);for(i=0;i<n.length;i++)for(var s=o[v=n[i]],a=Object.create(null),u=0;u<s.length;u++){var h=s[u];if(h.include){var m=[u,1];if(h.include!==v&&!a[h.include]){a[h.include]=!0;var y=o[h.include];if(!y)throw new Error("Cannot include nonexistent state '"+h.include+"' (in state '"+v+"')");for(var d=0;d<y.length;d++){var b=y[d];-1===s.indexOf(b)&&m.push(b)}}s.splice.apply(s,m),u--}}var g=Object.create(null);for(i=0;i<n.length;i++){var v;g[v=n[i]]=c(o[v],!0)}for(i=0;i<n.length;i++){var w=n[i],x=g[w],S=x.groups;for(u=0;u<S.length;u++)f(S[u],w,g);var k=Object.getOwnPropertyNames(x.fast);for(u=0;u<k.length;u++)f(x.fast[k[u]],w,g)}return new p(g,e)},error:Object.freeze({error:!0}),fallback:Object.freeze({fallback:!0}),keywords:function(t){for(var e=Object.create(null),r=Object.create(null),n=Object.getOwnPropertyNames(t),o=0;o<n.length;o++){var i=n[o],s=t[i];(Array.isArray(s)?s:[s]).forEach((function(t){if((r[t.length]=r[t.length]||[]).push(t),"string"!=typeof t)throw new Error("keyword must be string (in keyword '"+i+"')");e[t]=i}))}function a(t){return JSON.stringify(t)}var l="";for(var u in l+="switch (value.length) {\n",r)l+="case "+u+":\n",l+="switch (value) {\n",r[u].forEach((function(t){var r=e[t];l+="case "+a(t)+": return "+a(r)+"\n"})),l+="}\n";return l+="}\n",Function("value",l)}}},t.exports?t.exports=r():e.moo=r()})),yt=/[0-9a-zA-Z_@]+\b@*/,dt=new RegExp("^"+yt.source+"$"),bt={__proto__:null,boolean:/true|false|TRUE|FALSE\b(?!@)/,hexadecimal:/-?0x(?:[0-9a-fA-F]+)\b(?!@)/,octal:/-?0(?:[0-7]+)\b(?!@)/,measurement:/-?(?:[0-9]|[1-9][0-9]+)(?:\.[0-9]+)?[a-zA-Z]+\b(?!@)/,decimal:/-?(?:[0-9]|[1-9][0-9]+)\.[0-9]+(?:[eE][-+]?[0-9]+)?\b(?!@)/,integer:/-?(?:[0-9]|[1-9][0-9]+)(?:[eE][-+]?[0-9]+)?\b(?!@)/,taggedString:/[a-zA-Z][0-9a-zA-Z_@]*`(?:\\[`bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^`\\])*`/,doubleQuotedString:/"(?:\\["bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*"/,singleQuotedString:/'(?:\\['bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^'\\])*'/,tickedString:/`(?:\\[`bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^`\\])*`/,symbol:/[a-zA-Z_][0-9a-zA-Z_]*\b(?!@)/,identifier:yt,isValidIdentifier:function(t){return t&&dt.test(t)}},gt=function(t){return!!t.type&&"path"===t.type},vt=function(t){return gt(t)&&"ø"===t.id},wt=function(t){return gt(t)&&t.children&&0===t.children.length&&"ø"!==t.id};function xt(){return(xt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function St(t){return Array.isArray(t)?t:t instanceof Function?St(t()):void 0===t?[]:[t]}var kt=function(t,e){void 0===e&&(e={});var r=xt({type:"path"},e.id&&{id:e.id},e.labels&&{labels:e.labels},e.record&&{record:e.record});if(void 0===t)return r.id&&"ø"!==r.id?(r.children=[],r):(r.children=void 0,$t);if(0===t.length)return"ø"===r.id?$t:(r.children=[],r);if(1===t.length){var n=t[0];return vt(n)?(r.children=[],r):(r.children=[n],r)}if(2===t.length){if(e.kind&&"pair"!==e.kind&&wt(t[0])&&wt(t[1]))return r.kind=e.kind,r.children=[t[0],t[1]],r;if(vt(t[0])&&vt(t[1]))return r.kind=e.kind,r.children=[],r;r.children=[t[0],t[1]]}return r.kind=e.kind||"pair",r},$t={type:"path",id:"ø",labels:void 0,record:void 0,children:[]},Et=function(t,e,r){return xt({type:"path"},t&&{id:t},e&&{labels:e},r&&{record:r},{children:[]})},Pt=function(t){return{type:"string",value:t}};function At(t){return t[0]}var _t=mt.compile({whitespace:{match:/\s+/,lineBreaks:!0},lineComment:{match:/\/\/.*?\n?$/},hexadecimal:bt.hexadecimal,octal:bt.octal,measurement:bt.measurement,decimal:bt.decimal,integer:bt.integer,taggedString:{match:bt.taggedString},boolean:["true","TRUE","True","false","FALSE","False"],symbol:bt.symbol,identifier:bt.identifier,doubleQuotedString:{match:bt.doubleQuotedString,value:function(t){return t.slice(1,-1)}},singleQuotedString:{match:bt.singleQuotedString,value:function(t){return t.slice(1,-1)}},tickedString:{match:bt.tickedString,value:function(t){return t.slice(1,-1)}},"--\x3e":"--\x3e","--":"--","<--":"<--","-[]->":"-[]->","-[]-":"-[]-","<-[]-":"<-[]-","<-[":"<-[","]->":"]->","-[":"-[","]-":"]-","{":"{","}":"}","[":"[","]":"]","(":"(",")":")",",":",",":":":","`":"`","'":"'","ø":"ø"}),Ot=function(){return null},jt=function(t){return t[0].text},Lt={Lexer:_t,ParserRules:[{name:"GramSeq$ebnf$1$subexpression$1",symbols:["Path","_"],postprocess:function(t){return t[0]}},{name:"GramSeq$ebnf$1",symbols:["GramSeq$ebnf$1$subexpression$1"]},{name:"GramSeq$ebnf$1$subexpression$2",symbols:["Path","_"],postprocess:function(t){return t[0]}},{name:"GramSeq$ebnf$1",symbols:["GramSeq$ebnf$1","GramSeq$ebnf$1$subexpression$2"],postprocess:function(t){return t[0].concat([t[1]])}},{name:"GramSeq$ebnf$2",symbols:["EOL"],postprocess:At},{name:"GramSeq$ebnf$2",symbols:[],postprocess:function(){return null}},{name:"GramSeq",symbols:["GramSeq$ebnf$1","GramSeq$ebnf$2"],postprocess:function(t){var e;return void 0===e&&(e=1),xt({type:"seq",id:void 0},void 0,void 0,{children:St(t[0].flat(e).filter((function(t){return null!==t})))})}},{name:"Path",symbols:["NodePattern"],postprocess:At},{name:"Path",symbols:["PathComposition"],postprocess:At},{name:"Path",symbols:["PathPair"],postprocess:At},{name:"NodePattern",symbols:["Node","_","Edge","_","NodePattern"],postprocess:function(t){var e=t[2];return kt([t[0],t[4]],{kind:e.kind,id:e.id,labels:e.labels,record:e.record})}},{name:"NodePattern",symbols:["Node"],postprocess:At},{name:"Node",symbols:[{literal:"("},"_","Attributes","_",{literal:")"}],postprocess:function(t){var e=t[2];return Et(e.id,e.labels,e.record)}},{name:"Edge",symbols:[{literal:"-["},"_","Attributes",{literal:"]->"}],postprocess:function(t){return ht({kind:"right"},t[2])}},{name:"Edge",symbols:[{literal:"-["},"_","Attributes",{literal:"]-"}],postprocess:function(t){return ht({kind:"either"},t[2])}},{name:"Edge",symbols:[{literal:"<-["},"_","Attributes",{literal:"]-"}],postprocess:function(t){return ht({kind:"left"},t[2])}},{name:"Edge",symbols:[{literal:"-[]->"}],postprocess:function(){return{kind:"right"}}},{name:"Edge",symbols:[{literal:"-[]-"}],postprocess:function(){return{kind:"either"}}},{name:"Edge",symbols:[{literal:"<-[]-"}],postprocess:function(){return{kind:"left"}}},{name:"Edge",symbols:[{literal:"--\x3e"}],postprocess:function(){return{kind:"right"}}},{name:"Edge",symbols:[{literal:"--"}],postprocess:function(){return{kind:"either"}}},{name:"Edge",symbols:[{literal:"<--"}],postprocess:function(){return{kind:"left"}}},{name:"PathComposition",symbols:["PathPoint"],postprocess:At},{name:"PathComposition",symbols:["PathAnnotation"],postprocess:At},{name:"PathComposition",symbols:["PathExpression"],postprocess:At},{name:"PathPoint",symbols:[{literal:"["},"_","Attributes","_",{literal:"]"}],postprocess:function(t){var e=t[2];return(e.id||e.labels||e.record)&&"ø"!==e.id?Et(e.id,e.labels,e.record):$t}},{name:"PathAnnotation",symbols:[{literal:"["},"_","Attributes","_","Path",{literal:"]"}],postprocess:function(t){var e=t[2];return kt([t[4]],{id:e.id,labels:e.labels,record:e.record})}},{name:"PathExpression$ebnf$1",symbols:["Kind"],postprocess:At},{name:"PathExpression$ebnf$1",symbols:[],postprocess:function(){return null}},{name:"PathExpression",symbols:[{literal:"["},"_","Attributes","_","PathExpression$ebnf$1","_","Path","_","Path","_",{literal:"]"}],postprocess:function(t){var e=t[2];return kt([t[6],t[8]],{kind:t[4],id:e.id,labels:e.labels,record:e.record})}},{name:"PathPair$subexpression$1",symbols:["NodePattern"]},{name:"PathPair$subexpression$1",symbols:["PathComposition"]},{name:"PathPair",symbols:["PathPair$subexpression$1","_",{literal:","},"_","Path"],postprocess:function(t){return function(t,e,r,n,o){return xt({type:"path",kind:"pair",id:void 0},void 0,void 0,{children:e})}(0,[t[0][0],t[4]])}},{name:"Kind",symbols:[{literal:","}],postprocess:function(){return"pair"}},{name:"Kind",symbols:[{literal:"--\x3e"}],postprocess:function(){return"right"}},{name:"Kind",symbols:[{literal:"--"}],postprocess:function(){return"either"}},{name:"Kind",symbols:[{literal:"<--"}],postprocess:function(){return"left"}},{name:"Attributes$ebnf$1",symbols:["Identity"],postprocess:At},{name:"Attributes$ebnf$1",symbols:[],postprocess:function(){return null}},{name:"Attributes$ebnf$2$subexpression$1",symbols:["_","LabelList"],postprocess:function(t){return t[1]}},{name:"Attributes$ebnf$2",symbols:["Attributes$ebnf$2$subexpression$1"],postprocess:At},{name:"Attributes$ebnf$2",symbols:[],postprocess:function(){return null}},{name:"Attributes$ebnf$3$subexpression$1",symbols:["_","Record"],postprocess:function(t){return t[1]}},{name:"Attributes$ebnf$3",symbols:["Attributes$ebnf$3$subexpression$1"],postprocess:At},{name:"Attributes$ebnf$3",symbols:[],postprocess:function(){return null}},{name:"Attributes",symbols:["Attributes$ebnf$1","Attributes$ebnf$2","Attributes$ebnf$3"],postprocess:function(t){return{id:t[0],labels:t[1],record:t[2]}}},{name:"LabelList$ebnf$1",symbols:["Label"]},{name:"LabelList$ebnf$1",symbols:["LabelList$ebnf$1","Label"],postprocess:function(t){return t[0].concat([t[1]])}},{name:"LabelList",symbols:["LabelList$ebnf$1"],postprocess:function(t){return t[0]}},{name:"Label",symbols:[{literal:":"},"Symbol"],postprocess:function(t){return t[1]}},{name:"Identity",symbols:[_t.has("identifier")?{type:"identifier"}:identifier],postprocess:jt},{name:"Identity",symbols:[{literal:"ø"}],postprocess:jt},{name:"Identity",symbols:[_t.has("symbol")?{type:"symbol"}:symbol],postprocess:jt},{name:"Identity",symbols:[_t.has("integer")?{type:"integer"}:integer],postprocess:jt},{name:"Identity",symbols:[_t.has("octal")?{type:"octal"}:octal],postprocess:jt},{name:"Identity",symbols:[_t.has("hexadecimal")?{type:"hexadecimal"}:hexadecimal],postprocess:jt},{name:"Identity",symbols:[_t.has("measurement")?{type:"measurement"}:measurement],postprocess:jt},{name:"Identity",symbols:[_t.has("tickedString")?{type:"tickedString"}:tickedString],postprocess:function(t){return t[0].text.slice(1,-1)}},{name:"Symbol",symbols:[_t.has("symbol")?{type:"symbol"}:symbol],postprocess:jt},{name:"Symbol",symbols:[_t.has("tickedString")?{type:"tickedString"}:tickedString],postprocess:function(t){return t[0].text.slice(1,-1)}},{name:"Record",symbols:[{literal:"{"},"_",{literal:"}"}],postprocess:Ot},{name:"Record$ebnf$1",symbols:[]},{name:"Record$ebnf$1$subexpression$1",symbols:["_",{literal:","},"_","Property"]},{name:"Record$ebnf$1",symbols:["Record$ebnf$1","Record$ebnf$1$subexpression$1"],postprocess:function(t){return t[0].concat([t[1]])}},{name:"Record",symbols:[{literal:"{"},"_","Property","Record$ebnf$1","_",{literal:"}"}],postprocess:function(t){return[t[2]].concat(t[3].map((function(t){return t[3]})))}},{name:"Property",symbols:["Symbol","_",{literal:":"},"_","Value"],postprocess:function(t){return{type:"property",name:t[0],value:t[4]}}},{name:"Value",symbols:["StringLiteral"],postprocess:At},{name:"Value",symbols:["NumericLiteral"],postprocess:At},{name:"Value",symbols:[_t.has("boolean")?{type:"boolean"}:boolean],postprocess:function(t){return{type:"boolean",value:JSON.parse(t[0].value.toLowerCase())?"true":"false"}}},{name:"Value$ebnf$1",symbols:[]},{name:"Value$ebnf$1$subexpression$1",symbols:["_",{literal:","},"_","Value"]},{name:"Value$ebnf$1",symbols:["Value$ebnf$1","Value$ebnf$1$subexpression$1"],postprocess:function(t){return t[0].concat([t[1]])}},{name:"Value",symbols:[{literal:"["},"_","Value","Value$ebnf$1",{literal:"]"}],postprocess:function(t){return[t[2]].concat(t[3].map((function(t){return t[3]})))}},{name:"StringLiteral",symbols:[_t.has("singleQuotedString")?{type:"singleQuotedString"}:singleQuotedString],postprocess:function(t){return Pt(t[0].value)}},{name:"StringLiteral",symbols:[_t.has("doubleQuotedString")?{type:"doubleQuotedString"}:doubleQuotedString],postprocess:function(t){return Pt(t[0].value)}},{name:"StringLiteral",symbols:[_t.has("tickedString")?{type:"tickedString"}:tickedString],postprocess:function(t){return Pt(t[0].value)}},{name:"StringLiteral",symbols:[_t.has("taggedString")?{type:"taggedString"}:taggedString],postprocess:function(t){var e=function(t){var e=t.match(/([^`]+)`(.+)`$/);if(null==e)throw Error("Malformed tagged string: "+t);return{tag:e[1],value:e[2]}}(t[0].value);return{type:"tagged",value:e.value,tag:e.tag}}},{name:"NumericLiteral",symbols:[_t.has("integer")?{type:"integer"}:integer],postprocess:function(t){return{type:"integer",value:String(t[0].value)}}},{name:"NumericLiteral",symbols:[_t.has("decimal")?{type:"decimal"}:decimal],postprocess:function(t){return{type:"decimal",value:String(t[0].value)}}},{name:"NumericLiteral",symbols:[_t.has("hexadecimal")?{type:"hexadecimal"}:hexadecimal],postprocess:function(t){return{type:"hexadecimal",value:"number"==typeof(e=t[0].value)?e.toString(16):e};var e}},{name:"NumericLiteral",symbols:[_t.has("octal")?{type:"octal"}:octal],postprocess:function(t){return{type:"octal",value:"number"==typeof(e=t[0].value)?e.toString(8):e};var e}},{name:"NumericLiteral",symbols:[_t.has("measurement")?{type:"measurement"}:measurement],postprocess:function(t){var e,r=function(t){var e=t.match(/(-?[0-9.]+)([a-zA-Z]+)/);if(null==e)throw Error("Malformed measurement : "+t);return{value:e[1],unit:e[2]}}(t[0].value);return e=r.unit,{type:"measurement",value:String(r.value),unit:e}}},{name:"_",symbols:[]},{name:"_",symbols:[_t.has("whitespace")?{type:"whitespace"}:whitespace],postprocess:Ot},{name:"Comment",symbols:[_t.has("lineComment")?{type:"lineComment"}:lineComment],postprocess:Ot},{name:"EOL",symbols:[{literal:"\n"}],postprocess:Ot}],ParserStart:"GramSeq"},Tt=function(t,e){var r,n,o=new pt.Parser(pt.Grammar.fromCompiled(Lt));try{var i=o.feed(t);if(void 0===i.results[0]&&i.lexerState){var s={line:(n=i.lexerState).line,column:n.col};e.fail("Incomplete parse.",s)}return i.results.length>1&&e.info("[WARN] parsing is ambiguous"),i.results[0]||{type:"error"}}catch(t){var a=t.token?{line:(r=t.token).line,column:r.col}:{line:0,column:0};e.fail(t.message,a)}},Rt=function(){this.Parser=Tt};t.errors={__proto__:null,INCOMPLETE_PARSE:"Incomplete parse.",SYNTAX_ERROR:"Syntax error at"},t.gramParserPlugin=Rt,t.toAST=function(t){return rt().use(Rt).freeze().parse(t)},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t=t||self).gram=t.gram||{},t.gram.parse={}))}(this,(function(t){"use strict";var e=function(t){if(t)throw t},r=function(t){return null!=t&&null!=t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},n=Object.prototype.hasOwnProperty,o=Object.prototype.toString,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===o.call(t)},l=function(t){if(!t||"[object Object]"!==o.call(t))return!1;var e,r=n.call(t,"constructor"),i=t.constructor&&t.constructor.prototype&&n.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!i)return!1;for(e in t);return void 0===e||n.call(t,e)},u=function(t,e){i&&"__proto__"===e.name?i(t,e.name,{enumerable:!0,configurable:!0,value:e.newValue,writable:!0}):t[e.name]=e.newValue},c=function(t,e){if("__proto__"===e){if(!n.call(t,e))return;if(s)return s(t,e).value}return t[e]},f=function t(){var e,r,n,o,i,s,f=arguments[0],p=1,h=arguments.length,m=!1;for("boolean"==typeof f&&(m=f,f=arguments[1]||{},p=2),(null==f||"object"!=typeof f&&"function"!=typeof f)&&(f={});p<h;++p)if(null!=(e=arguments[p]))for(r in e)n=c(f,r),f!==(o=c(e,r))&&(m&&o&&(l(o)||(i=a(o)))?(i?(i=!1,s=n&&a(n)?n:[]):s=n&&l(n)?n:{},u(f,{name:r,newValue:t(m,s,o)})):void 0!==o&&u(f,{name:r,newValue:o}));return f},p=t=>{if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype},h=[].slice,m=function(t,e){var r;return function(){var e,i=h.call(arguments,0),s=t.length>i.length;s&&i.push(n);try{e=t.apply(null,i)}catch(t){if(s&&r)throw t;return n(t)}s||(e&&"function"==typeof e.then?e.then(o,n):e instanceof Error?n(e):o(e))};function n(){r||(r=!0,e.apply(null,arguments))}function o(t){n(null,t)}},y=b;b.wrap=m;var d=[].slice;function b(){var t=[],e={run:function(){var e=-1,r=d.call(arguments,0,-1),n=arguments[arguments.length-1];if("function"!=typeof n)throw new Error("Expected function as last argument, not "+n);function o(i){var s=t[++e],a=d.call(arguments,0),l=a.slice(1),u=r.length,c=-1;if(i)n(i);else{for(;++c<u;)null==l[c]&&(l[c]=r[c]);r=l,s?m(s,o).apply(null,r):n.apply(null,[null].concat(r))}}o.apply(null,[null].concat(r))},use:function(r){if("function"!=typeof r)throw new Error("Expected `fn` to be a function, not "+r);return t.push(r),e}};return e}var g={}.hasOwnProperty,v=function(t){return t&&"object"==typeof t?g.call(t,"position")||g.call(t,"type")?x(t.position):g.call(t,"start")||g.call(t,"end")?x(t):g.call(t,"line")||g.call(t,"column")?w(t):"":""};function w(t){return t&&"object"==typeof t||(t={}),S(t.line)+":"+S(t.column)}function x(t){return t&&"object"==typeof t||(t={}),w(t.start)+"-"+w(t.end)}function S(t){return t&&"number"==typeof t?t:1}var k=P;function $(){}$.prototype=Error.prototype;var E=P.prototype=new $;function P(t,e,r){var n,o,i;"string"==typeof e&&(r=e,e=null),n=function(t){var e,r=[null,null];return"string"==typeof t&&(-1===(e=t.indexOf(":"))?r[1]=t:(r[0]=t.slice(0,e),r[1]=t.slice(e+1))),r}(r),o=v(e)||"1:1",i={start:{line:null,column:null},end:{line:null,column:null}},e&&e.position&&(e=e.position),e&&(e.start?(i=e,e=e.start):i.start=e),t.stack&&(this.stack=t.stack,t=t.message),this.message=t,this.name=o,this.reason=t,this.line=e?e.line:null,this.column=e?e.column:null,this.location=i,this.source=n[0],this.ruleId=n[1]}function A(t){var e,r;return O(t),e=47===t.charCodeAt(0),(r=function(t,e){for(var r,n,o="",i=0,s=-1,a=0,l=-1;++l<=t.length;){if(l<t.length)r=t.charCodeAt(l);else{if(47===r)break;r=47}if(47===r){if(s===l-1||1===a);else if(s!==l-1&&2===a){if(o.length<2||2!==i||46!==o.charCodeAt(o.length-1)||46!==o.charCodeAt(o.length-2))if(o.length>2){if((n=o.lastIndexOf("/"))!==o.length-1){n<0?(o="",i=0):i=(o=o.slice(0,n)).length-1-o.lastIndexOf("/"),s=l,a=0;continue}}else if(o.length){o="",i=0,s=l,a=0;continue}e&&(o=o.length?o+"/..":"..",i=2)}else o.length?o+="/"+t.slice(s+1,l):o=t.slice(s+1,l),i=l-s-1;s=l,a=0}else 46===r&&a>-1?a++:a=-1}return o}(t,!e)).length||e||(r="."),r.length&&47===t.charCodeAt(t.length-1)&&(r+="/"),e?"/"+r:r}function O(t){if("string"!=typeof t)throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}E.file="",E.name="",E.reason="",E.message="",E.stack="",E.fatal=null,E.column=null,E.line=null;var _=function(t,e){var r,n,o,i,s=0,a=-1;if(void 0!==e&&"string"!=typeof e)throw new TypeError('"ext" argument must be a string');if(O(t),r=t.length,void 0===e||!e.length||e.length>t.length){for(;r--;)if(47===t.charCodeAt(r)){if(o){s=r+1;break}}else a<0&&(o=!0,a=r+1);return a<0?"":t.slice(s,a)}if(e===t)return"";for(n=-1,i=e.length-1;r--;)if(47===t.charCodeAt(r)){if(o){s=r+1;break}}else n<0&&(o=!0,n=r+1),i>-1&&(t.charCodeAt(r)===e.charCodeAt(i--)?i<0&&(a=r):(i=-1,a=n));return s===a?a=n:a<0&&(a=t.length),t.slice(s,a)},j=function(){for(var t,e=-1;++e<arguments.length;)O(arguments[e]),arguments[e]&&(t=void 0===t?arguments[e]:t+"/"+arguments[e]);return void 0===t?".":A(t)},C=T,L={}.hasOwnProperty,R=["history","path","basename","stem","extname","dirname"];function T(t){var e,n;if(t){if("string"==typeof t||r(t))t={contents:t};else if("message"in t&&"messages"in t)return t}else t={};if(!(this instanceof T))return new T(t);for(this.data={},this.messages=[],this.history=[],this.cwd="/",n=-1;++n<R.length;)L.call(t,e=R[n])&&(this[e]=t[e]);for(e in t)R.indexOf(e)<0&&(this[e]=t[e])}function N(t,e){if(t&&t.indexOf("/")>-1)throw new Error("`"+e+"` cannot be a path: did not expect `/`")}function q(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function I(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}T.prototype.toString=function(t){return(this.contents||"").toString(t)},Object.defineProperty(T.prototype,"path",{get:function(){return this.history[this.history.length-1]},set:function(t){q(t,"path"),this.path!==t&&this.history.push(t)}}),Object.defineProperty(T.prototype,"dirname",{get:function(){return"string"==typeof this.path?function(t){var e,r,n;if(O(t),!t.length)return".";for(e=-1,n=t.length;--n;)if(47===t.charCodeAt(n)){if(r){e=n;break}}else r||(r=!0);return e<0?47===t.charCodeAt(0)?"/":".":1===e&&47===t.charCodeAt(0)?"//":t.slice(0,e)}(this.path):void 0},set:function(t){I(this.path,"dirname"),this.path=j(t||"",this.basename)}}),Object.defineProperty(T.prototype,"basename",{get:function(){return"string"==typeof this.path?_(this.path):void 0},set:function(t){q(t,"basename"),N(t,"basename"),this.path=j(this.dirname||"",t)}}),Object.defineProperty(T.prototype,"extname",{get:function(){return"string"==typeof this.path?function(t){var e,r,n,o=-1,i=0,s=-1,a=0;for(O(t),n=t.length;n--;)if(47!==(r=t.charCodeAt(n)))s<0&&(e=!0,s=n+1),46===r?o<0?o=n:1!==a&&(a=1):o>-1&&(a=-1);else if(e){i=n+1;break}return o<0||s<0||0===a||1===a&&o===s-1&&o===i+1?"":t.slice(o,s)}(this.path):void 0},set:function(t){if(N(t,"extname"),I(this.path,"extname"),t){if(46!==t.charCodeAt(0))throw new Error("`extname` must start with `.`");if(t.indexOf(".",1)>-1)throw new Error("`extname` cannot contain multiple dots")}this.path=j(this.dirname,this.stem+(t||""))}}),Object.defineProperty(T.prototype,"stem",{get:function(){return"string"==typeof this.path?_(this.path,this.extname):void 0},set:function(t){q(t,"stem"),N(t,"stem"),this.path=j(this.dirname||"",t+(this.extname||""))}});var G=C;C.prototype.message=function(t,e,r){var n=new k(t,e,r);return this.path&&(n.name=this.path+":"+n.name,n.file=this.path),n.fatal=!1,this.messages.push(n),n},C.prototype.info=function(){var t=this.message.apply(this,arguments);return t.fatal=null,t},C.prototype.fail=function(){var t=this.message.apply(this,arguments);throw t.fatal=!0,t};var B=G,V=function t(){var r=[],n=y(),o={},i=!1,s=-1;return a.data=function(t,e){return"string"==typeof t?2===arguments.length?(Z("data",i),o[t]=e,a):F.call(o,t)&&o[t]||null:t?(Z("data",i),o=t,a):o},a.freeze=l,a.attachers=r,a.use=function(t){var e;if(Z("use",i),null==t);else if("function"==typeof t)c.apply(null,arguments);else{if("object"!=typeof t)throw new Error("Expected usable value, not `"+t+"`");"length"in t?l(t):n(t)}return e&&(o.settings=f(o.settings||{},e)),a;function n(t){l(t.plugins),t.settings&&(e=f(e||{},t.settings))}function s(t){if("function"==typeof t)c(t);else{if("object"!=typeof t)throw new Error("Expected usable value, not `"+t+"`");"length"in t?c.apply(null,t):n(t)}}function l(t){var e,r;if(null==t);else{if("object"!=typeof t||!("length"in t))throw new Error("Expected a list of plugins, not `"+t+"`");for(e=t.length,r=-1;++r<e;)s(t[r])}}function c(t,e){var n=u(t);n?(p(n[1])&&p(e)&&(e=f(n[1],e)),n[1]=e):r.push(z.call(arguments))}},a.parse=function(t){var e,r=B(t);return l(),J("parse",e=a.Parser),M(e,"parse")?new e(String(r),r).parse():e(String(r),r)},a.stringify=function(t,e){var r,n=B(e);return l(),U("stringify",r=a.Compiler),H(t),M(r,"compile")?new r(t,n).compile():r(t,n)},a.run=c,a.runSync=function(t,r){var n,o=!1;return c(t,r,(function(t,r){o=!0,e(t),n=r})),K("runSync","run",o),n},a.process=h,a.processSync=function(t){var r,n=!1;return l(),J("processSync",a.Parser),U("processSync",a.Compiler),h(r=B(t),(function(t){n=!0,e(t)})),K("processSync","process",n),r},a;function a(){for(var e=t(),n=r.length,i=-1;++i<n;)e.use.apply(null,r[i]);return e.data(f(!0,{},o)),e}function l(){var t,e,o,l;if(i)return a;for(;++s<r.length;)e=(t=r[s])[0],!1!==(o=t[1])&&(!0===o&&(t[1]=void 0),"function"==typeof(l=e.apply(a,t.slice(1)))&&n.use(l));return i=!0,s=Infinity,a}function u(t){for(var e,n=r.length,o=-1;++o<n;)if((e=r[o])[0]===t)return e}function c(t,e,r){if(H(t),l(),r||"function"!=typeof e||(r=e,e=null),!r)return new Promise(o);function o(o,i){n.run(t,B(e),(function(e,n,s){n=n||t,e?i(e):o?o(n):r(null,n,s)}))}o(null,r)}function h(t,e){if(l(),J("process",a.Parser),U("process",a.Compiler),!e)return new Promise(r);function r(r,n){var o=B(t);Q.run(a,{file:o},(function(t){t?n(t):r?r(o):e(null,o)}))}r(null,e)}}().freeze(),z=[].slice,F={}.hasOwnProperty,Q=y().use((function(t,e){e.tree=t.parse(e.file)})).use((function(t,e,r){t.run(e.tree,e.file,(function(t,n,o){t?r(t):(e.tree=n,e.file=o,r())}))})).use((function(t,e){var n=t.stringify(e.tree,e.file),o=e.file;null==n||("string"==typeof n||r(n)?o.contents=n:o.result=n)}));function M(t,e){return"function"==typeof t&&t.prototype&&(function(t){var e;for(e in t)return!0;return!1}(t.prototype)||e in t.prototype)}function J(t,e){if("function"!=typeof e)throw new Error("Cannot `"+t+"` without `Parser`")}function U(t,e){if("function"!=typeof e)throw new Error("Cannot `"+t+"` without `Compiler`")}function Z(t,e){if(e)throw new Error("Cannot invoke `"+t+"` on a frozen processor.\nCreate a new processor first, by invoking it: use `processor()` instead of `processor`.")}function H(t){if(!t||"string"!=typeof t.type)throw new Error("Expected node, got `"+t+"`")}function K(t,e,r){if(!r)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}var D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function W(t,e){return t(e={exports:{}},e.exports),e.exports}var X=W((function(t){var e,r;e=D,r=function(){function t(e,r,n){return this.id=++t.highestId,this.name=e,this.symbols=r,this.postprocess=n,this}function e(t,e,r,n){this.rule=t,this.dot=e,this.reference=r,this.data=[],this.wantedBy=n,this.isComplete=this.dot===t.symbols.length}function r(t,e){this.grammar=t,this.index=e,this.states=[],this.wants={},this.scannable=[],this.completed={}}function n(t,e){this.rules=t,this.start=e||this.rules[0].name;var r=this.byName={};this.rules.forEach((function(t){r.hasOwnProperty(t.name)||(r[t.name]=[]),r[t.name].push(t)}))}function o(){this.reset("")}function i(t,e,i){if(t instanceof n){var s=t;i=e}else s=n.fromCompiled(t,e);for(var a in this.grammar=s,this.options={keepHistory:!1,lexer:s.lexer||new o},i||{})this.options[a]=i[a];this.lexer=this.options.lexer,this.lexerState=void 0;var l=new r(s,0);this.table=[l],l.wants[s.start]=[],l.predict(s.start),l.process(),this.current=0}function s(t){var e=typeof t;if("string"===e)return t;if("object"===e){if(t.literal)return JSON.stringify(t.literal);if(t instanceof RegExp)return t.toString();if(t.type)return"%"+t.type;if(t.test)return"<"+String(t.test)+">";throw new Error("Unknown symbol type: "+t)}}return t.highestId=0,t.prototype.toString=function(t){var e=void 0===t?this.symbols.map(s).join(" "):this.symbols.slice(0,t).map(s).join(" ")+" ● "+this.symbols.slice(t).map(s).join(" ");return this.name+" → "+e},e.prototype.toString=function(){return"{"+this.rule.toString(this.dot)+"}, from: "+(this.reference||0)},e.prototype.nextState=function(t){var r=new e(this.rule,this.dot+1,this.reference,this.wantedBy);return r.left=this,r.right=t,r.isComplete&&(r.data=r.build(),r.right=void 0),r},e.prototype.build=function(){var t=[],e=this;do{t.push(e.right.data),e=e.left}while(e.left);return t.reverse(),t},e.prototype.finish=function(){this.rule.postprocess&&(this.data=this.rule.postprocess(this.data,this.reference,i.fail))},r.prototype.process=function(t){for(var e=this.states,r=this.wants,n=this.completed,o=0;o<e.length;o++){var s=e[o];if(s.isComplete){if(s.finish(),s.data!==i.fail){for(var a=s.wantedBy,l=a.length;l--;)this.complete(a[l],s);s.reference===this.index&&(this.completed[u=s.rule.name]=this.completed[u]||[]).push(s)}}else{var u;if("string"!=typeof(u=s.rule.symbols[s.dot])){this.scannable.push(s);continue}if(r[u]){if(r[u].push(s),n.hasOwnProperty(u)){var c=n[u];for(l=0;l<c.length;l++)this.complete(s,c[l])}}else r[u]=[s],this.predict(u)}}},r.prototype.predict=function(t){for(var r=this.grammar.byName[t]||[],n=0;n<r.length;n++){var o=new e(r[n],0,this.index,this.wants[t]);this.states.push(o)}},r.prototype.complete=function(t,e){var r=t.nextState(e);this.states.push(r)},n.fromCompiled=function(e,r){var o=e.Lexer;e.ParserStart&&(r=e.ParserStart,e=e.ParserRules);var i=new n(e=e.map((function(e){return new t(e.name,e.symbols,e.postprocess)})),r);return i.lexer=o,i},o.prototype.reset=function(t,e){this.buffer=t,this.index=0,this.line=e?e.line:1,this.lastLineBreak=e?-e.col:0},o.prototype.next=function(){if(this.index<this.buffer.length){var t=this.buffer[this.index++];return"\n"===t&&(this.line+=1,this.lastLineBreak=this.index),{value:t}}},o.prototype.save=function(){return{line:this.line,col:this.index-this.lastLineBreak}},o.prototype.formatError=function(t,e){var r=this.buffer;if("string"==typeof r){var n=r.split("\n").slice(Math.max(0,this.line-5),this.line),o=r.indexOf("\n",this.index);-1===o&&(o=r.length);var i=this.index-this.lastLineBreak,s=String(this.line).length;return e+=" at line "+this.line+" col "+i+":\n\n",(e+=n.map((function(t,e){return a(this.line-n.length+e+1,s)+" "+t}),this).join("\n"))+"\n"+a("",s+i)+"^\n"}return e+" at index "+(this.index-1);function a(t,e){var r=String(t);return Array(e-r.length+1).join(" ")+r}},i.fail={},i.prototype.feed=function(t){var e,n=this.lexer;for(n.reset(t,this.lexerState);;){try{if(!(e=n.next()))break}catch(t){var i=new r(this.grammar,this.current+1);throw this.table.push(i),(l=new Error(this.reportLexerError(t))).offset=this.current,l.token=t.token,l}var s=this.table[this.current];this.options.keepHistory||delete this.table[this.current-1];var a=this.current+1;i=new r(this.grammar,a),this.table.push(i);for(var l,u=void 0!==e.text?e.text:e.value,c=n.constructor===o?e.value:e,f=s.scannable,p=f.length;p--;){var h=f[p],m=h.rule.symbols[h.dot];if(m.test?m.test(c):m.type?m.type===e.type:m.literal===u){var y=h.nextState({data:c,token:e,isToken:!0,reference:a-1});i.states.push(y)}}if(i.process(),0===i.states.length)throw(l=new Error(this.reportError(e))).offset=this.current,l.token=e,l;this.options.keepHistory&&(s.lexerState=n.save()),this.current++}return s&&(this.lexerState=n.save()),this.results=this.finish(),this},i.prototype.reportLexerError=function(t){var e,r,n=t.token;return n?(e="input "+JSON.stringify(n.text[0])+" (lexer error)",r=this.lexer.formatError(n,"Syntax error")):(e="input (lexer error)",r=t.message),this.reportErrorCommon(r,e)},i.prototype.reportError=function(t){var e=(t.type?t.type+" token: ":"")+JSON.stringify(void 0!==t.value?t.value:t),r=this.lexer.formatError(t,"Syntax error");return this.reportErrorCommon(r,e)},i.prototype.reportErrorCommon=function(t,e){var r=[];r.push(t);var n=this.table[this.table.length-2],o=n.states.filter((function(t){var e=t.rule.symbols[t.dot];return e&&"string"!=typeof e}));return 0===o.length?(r.push("Unexpected "+e+". I did not expect any more input. Here is the state of my parse table:\n"),this.displayStateStack(n.states,r)):(r.push("Unexpected "+e+". Instead, I was expecting to see one of the following:\n"),o.map((function(t){return this.buildFirstStateStack(t,[])||[t]}),this).forEach((function(t){var e=t[0],n=this.getSymbolDisplay(e.rule.symbols[e.dot]);r.push("A "+n+" based on:"),this.displayStateStack(t,r)}),this)),r.push(""),r.join("\n")},i.prototype.displayStateStack=function(t,e){for(var r,n=0,o=0;o<t.length;o++){var i=t[o],s=i.rule.toString(i.dot);s===r?n++:(n>0&&e.push(" ^ "+n+" more lines identical to this"),n=0,e.push(" "+s)),r=s}},i.prototype.getSymbolDisplay=function(t){return function(t){var e=typeof t;if("string"===e)return t;if("object"===e){if(t.literal)return JSON.stringify(t.literal);if(t instanceof RegExp)return"character matching "+t;if(t.type)return t.type+" token";if(t.test)return"token matching "+String(t.test);throw new Error("Unknown symbol type: "+t)}}(t)},i.prototype.buildFirstStateStack=function(t,e){if(-1!==e.indexOf(t))return null;if(0===t.wantedBy.length)return[t];var r=t.wantedBy[0],n=[t].concat(e),o=this.buildFirstStateStack(r,n);return null===o?null:[t].concat(o)},i.prototype.save=function(){var t=this.table[this.current];return t.lexerState=this.lexerState,t},i.prototype.restore=function(t){var e=t.index;this.current=e,this.table[e]=t,this.table.splice(e+1),this.lexerState=t.lexerState,this.results=this.finish()},i.prototype.rewind=function(t){if(!this.options.keepHistory)throw new Error("set option `keepHistory` to enable rewinding");this.restore(this.table[t])},i.prototype.finish=function(){var t=[],e=this.grammar.start;return this.table[this.table.length-1].states.forEach((function(r){r.rule.name===e&&r.dot===r.rule.symbols.length&&0===r.reference&&r.data!==i.fail&&t.push(r)})),t.map((function(t){return t.data}))},{Parser:i,Grammar:n,Rule:t}},t.exports?t.exports=r():e.nearley=r()}));function Y(){return(Y=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var tt=W((function(t){var e,r;e=D,r=function(){var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,r="boolean"==typeof(new RegExp).sticky;function n(t){return t&&"[object RegExp]"===e.call(t)}function o(t){return t&&"object"==typeof t&&!n(t)&&!Array.isArray(t)}function i(t){return t.length?"(?:"+t.map((function(t){return"(?:"+t+")"})).join("|")+")":"(?!)"}function s(t){if("string"==typeof t)return"(?:"+t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")+")";if(n(t)){if(t.ignoreCase)throw new Error("RegExp /i flag not allowed");if(t.global)throw new Error("RegExp /g flag is implied");if(t.sticky)throw new Error("RegExp /y flag is implied");if(t.multiline)throw new Error("RegExp /m flag is implied");return t.source}throw new Error("Not a pattern: "+t)}function a(e,r){if(o(r)||(r={match:r}),r.include)throw new Error("Matching rules cannot also include states");var i={defaultType:e,lineBreaks:!!r.error||!!r.fallback,pop:!1,next:null,push:null,error:!1,fallback:!1,value:null,type:null,shouldThrow:!1};for(var s in r)t.call(r,s)&&(i[s]=r[s]);if("string"==typeof i.type&&e!==i.type)throw new Error("Type transform cannot be a string (type '"+i.type+"' for token '"+e+"')");var a=i.match;return i.match=Array.isArray(a)?a:a?[a]:[],i.match.sort((function(t,e){return n(t)&&n(e)?0:n(e)?-1:n(t)?1:e.length-t.length})),i}function l(t){return Array.isArray(t)?function(t){for(var e=[],r=0;r<t.length;r++){var n=t[r];if(n.include)for(var o=[].concat(n.include),i=0;i<o.length;i++)e.push({include:o[i]});else{if(!n.type)throw new Error("Rule has no type: "+JSON.stringify(n));e.push(a(n.type,n))}}return e}(t):function(t){for(var e=Object.getOwnPropertyNames(t),r=[],n=0;n<e.length;n++){var i=e[n],s=[].concat(t[i]);if("include"!==i){var l=[];s.forEach((function(t){o(t)?(l.length&&r.push(a(i,l)),r.push(a(i,t)),l=[]):l.push(t)})),l.length&&r.push(a(i,l))}else for(var u=0;u<s.length;u++)r.push({include:s[u]})}return r}(t)}var u=a("error",{lineBreaks:!0,shouldThrow:!0});function c(t,e){for(var o=null,a=Object.create(null),l=!0,c=null,f=[],p=[],h=0;h<t.length;h++)t[h].fallback&&(l=!1);for(h=0;h<t.length;h++){var m=t[h];if(m.include)throw new Error("Inheritance is not allowed in stateless lexers");if(m.error||m.fallback){if(o)throw!m.fallback==!o.fallback?new Error("Multiple "+(m.fallback?"fallback":"error")+" rules not allowed (for token '"+m.defaultType+"')"):new Error("fallback and error are mutually exclusive (for token '"+m.defaultType+"')");o=m}var y=m.match.slice();if(l)for(;y.length&&"string"==typeof y[0]&&1===y[0].length;)a[y.shift().charCodeAt(0)]=m;if(m.pop||m.push||m.next){if(!e)throw new Error("State-switching options are not allowed in stateless lexers (for token '"+m.defaultType+"')");if(m.fallback)throw new Error("State-switching options are not allowed on fallback tokens (for token '"+m.defaultType+"')")}if(0!==y.length){l=!1,f.push(m);for(var d=0;d<y.length;d++){var b=y[d];if(n(b))if(null===c)c=b.unicode;else if(c!==b.unicode&&!1===m.fallback)throw new Error("If one rule is /u then all must be")}var g=i(y.map(s)),v=new RegExp(g);if(v.test(""))throw new Error("RegExp matches empty string: "+v);if(new RegExp("|"+g).exec("").length-1>0)throw new Error("RegExp has capture groups: "+v+"\nUse (?: … ) instead");if(!m.lineBreaks&&v.test("\n"))throw new Error("Rule should declare lineBreaks: "+v);p.push("("+g+")")}}var w=o&&o.fallback,x=r&&!w?"ym":"gm",S=r||w?"":"|";return!0===c&&(x+="u"),{regexp:new RegExp(i(p)+S,x),groups:f,fast:a,error:o||u}}function f(t,e,r){var n=t&&(t.push||t.next);if(n&&!r[n])throw new Error("Missing state '"+n+"' (in token '"+t.defaultType+"' of state '"+e+"')");if(t&&t.pop&&1!=+t.pop)throw new Error("pop must be 1 (in token '"+t.defaultType+"' of state '"+e+"')")}var p=function(t,e){this.startState=e,this.states=t,this.buffer="",this.stack=[],this.reset()};p.prototype.reset=function(t,e){return this.buffer=t||"",this.index=0,this.line=e?e.line:1,this.col=e?e.col:1,this.queuedToken=e?e.queuedToken:null,this.queuedThrow=e?e.queuedThrow:null,this.setState(e?e.state:this.startState),this.stack=e&&e.stack?e.stack.slice():[],this},p.prototype.save=function(){return{line:this.line,col:this.col,state:this.state,stack:this.stack.slice(),queuedToken:this.queuedToken,queuedThrow:this.queuedThrow}},p.prototype.setState=function(t){if(t&&this.state!==t){this.state=t;var e=this.states[t];this.groups=e.groups,this.error=e.error,this.re=e.regexp,this.fast=e.fast}},p.prototype.popState=function(){this.setState(this.stack.pop())},p.prototype.pushState=function(t){this.stack.push(this.state),this.setState(t)};var h=r?function(t,e){return t.exec(e)}:function(t,e){var r=t.exec(e);return 0===r[0].length?null:r};function m(){return this.value}if(p.prototype._getGroup=function(t){for(var e=this.groups.length,r=0;r<e;r++)if(void 0!==t[r+1])return this.groups[r];throw new Error("Cannot find token type for matched text")},p.prototype.next=function(){var t=this.index;if(this.queuedGroup){var e=this._token(this.queuedGroup,this.queuedText,t);return this.queuedGroup=null,this.queuedText="",e}var r=this.buffer;if(t!==r.length){if(s=this.fast[r.charCodeAt(t)])return this._token(s,r.charAt(t),t);var n=this.re;n.lastIndex=t;var o=h(n,r),i=this.error;if(null==o)return this._token(i,r.slice(t,r.length),t);var s=this._getGroup(o),a=o[0];return i.fallback&&o.index!==t?(this.queuedGroup=s,this.queuedText=a,this._token(i,r.slice(t,o.index),t)):this._token(s,a,t)}},p.prototype._token=function(t,e,r){var n=0;if(t.lineBreaks){var o=/\n/g,i=1;if("\n"===e)n=1;else for(;o.exec(e);)n++,i=o.lastIndex}var s={type:"function"==typeof t.type&&t.type(e)||t.defaultType,value:"function"==typeof t.value?t.value(e):e,text:e,toString:m,offset:r,lineBreaks:n,line:this.line,col:this.col},a=e.length;if(this.index+=a,this.line+=n,0!==n?this.col=a-i+1:this.col+=a,t.shouldThrow)throw new Error(this.formatError(s,"invalid syntax"));return t.pop?this.popState():t.push?this.pushState(t.push):t.next&&this.setState(t.next),s},"undefined"!=typeof Symbol&&Symbol.iterator){var y=function(t){this.lexer=t};y.prototype.next=function(){var t=this.lexer.next();return{value:t,done:!t}},y.prototype[Symbol.iterator]=function(){return this},p.prototype[Symbol.iterator]=function(){return new y(this)}}return p.prototype.formatError=function(t,e){if(null==t){var r=this.buffer.slice(this.index);t={text:r,offset:this.index,lineBreaks:-1===r.indexOf("\n")?0:1,line:this.line,col:this.col}}var n=Math.max(0,t.offset-t.col+1),o=t.lineBreaks?t.text.indexOf("\n"):t.text.length,i=this.buffer.substring(n,t.offset+o);return e+=" at line "+t.line+" col "+t.col+":\n\n",(e+=" "+i+"\n")+" "+Array(t.col).join(" ")+"^"},p.prototype.clone=function(){return new p(this.states,this.state)},p.prototype.has=function(t){return!0},{compile:function(t){var e=c(l(t));return new p({start:e},"start")},states:function(t,e){var r=t.$all?l(t.$all):[];delete t.$all;var n=Object.getOwnPropertyNames(t);e||(e=n[0]);for(var o=Object.create(null),i=0;i<n.length;i++)o[v=n[i]]=l(t[v]).concat(r);for(i=0;i<n.length;i++)for(var s=o[v=n[i]],a=Object.create(null),u=0;u<s.length;u++){var h=s[u];if(h.include){var m=[u,1];if(h.include!==v&&!a[h.include]){a[h.include]=!0;var y=o[h.include];if(!y)throw new Error("Cannot include nonexistent state '"+h.include+"' (in state '"+v+"')");for(var d=0;d<y.length;d++){var b=y[d];-1===s.indexOf(b)&&m.push(b)}}s.splice.apply(s,m),u--}}var g=Object.create(null);for(i=0;i<n.length;i++){var v;g[v=n[i]]=c(o[v],!0)}for(i=0;i<n.length;i++){var w=n[i],x=g[w],S=x.groups;for(u=0;u<S.length;u++)f(S[u],w,g);var k=Object.getOwnPropertyNames(x.fast);for(u=0;u<k.length;u++)f(x.fast[k[u]],w,g)}return new p(g,e)},error:Object.freeze({error:!0}),fallback:Object.freeze({fallback:!0}),keywords:function(t){for(var e=Object.create(null),r=Object.create(null),n=Object.getOwnPropertyNames(t),o=0;o<n.length;o++){var i=n[o],s=t[i];(Array.isArray(s)?s:[s]).forEach((function(t){if((r[t.length]=r[t.length]||[]).push(t),"string"!=typeof t)throw new Error("keyword must be string (in keyword '"+i+"')");e[t]=i}))}function a(t){return JSON.stringify(t)}var l="";for(var u in l+="switch (value.length) {\n",r)l+="case "+u+":\n",l+="switch (value) {\n",r[u].forEach((function(t){var r=e[t];l+="case "+a(t)+": return "+a(r)+"\n"})),l+="}\n";return l+="}\n",Function("value",l)}}},t.exports?t.exports=r():e.moo=r()})),et=/[0-9a-zA-Z_@]+\b@*/,rt=new RegExp("^"+et.source+"$"),nt={__proto__:null,boolean:/true|false|TRUE|FALSE\b(?!@)/,hexadecimal:/-?0x(?:[0-9a-fA-F]+)\b(?!@)/,octal:/-?0(?:[0-7]+)\b(?!@)/,measurement:/-?(?:[0-9]|[1-9][0-9]+)(?:\.[0-9]+)?[a-zA-Z]+\b(?!@)/,decimal:/-?(?:[0-9]|[1-9][0-9]+)\.[0-9]+(?:[eE][-+]?[0-9]+)?\b(?!@)/,integer:/-?(?:[0-9]|[1-9][0-9]+)(?:[eE][-+]?[0-9]+)?\b(?!@)/,taggedString:/[a-zA-Z][0-9a-zA-Z_@]*`(?:\\[`bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^`\\])*`/,doubleQuotedString:/"(?:\\["bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*"/,singleQuotedString:/'(?:\\['bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^'\\])*'/,tickedString:/`(?:\\[`bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^`\\])*`/,symbol:/[a-zA-Z_][0-9a-zA-Z_]*\b(?!@)/,identifier:et,isValidIdentifier:function(t){return t&&rt.test(t)}},ot=function(t){return!!t.type&&"path"===t.type},it=function(t){return ot(t)&&"ø"===t.id},st=function(t){return ot(t)&&t.children&&0===t.children.length&&"ø"!==t.id};function at(){return(at=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function lt(t){return Array.isArray(t)?t:t instanceof Function?lt(t()):void 0===t?[]:[t]}var ut=function(t,e){void 0===e&&(e={});var r=at({type:"path"},e.id&&{id:e.id},e.labels&&{labels:e.labels},e.record&&{record:e.record});if(void 0===t)return r.id&&"ø"!==r.id?(r.children=[],r):(r.children=void 0,ct);if(0===t.length)return"ø"===r.id?ct:(r.children=[],r);if(1===t.length){var n=t[0];return it(n)?(r.children=[],r):(r.children=[n],r)}if(2===t.length){if(e.kind&&"pair"!==e.kind&&st(t[0])&&st(t[1]))return r.kind=e.kind,r.children=[t[0],t[1]],r;if(it(t[0])&&it(t[1]))return r.kind=e.kind,r.children=[],r;r.children=[t[0],t[1]]}return r.kind=e.kind||"pair",r},ct={type:"path",id:"ø",labels:void 0,record:void 0,children:[]},ft=function(t,e,r){return at({type:"path"},t&&{id:t},e&&{labels:e},r&&{record:r},{children:[]})},pt=function(t){return{type:"string",value:t}};function ht(t){return t[0]}var mt=tt.compile({whitespace:{match:/\s+/,lineBreaks:!0},lineComment:{match:/\/\/.*?\n?$/},hexadecimal:nt.hexadecimal,octal:nt.octal,measurement:nt.measurement,decimal:nt.decimal,integer:nt.integer,taggedString:{match:nt.taggedString},boolean:["true","TRUE","True","false","FALSE","False"],symbol:nt.symbol,identifier:nt.identifier,doubleQuotedString:{match:nt.doubleQuotedString,value:function(t){return t.slice(1,-1)}},singleQuotedString:{match:nt.singleQuotedString,value:function(t){return t.slice(1,-1)}},tickedString:{match:nt.tickedString,value:function(t){return t.slice(1,-1)}},"--\x3e":"--\x3e","--":"--","<--":"<--","-[]->":"-[]->","-[]-":"-[]-","<-[]-":"<-[]-","<-[":"<-[","]->":"]->","-[":"-[","]-":"]-","{":"{","}":"}","[":"[","]":"]","(":"(",")":")",",":",",":":":","`":"`","'":"'","ø":"ø"}),yt=function(){return null},dt=function(t){return t[0].text},bt={Lexer:mt,ParserRules:[{name:"GramSeq$ebnf$1$subexpression$1",symbols:["Path","_"],postprocess:function(t){return t[0]}},{name:"GramSeq$ebnf$1",symbols:["GramSeq$ebnf$1$subexpression$1"]},{name:"GramSeq$ebnf$1$subexpression$2",symbols:["Path","_"],postprocess:function(t){return t[0]}},{name:"GramSeq$ebnf$1",symbols:["GramSeq$ebnf$1","GramSeq$ebnf$1$subexpression$2"],postprocess:function(t){return t[0].concat([t[1]])}},{name:"GramSeq$ebnf$2",symbols:["EOL"],postprocess:ht},{name:"GramSeq$ebnf$2",symbols:[],postprocess:function(){return null}},{name:"GramSeq",symbols:["GramSeq$ebnf$1","GramSeq$ebnf$2"],postprocess:function(t){var e;return void 0===e&&(e=1),at({type:"seq",id:void 0},void 0,void 0,{children:lt(t[0].flat(e).filter((function(t){return null!==t})))})}},{name:"Path",symbols:["NodePattern"],postprocess:ht},{name:"Path",symbols:["PathComposition"],postprocess:ht},{name:"Path",symbols:["PathPair"],postprocess:ht},{name:"NodePattern",symbols:["Node","_","Edge","_","NodePattern"],postprocess:function(t){var e=t[2];return ut([t[0],t[4]],{kind:e.kind,id:e.id,labels:e.labels,record:e.record})}},{name:"NodePattern",symbols:["Node"],postprocess:ht},{name:"Node",symbols:[{literal:"("},"_","Attributes","_",{literal:")"}],postprocess:function(t){var e=t[2];return ft(e.id,e.labels,e.record)}},{name:"Edge",symbols:[{literal:"-["},"_","Attributes",{literal:"]->"}],postprocess:function(t){return Y({kind:"right"},t[2])}},{name:"Edge",symbols:[{literal:"-["},"_","Attributes",{literal:"]-"}],postprocess:function(t){return Y({kind:"either"},t[2])}},{name:"Edge",symbols:[{literal:"<-["},"_","Attributes",{literal:"]-"}],postprocess:function(t){return Y({kind:"left"},t[2])}},{name:"Edge",symbols:[{literal:"-[]->"}],postprocess:function(){return{kind:"right"}}},{name:"Edge",symbols:[{literal:"-[]-"}],postprocess:function(){return{kind:"either"}}},{name:"Edge",symbols:[{literal:"<-[]-"}],postprocess:function(){return{kind:"left"}}},{name:"Edge",symbols:[{literal:"--\x3e"}],postprocess:function(){return{kind:"right"}}},{name:"Edge",symbols:[{literal:"--"}],postprocess:function(){return{kind:"either"}}},{name:"Edge",symbols:[{literal:"<--"}],postprocess:function(){return{kind:"left"}}},{name:"PathComposition",symbols:["PathPoint"],postprocess:ht},{name:"PathComposition",symbols:["PathAnnotation"],postprocess:ht},{name:"PathComposition",symbols:["PathExpression"],postprocess:ht},{name:"PathPoint",symbols:[{literal:"["},"_","Attributes","_",{literal:"]"}],postprocess:function(t){var e=t[2];return(e.id||e.labels||e.record)&&"ø"!==e.id?ft(e.id,e.labels,e.record):ct}},{name:"PathAnnotation",symbols:[{literal:"["},"_","Attributes","_","Path",{literal:"]"}],postprocess:function(t){var e=t[2];return ut([t[4]],{id:e.id,labels:e.labels,record:e.record})}},{name:"PathExpression$ebnf$1",symbols:["Kind"],postprocess:ht},{name:"PathExpression$ebnf$1",symbols:[],postprocess:function(){return null}},{name:"PathExpression",symbols:[{literal:"["},"_","Attributes","_","PathExpression$ebnf$1","_","Path","_","Path","_",{literal:"]"}],postprocess:function(t){var e=t[2];return ut([t[6],t[8]],{kind:t[4],id:e.id,labels:e.labels,record:e.record})}},{name:"PathPair$subexpression$1",symbols:["NodePattern"]},{name:"PathPair$subexpression$1",symbols:["PathComposition"]},{name:"PathPair",symbols:["PathPair$subexpression$1","_",{literal:","},"_","Path"],postprocess:function(t){return function(t,e,r,n,o){return at({type:"path",kind:"pair",id:void 0},void 0,void 0,{children:e})}(0,[t[0][0],t[4]])}},{name:"Kind",symbols:[{literal:","}],postprocess:function(){return"pair"}},{name:"Kind",symbols:[{literal:"--\x3e"}],postprocess:function(){return"right"}},{name:"Kind",symbols:[{literal:"--"}],postprocess:function(){return"either"}},{name:"Kind",symbols:[{literal:"<--"}],postprocess:function(){return"left"}},{name:"Attributes$ebnf$1",symbols:["Identity"],postprocess:ht},{name:"Attributes$ebnf$1",symbols:[],postprocess:function(){return null}},{name:"Attributes$ebnf$2$subexpression$1",symbols:["_","LabelList"],postprocess:function(t){return t[1]}},{name:"Attributes$ebnf$2",symbols:["Attributes$ebnf$2$subexpression$1"],postprocess:ht},{name:"Attributes$ebnf$2",symbols:[],postprocess:function(){return null}},{name:"Attributes$ebnf$3$subexpression$1",symbols:["_","Record"],postprocess:function(t){return t[1]}},{name:"Attributes$ebnf$3",symbols:["Attributes$ebnf$3$subexpression$1"],postprocess:ht},{name:"Attributes$ebnf$3",symbols:[],postprocess:function(){return null}},{name:"Attributes",symbols:["Attributes$ebnf$1","Attributes$ebnf$2","Attributes$ebnf$3"],postprocess:function(t){return{id:t[0],labels:t[1],record:t[2]}}},{name:"LabelList$ebnf$1",symbols:["Label"]},{name:"LabelList$ebnf$1",symbols:["LabelList$ebnf$1","Label"],postprocess:function(t){return t[0].concat([t[1]])}},{name:"LabelList",symbols:["LabelList$ebnf$1"],postprocess:function(t){return t[0]}},{name:"Label",symbols:[{literal:":"},"Symbol"],postprocess:function(t){return t[1]}},{name:"Identity",symbols:[mt.has("identifier")?{type:"identifier"}:identifier],postprocess:dt},{name:"Identity",symbols:[{literal:"ø"}],postprocess:dt},{name:"Identity",symbols:[mt.has("symbol")?{type:"symbol"}:symbol],postprocess:dt},{name:"Identity",symbols:[mt.has("integer")?{type:"integer"}:integer],postprocess:dt},{name:"Identity",symbols:[mt.has("octal")?{type:"octal"}:octal],postprocess:dt},{name:"Identity",symbols:[mt.has("hexadecimal")?{type:"hexadecimal"}:hexadecimal],postprocess:dt},{name:"Identity",symbols:[mt.has("measurement")?{type:"measurement"}:measurement],postprocess:dt},{name:"Identity",symbols:[mt.has("tickedString")?{type:"tickedString"}:tickedString],postprocess:function(t){return t[0].text.slice(1,-1)}},{name:"Symbol",symbols:[mt.has("symbol")?{type:"symbol"}:symbol],postprocess:dt},{name:"Symbol",symbols:[mt.has("tickedString")?{type:"tickedString"}:tickedString],postprocess:function(t){return t[0].text.slice(1,-1)}},{name:"Record",symbols:[{literal:"{"},"_",{literal:"}"}],postprocess:yt},{name:"Record$ebnf$1",symbols:[]},{name:"Record$ebnf$1$subexpression$1",symbols:["_",{literal:","},"_","Property"]},{name:"Record$ebnf$1",symbols:["Record$ebnf$1","Record$ebnf$1$subexpression$1"],postprocess:function(t){return t[0].concat([t[1]])}},{name:"Record",symbols:[{literal:"{"},"_","Property","Record$ebnf$1","_",{literal:"}"}],postprocess:function(t){return[t[2]].concat(t[3].map((function(t){return t[3]})))}},{name:"Property",symbols:["Symbol","_",{literal:":"},"_","Value"],postprocess:function(t){return{type:"property",name:t[0],value:t[4]}}},{name:"Value",symbols:["StringLiteral"],postprocess:ht},{name:"Value",symbols:["NumericLiteral"],postprocess:ht},{name:"Value",symbols:[mt.has("boolean")?{type:"boolean"}:boolean],postprocess:function(t){return{type:"boolean",value:JSON.parse(t[0].value.toLowerCase())?"true":"false"}}},{name:"Value$ebnf$1",symbols:[]},{name:"Value$ebnf$1$subexpression$1",symbols:["_",{literal:","},"_","Value"]},{name:"Value$ebnf$1",symbols:["Value$ebnf$1","Value$ebnf$1$subexpression$1"],postprocess:function(t){return t[0].concat([t[1]])}},{name:"Value",symbols:[{literal:"["},"_","Value","Value$ebnf$1",{literal:"]"}],postprocess:function(t){return[t[2]].concat(t[3].map((function(t){return t[3]})))}},{name:"StringLiteral",symbols:[mt.has("singleQuotedString")?{type:"singleQuotedString"}:singleQuotedString],postprocess:function(t){return pt(t[0].value)}},{name:"StringLiteral",symbols:[mt.has("doubleQuotedString")?{type:"doubleQuotedString"}:doubleQuotedString],postprocess:function(t){return pt(t[0].value)}},{name:"StringLiteral",symbols:[mt.has("tickedString")?{type:"tickedString"}:tickedString],postprocess:function(t){return pt(t[0].value)}},{name:"StringLiteral",symbols:[mt.has("taggedString")?{type:"taggedString"}:taggedString],postprocess:function(t){var e=function(t){var e=t.match(/([^`]+)`(.+)`$/);if(null==e)throw Error("Malformed tagged string: "+t);return{tag:e[1],value:e[2]}}(t[0].value);return{type:"tagged",value:e.value,tag:e.tag}}},{name:"NumericLiteral",symbols:[mt.has("integer")?{type:"integer"}:integer],postprocess:function(t){return{type:"integer",value:String(t[0].value)}}},{name:"NumericLiteral",symbols:[mt.has("decimal")?{type:"decimal"}:decimal],postprocess:function(t){return{type:"decimal",value:String(t[0].value)}}},{name:"NumericLiteral",symbols:[mt.has("hexadecimal")?{type:"hexadecimal"}:hexadecimal],postprocess:function(t){return{type:"hexadecimal",value:"number"==typeof(e=t[0].value)?e.toString(16):e};var e}},{name:"NumericLiteral",symbols:[mt.has("octal")?{type:"octal"}:octal],postprocess:function(t){return{type:"octal",value:"number"==typeof(e=t[0].value)?e.toString(8):e};var e}},{name:"NumericLiteral",symbols:[mt.has("measurement")?{type:"measurement"}:measurement],postprocess:function(t){var e,r=function(t){var e=t.match(/(-?[0-9.]+)([a-zA-Z]+)/);if(null==e)throw Error("Malformed measurement : "+t);return{value:e[1],unit:e[2]}}(t[0].value);return e=r.unit,{type:"measurement",value:String(r.value),unit:e}}},{name:"_",symbols:[]},{name:"_",symbols:[mt.has("whitespace")?{type:"whitespace"}:whitespace],postprocess:yt},{name:"Comment",symbols:[mt.has("lineComment")?{type:"lineComment"}:lineComment],postprocess:yt},{name:"EOL",symbols:[{literal:"\n"}],postprocess:yt}],ParserStart:"GramSeq"},gt=function(t,e){var r,n,o=new X.Parser(X.Grammar.fromCompiled(bt));try{var i=o.feed(t);if(void 0===i.results[0]&&i.lexerState){var s={line:(n=i.lexerState).line,column:n.col};e.fail("Incomplete parse.",s)}return i.results.length>1&&e.info("[WARN] parsing is ambiguous"),i.results[0]||{type:"error"}}catch(t){var a=t.token?{line:(r=t.token).line,column:r.col}:{line:0,column:0};e.fail(t.message,a)}},vt=function(){this.Parser=gt};t.errors={__proto__:null,INCOMPLETE_PARSE:"Incomplete parse.",SYNTAX_ERROR:"Syntax error at"},t.gramParserPlugin=vt,t.toAST=function(t){return V().use(vt).freeze().parse(t)},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=gram-parse.umd.production.min.js.map |
{ | ||
"name": "@gram-data/gram-parse", | ||
"description": "parse text into gram data graphs", | ||
"keywords": [ | ||
@@ -9,3 +10,3 @@ "graph", | ||
], | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"license": "MIT", | ||
@@ -58,10 +59,10 @@ "author": "Andreas Kollegger", | ||
"devDependencies": { | ||
"@gram-data/gram-stringify": "^0.3.3", | ||
"@types/jest": "^26.0.15", | ||
"@gram-data/gram-stringify": "^0.3.4", | ||
"@types/jest": "^26.0.18", | ||
"@types/moo": "^0.5.3", | ||
"@types/nearley": "^2.11.1", | ||
"@types/unist": "^2.0.3", | ||
"@typescript-eslint/parser": "^4.8.2", | ||
"husky": "^4.3.0", | ||
"npm-check-updates": "^10.2.2", | ||
"@typescript-eslint/parser": "^4.9.1", | ||
"husky": "^4.3.5", | ||
"npm-check-updates": "^10.2.3", | ||
"npm-run-all": "^4.1.5", | ||
@@ -79,10 +80,10 @@ "parcel-bundler": "^1.12.4", | ||
"dependencies": { | ||
"@gram-data/gram-ast": "^0.3.2", | ||
"@gram-data/gram-builder": "^0.3.2", | ||
"@gram-data/gram-ast": "^0.3.4", | ||
"@gram-data/gram-builder": "^0.3.4", | ||
"moo": "^0.5.1", | ||
"nearley": "^2.19.8", | ||
"nearley": "^2.20.1", | ||
"unified": "^9.2.0", | ||
"vfile": "^4.2.0" | ||
"vfile": "^4.2.1" | ||
}, | ||
"gitHead": "4968a0ac1569f0bab127c1c991ccf5314e306670", | ||
"gitHead": "27de40df779bc903e8873563db12f7db477e4ad3", | ||
"publishConfig": { | ||
@@ -89,0 +90,0 @@ "access": "public" |
@@ -1,2 +0,2 @@ | ||
// Generated automatically by nearley, version 2.19.8 | ||
// Generated automatically by nearley, version 2.20.1 | ||
// http://github.com/Hardmath123/nearley | ||
@@ -117,3 +117,3 @@ // Bypasses TS6133. Allow declared but unused functions. | ||
save: () => any; | ||
formatError: (token: NearleyToken) => string; | ||
formatError: (token: never) => string; | ||
has: (tokenType: string) => boolean; | ||
@@ -120,0 +120,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
693944
-1.81%5799
-1.29%Updated
Updated
Updated