@gram-data/gram-parse
Advanced tools
Comparing version 0.2.8 to 0.2.9
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e=e||self).gram=e.gram||{},e.gram.parse={}))}(this,(function(e){"use strict";var t=function(e){if(e)throw e},n=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},r=Object.prototype.hasOwnProperty,o=Object.prototype.toString,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===o.call(e)},l=function(e){if(!e||"[object Object]"!==o.call(e))return!1;var t,n=r.call(e,"constructor"),i=e.constructor&&e.constructor.prototype&&r.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!i)return!1;for(t in e);return void 0===t||r.call(e,t)},u=function(e,t){i&&"__proto__"===t.name?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},c=function(e,t){if("__proto__"===t){if(!r.call(e,t))return;if(s)return s(e,t).value}return e[t]},f=function e(){var t,n,r,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!=(t=arguments[p]))for(n in t)r=c(f,n),f!==(o=c(t,n))&&(m&&o&&(l(o)||(i=a(o)))?(i?(i=!1,s=r&&a(r)?r:[]):s=r&&l(r)?r:{},u(f,{name:n,newValue:e(m,s,o)})):void 0!==o&&u(f,{name:n,newValue:o}));return f},p=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},h=[].slice,m=function(e,t){var n;return function(){var t,i=h.call(arguments,0),s=e.length>i.length;s&&i.push(r);try{t=e.apply(null,i)}catch(e){if(s&&n)throw e;return r(e)}s||(t&&"function"==typeof t.then?t.then(o,r):t instanceof Error?r(t):o(t))};function r(){n||(n=!0,t.apply(null,arguments))}function o(e){r(null,e)}},y=b;b.wrap=m;var d=[].slice;function b(){var e=[],t={run:function(){var t=-1,n=d.call(arguments,0,-1),r=arguments[arguments.length-1];if("function"!=typeof r)throw new Error("Expected function as last argument, not "+r);function o(i){var s=e[++t],a=d.call(arguments,0),l=a.slice(1),u=n.length,c=-1;if(i)r(i);else{for(;++c<u;)null==l[c]&&(l[c]=n[c]);n=l,s?m(s,o).apply(null,n):r.apply(null,[null].concat(n))}}o.apply(null,[null].concat(n))},use:function(n){if("function"!=typeof n)throw new Error("Expected `fn` to be a function, not "+n);return e.push(n),t}};return t}var g={}.hasOwnProperty,v=function(e){return e&&"object"==typeof e?g.call(e,"position")||g.call(e,"type")?x(e.position):g.call(e,"start")||g.call(e,"end")?x(e):g.call(e,"line")||g.call(e,"column")?w(e):"":""};function w(e){return e&&"object"==typeof e||(e={}),S(e.line)+":"+S(e.column)}function x(e){return e&&"object"==typeof e||(e={}),w(e.start)+"-"+w(e.end)}function S(e){return e&&"number"==typeof e?e:1}var $=P;function E(){}E.prototype=Error.prototype;var k=P.prototype=new E;function P(e,t,n){var r,o,i;"string"==typeof t&&(n=t,t=null),r=function(e){var t,n=[null,null];return"string"==typeof e&&(-1===(t=e.indexOf(":"))?n[1]=e:(n[0]=e.slice(0,t),n[1]=e.slice(t+1))),n}(n),o=v(t)||"1:1",i={start:{line:null,column:null},end:{line:null,column:null}},t&&t.position&&(t=t.position),t&&(t.start?(i=t,t=t.start):i.start=t),e.stack&&(this.stack=e.stack,e=e.message),this.message=e,this.name=o,this.reason=e,this.line=t?t.line:null,this.column=t?t.column:null,this.location=i,this.source=r[0],this.ruleId=r[1]}k.file="",k.name="",k.reason="",k.message="",k.stack="",k.fatal=null,k.column=null,k.line=null;var O="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function j(e,t){for(var n=0,r=e.length-1;r>=0;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}"function"==typeof O.setTimeout&&setTimeout,"function"==typeof O.clearTimeout&&clearTimeout,new Date;var _=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,A=function(e){return _.exec(e).slice(1)};function C(){for(var e="",t=!1,n=arguments.length-1;n>=-1&&!t;n--){var r=n>=0?arguments[n]:"/";if("string"!=typeof r)throw new TypeError("Arguments to path.resolve must be strings");r&&(e=r+"/"+e,t="/"===r.charAt(0))}return(t?"/":"")+(e=j(M(e.split("/"),(function(e){return!!e})),!t).join("/"))||"."}function T(e){var t=R(e),n="/"===z(e,-1);return(e=j(M(e.split("/"),(function(e){return!!e})),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e}function R(e){return"/"===e.charAt(0)}function L(){var e=Array.prototype.slice.call(arguments,0);return T(M(e,(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))}function q(e,t){function n(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=C(e).substr(1),t=C(t).substr(1);for(var r=n(e.split("/")),o=n(t.split("/")),i=Math.min(r.length,o.length),s=i,a=0;a<i;a++)if(r[a]!==o[a]){s=a;break}var l=[];for(a=s;a<r.length;a++)l.push("..");return(l=l.concat(o.slice(s))).join("/")}function N(e){var t=A(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."}function I(e,t){var n=A(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n}function B(e){return A(e)[3]}var V={extname:B,basename:I,dirname:N,sep:"/",delimiter:":",relative:q,join:L,isAbsolute:R,normalize:T,resolve:C};function M(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}var z="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return t<0&&(t=e.length+t),e.substr(t,n)},F="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function U(e,t){return e(t={exports:{}},t.exports),t.exports}var Q,D=(Q={__proto__:null,resolve:C,normalize:T,isAbsolute:R,join:L,relative:q,sep:"/",delimiter:":",dirname:N,basename:I,extname:B,default:V})&&Q.default||Q,H=Y,G={}.hasOwnProperty,J=Y.prototype,Z=["history","path","basename","stem","extname","dirname"];function Y(e){var t,r,o;if(e){if("string"==typeof e||n(e))e={contents:e};else if("message"in e&&"messages"in e)return e}else e={};if(!(this instanceof Y))return new Y(e);for(this.data={},this.messages=[],this.history=[],this.cwd="/",r=-1,o=Z.length;++r<o;)G.call(e,t=Z[r])&&(this[t]=e[t]);for(t in e)-1===Z.indexOf(t)&&(this[t]=e[t])}function X(e,t){if(-1!==e.indexOf(D.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+D.sep+"`")}function K(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function W(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}J.toString=function(e){var t=this.contents||"";return n(t)?t.toString(e):String(t)},Object.defineProperty(J,"path",{get:function(){return this.history[this.history.length-1]},set:function(e){K(e,"path"),e!==this.path&&this.history.push(e)}}),Object.defineProperty(J,"dirname",{get:function(){return"string"==typeof this.path?D.dirname(this.path):void 0},set:function(e){W(this.path,"dirname"),this.path=D.join(e||"",this.basename)}}),Object.defineProperty(J,"basename",{get:function(){return"string"==typeof this.path?D.basename(this.path):void 0},set:function(e){K(e,"basename"),X(e,"basename"),this.path=D.join(this.dirname||"",e)}}),Object.defineProperty(J,"extname",{get:function(){return"string"==typeof this.path?D.extname(this.path):void 0},set:function(e){var t=e||"";if(X(t,"extname"),W(this.path,"extname"),t){if("."!==t.charAt(0))throw new Error("`extname` must start with `.`");if(-1!==t.indexOf(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=function(e,t){if("string"!=typeof e)return e;if(0===e.length)return e;var n=D.basename(e,D.extname(e))+t;return D.join(D.dirname(e),n)}(this.path,t)}}),Object.defineProperty(J,"stem",{get:function(){return"string"==typeof this.path?D.basename(this.path,this.extname):void 0},set:function(e){K(e,"stem"),X(e,"stem"),this.path=D.join(this.dirname||"",e+(this.extname||""))}});var ee=H,te=H.prototype;te.message=function(e,t,n){var r=this.path,o=new $(e,t,n);return r&&(o.name=r+":"+o.name,o.file=r),o.fatal=!1,this.messages.push(o),o},te.info=function(){var e=this.message.apply(this,arguments);return e.fatal=null,e},te.fail=function(){var e=this.message.apply(this,arguments);throw e.fatal=!0,e};var ne=function e(){var n=[],r=y(),o={},i=!1,s=-1;return a.data=function(e,t){return"string"==typeof e?2===arguments.length?(ue("data",i),o[e]=t,a):oe.call(o,e)&&o[e]||null:e?(ue("data",i),o=e,a):o},a.freeze=l,a.attachers=n,a.use=function(e){var t;if(ue("use",i),null==e);else if("function"==typeof e)c.apply(null,arguments);else{if("object"!=typeof e)throw new Error("Expected usable value, not `"+e+"`");"length"in e?l(e):r(e)}return t&&(o.settings=f(o.settings||{},t)),a;function r(e){l(e.plugins),e.settings&&(t=f(t||{},e.settings))}function s(e){if("function"==typeof e)c(e);else{if("object"!=typeof e)throw new Error("Expected usable value, not `"+e+"`");"length"in e?c.apply(null,e):r(e)}}function l(e){var t,n;if(null==e);else{if("object"!=typeof e||!("length"in e))throw new Error("Expected a list of plugins, not `"+e+"`");for(t=e.length,n=-1;++n<t;)s(e[n])}}function c(e,t){var r=u(e);r?(p(r[1])&&p(t)&&(t=f(r[1],t)),r[1]=t):n.push(re.call(arguments))}},a.parse=function(e){var t,n=ee(e);return l(),ae("parse",t=a.Parser),se(t,"parse")?new t(String(n),n).parse():t(String(n),n)},a.stringify=function(e,t){var n,r=ee(t);return l(),le("stringify",n=a.Compiler),ce(e),se(n,"compile")?new n(e,r).compile():n(e,r)},a.run=c,a.runSync=function(e,n){var r,o=!1;return c(e,n,(function(e,n){o=!0,t(e),r=n})),fe("runSync","run",o),r},a.process=h,a.processSync=function(e){var n,r=!1;return l(),ae("processSync",a.Parser),le("processSync",a.Compiler),h(n=ee(e),(function(e){r=!0,t(e)})),fe("processSync","process",r),n},a;function a(){for(var t=e(),r=n.length,i=-1;++i<r;)t.use.apply(null,n[i]);return t.data(f(!0,{},o)),t}function l(){var e,t,o,l;if(i)return a;for(;++s<n.length;)t=(e=n[s])[0],!1!==(o=e[1])&&(!0===o&&(e[1]=void 0),"function"==typeof(l=t.apply(a,e.slice(1)))&&r.use(l));return i=!0,s=Infinity,a}function u(e){for(var t,r=n.length,o=-1;++o<r;)if((t=n[o])[0]===e)return t}function c(e,t,n){if(ce(e),l(),n||"function"!=typeof t||(n=t,t=null),!n)return new Promise(o);function o(o,i){r.run(e,ee(t),(function(t,r,s){r=r||e,t?i(t):o?o(r):n(null,r,s)}))}o(null,n)}function h(e,t){if(l(),ae("process",a.Parser),le("process",a.Compiler),!t)return new Promise(n);function n(n,r){var o=ee(e);ie.run(a,{file:o},(function(e){e?r(e):n?n(o):t(null,o)}))}n(null,t)}}().freeze(),re=[].slice,oe={}.hasOwnProperty,ie=y().use((function(e,t){t.tree=e.parse(t.file)})).use((function(e,t,n){e.run(t.tree,t.file,(function(e,r,o){e?n(e):(t.tree=r,t.file=o,n())}))})).use((function(e,t){var r=e.stringify(t.tree,t.file),o=t.file;null==r||("string"==typeof r||n(r)?o.contents=r:o.result=r)}));function se(e,t){return"function"==typeof e&&e.prototype&&(function(e){var t;for(t in e)return!0;return!1}(e.prototype)||t in e.prototype)}function ae(e,t){if("function"!=typeof t)throw new Error("Cannot `"+e+"` without `Parser`")}function le(e,t){if("function"!=typeof t)throw new Error("Cannot `"+e+"` without `Compiler`")}function ue(e,t){if(t)throw new Error("Cannot invoke `"+e+"` on a frozen processor.\nCreate a new processor first, by invoking it: use `processor()` instead of `processor`.")}function ce(e){if(!e||"string"!=typeof e.type)throw new Error("Expected node, got `"+e+"`")}function fe(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}var pe=U((function(e){var t,n;t=F,n=function(){function e(t,n,r){return this.id=++e.highestId,this.name=t,this.symbols=n,this.postprocess=r,this}function t(e,t,n,r){this.rule=e,this.dot=t,this.reference=n,this.data=[],this.wantedBy=r,this.isComplete=this.dot===e.symbols.length}function n(e,t){this.grammar=e,this.index=t,this.states=[],this.wants={},this.scannable=[],this.completed={}}function r(e,t){this.rules=e,this.start=t||this.rules[0].name;var n=this.byName={};this.rules.forEach((function(e){n.hasOwnProperty(e.name)||(n[e.name]=[]),n[e.name].push(e)}))}function o(){this.reset("")}function i(e,t,i){if(e instanceof r){var s=e;i=t}else s=r.fromCompiled(e,t);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 n(s,0);this.table=[l],l.wants[s.start]=[],l.predict(s.start),l.process(),this.current=0}function s(e){var t=typeof e;if("string"===t)return e;if("object"===t){if(e.literal)return JSON.stringify(e.literal);if(e instanceof RegExp)return e.toString();if(e.type)return"%"+e.type;if(e.test)return"<"+String(e.test)+">";throw new Error("Unknown symbol type: "+e)}}return e.highestId=0,e.prototype.toString=function(e){var t=void 0===e?this.symbols.map(s).join(" "):this.symbols.slice(0,e).map(s).join(" ")+" ● "+this.symbols.slice(e).map(s).join(" ");return this.name+" → "+t},t.prototype.toString=function(){return"{"+this.rule.toString(this.dot)+"}, from: "+(this.reference||0)},t.prototype.nextState=function(e){var n=new t(this.rule,this.dot+1,this.reference,this.wantedBy);return n.left=this,n.right=e,n.isComplete&&(n.data=n.build(),n.right=void 0),n},t.prototype.build=function(){var e=[],t=this;do{e.push(t.right.data),t=t.left}while(t.left);return e.reverse(),e},t.prototype.finish=function(){this.rule.postprocess&&(this.data=this.rule.postprocess(this.data,this.reference,i.fail))},n.prototype.process=function(e){for(var t=this.states,n=this.wants,r=this.completed,o=0;o<t.length;o++){var s=t[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(n[u]){if(n[u].push(s),r.hasOwnProperty(u)){var c=r[u];for(l=0;l<c.length;l++)this.complete(s,c[l])}}else n[u]=[s],this.predict(u)}}},n.prototype.predict=function(e){for(var n=this.grammar.byName[e]||[],r=0;r<n.length;r++){var o=new t(n[r],0,this.index,this.wants[e]);this.states.push(o)}},n.prototype.complete=function(e,t){var n=e.nextState(t);this.states.push(n)},r.fromCompiled=function(t,n){var o=t.Lexer;t.ParserStart&&(n=t.ParserStart,t=t.ParserRules);var i=new r(t=t.map((function(t){return new e(t.name,t.symbols,t.postprocess)})),n);return i.lexer=o,i},o.prototype.reset=function(e,t){this.buffer=e,this.index=0,this.line=t?t.line:1,this.lastLineBreak=t?-t.col:0},o.prototype.next=function(){if(this.index<this.buffer.length){var e=this.buffer[this.index++];return"\n"===e&&(this.line+=1,this.lastLineBreak=this.index),{value:e}}},o.prototype.save=function(){return{line:this.line,col:this.index-this.lastLineBreak}},o.prototype.formatError=function(e,t){var n=this.buffer;if("string"==typeof n){var r=n.split("\n").slice(Math.max(0,this.line-5),this.line),o=n.indexOf("\n",this.index);-1===o&&(o=n.length);var i=this.index-this.lastLineBreak,s=String(this.line).length;return t+=" at line "+this.line+" col "+i+":\n\n",(t+=r.map((function(e,t){return a(this.line-r.length+t+1,s)+" "+e}),this).join("\n"))+"\n"+a("",s+i)+"^\n"}return t+" at index "+(this.index-1);function a(e,t){var n=String(e);return Array(t-n.length+1).join(" ")+n}},i.fail={},i.prototype.feed=function(e){var t,r=this.lexer;for(r.reset(e,this.lexerState);;){try{if(!(t=r.next()))break}catch(e){var i=new n(this.grammar,this.current+1);throw this.table.push(i),(l=new Error(this.reportLexerError(e))).offset=this.current,l.token=e.token,l}var s=this.table[this.current];this.options.keepHistory||delete this.table[this.current-1];var a=this.current+1;i=new n(this.grammar,a),this.table.push(i);for(var l,u=void 0!==t.text?t.text:t.value,c=r.constructor===o?t.value:t,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===t.type:m.literal===u){var y=h.nextState({data:c,token:t,isToken:!0,reference:a-1});i.states.push(y)}}if(i.process(),0===i.states.length)throw(l=new Error(this.reportError(t))).offset=this.current,l.token=t,l;this.options.keepHistory&&(s.lexerState=r.save()),this.current++}return s&&(this.lexerState=r.save()),this.results=this.finish(),this},i.prototype.reportLexerError=function(e){var t,n,r=e.token;return r?(t="input "+JSON.stringify(r.text[0])+" (lexer error)",n=this.lexer.formatError(r,"Syntax error")):(t="input (lexer error)",n=e.message),this.reportErrorCommon(n,t)},i.prototype.reportError=function(e){var t=(e.type?e.type+" token: ":"")+JSON.stringify(void 0!==e.value?e.value:e),n=this.lexer.formatError(e,"Syntax error");return this.reportErrorCommon(n,t)},i.prototype.reportErrorCommon=function(e,t){var n=[];n.push(e);var r=this.table[this.table.length-2],o=r.states.filter((function(e){var t=e.rule.symbols[e.dot];return t&&"string"!=typeof t}));return 0===o.length?(n.push("Unexpected "+t+". I did not expect any more input. Here is the state of my parse table:\n"),this.displayStateStack(r.states,n)):(n.push("Unexpected "+t+". Instead, I was expecting to see one of the following:\n"),o.map((function(e){return this.buildFirstStateStack(e,[])||[e]}),this).forEach((function(e){var t=e[0],r=this.getSymbolDisplay(t.rule.symbols[t.dot]);n.push("A "+r+" based on:"),this.displayStateStack(e,n)}),this)),n.push(""),n.join("\n")},i.prototype.displayStateStack=function(e,t){for(var n,r=0,o=0;o<e.length;o++){var i=e[o],s=i.rule.toString(i.dot);s===n?r++:(r>0&&t.push(" ^ "+r+" more lines identical to this"),r=0,t.push(" "+s)),n=s}},i.prototype.getSymbolDisplay=function(e){return function(e){var t=typeof e;if("string"===t)return e;if("object"===t){if(e.literal)return JSON.stringify(e.literal);if(e instanceof RegExp)return"character matching "+e;if(e.type)return e.type+" token";if(e.test)return"token matching "+String(e.test);throw new Error("Unknown symbol type: "+e)}}(e)},i.prototype.buildFirstStateStack=function(e,t){if(-1!==t.indexOf(e))return null;if(0===e.wantedBy.length)return[e];var n=e.wantedBy[0],r=[e].concat(t),o=this.buildFirstStateStack(n,r);return null===o?null:[e].concat(o)},i.prototype.save=function(){var e=this.table[this.current];return e.lexerState=this.lexerState,e},i.prototype.restore=function(e){var t=e.index;this.current=t,this.table[t]=e,this.table.splice(t+1),this.lexerState=e.lexerState,this.results=this.finish()},i.prototype.rewind=function(e){if(!this.options.keepHistory)throw new Error("set option `keepHistory` to enable rewinding");this.restore(this.table[e])},i.prototype.finish=function(){var e=[],t=this.grammar.start;return this.table[this.table.length-1].states.forEach((function(n){n.rule.name===t&&n.dot===n.rule.symbols.length&&0===n.reference&&n.data!==i.fail&&e.push(n)})),e.map((function(e){return e.data}))},{Parser:i,Grammar:r,Rule:e}},e.exports?e.exports=n():t.nearley=n()}));function he(){return(he=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var me=U((function(e){var t,n;t=F,n=function(){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n="boolean"==typeof(new RegExp).sticky;function r(e){return e&&"[object RegExp]"===t.call(e)}function o(e){return e&&"object"==typeof e&&!r(e)&&!Array.isArray(e)}function i(e){return e.length?"(?:"+e.map((function(e){return"(?:"+e+")"})).join("|")+")":"(?!)"}function s(e){if("string"==typeof e)return"(?:"+e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")+")";if(r(e)){if(e.ignoreCase)throw new Error("RegExp /i flag not allowed");if(e.global)throw new Error("RegExp /g flag is implied");if(e.sticky)throw new Error("RegExp /y flag is implied");if(e.multiline)throw new Error("RegExp /m flag is implied");return e.source}throw new Error("Not a pattern: "+e)}function a(t,n){if(o(n)||(n={match:n}),n.include)throw new Error("Matching rules cannot also include states");var i={defaultType:t,lineBreaks:!!n.error||!!n.fallback,pop:!1,next:null,push:null,error:!1,fallback:!1,value:null,type:null,shouldThrow:!1};for(var s in n)e.call(n,s)&&(i[s]=n[s]);if("string"==typeof i.type&&t!==i.type)throw new Error("Type transform cannot be a string (type '"+i.type+"' for token '"+t+"')");var a=i.match;return i.match=Array.isArray(a)?a:a?[a]:[],i.match.sort((function(e,t){return r(e)&&r(t)?0:r(t)?-1:r(e)?1:t.length-e.length})),i}function l(e){return Array.isArray(e)?function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];if(r.include)for(var o=[].concat(r.include),i=0;i<o.length;i++)t.push({include:o[i]});else{if(!r.type)throw new Error("Rule has no type: "+JSON.stringify(r));t.push(a(r.type,r))}}return t}(e):function(e){for(var t=Object.getOwnPropertyNames(e),n=[],r=0;r<t.length;r++){var i=t[r],s=[].concat(e[i]);if("include"!==i){var l=[];s.forEach((function(e){o(e)?(l.length&&n.push(a(i,l)),n.push(a(i,e)),l=[]):l.push(e)})),l.length&&n.push(a(i,l))}else for(var u=0;u<s.length;u++)n.push({include:s[u]})}return n}(e)}var u=a("error",{lineBreaks:!0,shouldThrow:!0});function c(e,t){for(var o=null,a=Object.create(null),l=!0,c=null,f=[],p=[],h=0;h<e.length;h++)e[h].fallback&&(l=!1);for(h=0;h<e.length;h++){var m=e[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(!t)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(r(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=n&&!w?"ym":"gm",S=n||w?"":"|";return!0===c&&(x+="u"),{regexp:new RegExp(i(p)+S,x),groups:f,fast:a,error:o||u}}function f(e,t,n){var r=e&&(e.push||e.next);if(r&&!n[r])throw new Error("Missing state '"+r+"' (in token '"+e.defaultType+"' of state '"+t+"')");if(e&&e.pop&&1!=+e.pop)throw new Error("pop must be 1 (in token '"+e.defaultType+"' of state '"+t+"')")}var p=function(e,t){this.startState=t,this.states=e,this.buffer="",this.stack=[],this.reset()};p.prototype.reset=function(e,t){return this.buffer=e||"",this.index=0,this.line=t?t.line:1,this.col=t?t.col:1,this.queuedToken=t?t.queuedToken:null,this.queuedThrow=t?t.queuedThrow:null,this.setState(t?t.state:this.startState),this.stack=t&&t.stack?t.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(e){if(e&&this.state!==e){this.state=e;var t=this.states[e];this.groups=t.groups,this.error=t.error,this.re=t.regexp,this.fast=t.fast}},p.prototype.popState=function(){this.setState(this.stack.pop())},p.prototype.pushState=function(e){this.stack.push(this.state),this.setState(e)};var h=n?function(e,t){return e.exec(t)}:function(e,t){var n=e.exec(t);return 0===n[0].length?null:n};function m(){return this.value}if(p.prototype._getGroup=function(e){for(var t=this.groups.length,n=0;n<t;n++)if(void 0!==e[n+1])return this.groups[n];throw new Error("Cannot find token type for matched text")},p.prototype.next=function(){var e=this.index;if(this.queuedGroup){var t=this._token(this.queuedGroup,this.queuedText,e);return this.queuedGroup=null,this.queuedText="",t}var n=this.buffer;if(e!==n.length){if(s=this.fast[n.charCodeAt(e)])return this._token(s,n.charAt(e),e);var r=this.re;r.lastIndex=e;var o=h(r,n),i=this.error;if(null==o)return this._token(i,n.slice(e,n.length),e);var s=this._getGroup(o),a=o[0];return i.fallback&&o.index!==e?(this.queuedGroup=s,this.queuedText=a,this._token(i,n.slice(e,o.index),e)):this._token(s,a,e)}},p.prototype._token=function(e,t,n){var r=0;if(e.lineBreaks){var o=/\n/g,i=1;if("\n"===t)r=1;else for(;o.exec(t);)r++,i=o.lastIndex}var s={type:"function"==typeof e.type&&e.type(t)||e.defaultType,value:"function"==typeof e.value?e.value(t):t,text:t,toString:m,offset:n,lineBreaks:r,line:this.line,col:this.col},a=t.length;if(this.index+=a,this.line+=r,0!==r?this.col=a-i+1:this.col+=a,e.shouldThrow)throw new Error(this.formatError(s,"invalid syntax"));return e.pop?this.popState():e.push?this.pushState(e.push):e.next&&this.setState(e.next),s},"undefined"!=typeof Symbol&&Symbol.iterator){var y=function(e){this.lexer=e};y.prototype.next=function(){var e=this.lexer.next();return{value:e,done:!e}},y.prototype[Symbol.iterator]=function(){return this},p.prototype[Symbol.iterator]=function(){return new y(this)}}return p.prototype.formatError=function(e,t){if(null==e){var n=this.buffer.slice(this.index);e={text:n,offset:this.index,lineBreaks:-1===n.indexOf("\n")?0:1,line:this.line,col:this.col}}var r=Math.max(0,e.offset-e.col+1),o=e.lineBreaks?e.text.indexOf("\n"):e.text.length,i=this.buffer.substring(r,e.offset+o);return t+=" at line "+e.line+" col "+e.col+":\n\n",(t+=" "+i+"\n")+" "+Array(e.col).join(" ")+"^"},p.prototype.clone=function(){return new p(this.states,this.state)},p.prototype.has=function(e){return!0},{compile:function(e){var t=c(l(e));return new p({start:t},"start")},states:function(e,t){var n=e.$all?l(e.$all):[];delete e.$all;var r=Object.getOwnPropertyNames(e);t||(t=r[0]);for(var o=Object.create(null),i=0;i<r.length;i++)o[v=r[i]]=l(e[v]).concat(n);for(i=0;i<r.length;i++)for(var s=o[v=r[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<r.length;i++){var v;g[v=r[i]]=c(o[v],!0)}for(i=0;i<r.length;i++){var w=r[i],x=g[w],S=x.groups;for(u=0;u<S.length;u++)f(S[u],w,g);var $=Object.getOwnPropertyNames(x.fast);for(u=0;u<$.length;u++)f(x.fast[$[u]],w,g)}return new p(g,t)},error:Object.freeze({error:!0}),fallback:Object.freeze({fallback:!0}),keywords:function(e){for(var t=Object.create(null),n=Object.create(null),r=Object.getOwnPropertyNames(e),o=0;o<r.length;o++){var i=r[o],s=e[i];(Array.isArray(s)?s:[s]).forEach((function(e){if((n[e.length]=n[e.length]||[]).push(e),"string"!=typeof e)throw new Error("keyword must be string (in keyword '"+i+"')");t[e]=i}))}function a(e){return JSON.stringify(e)}var l="";for(var u in l+="switch (value.length) {\n",n)l+="case "+u+":\n",l+="switch (value) {\n",n[u].forEach((function(e){var n=t[e];l+="case "+a(e)+": return "+a(n)+"\n"})),l+="}\n";return l+="}\n",Function("value",l)}}},e.exports?e.exports=n():t.moo=n()})),ye=/[0-9a-zA-Z_@]+\b@*/,de=new RegExp("^"+ye.source+"$"),be={__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:ye,isValidIdentifier:function(e){return e&&de.test(e)}},ge=function(e){return!!e.type&&"path"===e.type},ve=function(e){return ge(e)&&void 0===e.children&&"ø"===e.id},we=function(e){return ge(e)&&e.children&&0===e.children.length&&"ø"!==e.id};function xe(){return(xe=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function Se(e){return Array.isArray(e)?e:e instanceof Function?Se(e()):void 0===e?[]:[e]}var $e=function(e,t,n,r){return xe({type:"seq",id:t},n&&{labels:n},r&&{record:r},{children:Se(e)})},Ee=function(e,t){void 0===t&&(t={});var n=xe({type:"path"},t.id&&{id:t.id},t.labels&&{labels:t.labels},t.record&&{record:t.record});if(void 0===e)return n.id&&"ø"!==n.id?(n.children=[],n):(n.children=void 0,ke);if(0===e.length)return"ø"===n.id?ke:(n.children=[],n);if(1===e.length){var r=e[0];return ve(r)?(n.children=[],n):(n.children=[r],n)}if(2===e.length){if(t.relation&&"pair"!==t.relation&&we(e[0])&&we(e[1]))return n.relation=t.relation,n.children=[e[0],e[1]],n;if(ve(e[0])&&ve(e[1]))return n.relation=t.relation,n.children=[],n;n.children=[e[0],e[1]]}return n.relation=t.relation||"pair",n},ke={type:"path",id:"ø",labels:void 0,record:void 0,children:void 0},Pe=function(){return ke},Oe=function(e,t,n){return xe({type:"path"},e&&{id:e},t&&{labels:t},n&&{record:n},{children:[]})},je=function(e,t,n,r,o){return xe({type:"path",id:n},r&&{labels:r},o&&{record:o},{relation:t,children:e})},_e=function(e,t,n,r){return xe({type:"path",id:t},n&&{labels:n},r&&{record:r},{children:e})},Ae=function(e){return e.reduce((function(e,t){return e[t.name]=t.value,e}),{})},Ce=function(e){return Object.entries(e).reduce((function(e,t){return e.push(Te(t[0],t[1])),e}),[])},Te=function(e,t){return{type:"property",name:e,value:t}},Re=function(e){return{type:"boolean",value:e?"true":"false"}},Le=function(e){return{type:"string",value:e}},qe=function(e,t){return{type:"tagged",value:t,tag:e}},Ne=function(e){return{type:"integer",value:String(e)}},Ie=function(e){return{type:"decimal",value:String(e)}},Be=function(e){return{type:"hexadecimal",value:"number"==typeof e?e.toString(16):e}},Ve=function(e){return{type:"octal",value:"number"==typeof e?e.toString(8):e}},Me=function(e,t){return{type:"measurement",value:String(t),unit:e}},ze=function(e){return qe("date",e instanceof Date?e.toISOString().slice(0,10):e)},Fe=function(e){return qe("time",e instanceof Date?e.toTimeString():e)},Ue=function(e){return qe("duration",e instanceof Date?"P"+(e.getUTCFullYear()-1970)+"Y"+e.getUTCMonth()+"M"+e.getUTCDate()+"DT"+e.getUTCHours()+"H"+e.getUTCMinutes()+"M"+e.getUTCMilliseconds()/1e3+"S":e)},Qe=function(e,t){return void 0===t&&(t=1),e.flat(t).filter((function(e){return null!==e}))},De={__proto__:null,seq:$e,reduce:function(e,t,n){return void 0===e&&(e="pair"),t.length>1?t.reduceRight((function(t,r){return Ee([r,t],{relation:e,id:n?""+n+0:void 0})}),ke):t[0]},cons:Ee,EMPTY_PATH:ke,empty:Pe,node:Oe,edge:je,path:_e,reduceRecord:Ae,unfoldProperties:Ce,property:Te,boolean:Re,string:Le,tagged:qe,integer:Ne,decimal:Ie,hexadecimal:Be,octal:Ve,measurement:Me,year:function(e){return qe("date",e instanceof Date?e.getFullYear().toString():e)},date:ze,dayOfMonth:function(e){return qe("date",e instanceof Date?"--"+e.toISOString().slice(5,10):e)},time:Fe,duration:Ue,flatten:Qe,default:{seq:$e,empty:Pe,cons:Ee,path:_e,node:Oe,edge:je,property:Te,boolean:Re,string:Le,tagged:qe,integer:Ne,decimal:Ie,hexadecimal:Be,octal:Ve,measurement:Me,date:ze,time:Fe,duration:Ue,flatten:Qe,reduceRecord:Ae,unfoldProperties:Ce}};function He(e){return e[0]}var Ge=me.compile({whitespace:{match:/\s+/,lineBreaks:!0},lineComment:{match:/\/\/.*?\n?$/},hexadecimal:be.hexadecimal,octal:be.octal,measurement:be.measurement,decimal:be.decimal,integer:be.integer,taggedString:{match:be.taggedString},boolean:["true","TRUE","True","false","FALSE","False"],symbol:be.symbol,identifier:be.identifier,doubleQuotedString:{match:be.doubleQuotedString,value:function(e){return e.slice(1,-1)}},singleQuotedString:{match:be.singleQuotedString,value:function(e){return e.slice(1,-1)}},tickedString:{match:be.tickedString,value:function(e){return e.slice(1,-1)}},"--\x3e":"--\x3e","--":"--","<--":"<--","-[]->":"-[]->","-[]-":"-[]-","<-[]-":"<-[]-","<-[":"<-[","]->":"]->","-[":"-[","]-":"]-","{":"{","}":"}","[":"[","]":"]","(":"(",")":")",",":",",":":":","`":"`","'":"'","ø":"ø"}),Je=function(){return null},Ze=function(e){return e[0].text},Ye={Lexer:Ge,ParserRules:[{name:"PathSequence$ebnf$1$subexpression$1$ebnf$1",symbols:[{literal:","}],postprocess:He},{name:"PathSequence$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:function(){return null}},{name:"PathSequence$ebnf$1$subexpression$1",symbols:["Path","PathSequence$ebnf$1$subexpression$1$ebnf$1","_"],postprocess:function(e){return e[0]}},{name:"PathSequence$ebnf$1",symbols:["PathSequence$ebnf$1$subexpression$1"]},{name:"PathSequence$ebnf$1$subexpression$2$ebnf$1",symbols:[{literal:","}],postprocess:He},{name:"PathSequence$ebnf$1$subexpression$2$ebnf$1",symbols:[],postprocess:function(){return null}},{name:"PathSequence$ebnf$1$subexpression$2",symbols:["Path","PathSequence$ebnf$1$subexpression$2$ebnf$1","_"],postprocess:function(e){return e[0]}},{name:"PathSequence$ebnf$1",symbols:["PathSequence$ebnf$1","PathSequence$ebnf$1$subexpression$2"],postprocess:function(e){return e[0].concat([e[1]])}},{name:"PathSequence$ebnf$2",symbols:["EOL"],postprocess:He},{name:"PathSequence$ebnf$2",symbols:[],postprocess:function(){return null}},{name:"PathSequence",symbols:["PathSequence$ebnf$1","PathSequence$ebnf$2"],postprocess:function(e){return De.seq(De.flatten(e[0]))}},{name:"Path",symbols:["NodePattern"],postprocess:He},{name:"Path",symbols:["PathComposition"],postprocess:He},{name:"Path",symbols:["Comment"],postprocess:He},{name:"NodePattern",symbols:["Node","Edge","NodePattern"],postprocess:function(e){var t=e[1];return De.cons([e[0],e[2]],{relation:t.relation,id:t.id,labels:t.labels,record:t.record})}},{name:"NodePattern",symbols:["Node"],postprocess:He},{name:"Node",symbols:[{literal:"("},"_","Attributes","_",{literal:")"}],postprocess:function(e){var t=e[2];return De.node(t.id,t.labels,t.record)}},{name:"Edge",symbols:[{literal:"-["},"_","Attributes",{literal:"]->"}],postprocess:function(e){return he({relation:"right"},e[2])}},{name:"Edge",symbols:[{literal:"-["},"_","Attributes",{literal:"]-"}],postprocess:function(e){return he({relation:"either"},e[2])}},{name:"Edge",symbols:[{literal:"<-["},"_","Attributes",{literal:"]-"}],postprocess:function(e){return he({relation:"left"},e[2])}},{name:"Edge",symbols:[{literal:"-[]->"}],postprocess:function(){return{relation:"right"}}},{name:"Edge",symbols:[{literal:"-[]-"}],postprocess:function(){return{relation:"either"}}},{name:"Edge",symbols:[{literal:"<-[]-"}],postprocess:function(){return{relation:"left"}}},{name:"Edge",symbols:[{literal:"--\x3e"}],postprocess:function(){return{relation:"right"}}},{name:"Edge",symbols:[{literal:"--"}],postprocess:function(){return{relation:"either"}}},{name:"Edge",symbols:[{literal:"<--"}],postprocess:function(){return{relation:"left"}}},{name:"PathComposition",symbols:[{literal:"["},"_",{literal:"]"}],postprocess:function(){return De.empty()}},{name:"PathComposition$ebnf$1",symbols:["Relation"],postprocess:He},{name:"PathComposition$ebnf$1",symbols:[],postprocess:function(){return null}},{name:"PathComposition$ebnf$2",symbols:["Path"],postprocess:He},{name:"PathComposition$ebnf$2",symbols:[],postprocess:function(){return null}},{name:"PathComposition$ebnf$3",symbols:["Path"],postprocess:He},{name:"PathComposition$ebnf$3",symbols:[],postprocess:function(){return null}},{name:"PathComposition",symbols:[{literal:"["},"_","Attributes","_","PathComposition$ebnf$1","_","PathComposition$ebnf$2","_","PathComposition$ebnf$3","_",{literal:"]"}],postprocess:function(e){var t=e[2],n=e[6],r=e[8];return De.cons(r?n?[n,r]:[r]:[],{relation:e[4],id:t.id,labels:t.labels,record:t.record})}},{name:"Relation",symbols:[{literal:","}],postprocess:function(){return"pair"}},{name:"Relation",symbols:[{literal:"--\x3e"}],postprocess:function(){return"right"}},{name:"Relation",symbols:[{literal:"--"}],postprocess:function(){return"either"}},{name:"Relation",symbols:[{literal:"<--"}],postprocess:function(){return"left"}},{name:"Attributes$ebnf$1",symbols:["Identity"],postprocess:He},{name:"Attributes$ebnf$1",symbols:[],postprocess:function(){return null}},{name:"Attributes$ebnf$2",symbols:["LabelList"],postprocess:He},{name:"Attributes$ebnf$2",symbols:[],postprocess:function(){return null}},{name:"Attributes$ebnf$3",symbols:["Record"],postprocess:He},{name:"Attributes$ebnf$3",symbols:[],postprocess:function(){return null}},{name:"Attributes",symbols:["Attributes$ebnf$1","_","Attributes$ebnf$2","_","Attributes$ebnf$3"],postprocess:function(e){return{id:e[0],labels:e[2],record:e[4]}}},{name:"LabelList$ebnf$1",symbols:["Label"]},{name:"LabelList$ebnf$1",symbols:["LabelList$ebnf$1","Label"],postprocess:function(e){return e[0].concat([e[1]])}},{name:"LabelList",symbols:["LabelList$ebnf$1"],postprocess:function(e){return e[0]}},{name:"Label",symbols:[{literal:":"},"Symbol"],postprocess:function(e){return e[1]}},{name:"Identity",symbols:[Ge.has("identifier")?{type:"identifier"}:identifier],postprocess:Ze},{name:"Identity",symbols:[{literal:"ø"}],postprocess:Ze},{name:"Identity",symbols:[Ge.has("symbol")?{type:"symbol"}:symbol],postprocess:Ze},{name:"Identity",symbols:[Ge.has("integer")?{type:"integer"}:integer],postprocess:Ze},{name:"Identity",symbols:[Ge.has("octal")?{type:"octal"}:octal],postprocess:Ze},{name:"Identity",symbols:[Ge.has("hexadecimal")?{type:"hexadecimal"}:hexadecimal],postprocess:Ze},{name:"Identity",symbols:[Ge.has("measurement")?{type:"measurement"}:measurement],postprocess:Ze},{name:"Identity",symbols:[Ge.has("tickedString")?{type:"tickedString"}:tickedString],postprocess:function(e){return e[0].text.slice(1,-1)}},{name:"Symbol",symbols:[Ge.has("symbol")?{type:"symbol"}:symbol],postprocess:Ze},{name:"Symbol",symbols:[Ge.has("tickedString")?{type:"tickedString"}:tickedString],postprocess:function(e){return e[0].text.slice(1,-1)}},{name:"Record",symbols:[{literal:"{"},"_",{literal:"}"}],postprocess:Je},{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(e){return e[0].concat([e[1]])}},{name:"Record",symbols:[{literal:"{"},"_","Property","Record$ebnf$1","_",{literal:"}"}],postprocess:function(e){return[e[2]].concat(e[3].map((function(e){return e[3]})))}},{name:"Property",symbols:["Symbol","_",{literal:":"},"_","Value"],postprocess:function(e){return De.property(e[0],e[4])}},{name:"Value",symbols:["StringLiteral"],postprocess:He},{name:"Value",symbols:["NumericLiteral"],postprocess:He},{name:"Value",symbols:[Ge.has("boolean")?{type:"boolean"}:boolean],postprocess:function(e){return De.boolean(JSON.parse(e[0].value.toLowerCase()))}},{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(e){return e[0].concat([e[1]])}},{name:"Value",symbols:[{literal:"["},"_","Value","Value$ebnf$1",{literal:"]"}],postprocess:function(e){return[e[2]].concat(e[3].map((function(e){return e[3]})))}},{name:"StringLiteral",symbols:[Ge.has("singleQuotedString")?{type:"singleQuotedString"}:singleQuotedString],postprocess:function(e){return De.string(e[0].value)}},{name:"StringLiteral",symbols:[Ge.has("doubleQuotedString")?{type:"doubleQuotedString"}:doubleQuotedString],postprocess:function(e){return De.string(e[0].value)}},{name:"StringLiteral",symbols:[Ge.has("tickedString")?{type:"tickedString"}:tickedString],postprocess:function(e){return De.string(e[0].value)}},{name:"StringLiteral",symbols:[Ge.has("taggedString")?{type:"taggedString"}:taggedString],postprocess:function(e){var t=function(e){var t=e.match(/([^`]+)`(.+)`$/);if(null==t)throw Error("Malformed tagged string: "+e);return{tag:t[1],value:t[2]}}(e[0].value);return De.tagged(t.tag,t.value)}},{name:"NumericLiteral",symbols:[Ge.has("integer")?{type:"integer"}:integer],postprocess:function(e){return De.integer(e[0].value)}},{name:"NumericLiteral",symbols:[Ge.has("decimal")?{type:"decimal"}:decimal],postprocess:function(e){return De.decimal(e[0].value)}},{name:"NumericLiteral",symbols:[Ge.has("hexadecimal")?{type:"hexadecimal"}:hexadecimal],postprocess:function(e){return De.hexadecimal(e[0].value)}},{name:"NumericLiteral",symbols:[Ge.has("octal")?{type:"octal"}:octal],postprocess:function(e){return De.octal(e[0].value)}},{name:"NumericLiteral",symbols:[Ge.has("measurement")?{type:"measurement"}:measurement],postprocess:function(e){var t=function(e){var t=e.match(/(-?[0-9.]+)([a-zA-Z]+)/);if(null==t)throw Error("Malformed measurement : "+e);return{value:t[1],unit:t[2]}}(e[0].value);return De.measurement(t.unit,t.value)}},{name:"_",symbols:[]},{name:"_",symbols:[Ge.has("whitespace")?{type:"whitespace"}:whitespace],postprocess:Je},{name:"Comment",symbols:[Ge.has("lineComment")?{type:"lineComment"}:lineComment],postprocess:Je},{name:"EOL",symbols:[{literal:"\n"}],postprocess:Je}],ParserStart:"PathSequence"},Xe=function(e,t){var n,r,o=new pe.Parser(pe.Grammar.fromCompiled(Ye));try{var i=o.feed(e);if(void 0===i.results[0]&&i.lexerState){var s={line:(r=i.lexerState).line,column:r.col};t.fail("Incomplete parse.",s)}return i.results[0]||{type:"error"}}catch(e){var a=e.token?{line:(n=e.token).line,column:n.col}:{line:0,column:0};t.fail(e.message,a)}},Ke=function(){this.Parser=Xe};e.errors={__proto__:null,INCOMPLETE_PARSE:"Incomplete parse.",SYNTAX_ERROR:"Syntax error at"},e.gramParserPlugin=Ke,e.toAST=function(e){return ne().use(Ke).freeze().parse(e)},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e=e||self).gram=e.gram||{},e.gram.parse={}))}(this,(function(e){"use strict";var t=function(e){if(e)throw e},n=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},r=Object.prototype.hasOwnProperty,o=Object.prototype.toString,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===o.call(e)},l=function(e){if(!e||"[object Object]"!==o.call(e))return!1;var t,n=r.call(e,"constructor"),i=e.constructor&&e.constructor.prototype&&r.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!i)return!1;for(t in e);return void 0===t||r.call(e,t)},u=function(e,t){i&&"__proto__"===t.name?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},c=function(e,t){if("__proto__"===t){if(!r.call(e,t))return;if(s)return s(e,t).value}return e[t]},f=function e(){var t,n,r,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!=(t=arguments[p]))for(n in t)r=c(f,n),f!==(o=c(t,n))&&(m&&o&&(l(o)||(i=a(o)))?(i?(i=!1,s=r&&a(r)?r:[]):s=r&&l(r)?r:{},u(f,{name:n,newValue:e(m,s,o)})):void 0!==o&&u(f,{name:n,newValue:o}));return f},p=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},h=[].slice,m=function(e,t){var n;return function(){var t,i=h.call(arguments,0),s=e.length>i.length;s&&i.push(r);try{t=e.apply(null,i)}catch(e){if(s&&n)throw e;return r(e)}s||(t&&"function"==typeof t.then?t.then(o,r):t instanceof Error?r(t):o(t))};function r(){n||(n=!0,t.apply(null,arguments))}function o(e){r(null,e)}},y=b;b.wrap=m;var d=[].slice;function b(){var e=[],t={run:function(){var t=-1,n=d.call(arguments,0,-1),r=arguments[arguments.length-1];if("function"!=typeof r)throw new Error("Expected function as last argument, not "+r);function o(i){var s=e[++t],a=d.call(arguments,0),l=a.slice(1),u=n.length,c=-1;if(i)r(i);else{for(;++c<u;)null==l[c]&&(l[c]=n[c]);n=l,s?m(s,o).apply(null,n):r.apply(null,[null].concat(n))}}o.apply(null,[null].concat(n))},use:function(n){if("function"!=typeof n)throw new Error("Expected `fn` to be a function, not "+n);return e.push(n),t}};return t}var g={}.hasOwnProperty,v=function(e){return e&&"object"==typeof e?g.call(e,"position")||g.call(e,"type")?x(e.position):g.call(e,"start")||g.call(e,"end")?x(e):g.call(e,"line")||g.call(e,"column")?w(e):"":""};function w(e){return e&&"object"==typeof e||(e={}),S(e.line)+":"+S(e.column)}function x(e){return e&&"object"==typeof e||(e={}),w(e.start)+"-"+w(e.end)}function S(e){return e&&"number"==typeof e?e:1}var $=P;function E(){}E.prototype=Error.prototype;var k=P.prototype=new E;function P(e,t,n){var r,o,i;"string"==typeof t&&(n=t,t=null),r=function(e){var t,n=[null,null];return"string"==typeof e&&(-1===(t=e.indexOf(":"))?n[1]=e:(n[0]=e.slice(0,t),n[1]=e.slice(t+1))),n}(n),o=v(t)||"1:1",i={start:{line:null,column:null},end:{line:null,column:null}},t&&t.position&&(t=t.position),t&&(t.start?(i=t,t=t.start):i.start=t),e.stack&&(this.stack=e.stack,e=e.message),this.message=e,this.name=o,this.reason=e,this.line=t?t.line:null,this.column=t?t.column:null,this.location=i,this.source=r[0],this.ruleId=r[1]}k.file="",k.name="",k.reason="",k.message="",k.stack="",k.fatal=null,k.column=null,k.line=null;var O="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function j(e,t){for(var n=0,r=e.length-1;r>=0;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}"function"==typeof O.setTimeout&&setTimeout,"function"==typeof O.clearTimeout&&clearTimeout,new Date;var _=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,A=function(e){return _.exec(e).slice(1)};function T(){for(var e="",t=!1,n=arguments.length-1;n>=-1&&!t;n--){var r=n>=0?arguments[n]:"/";if("string"!=typeof r)throw new TypeError("Arguments to path.resolve must be strings");r&&(e=r+"/"+e,t="/"===r.charAt(0))}return(t?"/":"")+(e=j(V(e.split("/"),(function(e){return!!e})),!t).join("/"))||"."}function C(e){var t=R(e),n="/"===z(e,-1);return(e=j(V(e.split("/"),(function(e){return!!e})),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e}function R(e){return"/"===e.charAt(0)}function L(){var e=Array.prototype.slice.call(arguments,0);return C(V(e,(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))}function q(e,t){function n(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=T(e).substr(1),t=T(t).substr(1);for(var r=n(e.split("/")),o=n(t.split("/")),i=Math.min(r.length,o.length),s=i,a=0;a<i;a++)if(r[a]!==o[a]){s=a;break}var l=[];for(a=s;a<r.length;a++)l.push("..");return(l=l.concat(o.slice(s))).join("/")}function N(e){var t=A(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."}function I(e,t){var n=A(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n}function B(e){return A(e)[3]}var M={extname:B,basename:I,dirname:N,sep:"/",delimiter:":",relative:q,join:L,isAbsolute:R,normalize:C,resolve:T};function V(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}var z="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return t<0&&(t=e.length+t),e.substr(t,n)},F="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function U(e,t){return e(t={exports:{}},t.exports),t.exports}var Q,D=(Q={__proto__:null,resolve:T,normalize:C,isAbsolute:R,join:L,relative:q,sep:"/",delimiter:":",dirname:N,basename:I,extname:B,default:M})&&Q.default||Q,H=Y,G={}.hasOwnProperty,J=Y.prototype,Z=["history","path","basename","stem","extname","dirname"];function Y(e){var t,r,o;if(e){if("string"==typeof e||n(e))e={contents:e};else if("message"in e&&"messages"in e)return e}else e={};if(!(this instanceof Y))return new Y(e);for(this.data={},this.messages=[],this.history=[],this.cwd="/",r=-1,o=Z.length;++r<o;)G.call(e,t=Z[r])&&(this[t]=e[t]);for(t in e)-1===Z.indexOf(t)&&(this[t]=e[t])}function X(e,t){if(-1!==e.indexOf(D.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+D.sep+"`")}function K(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function W(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}J.toString=function(e){var t=this.contents||"";return n(t)?t.toString(e):String(t)},Object.defineProperty(J,"path",{get:function(){return this.history[this.history.length-1]},set:function(e){K(e,"path"),e!==this.path&&this.history.push(e)}}),Object.defineProperty(J,"dirname",{get:function(){return"string"==typeof this.path?D.dirname(this.path):void 0},set:function(e){W(this.path,"dirname"),this.path=D.join(e||"",this.basename)}}),Object.defineProperty(J,"basename",{get:function(){return"string"==typeof this.path?D.basename(this.path):void 0},set:function(e){K(e,"basename"),X(e,"basename"),this.path=D.join(this.dirname||"",e)}}),Object.defineProperty(J,"extname",{get:function(){return"string"==typeof this.path?D.extname(this.path):void 0},set:function(e){var t=e||"";if(X(t,"extname"),W(this.path,"extname"),t){if("."!==t.charAt(0))throw new Error("`extname` must start with `.`");if(-1!==t.indexOf(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=function(e,t){if("string"!=typeof e)return e;if(0===e.length)return e;var n=D.basename(e,D.extname(e))+t;return D.join(D.dirname(e),n)}(this.path,t)}}),Object.defineProperty(J,"stem",{get:function(){return"string"==typeof this.path?D.basename(this.path,this.extname):void 0},set:function(e){K(e,"stem"),X(e,"stem"),this.path=D.join(this.dirname||"",e+(this.extname||""))}});var ee=H,te=H.prototype;te.message=function(e,t,n){var r=this.path,o=new $(e,t,n);return r&&(o.name=r+":"+o.name,o.file=r),o.fatal=!1,this.messages.push(o),o},te.info=function(){var e=this.message.apply(this,arguments);return e.fatal=null,e},te.fail=function(){var e=this.message.apply(this,arguments);throw e.fatal=!0,e};var ne=function e(){var n=[],r=y(),o={},i=!1,s=-1;return a.data=function(e,t){return"string"==typeof e?2===arguments.length?(ue("data",i),o[e]=t,a):oe.call(o,e)&&o[e]||null:e?(ue("data",i),o=e,a):o},a.freeze=l,a.attachers=n,a.use=function(e){var t;if(ue("use",i),null==e);else if("function"==typeof e)c.apply(null,arguments);else{if("object"!=typeof e)throw new Error("Expected usable value, not `"+e+"`");"length"in e?l(e):r(e)}return t&&(o.settings=f(o.settings||{},t)),a;function r(e){l(e.plugins),e.settings&&(t=f(t||{},e.settings))}function s(e){if("function"==typeof e)c(e);else{if("object"!=typeof e)throw new Error("Expected usable value, not `"+e+"`");"length"in e?c.apply(null,e):r(e)}}function l(e){var t,n;if(null==e);else{if("object"!=typeof e||!("length"in e))throw new Error("Expected a list of plugins, not `"+e+"`");for(t=e.length,n=-1;++n<t;)s(e[n])}}function c(e,t){var r=u(e);r?(p(r[1])&&p(t)&&(t=f(r[1],t)),r[1]=t):n.push(re.call(arguments))}},a.parse=function(e){var t,n=ee(e);return l(),ae("parse",t=a.Parser),se(t,"parse")?new t(String(n),n).parse():t(String(n),n)},a.stringify=function(e,t){var n,r=ee(t);return l(),le("stringify",n=a.Compiler),ce(e),se(n,"compile")?new n(e,r).compile():n(e,r)},a.run=c,a.runSync=function(e,n){var r,o=!1;return c(e,n,(function(e,n){o=!0,t(e),r=n})),fe("runSync","run",o),r},a.process=h,a.processSync=function(e){var n,r=!1;return l(),ae("processSync",a.Parser),le("processSync",a.Compiler),h(n=ee(e),(function(e){r=!0,t(e)})),fe("processSync","process",r),n},a;function a(){for(var t=e(),r=n.length,i=-1;++i<r;)t.use.apply(null,n[i]);return t.data(f(!0,{},o)),t}function l(){var e,t,o,l;if(i)return a;for(;++s<n.length;)t=(e=n[s])[0],!1!==(o=e[1])&&(!0===o&&(e[1]=void 0),"function"==typeof(l=t.apply(a,e.slice(1)))&&r.use(l));return i=!0,s=Infinity,a}function u(e){for(var t,r=n.length,o=-1;++o<r;)if((t=n[o])[0]===e)return t}function c(e,t,n){if(ce(e),l(),n||"function"!=typeof t||(n=t,t=null),!n)return new Promise(o);function o(o,i){r.run(e,ee(t),(function(t,r,s){r=r||e,t?i(t):o?o(r):n(null,r,s)}))}o(null,n)}function h(e,t){if(l(),ae("process",a.Parser),le("process",a.Compiler),!t)return new Promise(n);function n(n,r){var o=ee(e);ie.run(a,{file:o},(function(e){e?r(e):n?n(o):t(null,o)}))}n(null,t)}}().freeze(),re=[].slice,oe={}.hasOwnProperty,ie=y().use((function(e,t){t.tree=e.parse(t.file)})).use((function(e,t,n){e.run(t.tree,t.file,(function(e,r,o){e?n(e):(t.tree=r,t.file=o,n())}))})).use((function(e,t){var r=e.stringify(t.tree,t.file),o=t.file;null==r||("string"==typeof r||n(r)?o.contents=r:o.result=r)}));function se(e,t){return"function"==typeof e&&e.prototype&&(function(e){var t;for(t in e)return!0;return!1}(e.prototype)||t in e.prototype)}function ae(e,t){if("function"!=typeof t)throw new Error("Cannot `"+e+"` without `Parser`")}function le(e,t){if("function"!=typeof t)throw new Error("Cannot `"+e+"` without `Compiler`")}function ue(e,t){if(t)throw new Error("Cannot invoke `"+e+"` on a frozen processor.\nCreate a new processor first, by invoking it: use `processor()` instead of `processor`.")}function ce(e){if(!e||"string"!=typeof e.type)throw new Error("Expected node, got `"+e+"`")}function fe(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}var pe=U((function(e){var t,n;t=F,n=function(){function e(t,n,r){return this.id=++e.highestId,this.name=t,this.symbols=n,this.postprocess=r,this}function t(e,t,n,r){this.rule=e,this.dot=t,this.reference=n,this.data=[],this.wantedBy=r,this.isComplete=this.dot===e.symbols.length}function n(e,t){this.grammar=e,this.index=t,this.states=[],this.wants={},this.scannable=[],this.completed={}}function r(e,t){this.rules=e,this.start=t||this.rules[0].name;var n=this.byName={};this.rules.forEach((function(e){n.hasOwnProperty(e.name)||(n[e.name]=[]),n[e.name].push(e)}))}function o(){this.reset("")}function i(e,t,i){if(e instanceof r){var s=e;i=t}else s=r.fromCompiled(e,t);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 n(s,0);this.table=[l],l.wants[s.start]=[],l.predict(s.start),l.process(),this.current=0}function s(e){var t=typeof e;if("string"===t)return e;if("object"===t){if(e.literal)return JSON.stringify(e.literal);if(e instanceof RegExp)return e.toString();if(e.type)return"%"+e.type;if(e.test)return"<"+String(e.test)+">";throw new Error("Unknown symbol type: "+e)}}return e.highestId=0,e.prototype.toString=function(e){var t=void 0===e?this.symbols.map(s).join(" "):this.symbols.slice(0,e).map(s).join(" ")+" ● "+this.symbols.slice(e).map(s).join(" ");return this.name+" → "+t},t.prototype.toString=function(){return"{"+this.rule.toString(this.dot)+"}, from: "+(this.reference||0)},t.prototype.nextState=function(e){var n=new t(this.rule,this.dot+1,this.reference,this.wantedBy);return n.left=this,n.right=e,n.isComplete&&(n.data=n.build(),n.right=void 0),n},t.prototype.build=function(){var e=[],t=this;do{e.push(t.right.data),t=t.left}while(t.left);return e.reverse(),e},t.prototype.finish=function(){this.rule.postprocess&&(this.data=this.rule.postprocess(this.data,this.reference,i.fail))},n.prototype.process=function(e){for(var t=this.states,n=this.wants,r=this.completed,o=0;o<t.length;o++){var s=t[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(n[u]){if(n[u].push(s),r.hasOwnProperty(u)){var c=r[u];for(l=0;l<c.length;l++)this.complete(s,c[l])}}else n[u]=[s],this.predict(u)}}},n.prototype.predict=function(e){for(var n=this.grammar.byName[e]||[],r=0;r<n.length;r++){var o=new t(n[r],0,this.index,this.wants[e]);this.states.push(o)}},n.prototype.complete=function(e,t){var n=e.nextState(t);this.states.push(n)},r.fromCompiled=function(t,n){var o=t.Lexer;t.ParserStart&&(n=t.ParserStart,t=t.ParserRules);var i=new r(t=t.map((function(t){return new e(t.name,t.symbols,t.postprocess)})),n);return i.lexer=o,i},o.prototype.reset=function(e,t){this.buffer=e,this.index=0,this.line=t?t.line:1,this.lastLineBreak=t?-t.col:0},o.prototype.next=function(){if(this.index<this.buffer.length){var e=this.buffer[this.index++];return"\n"===e&&(this.line+=1,this.lastLineBreak=this.index),{value:e}}},o.prototype.save=function(){return{line:this.line,col:this.index-this.lastLineBreak}},o.prototype.formatError=function(e,t){var n=this.buffer;if("string"==typeof n){var r=n.split("\n").slice(Math.max(0,this.line-5),this.line),o=n.indexOf("\n",this.index);-1===o&&(o=n.length);var i=this.index-this.lastLineBreak,s=String(this.line).length;return t+=" at line "+this.line+" col "+i+":\n\n",(t+=r.map((function(e,t){return a(this.line-r.length+t+1,s)+" "+e}),this).join("\n"))+"\n"+a("",s+i)+"^\n"}return t+" at index "+(this.index-1);function a(e,t){var n=String(e);return Array(t-n.length+1).join(" ")+n}},i.fail={},i.prototype.feed=function(e){var t,r=this.lexer;for(r.reset(e,this.lexerState);;){try{if(!(t=r.next()))break}catch(e){var i=new n(this.grammar,this.current+1);throw this.table.push(i),(l=new Error(this.reportLexerError(e))).offset=this.current,l.token=e.token,l}var s=this.table[this.current];this.options.keepHistory||delete this.table[this.current-1];var a=this.current+1;i=new n(this.grammar,a),this.table.push(i);for(var l,u=void 0!==t.text?t.text:t.value,c=r.constructor===o?t.value:t,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===t.type:m.literal===u){var y=h.nextState({data:c,token:t,isToken:!0,reference:a-1});i.states.push(y)}}if(i.process(),0===i.states.length)throw(l=new Error(this.reportError(t))).offset=this.current,l.token=t,l;this.options.keepHistory&&(s.lexerState=r.save()),this.current++}return s&&(this.lexerState=r.save()),this.results=this.finish(),this},i.prototype.reportLexerError=function(e){var t,n,r=e.token;return r?(t="input "+JSON.stringify(r.text[0])+" (lexer error)",n=this.lexer.formatError(r,"Syntax error")):(t="input (lexer error)",n=e.message),this.reportErrorCommon(n,t)},i.prototype.reportError=function(e){var t=(e.type?e.type+" token: ":"")+JSON.stringify(void 0!==e.value?e.value:e),n=this.lexer.formatError(e,"Syntax error");return this.reportErrorCommon(n,t)},i.prototype.reportErrorCommon=function(e,t){var n=[];n.push(e);var r=this.table[this.table.length-2],o=r.states.filter((function(e){var t=e.rule.symbols[e.dot];return t&&"string"!=typeof t}));return 0===o.length?(n.push("Unexpected "+t+". I did not expect any more input. Here is the state of my parse table:\n"),this.displayStateStack(r.states,n)):(n.push("Unexpected "+t+". Instead, I was expecting to see one of the following:\n"),o.map((function(e){return this.buildFirstStateStack(e,[])||[e]}),this).forEach((function(e){var t=e[0],r=this.getSymbolDisplay(t.rule.symbols[t.dot]);n.push("A "+r+" based on:"),this.displayStateStack(e,n)}),this)),n.push(""),n.join("\n")},i.prototype.displayStateStack=function(e,t){for(var n,r=0,o=0;o<e.length;o++){var i=e[o],s=i.rule.toString(i.dot);s===n?r++:(r>0&&t.push(" ^ "+r+" more lines identical to this"),r=0,t.push(" "+s)),n=s}},i.prototype.getSymbolDisplay=function(e){return function(e){var t=typeof e;if("string"===t)return e;if("object"===t){if(e.literal)return JSON.stringify(e.literal);if(e instanceof RegExp)return"character matching "+e;if(e.type)return e.type+" token";if(e.test)return"token matching "+String(e.test);throw new Error("Unknown symbol type: "+e)}}(e)},i.prototype.buildFirstStateStack=function(e,t){if(-1!==t.indexOf(e))return null;if(0===e.wantedBy.length)return[e];var n=e.wantedBy[0],r=[e].concat(t),o=this.buildFirstStateStack(n,r);return null===o?null:[e].concat(o)},i.prototype.save=function(){var e=this.table[this.current];return e.lexerState=this.lexerState,e},i.prototype.restore=function(e){var t=e.index;this.current=t,this.table[t]=e,this.table.splice(t+1),this.lexerState=e.lexerState,this.results=this.finish()},i.prototype.rewind=function(e){if(!this.options.keepHistory)throw new Error("set option `keepHistory` to enable rewinding");this.restore(this.table[e])},i.prototype.finish=function(){var e=[],t=this.grammar.start;return this.table[this.table.length-1].states.forEach((function(n){n.rule.name===t&&n.dot===n.rule.symbols.length&&0===n.reference&&n.data!==i.fail&&e.push(n)})),e.map((function(e){return e.data}))},{Parser:i,Grammar:r,Rule:e}},e.exports?e.exports=n():t.nearley=n()}));function he(){return(he=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var me=U((function(e){var t,n;t=F,n=function(){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n="boolean"==typeof(new RegExp).sticky;function r(e){return e&&"[object RegExp]"===t.call(e)}function o(e){return e&&"object"==typeof e&&!r(e)&&!Array.isArray(e)}function i(e){return e.length?"(?:"+e.map((function(e){return"(?:"+e+")"})).join("|")+")":"(?!)"}function s(e){if("string"==typeof e)return"(?:"+e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")+")";if(r(e)){if(e.ignoreCase)throw new Error("RegExp /i flag not allowed");if(e.global)throw new Error("RegExp /g flag is implied");if(e.sticky)throw new Error("RegExp /y flag is implied");if(e.multiline)throw new Error("RegExp /m flag is implied");return e.source}throw new Error("Not a pattern: "+e)}function a(t,n){if(o(n)||(n={match:n}),n.include)throw new Error("Matching rules cannot also include states");var i={defaultType:t,lineBreaks:!!n.error||!!n.fallback,pop:!1,next:null,push:null,error:!1,fallback:!1,value:null,type:null,shouldThrow:!1};for(var s in n)e.call(n,s)&&(i[s]=n[s]);if("string"==typeof i.type&&t!==i.type)throw new Error("Type transform cannot be a string (type '"+i.type+"' for token '"+t+"')");var a=i.match;return i.match=Array.isArray(a)?a:a?[a]:[],i.match.sort((function(e,t){return r(e)&&r(t)?0:r(t)?-1:r(e)?1:t.length-e.length})),i}function l(e){return Array.isArray(e)?function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];if(r.include)for(var o=[].concat(r.include),i=0;i<o.length;i++)t.push({include:o[i]});else{if(!r.type)throw new Error("Rule has no type: "+JSON.stringify(r));t.push(a(r.type,r))}}return t}(e):function(e){for(var t=Object.getOwnPropertyNames(e),n=[],r=0;r<t.length;r++){var i=t[r],s=[].concat(e[i]);if("include"!==i){var l=[];s.forEach((function(e){o(e)?(l.length&&n.push(a(i,l)),n.push(a(i,e)),l=[]):l.push(e)})),l.length&&n.push(a(i,l))}else for(var u=0;u<s.length;u++)n.push({include:s[u]})}return n}(e)}var u=a("error",{lineBreaks:!0,shouldThrow:!0});function c(e,t){for(var o=null,a=Object.create(null),l=!0,c=null,f=[],p=[],h=0;h<e.length;h++)e[h].fallback&&(l=!1);for(h=0;h<e.length;h++){var m=e[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(!t)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(r(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=n&&!w?"ym":"gm",S=n||w?"":"|";return!0===c&&(x+="u"),{regexp:new RegExp(i(p)+S,x),groups:f,fast:a,error:o||u}}function f(e,t,n){var r=e&&(e.push||e.next);if(r&&!n[r])throw new Error("Missing state '"+r+"' (in token '"+e.defaultType+"' of state '"+t+"')");if(e&&e.pop&&1!=+e.pop)throw new Error("pop must be 1 (in token '"+e.defaultType+"' of state '"+t+"')")}var p=function(e,t){this.startState=t,this.states=e,this.buffer="",this.stack=[],this.reset()};p.prototype.reset=function(e,t){return this.buffer=e||"",this.index=0,this.line=t?t.line:1,this.col=t?t.col:1,this.queuedToken=t?t.queuedToken:null,this.queuedThrow=t?t.queuedThrow:null,this.setState(t?t.state:this.startState),this.stack=t&&t.stack?t.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(e){if(e&&this.state!==e){this.state=e;var t=this.states[e];this.groups=t.groups,this.error=t.error,this.re=t.regexp,this.fast=t.fast}},p.prototype.popState=function(){this.setState(this.stack.pop())},p.prototype.pushState=function(e){this.stack.push(this.state),this.setState(e)};var h=n?function(e,t){return e.exec(t)}:function(e,t){var n=e.exec(t);return 0===n[0].length?null:n};function m(){return this.value}if(p.prototype._getGroup=function(e){for(var t=this.groups.length,n=0;n<t;n++)if(void 0!==e[n+1])return this.groups[n];throw new Error("Cannot find token type for matched text")},p.prototype.next=function(){var e=this.index;if(this.queuedGroup){var t=this._token(this.queuedGroup,this.queuedText,e);return this.queuedGroup=null,this.queuedText="",t}var n=this.buffer;if(e!==n.length){if(s=this.fast[n.charCodeAt(e)])return this._token(s,n.charAt(e),e);var r=this.re;r.lastIndex=e;var o=h(r,n),i=this.error;if(null==o)return this._token(i,n.slice(e,n.length),e);var s=this._getGroup(o),a=o[0];return i.fallback&&o.index!==e?(this.queuedGroup=s,this.queuedText=a,this._token(i,n.slice(e,o.index),e)):this._token(s,a,e)}},p.prototype._token=function(e,t,n){var r=0;if(e.lineBreaks){var o=/\n/g,i=1;if("\n"===t)r=1;else for(;o.exec(t);)r++,i=o.lastIndex}var s={type:"function"==typeof e.type&&e.type(t)||e.defaultType,value:"function"==typeof e.value?e.value(t):t,text:t,toString:m,offset:n,lineBreaks:r,line:this.line,col:this.col},a=t.length;if(this.index+=a,this.line+=r,0!==r?this.col=a-i+1:this.col+=a,e.shouldThrow)throw new Error(this.formatError(s,"invalid syntax"));return e.pop?this.popState():e.push?this.pushState(e.push):e.next&&this.setState(e.next),s},"undefined"!=typeof Symbol&&Symbol.iterator){var y=function(e){this.lexer=e};y.prototype.next=function(){var e=this.lexer.next();return{value:e,done:!e}},y.prototype[Symbol.iterator]=function(){return this},p.prototype[Symbol.iterator]=function(){return new y(this)}}return p.prototype.formatError=function(e,t){if(null==e){var n=this.buffer.slice(this.index);e={text:n,offset:this.index,lineBreaks:-1===n.indexOf("\n")?0:1,line:this.line,col:this.col}}var r=Math.max(0,e.offset-e.col+1),o=e.lineBreaks?e.text.indexOf("\n"):e.text.length,i=this.buffer.substring(r,e.offset+o);return t+=" at line "+e.line+" col "+e.col+":\n\n",(t+=" "+i+"\n")+" "+Array(e.col).join(" ")+"^"},p.prototype.clone=function(){return new p(this.states,this.state)},p.prototype.has=function(e){return!0},{compile:function(e){var t=c(l(e));return new p({start:t},"start")},states:function(e,t){var n=e.$all?l(e.$all):[];delete e.$all;var r=Object.getOwnPropertyNames(e);t||(t=r[0]);for(var o=Object.create(null),i=0;i<r.length;i++)o[v=r[i]]=l(e[v]).concat(n);for(i=0;i<r.length;i++)for(var s=o[v=r[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<r.length;i++){var v;g[v=r[i]]=c(o[v],!0)}for(i=0;i<r.length;i++){var w=r[i],x=g[w],S=x.groups;for(u=0;u<S.length;u++)f(S[u],w,g);var $=Object.getOwnPropertyNames(x.fast);for(u=0;u<$.length;u++)f(x.fast[$[u]],w,g)}return new p(g,t)},error:Object.freeze({error:!0}),fallback:Object.freeze({fallback:!0}),keywords:function(e){for(var t=Object.create(null),n=Object.create(null),r=Object.getOwnPropertyNames(e),o=0;o<r.length;o++){var i=r[o],s=e[i];(Array.isArray(s)?s:[s]).forEach((function(e){if((n[e.length]=n[e.length]||[]).push(e),"string"!=typeof e)throw new Error("keyword must be string (in keyword '"+i+"')");t[e]=i}))}function a(e){return JSON.stringify(e)}var l="";for(var u in l+="switch (value.length) {\n",n)l+="case "+u+":\n",l+="switch (value) {\n",n[u].forEach((function(e){var n=t[e];l+="case "+a(e)+": return "+a(n)+"\n"})),l+="}\n";return l+="}\n",Function("value",l)}}},e.exports?e.exports=n():t.moo=n()})),ye=/[0-9a-zA-Z_@]+\b@*/,de=new RegExp("^"+ye.source+"$"),be={__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:ye,isValidIdentifier:function(e){return e&&de.test(e)}},ge=function(e){return!!e.type&&"path"===e.type},ve=function(e){return ge(e)&&void 0===e.children&&"ø"===e.id},we=function(e){return ge(e)&&e.children&&0===e.children.length&&"ø"!==e.id};function xe(){return(xe=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function Se(e){return Array.isArray(e)?e:e instanceof Function?Se(e()):void 0===e?[]:[e]}var $e=function(e,t,n,r){return xe({type:"seq",id:t},n&&{labels:n},r&&{record:r},{children:Se(e)})},Ee=function(e,t){void 0===t&&(t={});var n=xe({type:"path"},t.id&&{id:t.id},t.labels&&{labels:t.labels},t.record&&{record:t.record});if(void 0===e)return n.id&&"ø"!==n.id?(n.children=[],n):(n.children=void 0,ke);if(0===e.length)return"ø"===n.id?ke:(n.children=[],n);if(1===e.length){var r=e[0];return ve(r)?(n.children=[],n):(n.children=[r],n)}if(2===e.length){if(t.relation&&"pair"!==t.relation&&we(e[0])&&we(e[1]))return n.relation=t.relation,n.children=[e[0],e[1]],n;if(ve(e[0])&&ve(e[1]))return n.relation=t.relation,n.children=[],n;n.children=[e[0],e[1]]}return n.relation=t.relation||"pair",n},ke={type:"path",id:"ø",labels:void 0,record:void 0,children:void 0},Pe=function(){return ke},Oe=function(e,t,n){return xe({type:"path"},e&&{id:e},t&&{labels:t},n&&{record:n},{children:[]})},je=function(e,t,n,r,o){return xe({type:"path",id:n},r&&{labels:r},o&&{record:o},{relation:t,children:e})},_e=function(e,t,n,r){return xe({type:"path",id:t},n&&{labels:n},r&&{record:r},{children:e})},Ae=function(e){return e.reduce((function(e,t){return e[t.name]=t.value,e}),{})},Te=function(e){return Object.entries(e).reduce((function(e,t){return e.push(Ce(t[0],t[1])),e}),[])},Ce=function(e,t){return{type:"property",name:e,value:t}},Re=function(e){return{type:"boolean",value:e?"true":"false"}},Le=function(e){return{type:"string",value:e}},qe=function(e,t){return{type:"tagged",value:t,tag:e}},Ne=function(e){return{type:"integer",value:String(e)}},Ie=function(e){return{type:"decimal",value:String(e)}},Be=function(e){return{type:"hexadecimal",value:"number"==typeof e?e.toString(16):e}},Me=function(e){return{type:"octal",value:"number"==typeof e?e.toString(8):e}},Ve=function(e,t){return{type:"measurement",value:String(t),unit:e}},ze=function(e){return qe("date",e instanceof Date?e.toISOString().slice(0,10):e)},Fe=function(e){return qe("time",e instanceof Date?e.toTimeString():e)},Ue=function(e){return qe("duration",e instanceof Date?"P"+(e.getUTCFullYear()-1970)+"Y"+e.getUTCMonth()+"M"+e.getUTCDate()+"DT"+e.getUTCHours()+"H"+e.getUTCMinutes()+"M"+e.getUTCMilliseconds()/1e3+"S":e)},Qe=function(e,t){return void 0===t&&(t=1),e.flat(t).filter((function(e){return null!==e}))},De={__proto__:null,seq:$e,reduce:function(e,t,n){return void 0===e&&(e="pair"),t.length>1?t.reduceRight((function(t,r){return Ee([r,t],{relation:e,id:n?""+n+0:void 0})}),ke):t[0]},cons:Ee,EMPTY_PATH:ke,empty:Pe,node:Oe,edge:je,path:_e,recordToMap:Ae,mapToRecord:Te,pluck:function(e,t){return e.reduce((function(e,n){return n.name===t?n:e}))},property:Ce,boolean:Re,string:Le,tagged:qe,integer:Ne,decimal:Ie,hexadecimal:Be,octal:Me,measurement:Ve,year:function(e){return qe("date",e instanceof Date?e.getFullYear().toString():e)},date:ze,dayOfMonth:function(e){return qe("date",e instanceof Date?"--"+e.toISOString().slice(5,10):e)},time:Fe,duration:Ue,flatten:Qe,default:{seq:$e,empty:Pe,cons:Ee,path:_e,node:Oe,edge:je,property:Ce,boolean:Re,string:Le,tagged:qe,integer:Ne,decimal:Ie,hexadecimal:Be,octal:Me,measurement:Ve,date:ze,time:Fe,duration:Ue,flatten:Qe,recordToMap:Ae,mapToRecord:Te}};function He(e){return e[0]}var Ge=me.compile({whitespace:{match:/\s+/,lineBreaks:!0},lineComment:{match:/\/\/.*?\n?$/},hexadecimal:be.hexadecimal,octal:be.octal,measurement:be.measurement,decimal:be.decimal,integer:be.integer,taggedString:{match:be.taggedString},boolean:["true","TRUE","True","false","FALSE","False"],symbol:be.symbol,identifier:be.identifier,doubleQuotedString:{match:be.doubleQuotedString,value:function(e){return e.slice(1,-1)}},singleQuotedString:{match:be.singleQuotedString,value:function(e){return e.slice(1,-1)}},tickedString:{match:be.tickedString,value:function(e){return e.slice(1,-1)}},"--\x3e":"--\x3e","--":"--","<--":"<--","-[]->":"-[]->","-[]-":"-[]-","<-[]-":"<-[]-","<-[":"<-[","]->":"]->","-[":"-[","]-":"]-","{":"{","}":"}","[":"[","]":"]","(":"(",")":")",",":",",":":":","`":"`","'":"'","ø":"ø"}),Je=function(){return null},Ze=function(e){return e[0].text},Ye={Lexer:Ge,ParserRules:[{name:"PathSequence$ebnf$1$subexpression$1$ebnf$1",symbols:[{literal:","}],postprocess:He},{name:"PathSequence$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:function(){return null}},{name:"PathSequence$ebnf$1$subexpression$1",symbols:["Path","PathSequence$ebnf$1$subexpression$1$ebnf$1","_"],postprocess:function(e){return e[0]}},{name:"PathSequence$ebnf$1",symbols:["PathSequence$ebnf$1$subexpression$1"]},{name:"PathSequence$ebnf$1$subexpression$2$ebnf$1",symbols:[{literal:","}],postprocess:He},{name:"PathSequence$ebnf$1$subexpression$2$ebnf$1",symbols:[],postprocess:function(){return null}},{name:"PathSequence$ebnf$1$subexpression$2",symbols:["Path","PathSequence$ebnf$1$subexpression$2$ebnf$1","_"],postprocess:function(e){return e[0]}},{name:"PathSequence$ebnf$1",symbols:["PathSequence$ebnf$1","PathSequence$ebnf$1$subexpression$2"],postprocess:function(e){return e[0].concat([e[1]])}},{name:"PathSequence$ebnf$2",symbols:["EOL"],postprocess:He},{name:"PathSequence$ebnf$2",symbols:[],postprocess:function(){return null}},{name:"PathSequence",symbols:["PathSequence$ebnf$1","PathSequence$ebnf$2"],postprocess:function(e){return De.seq(De.flatten(e[0]))}},{name:"Path",symbols:["NodePattern"],postprocess:He},{name:"Path",symbols:["PathComposition"],postprocess:He},{name:"Path",symbols:["Comment"],postprocess:He},{name:"NodePattern",symbols:["Node","Edge","NodePattern"],postprocess:function(e){var t=e[1];return De.cons([e[0],e[2]],{relation:t.relation,id:t.id,labels:t.labels,record:t.record})}},{name:"NodePattern",symbols:["Node"],postprocess:He},{name:"Node",symbols:[{literal:"("},"_","Attributes","_",{literal:")"}],postprocess:function(e){var t=e[2];return De.node(t.id,t.labels,t.record)}},{name:"Edge",symbols:[{literal:"-["},"_","Attributes",{literal:"]->"}],postprocess:function(e){return he({relation:"right"},e[2])}},{name:"Edge",symbols:[{literal:"-["},"_","Attributes",{literal:"]-"}],postprocess:function(e){return he({relation:"either"},e[2])}},{name:"Edge",symbols:[{literal:"<-["},"_","Attributes",{literal:"]-"}],postprocess:function(e){return he({relation:"left"},e[2])}},{name:"Edge",symbols:[{literal:"-[]->"}],postprocess:function(){return{relation:"right"}}},{name:"Edge",symbols:[{literal:"-[]-"}],postprocess:function(){return{relation:"either"}}},{name:"Edge",symbols:[{literal:"<-[]-"}],postprocess:function(){return{relation:"left"}}},{name:"Edge",symbols:[{literal:"--\x3e"}],postprocess:function(){return{relation:"right"}}},{name:"Edge",symbols:[{literal:"--"}],postprocess:function(){return{relation:"either"}}},{name:"Edge",symbols:[{literal:"<--"}],postprocess:function(){return{relation:"left"}}},{name:"PathComposition",symbols:[{literal:"["},"_",{literal:"]"}],postprocess:function(){return De.empty()}},{name:"PathComposition$ebnf$1",symbols:["Relation"],postprocess:He},{name:"PathComposition$ebnf$1",symbols:[],postprocess:function(){return null}},{name:"PathComposition$ebnf$2",symbols:["Path"],postprocess:He},{name:"PathComposition$ebnf$2",symbols:[],postprocess:function(){return null}},{name:"PathComposition$ebnf$3",symbols:["Path"],postprocess:He},{name:"PathComposition$ebnf$3",symbols:[],postprocess:function(){return null}},{name:"PathComposition",symbols:[{literal:"["},"_","Attributes","_","PathComposition$ebnf$1","_","PathComposition$ebnf$2","_","PathComposition$ebnf$3","_",{literal:"]"}],postprocess:function(e){var t=e[2],n=e[6],r=e[8];return De.cons(r?n?[n,r]:[r]:[],{relation:e[4],id:t.id,labels:t.labels,record:t.record})}},{name:"Relation",symbols:[{literal:","}],postprocess:function(){return"pair"}},{name:"Relation",symbols:[{literal:"--\x3e"}],postprocess:function(){return"right"}},{name:"Relation",symbols:[{literal:"--"}],postprocess:function(){return"either"}},{name:"Relation",symbols:[{literal:"<--"}],postprocess:function(){return"left"}},{name:"Attributes$ebnf$1",symbols:["Identity"],postprocess:He},{name:"Attributes$ebnf$1",symbols:[],postprocess:function(){return null}},{name:"Attributes$ebnf$2",symbols:["LabelList"],postprocess:He},{name:"Attributes$ebnf$2",symbols:[],postprocess:function(){return null}},{name:"Attributes$ebnf$3",symbols:["Record"],postprocess:He},{name:"Attributes$ebnf$3",symbols:[],postprocess:function(){return null}},{name:"Attributes",symbols:["Attributes$ebnf$1","_","Attributes$ebnf$2","_","Attributes$ebnf$3"],postprocess:function(e){return{id:e[0],labels:e[2],record:e[4]}}},{name:"LabelList$ebnf$1",symbols:["Label"]},{name:"LabelList$ebnf$1",symbols:["LabelList$ebnf$1","Label"],postprocess:function(e){return e[0].concat([e[1]])}},{name:"LabelList",symbols:["LabelList$ebnf$1"],postprocess:function(e){return e[0]}},{name:"Label",symbols:[{literal:":"},"Symbol"],postprocess:function(e){return e[1]}},{name:"Identity",symbols:[Ge.has("identifier")?{type:"identifier"}:identifier],postprocess:Ze},{name:"Identity",symbols:[{literal:"ø"}],postprocess:Ze},{name:"Identity",symbols:[Ge.has("symbol")?{type:"symbol"}:symbol],postprocess:Ze},{name:"Identity",symbols:[Ge.has("integer")?{type:"integer"}:integer],postprocess:Ze},{name:"Identity",symbols:[Ge.has("octal")?{type:"octal"}:octal],postprocess:Ze},{name:"Identity",symbols:[Ge.has("hexadecimal")?{type:"hexadecimal"}:hexadecimal],postprocess:Ze},{name:"Identity",symbols:[Ge.has("measurement")?{type:"measurement"}:measurement],postprocess:Ze},{name:"Identity",symbols:[Ge.has("tickedString")?{type:"tickedString"}:tickedString],postprocess:function(e){return e[0].text.slice(1,-1)}},{name:"Symbol",symbols:[Ge.has("symbol")?{type:"symbol"}:symbol],postprocess:Ze},{name:"Symbol",symbols:[Ge.has("tickedString")?{type:"tickedString"}:tickedString],postprocess:function(e){return e[0].text.slice(1,-1)}},{name:"Record",symbols:[{literal:"{"},"_",{literal:"}"}],postprocess:Je},{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(e){return e[0].concat([e[1]])}},{name:"Record",symbols:[{literal:"{"},"_","Property","Record$ebnf$1","_",{literal:"}"}],postprocess:function(e){return[e[2]].concat(e[3].map((function(e){return e[3]})))}},{name:"Property",symbols:["Symbol","_",{literal:":"},"_","Value"],postprocess:function(e){return De.property(e[0],e[4])}},{name:"Value",symbols:["StringLiteral"],postprocess:He},{name:"Value",symbols:["NumericLiteral"],postprocess:He},{name:"Value",symbols:[Ge.has("boolean")?{type:"boolean"}:boolean],postprocess:function(e){return De.boolean(JSON.parse(e[0].value.toLowerCase()))}},{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(e){return e[0].concat([e[1]])}},{name:"Value",symbols:[{literal:"["},"_","Value","Value$ebnf$1",{literal:"]"}],postprocess:function(e){return[e[2]].concat(e[3].map((function(e){return e[3]})))}},{name:"StringLiteral",symbols:[Ge.has("singleQuotedString")?{type:"singleQuotedString"}:singleQuotedString],postprocess:function(e){return De.string(e[0].value)}},{name:"StringLiteral",symbols:[Ge.has("doubleQuotedString")?{type:"doubleQuotedString"}:doubleQuotedString],postprocess:function(e){return De.string(e[0].value)}},{name:"StringLiteral",symbols:[Ge.has("tickedString")?{type:"tickedString"}:tickedString],postprocess:function(e){return De.string(e[0].value)}},{name:"StringLiteral",symbols:[Ge.has("taggedString")?{type:"taggedString"}:taggedString],postprocess:function(e){var t=function(e){var t=e.match(/([^`]+)`(.+)`$/);if(null==t)throw Error("Malformed tagged string: "+e);return{tag:t[1],value:t[2]}}(e[0].value);return De.tagged(t.tag,t.value)}},{name:"NumericLiteral",symbols:[Ge.has("integer")?{type:"integer"}:integer],postprocess:function(e){return De.integer(e[0].value)}},{name:"NumericLiteral",symbols:[Ge.has("decimal")?{type:"decimal"}:decimal],postprocess:function(e){return De.decimal(e[0].value)}},{name:"NumericLiteral",symbols:[Ge.has("hexadecimal")?{type:"hexadecimal"}:hexadecimal],postprocess:function(e){return De.hexadecimal(e[0].value)}},{name:"NumericLiteral",symbols:[Ge.has("octal")?{type:"octal"}:octal],postprocess:function(e){return De.octal(e[0].value)}},{name:"NumericLiteral",symbols:[Ge.has("measurement")?{type:"measurement"}:measurement],postprocess:function(e){var t=function(e){var t=e.match(/(-?[0-9.]+)([a-zA-Z]+)/);if(null==t)throw Error("Malformed measurement : "+e);return{value:t[1],unit:t[2]}}(e[0].value);return De.measurement(t.unit,t.value)}},{name:"_",symbols:[]},{name:"_",symbols:[Ge.has("whitespace")?{type:"whitespace"}:whitespace],postprocess:Je},{name:"Comment",symbols:[Ge.has("lineComment")?{type:"lineComment"}:lineComment],postprocess:Je},{name:"EOL",symbols:[{literal:"\n"}],postprocess:Je}],ParserStart:"PathSequence"},Xe=function(e,t){var n,r,o=new pe.Parser(pe.Grammar.fromCompiled(Ye));try{var i=o.feed(e);if(void 0===i.results[0]&&i.lexerState){var s={line:(r=i.lexerState).line,column:r.col};t.fail("Incomplete parse.",s)}return i.results[0]||{type:"error"}}catch(e){var a=e.token?{line:(n=e.token).line,column:n.col}:{line:0,column:0};t.fail(e.message,a)}},Ke=function(){this.Parser=Xe};e.errors={__proto__:null,INCOMPLETE_PARSE:"Incomplete parse.",SYNTAX_ERROR:"Syntax error at"},e.gramParserPlugin=Ke,e.toAST=function(e){return ne().use(Ke).freeze().parse(e)},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=gram-parse.umd.production.min.js.map |
@@ -8,3 +8,3 @@ { | ||
], | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"license": "MIT", | ||
@@ -60,5 +60,5 @@ "author": "Andreas Kollegger", | ||
"@types/unist": "^2.0.3", | ||
"@typescript-eslint/parser": "^4.6.0", | ||
"@typescript-eslint/parser": "^4.8.1", | ||
"husky": "^4.3.0", | ||
"npm-check-updates": "^9.2.3", | ||
"npm-check-updates": "^10.2.1", | ||
"npm-run-all": "^4.1.5", | ||
@@ -76,4 +76,4 @@ "rollup-plugin-node-builtins": "^2.1.2", | ||
"dependencies": { | ||
"@gram-data/gram-ast": "^0.2.8", | ||
"@gram-data/gram-builder": "^0.2.8", | ||
"@gram-data/gram-ast": "^0.2.9", | ||
"@gram-data/gram-builder": "^0.2.9", | ||
"moo": "^0.5.1", | ||
@@ -84,3 +84,3 @@ "nearley": "^2.19.7", | ||
}, | ||
"gitHead": "3d28a7b7186d406e75bfd22aac54cd1b4ba0dbfa", | ||
"gitHead": "1ff6bdb1c799a29a95540314bdb5b2a881971774", | ||
"publishConfig": { | ||
@@ -87,0 +87,0 @@ "access": "public" |
@@ -7,3 +7,3 @@ From text literal `(a)-->(b)` to an gram AST. | ||
``` | ||
``` bash | ||
npm install @gram-data/gram-parse | ||
@@ -14,3 +14,3 @@ ``` | ||
``` | ||
``` TypeScript | ||
import { toAST } from '@gram-data/gram-parse'; | ||
@@ -24,3 +24,3 @@ | ||
``` | ||
``` TypeScript | ||
const inspect = require('unist-util-inspect'); | ||
@@ -27,0 +27,0 @@ |
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
707359
5939
Updated@gram-data/gram-ast@^0.2.9