json-asty 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ase/service.log +1 -0
- package/lib/json-asty.browser.js +1 -1
- package/lib/json-asty.node.js +1 -1
- package/package.json +9 -6
- package/.ase/service.yaml +0 -1
package/.ase/service.log
CHANGED
|
@@ -16,3 +16,4 @@ ase: [2026-07-05 01:54:14.397]: [INFO]: mcp: POST /mcp [initialize]
|
|
|
16
16
|
ase: [2026-07-05 01:54:14.409]: [INFO]: mcp: POST /mcp [notifications/initialized]
|
|
17
17
|
ase: [2026-07-05 01:54:14.413]: [INFO]: mcp: POST /mcp [tools/list]
|
|
18
18
|
ase: [2026-07-05 01:54:14.418]: [INFO]: mcp: GET /mcp
|
|
19
|
+
ase: [2026-07-05 02:26:58.553]: [INFO]: service: idle timeout reached, stopping
|
package/lib/json-asty.browser.js
CHANGED
|
@@ -49,6 +49,6 @@ const conversions=_dereq_("./conversions");function buildGraph(){const n={},e=Ob
|
|
|
49
49
|
},{}],11:[function(_dereq_,module,exports){
|
|
50
50
|
"use strict";module.exports={stdout:!1,stderr:!1};
|
|
51
51
|
},{}],12:[function(_dereq_,module,exports){
|
|
52
|
-
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof(t)?t:t+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var ASTY=_dereq_("asty-astq"),PEGUtil=_dereq_("pegjs-util"),chalk=_dereq_("chalk"),PEGparser=function(){class e extends SyntaxError{constructor(e,t,r,n){super(e),this.expected=t,this.found=r,this.location=n,this.name="SyntaxError"}format(e){let t="Error: "+this.message;if(this.location){let r=null;const n=e.find(e=>e.source===this.location.source);n&&(r=n.text.split(/\r\n|\n|\r/g));const o=this.location.start,l=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(o):o,u=this.location.source+":"+l.line+":"+l.column;if(r){const e=this.location.end,n="".padEnd(l.line.toString().length," "),a=r[o.line-1],i=(o.line===e.line?e.column:a.length+1)-o.column||1;t+="\n --\x3e "+u+"\n"+n+" |\n"+l.line+" | "+a+"\n"+n+" | "+"".padEnd(o.column-1," ")+"".padEnd(i,"^")}else t+="\n at "+u}return t}static buildMessage(e,t){function r(e){return e.codePointAt(0).toString(16).toUpperCase()}const n=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function o(e){return n?e.replace(n,e=>"\\u{"+r(e)+"}"):e}function l(e){return o(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}function u(e){return o(e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}const a={literal:e=>'"'+l(e.text)+'"',class(e){const t=e.parts.map(e=>Array.isArray(e)?u(e[0])+"-"+u(e[1]):u(e));return"["+(e.inverted?"^":"")+t.join("")+"]"+(e.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:e=>e.description};function i(e){return a[e.type](e)}return"Expected "+function(e){const t=e.map(i);if(t.sort(),t.length>0){let e=1;for(let r=1;r<t.length;r++)t[r-1]!==t[r]&&(t[e]=t[r],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+" or "+t[1];default:return t.slice(0,-1).join(", ")+", or "+t[t.length-1]}}(e)+" but "+function(e){return e?'"'+l(e)+'"':"end of input"}(t)+" found."}}return{StartRules:["json"],SyntaxError:e,parse:function(t,r){const n={},o=(r=void 0!==r?r:{}).grammarSource,l={json:Te};let u=Te;const a="{",i=",",s="}",c=":",f="[",p="]",g="-",h="0",d=".",y='"',b="\\",A="b",m="f",v="n",C="r",x="t",w="u",E="null",S="false",P="true",k=/^[1-9]/,j=/^[0-9]/,_=/^[eE]/,F=/^[+\-]/,R=/^[^\0-\x1F"\\]/,$=/^["\/\\]/,O=/^[0-9a-f]/i,T=/^[ \t\n\r]/,q=ke("{",!1),G=ke(",",!1),J=ke("}",!1),M=ke(":",!1),N=ke("[",!1),U=ke("]",!1),I=_e("number literal value"),K=ke("-",!1),Y=ke("0",!1),D=je([["1","9"]],!1,!1,!1),L=je([["0","9"]],!1,!1,!1),z=ke(".",!1),B=je(["e","E"],!1,!1,!1),H=je(["+","-"],!1,!1,!1),Q=_e("quoted string literal value"),V=ke('"',!1),W=je([["\0",""],'"',"\\"],!0,!1,!1),X=ke("\\",!1),Z=je(['"',"/","\\"],!1,!1,!1),ee=ke("b",!1),te=ke("f",!1),re=ke("n",!1),ne=ke("r",!1),oe=ke("t",!1),le=ke("u",!1),ue=je([["0","9"],["a","f"]],!1,!0,!1),ae=_e("object null literal value"),ie=ke("null",!1),se=_e("boolean false literal value"),ce=ke("false",!1),fe=_e("boolean true literal value"),pe=ke("true",!1),ge=_e("whitespace"),he=je([" ","\t","\n","\r"],!1,!1,!1),de=_e("end of file"),ye={type:"any"};function be(e){return String.fromCharCode(parseInt(e,16))}function Ae(e){return e}let me=0|r.peg$currPos,ve=me;const Ce=[{line:1,column:1}];let xe,we=me,Ee=r.peg$maxFailExpected||[],Se=0|r.peg$silentFails;if(r.startRule){if(!(r.startRule in l))throw new Error("Can't start parsing from rule \""+r.startRule+'".');u=l[r.startRule]}function Pe(){return t.substring(ve,me)}function ke(e,t){return{type:"literal",text:e,ignoreCase:t}}function je(e,t,r,n){return{type:"class",parts:e,inverted:t,ignoreCase:r,unicode:n}}function _e(e){return{type:"other",description:e}}function Fe(e){let r,n=Ce[e];if(n)return n;if(e>=Ce.length)r=Ce.length-1;else for(r=e;!Ce[--r];);for(n={line:(n=Ce[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return Ce[e]=n,n}function Re(e,t,r){const n=Fe(e),l=Fe(t),u={source:o,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:l.line,column:l.column}};return r&&o&&"function"==typeof o.offset&&(u.start=o.offset(u.start),u.end=o.offset(u.end)),u}function $e(e){me<we||(me>we&&(we=me,Ee=[]),Ee.push(e))}function Oe(t,r,n){return new e(e.buildMessage(t,r),t,r,n)}function Te(){let e,r,o,l,u;var a,i,s;return e=me,r=me,(o=Me())===n&&(o=null),r=t.substring(r,me),(o=qe())!==n?(l=me,(u=Me())===n&&(u=null),l=t.substring(l,me),(u=function(){let e,r;return Se++,e=me,Se++,t.length>me?(r=t.charAt(me),me++):(r=n,0===Se&&$e(ye)),Se--,r===n?e=void 0:(me=e,e=n),Se--,e===n&&(r=n,0===Se&&$e(de)),e}())!==n?(ve=e,i=o,s=l,(a=r)&&i.set("prolog",a+(i.get("prolog")||"")),s&&i.set("epilog",(i.get("epilog")||"")+s),e=i):(me=e,e=n)):(me=e,e=n),e}function qe(){let e;return(e=function(){let e,r,o,l,u,c,f,p,g,h,d;if(e=me,r=me,o=me,(l=Me())===n&&(l=null),123===t.charCodeAt(me)?(u=a,me++):(u=n,0===Se&&$e(q)),u!==n?((c=Me())===n&&(c=null),o=l=[l,u,c]):(me=o,o=n),(r=o!==n?t.substring(r,me):o)!==n){if(o=me,(l=Ge())!==n){for(u=[],c=me,f=me,p=me,(g=Me())===n&&(g=null),44===t.charCodeAt(me)?(h=i,me++):(h=n,0===Se&&$e(G)),h!==n?((d=Me())===n&&(d=null),p=g=[g,h,d]):(me=p,p=n),(f=p!==n?t.substring(f,me):p)!==n&&(p=Ge())!==n?c=f=[f,p]:(me=c,c=n);c!==n;)u.push(c),c=me,f=me,p=me,(g=Me())===n&&(g=null),44===t.charCodeAt(me)?(h=i,me++):(h=n,0===Se&&$e(G)),h!==n?((d=Me())===n&&(d=null),p=g=[g,h,d]):(me=p,p=n),(f=p!==n?t.substring(f,me):p)!==n&&(p=Ge())!==n?c=f=[f,p]:(me=c,c=n);ve=o,m=l,o=u.reduce((e,t)=>{const r=e[e.length-1].get("epilog")||"";return e[e.length-1].set({epilog:r+t[0]}),e.concat([t[1]])},[m])}else me=o,o=n;o===n&&(o=null),l=me,u=me,(c=Me())===n&&(c=null),125===t.charCodeAt(me)?(f=s,me++):(f=n,0===Se&&$e(J)),f!==n?((p=Me())===n&&(p=null),u=c=[c,f,p]):(me=u,u=n),(l=u!==n?t.substring(l,me):u)!==n?(ve=e,y=r,b=o,A=l,e=Ne("object").set({prolog:y}).set({epilog:A}).add(b)):(me=e,e=n)}else me=e,e=n;var y,b,A,m;return e}())===n&&(e=function(){let e,r,o,l,u,a,s,c,g,h,d;if(e=me,r=me,o=me,(l=Me())===n&&(l=null),91===t.charCodeAt(me)?(u=f,me++):(u=n,0===Se&&$e(N)),u!==n?((a=Me())===n&&(a=null),o=l=[l,u,a]):(me=o,o=n),(r=o!==n?t.substring(r,me):o)!==n){if(o=me,(l=qe())!==n){for(u=[],a=me,s=me,c=me,(g=Me())===n&&(g=null),44===t.charCodeAt(me)?(h=i,me++):(h=n,0===Se&&$e(G)),h!==n?((d=Me())===n&&(d=null),c=g=[g,h,d]):(me=c,c=n),(s=c!==n?t.substring(s,me):c)!==n&&(c=qe())!==n?a=s=[s,c]:(me=a,a=n);a!==n;)u.push(a),a=me,s=me,c=me,(g=Me())===n&&(g=null),44===t.charCodeAt(me)?(h=i,me++):(h=n,0===Se&&$e(G)),h!==n?((d=Me())===n&&(d=null),c=g=[g,h,d]):(me=c,c=n),(s=c!==n?t.substring(s,me):c)!==n&&(c=qe())!==n?a=s=[s,c]:(me=a,a=n);ve=o,m=l,o=u.reduce((e,t)=>{const r=e[e.length-1].get("epilog")||"";return e[e.length-1].set({epilog:r+t[0]}),e.concat([t[1]])},[m])}else me=o,o=n;o===n&&(o=null),l=me,u=me,(a=Me())===n&&(a=null),93===t.charCodeAt(me)?(s=p,me++):(s=n,0===Se&&$e(U)),s!==n?((c=Me())===n&&(c=null),u=a=[a,s,c]):(me=u,u=n),(l=u!==n?t.substring(l,me):u)!==n?(ve=e,y=r,b=o,A=l,e=Ne("array").set({prolog:y}).set({epilog:A}).add(b)):(me=e,e=n)}else me=e,e=n;var y,b,A,m;return e}())===n&&(e=function(){let e,r,o,l,u,a,i,s,c;if(Se++,e=me,45===t.charCodeAt(me)?(r=g,me++):(r=n,0===Se&&$e(K)),r===n&&(r=null),48===t.charCodeAt(me)?(o=h,me++):(o=n,0===Se&&$e(Y)),o===n)if(o=me,l=t.charAt(me),k.test(l)?me++:(l=n,0===Se&&$e(D)),l!==n){for(u=[],a=t.charAt(me),j.test(a)?me++:(a=n,0===Se&&$e(L));a!==n;)u.push(a),a=t.charAt(me),j.test(a)?me++:(a=n,0===Se&&$e(L));o=l=[l,u]}else me=o,o=n;if(o!==n){if(l=me,46===t.charCodeAt(me)?(u=d,me++):(u=n,0===Se&&$e(z)),u!==n){if(a=[],i=t.charAt(me),j.test(i)?me++:(i=n,0===Se&&$e(L)),i!==n)for(;i!==n;)a.push(i),i=t.charAt(me),j.test(i)?me++:(i=n,0===Se&&$e(L));else a=n;a!==n?l=u=[u,a]:(me=l,l=n)}else me=l,l=n;if(l===n&&(l=null),u=me,a=t.charAt(me),_.test(a)?me++:(a=n,0===Se&&$e(B)),a!==n){if(i=t.charAt(me),F.test(i)?me++:(i=n,0===Se&&$e(H)),i===n&&(i=null),s=[],c=t.charAt(me),j.test(c)?me++:(c=n,0===Se&&$e(L)),c!==n)for(;c!==n;)s.push(c),c=t.charAt(me),j.test(c)?me++:(c=n,0===Se&&$e(L));else s=n;s!==n?u=a=[a,i,s]:(me=u,u=n)}else me=u,u=n;u===n&&(u=null),ve=e,e=Ne("number").set({body:Pe(),value:parseFloat(Pe())})}else me=e,e=n;return Se--,e===n&&(r=n,0===Se&&$e(I)),e}())===n&&(e=Je())===n&&(e=function(){let e,r;return Se++,e=me,t.substr(me,4)===E?(r=E,me+=4):(r=n,0===Se&&$e(ie)),r!==n&&(ve=e,r=Ne("null").set({body:Pe(),value:null})),Se--,(e=r)===n&&(r=n,0===Se&&$e(ae)),e}())===n&&(e=function(){let e,r;return Se++,e=me,t.substr(me,5)===S?(r=S,me+=5):(r=n,0===Se&&$e(ce)),r!==n&&(ve=e,r=Ne("boolean").set({body:Pe(),value:!1})),Se--,(e=r)===n&&(r=n,0===Se&&$e(se)),e}())===n&&(e=function(){let e,r;return Se++,e=me,t.substr(me,4)===P?(r=P,me+=4):(r=n,0===Se&&$e(pe)),r!==n&&(ve=e,r=Ne("boolean").set({body:Pe(),value:!0})),Se--,(e=r)===n&&(r=n,0===Se&&$e(fe)),e}()),e}function Ge(){let e,r,o,l,u,a,i;var s,f,p;return e=me,(r=Je())!==n?(o=me,l=me,(u=Me())===n&&(u=null),58===t.charCodeAt(me)?(a=c,me++):(a=n,0===Se&&$e(M)),a!==n?((i=Me())===n&&(i=null),l=u=[u,a,i]):(me=l,l=n),(o=l!==n?t.substring(o,me):l)!==n&&(l=qe())!==n?(ve=e,s=r,f=o,p=l,e=Ne("member").add(s.set({epilog:f}),p)):(me=e,e=n)):(me=e,e=n),e}function Je(){let e,r,o,l,u,a,i,s,c,f,p,g,h;if(Se++,e=me,34===t.charCodeAt(me)?(r=y,me++):(r=n,0===Se&&$e(V)),r!==n){for(o=[],l=t.charAt(me),R.test(l)?me++:(l=n,0===Se&&$e(W)),l===n&&(l=me,92===t.charCodeAt(me)?(u=b,me++):(u=n,0===Se&&$e(X)),u!==n?(a=t.charAt(me),$.test(a)?me++:(a=n,0===Se&&$e(Z)),a===n&&(a=me,98===t.charCodeAt(me)?(i=A,me++):(i=n,0===Se&&$e(ee)),i!==n&&(ve=a,i="\b"),(a=i)===n&&(a=me,102===t.charCodeAt(me)?(i=m,me++):(i=n,0===Se&&$e(te)),i!==n&&(ve=a,i="\f"),(a=i)===n&&(a=me,110===t.charCodeAt(me)?(i=v,me++):(i=n,0===Se&&$e(re)),i!==n&&(ve=a,i="\n"),(a=i)===n&&(a=me,114===t.charCodeAt(me)?(i=C,me++):(i=n,0===Se&&$e(ne)),i!==n&&(ve=a,i="\r"),(a=i)===n&&(a=me,116===t.charCodeAt(me)?(i=x,me++):(i=n,0===Se&&$e(oe)),i!==n&&(ve=a,i="\t"),(a=i)===n&&(a=me,117===t.charCodeAt(me)?(i=w,me++):(i=n,0===Se&&$e(le)),i!==n?(s=me,c=me,f=t.charAt(me),O.test(f)?me++:(f=n,0===Se&&$e(ue)),f!==n?(p=t.charAt(me),O.test(p)?me++:(p=n,0===Se&&$e(ue)),p!==n?(g=t.charAt(me),O.test(g)?me++:(g=n,0===Se&&$e(ue)),g!==n?(h=t.charAt(me),O.test(h)?me++:(h=n,0===Se&&$e(ue)),h!==n?c=f=[f,p,g,h]:(me=c,c=n)):(me=c,c=n)):(me=c,c=n)):(me=c,c=n),(s=c!==n?t.substring(s,me):c)!==n?(ve=a,a=be(s)):(me=a,a=n)):(me=a,a=n))))))),a!==n?(ve=l,l=Ae(a)):(me=l,l=n)):(me=l,l=n));l!==n;)o.push(l),l=t.charAt(me),R.test(l)?me++:(l=n,0===Se&&$e(W)),l===n&&(l=me,92===t.charCodeAt(me)?(u=b,me++):(u=n,0===Se&&$e(X)),u!==n?(a=t.charAt(me),$.test(a)?me++:(a=n,0===Se&&$e(Z)),a===n&&(a=me,98===t.charCodeAt(me)?(i=A,me++):(i=n,0===Se&&$e(ee)),i!==n&&(ve=a,i="\b"),(a=i)===n&&(a=me,102===t.charCodeAt(me)?(i=m,me++):(i=n,0===Se&&$e(te)),i!==n&&(ve=a,i="\f"),(a=i)===n&&(a=me,110===t.charCodeAt(me)?(i=v,me++):(i=n,0===Se&&$e(re)),i!==n&&(ve=a,i="\n"),(a=i)===n&&(a=me,114===t.charCodeAt(me)?(i=C,me++):(i=n,0===Se&&$e(ne)),i!==n&&(ve=a,i="\r"),(a=i)===n&&(a=me,116===t.charCodeAt(me)?(i=x,me++):(i=n,0===Se&&$e(oe)),i!==n&&(ve=a,i="\t"),(a=i)===n&&(a=me,117===t.charCodeAt(me)?(i=w,me++):(i=n,0===Se&&$e(le)),i!==n?(s=me,c=me,f=t.charAt(me),O.test(f)?me++:(f=n,0===Se&&$e(ue)),f!==n?(p=t.charAt(me),O.test(p)?me++:(p=n,0===Se&&$e(ue)),p!==n?(g=t.charAt(me),O.test(g)?me++:(g=n,0===Se&&$e(ue)),g!==n?(h=t.charAt(me),O.test(h)?me++:(h=n,0===Se&&$e(ue)),h!==n?c=f=[f,p,g,h]:(me=c,c=n)):(me=c,c=n)):(me=c,c=n)):(me=c,c=n),(s=c!==n?t.substring(s,me):c)!==n?(ve=a,a=be(s)):(me=a,a=n)):(me=a,a=n))))))),a!==n?(ve=l,l=Ae(a)):(me=l,l=n)):(me=l,l=n));34===t.charCodeAt(me)?(l=y,me++):(l=n,0===Se&&$e(V)),l!==n?(ve=e,d=o,e=Ne("string").set({body:Pe(),value:d.join("")})):(me=e,e=n)}else me=e,e=n;var d;return Se--,e===n&&(r=n,0===Se&&$e(Q)),e}function Me(){let e,r;if(Se++,e=[],r=t.charAt(me),T.test(r)?me++:(r=n,0===Se&&$e(he)),r!==n)for(;r!==n;)e.push(r),r=t.charAt(me),T.test(r)?me++:(r=n,0===Se&&$e(he));else e=n;return Se--,e===n&&(r=n,0===Se&&$e(ge)),e}var Ne=r.util.makeAST(function(){return Re(ve,me)},r);const Ue=(xe=u())!==n&&me===t.length;function Ie(){throw xe!==n&&me<t.length&&$e({type:"end"}),Oe(Ee,we<t.length?function(e=me){const r=t.codePointAt(e);return void 0===r?"":String.fromCodePoint(r)}(we):null,we<t.length?Re(we,we+1):Re(we,we))}return r.peg$library?{peg$result:xe,peg$currPos:me,peg$FAILED:n,peg$maxFailExpected:Ee,peg$maxFailPos:we,peg$success:Ue,peg$throw:Ue?void 0:Ie}:Ue?xe:void Ie()}}}(),JsonAsty=function(){return _createClass(function e(){_classCallCheck(this,e)},null,[{key:"parse",value:function(e){if("string"!=typeof e)throw new Error("invalid JSON argument (expected type string)");var t=new ASTY,r=PEGUtil.parse(PEGparser,e,{startRule:"json",makeAST:function(e,r,n,o){return t.create.apply(t,o).pos(e,r,n)}});if(null!==r.error)throw new Error("parse: JSON parsing failure:\n"+PEGUtil.errorMessage(r.error,!0).replace(/^/gm,"ERROR: ")+"\n");return r.ast}},{key:"dump",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(t=Object.assign({},{colors:!1},t)).colors?e.dump(1/0,function(e,t){switch(e){case"tree":t=chalk.grey(t);break;case"type":t=chalk.blue(t);break;case"value":t=chalk.yellow(t);break;case"position":t=chalk.grey(t)}return t}):e.dump(1/0)}},{key:"unparse",value:function(e){if("object"!==_typeof(e))throw new Error("generate: invalid AST argument (expected type object)");var t="";return e.walk(function(e,r,n,o){if("downward"===o){var l=e.get("prolog");void 0!==l&&(t+=l);var u=e.get("body");if(void 0!==u)t+=u;else{var a=e.get("value");void 0!==a&&(t+=JSON.stringify(a))}}else if("upward"===o){var i=e.get("epilog");void 0!==i&&(t+=i)}},"both"),t}}])}();module.exports=JsonAsty;
|
|
52
|
+
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof(t)?t:t+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var ASTY=_dereq_("asty-astq"),PEG={},PEGUtil=_dereq_("pegjs-util"),chalk=_dereq_("chalk"),PEGparser=function(){class e extends SyntaxError{constructor(e,t,r,n){super(e),this.expected=t,this.found=r,this.location=n,this.name="SyntaxError"}format(e){let t="Error: "+this.message;if(this.location){let r=null;const n=e.find(e=>e.source===this.location.source);n&&(r=n.text.split(/\r\n|\n|\r/g));const o=this.location.start,l=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(o):o,u=this.location.source+":"+l.line+":"+l.column;if(r){const e=this.location.end,n="".padEnd(l.line.toString().length," "),a=r[o.line-1],i=(o.line===e.line?e.column:a.length+1)-o.column||1;t+="\n --\x3e "+u+"\n"+n+" |\n"+l.line+" | "+a+"\n"+n+" | "+"".padEnd(o.column-1," ")+"".padEnd(i,"^")}else t+="\n at "+u}return t}static buildMessage(e,t){function r(e){return e.codePointAt(0).toString(16).toUpperCase()}const n=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function o(e){return n?e.replace(n,e=>"\\u{"+r(e)+"}"):e}function l(e){return o(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}function u(e){return o(e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}const a={literal:e=>'"'+l(e.text)+'"',class(e){const t=e.parts.map(e=>Array.isArray(e)?u(e[0])+"-"+u(e[1]):u(e));return"["+(e.inverted?"^":"")+t.join("")+"]"+(e.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:e=>e.description};function i(e){return a[e.type](e)}return"Expected "+function(e){const t=e.map(i);if(t.sort(),t.length>0){let e=1;for(let r=1;r<t.length;r++)t[r-1]!==t[r]&&(t[e]=t[r],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+" or "+t[1];default:return t.slice(0,-1).join(", ")+", or "+t[t.length-1]}}(e)+" but "+function(e){return e?'"'+l(e)+'"':"end of input"}(t)+" found."}}return{StartRules:["json"],SyntaxError:e,parse:function(t,r){const n={},o=(r=void 0!==r?r:{}).grammarSource,l={json:Te};let u=Te;const a="{",i=",",s="}",c=":",f="[",p="]",g="-",h="0",d=".",y='"',b="\\",A="b",m="f",v="n",C="r",x="t",w="u",E="null",P="false",S="true",k=/^[1-9]/,j=/^[0-9]/,_=/^[eE]/,F=/^[+\-]/,R=/^[^\0-\x1F"\\]/,$=/^["\/\\]/,O=/^[0-9a-f]/i,T=/^[ \t\n\r]/,G=ke("{",!1),q=ke(",",!1),J=ke("}",!1),M=ke(":",!1),N=ke("[",!1),U=ke("]",!1),I=_e("number literal value"),K=ke("-",!1),Y=ke("0",!1),D=je([["1","9"]],!1,!1,!1),L=je([["0","9"]],!1,!1,!1),z=ke(".",!1),B=je(["e","E"],!1,!1,!1),H=je(["+","-"],!1,!1,!1),Q=_e("quoted string literal value"),V=ke('"',!1),W=je([["\0",""],'"',"\\"],!0,!1,!1),X=ke("\\",!1),Z=je(['"',"/","\\"],!1,!1,!1),ee=ke("b",!1),te=ke("f",!1),re=ke("n",!1),ne=ke("r",!1),oe=ke("t",!1),le=ke("u",!1),ue=je([["0","9"],["a","f"]],!1,!0,!1),ae=_e("object null literal value"),ie=ke("null",!1),se=_e("boolean false literal value"),ce=ke("false",!1),fe=_e("boolean true literal value"),pe=ke("true",!1),ge=_e("whitespace"),he=je([" ","\t","\n","\r"],!1,!1,!1),de=_e("end of file"),ye={type:"any"};function be(e){return String.fromCharCode(parseInt(e,16))}function Ae(e){return e}let me=0|r.peg$currPos,ve=me;const Ce=[{line:1,column:1}];let xe,we=me,Ee=r.peg$maxFailExpected||[],Pe=0|r.peg$silentFails;if(r.startRule){if(!(r.startRule in l))throw new Error("Can't start parsing from rule \""+r.startRule+'".');u=l[r.startRule]}function Se(){return t.substring(ve,me)}function ke(e,t){return{type:"literal",text:e,ignoreCase:t}}function je(e,t,r,n){return{type:"class",parts:e,inverted:t,ignoreCase:r,unicode:n}}function _e(e){return{type:"other",description:e}}function Fe(e){let r,n=Ce[e];if(n)return n;if(e>=Ce.length)r=Ce.length-1;else for(r=e;!Ce[--r];);for(n={line:(n=Ce[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return Ce[e]=n,n}function Re(e,t,r){const n=Fe(e),l=Fe(t),u={source:o,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:l.line,column:l.column}};return r&&o&&"function"==typeof o.offset&&(u.start=o.offset(u.start),u.end=o.offset(u.end)),u}function $e(e){me<we||(me>we&&(we=me,Ee=[]),Ee.push(e))}function Oe(t,r,n){return new e(e.buildMessage(t,r),t,r,n)}function Te(){let e,r,o,l,u;var a,i,s;return e=me,r=me,(o=Me())===n&&(o=null),r=t.substring(r,me),(o=Ge())!==n?(l=me,(u=Me())===n&&(u=null),l=t.substring(l,me),(u=function(){let e,r;return Pe++,e=me,Pe++,t.length>me?(r=t.charAt(me),me++):(r=n,0===Pe&&$e(ye)),Pe--,r===n?e=void 0:(me=e,e=n),Pe--,e===n&&(r=n,0===Pe&&$e(de)),e}())!==n?(ve=e,i=o,s=l,(a=r)&&i.set("prolog",a+(i.get("prolog")||"")),s&&i.set("epilog",(i.get("epilog")||"")+s),e=i):(me=e,e=n)):(me=e,e=n),e}function Ge(){let e;return(e=function(){let e,r,o,l,u,c,f,p,g,h,d;if(e=me,r=me,o=me,(l=Me())===n&&(l=null),123===t.charCodeAt(me)?(u=a,me++):(u=n,0===Pe&&$e(G)),u!==n?((c=Me())===n&&(c=null),o=l=[l,u,c]):(me=o,o=n),(r=o!==n?t.substring(r,me):o)!==n){if(o=me,(l=qe())!==n){for(u=[],c=me,f=me,p=me,(g=Me())===n&&(g=null),44===t.charCodeAt(me)?(h=i,me++):(h=n,0===Pe&&$e(q)),h!==n?((d=Me())===n&&(d=null),p=g=[g,h,d]):(me=p,p=n),(f=p!==n?t.substring(f,me):p)!==n&&(p=qe())!==n?c=f=[f,p]:(me=c,c=n);c!==n;)u.push(c),c=me,f=me,p=me,(g=Me())===n&&(g=null),44===t.charCodeAt(me)?(h=i,me++):(h=n,0===Pe&&$e(q)),h!==n?((d=Me())===n&&(d=null),p=g=[g,h,d]):(me=p,p=n),(f=p!==n?t.substring(f,me):p)!==n&&(p=qe())!==n?c=f=[f,p]:(me=c,c=n);ve=o,m=l,o=u.reduce((e,t)=>{const r=e[e.length-1].get("epilog")||"";return e[e.length-1].set({epilog:r+t[0]}),e.concat([t[1]])},[m])}else me=o,o=n;o===n&&(o=null),l=me,u=me,(c=Me())===n&&(c=null),125===t.charCodeAt(me)?(f=s,me++):(f=n,0===Pe&&$e(J)),f!==n?((p=Me())===n&&(p=null),u=c=[c,f,p]):(me=u,u=n),(l=u!==n?t.substring(l,me):u)!==n?(ve=e,y=r,b=o,A=l,e=Ne("object").set({prolog:y}).set({epilog:A}).add(b)):(me=e,e=n)}else me=e,e=n;var y,b,A,m;return e}())===n&&(e=function(){let e,r,o,l,u,a,s,c,g,h,d;if(e=me,r=me,o=me,(l=Me())===n&&(l=null),91===t.charCodeAt(me)?(u=f,me++):(u=n,0===Pe&&$e(N)),u!==n?((a=Me())===n&&(a=null),o=l=[l,u,a]):(me=o,o=n),(r=o!==n?t.substring(r,me):o)!==n){if(o=me,(l=Ge())!==n){for(u=[],a=me,s=me,c=me,(g=Me())===n&&(g=null),44===t.charCodeAt(me)?(h=i,me++):(h=n,0===Pe&&$e(q)),h!==n?((d=Me())===n&&(d=null),c=g=[g,h,d]):(me=c,c=n),(s=c!==n?t.substring(s,me):c)!==n&&(c=Ge())!==n?a=s=[s,c]:(me=a,a=n);a!==n;)u.push(a),a=me,s=me,c=me,(g=Me())===n&&(g=null),44===t.charCodeAt(me)?(h=i,me++):(h=n,0===Pe&&$e(q)),h!==n?((d=Me())===n&&(d=null),c=g=[g,h,d]):(me=c,c=n),(s=c!==n?t.substring(s,me):c)!==n&&(c=Ge())!==n?a=s=[s,c]:(me=a,a=n);ve=o,m=l,o=u.reduce((e,t)=>{const r=e[e.length-1].get("epilog")||"";return e[e.length-1].set({epilog:r+t[0]}),e.concat([t[1]])},[m])}else me=o,o=n;o===n&&(o=null),l=me,u=me,(a=Me())===n&&(a=null),93===t.charCodeAt(me)?(s=p,me++):(s=n,0===Pe&&$e(U)),s!==n?((c=Me())===n&&(c=null),u=a=[a,s,c]):(me=u,u=n),(l=u!==n?t.substring(l,me):u)!==n?(ve=e,y=r,b=o,A=l,e=Ne("array").set({prolog:y}).set({epilog:A}).add(b)):(me=e,e=n)}else me=e,e=n;var y,b,A,m;return e}())===n&&(e=function(){let e,r,o,l,u,a,i,s,c;if(Pe++,e=me,45===t.charCodeAt(me)?(r=g,me++):(r=n,0===Pe&&$e(K)),r===n&&(r=null),48===t.charCodeAt(me)?(o=h,me++):(o=n,0===Pe&&$e(Y)),o===n)if(o=me,l=t.charAt(me),k.test(l)?me++:(l=n,0===Pe&&$e(D)),l!==n){for(u=[],a=t.charAt(me),j.test(a)?me++:(a=n,0===Pe&&$e(L));a!==n;)u.push(a),a=t.charAt(me),j.test(a)?me++:(a=n,0===Pe&&$e(L));o=l=[l,u]}else me=o,o=n;if(o!==n){if(l=me,46===t.charCodeAt(me)?(u=d,me++):(u=n,0===Pe&&$e(z)),u!==n){if(a=[],i=t.charAt(me),j.test(i)?me++:(i=n,0===Pe&&$e(L)),i!==n)for(;i!==n;)a.push(i),i=t.charAt(me),j.test(i)?me++:(i=n,0===Pe&&$e(L));else a=n;a!==n?l=u=[u,a]:(me=l,l=n)}else me=l,l=n;if(l===n&&(l=null),u=me,a=t.charAt(me),_.test(a)?me++:(a=n,0===Pe&&$e(B)),a!==n){if(i=t.charAt(me),F.test(i)?me++:(i=n,0===Pe&&$e(H)),i===n&&(i=null),s=[],c=t.charAt(me),j.test(c)?me++:(c=n,0===Pe&&$e(L)),c!==n)for(;c!==n;)s.push(c),c=t.charAt(me),j.test(c)?me++:(c=n,0===Pe&&$e(L));else s=n;s!==n?u=a=[a,i,s]:(me=u,u=n)}else me=u,u=n;u===n&&(u=null),ve=e,e=Ne("number").set({body:Se(),value:parseFloat(Se())})}else me=e,e=n;return Pe--,e===n&&(r=n,0===Pe&&$e(I)),e}())===n&&(e=Je())===n&&(e=function(){let e,r;return Pe++,e=me,t.substr(me,4)===E?(r=E,me+=4):(r=n,0===Pe&&$e(ie)),r!==n&&(ve=e,r=Ne("null").set({body:Se(),value:null})),Pe--,(e=r)===n&&(r=n,0===Pe&&$e(ae)),e}())===n&&(e=function(){let e,r;return Pe++,e=me,t.substr(me,5)===P?(r=P,me+=5):(r=n,0===Pe&&$e(ce)),r!==n&&(ve=e,r=Ne("boolean").set({body:Se(),value:!1})),Pe--,(e=r)===n&&(r=n,0===Pe&&$e(se)),e}())===n&&(e=function(){let e,r;return Pe++,e=me,t.substr(me,4)===S?(r=S,me+=4):(r=n,0===Pe&&$e(pe)),r!==n&&(ve=e,r=Ne("boolean").set({body:Se(),value:!0})),Pe--,(e=r)===n&&(r=n,0===Pe&&$e(fe)),e}()),e}function qe(){let e,r,o,l,u,a,i;var s,f,p;return e=me,(r=Je())!==n?(o=me,l=me,(u=Me())===n&&(u=null),58===t.charCodeAt(me)?(a=c,me++):(a=n,0===Pe&&$e(M)),a!==n?((i=Me())===n&&(i=null),l=u=[u,a,i]):(me=l,l=n),(o=l!==n?t.substring(o,me):l)!==n&&(l=Ge())!==n?(ve=e,s=r,f=o,p=l,e=Ne("member").add(s.set({epilog:f}),p)):(me=e,e=n)):(me=e,e=n),e}function Je(){let e,r,o,l,u,a,i,s,c,f,p,g,h;if(Pe++,e=me,34===t.charCodeAt(me)?(r=y,me++):(r=n,0===Pe&&$e(V)),r!==n){for(o=[],l=t.charAt(me),R.test(l)?me++:(l=n,0===Pe&&$e(W)),l===n&&(l=me,92===t.charCodeAt(me)?(u=b,me++):(u=n,0===Pe&&$e(X)),u!==n?(a=t.charAt(me),$.test(a)?me++:(a=n,0===Pe&&$e(Z)),a===n&&(a=me,98===t.charCodeAt(me)?(i=A,me++):(i=n,0===Pe&&$e(ee)),i!==n&&(ve=a,i="\b"),(a=i)===n&&(a=me,102===t.charCodeAt(me)?(i=m,me++):(i=n,0===Pe&&$e(te)),i!==n&&(ve=a,i="\f"),(a=i)===n&&(a=me,110===t.charCodeAt(me)?(i=v,me++):(i=n,0===Pe&&$e(re)),i!==n&&(ve=a,i="\n"),(a=i)===n&&(a=me,114===t.charCodeAt(me)?(i=C,me++):(i=n,0===Pe&&$e(ne)),i!==n&&(ve=a,i="\r"),(a=i)===n&&(a=me,116===t.charCodeAt(me)?(i=x,me++):(i=n,0===Pe&&$e(oe)),i!==n&&(ve=a,i="\t"),(a=i)===n&&(a=me,117===t.charCodeAt(me)?(i=w,me++):(i=n,0===Pe&&$e(le)),i!==n?(s=me,c=me,f=t.charAt(me),O.test(f)?me++:(f=n,0===Pe&&$e(ue)),f!==n?(p=t.charAt(me),O.test(p)?me++:(p=n,0===Pe&&$e(ue)),p!==n?(g=t.charAt(me),O.test(g)?me++:(g=n,0===Pe&&$e(ue)),g!==n?(h=t.charAt(me),O.test(h)?me++:(h=n,0===Pe&&$e(ue)),h!==n?c=f=[f,p,g,h]:(me=c,c=n)):(me=c,c=n)):(me=c,c=n)):(me=c,c=n),(s=c!==n?t.substring(s,me):c)!==n?(ve=a,a=be(s)):(me=a,a=n)):(me=a,a=n))))))),a!==n?(ve=l,l=Ae(a)):(me=l,l=n)):(me=l,l=n));l!==n;)o.push(l),l=t.charAt(me),R.test(l)?me++:(l=n,0===Pe&&$e(W)),l===n&&(l=me,92===t.charCodeAt(me)?(u=b,me++):(u=n,0===Pe&&$e(X)),u!==n?(a=t.charAt(me),$.test(a)?me++:(a=n,0===Pe&&$e(Z)),a===n&&(a=me,98===t.charCodeAt(me)?(i=A,me++):(i=n,0===Pe&&$e(ee)),i!==n&&(ve=a,i="\b"),(a=i)===n&&(a=me,102===t.charCodeAt(me)?(i=m,me++):(i=n,0===Pe&&$e(te)),i!==n&&(ve=a,i="\f"),(a=i)===n&&(a=me,110===t.charCodeAt(me)?(i=v,me++):(i=n,0===Pe&&$e(re)),i!==n&&(ve=a,i="\n"),(a=i)===n&&(a=me,114===t.charCodeAt(me)?(i=C,me++):(i=n,0===Pe&&$e(ne)),i!==n&&(ve=a,i="\r"),(a=i)===n&&(a=me,116===t.charCodeAt(me)?(i=x,me++):(i=n,0===Pe&&$e(oe)),i!==n&&(ve=a,i="\t"),(a=i)===n&&(a=me,117===t.charCodeAt(me)?(i=w,me++):(i=n,0===Pe&&$e(le)),i!==n?(s=me,c=me,f=t.charAt(me),O.test(f)?me++:(f=n,0===Pe&&$e(ue)),f!==n?(p=t.charAt(me),O.test(p)?me++:(p=n,0===Pe&&$e(ue)),p!==n?(g=t.charAt(me),O.test(g)?me++:(g=n,0===Pe&&$e(ue)),g!==n?(h=t.charAt(me),O.test(h)?me++:(h=n,0===Pe&&$e(ue)),h!==n?c=f=[f,p,g,h]:(me=c,c=n)):(me=c,c=n)):(me=c,c=n)):(me=c,c=n),(s=c!==n?t.substring(s,me):c)!==n?(ve=a,a=be(s)):(me=a,a=n)):(me=a,a=n))))))),a!==n?(ve=l,l=Ae(a)):(me=l,l=n)):(me=l,l=n));34===t.charCodeAt(me)?(l=y,me++):(l=n,0===Pe&&$e(V)),l!==n?(ve=e,d=o,e=Ne("string").set({body:Se(),value:d.join("")})):(me=e,e=n)}else me=e,e=n;var d;return Pe--,e===n&&(r=n,0===Pe&&$e(Q)),e}function Me(){let e,r;if(Pe++,e=[],r=t.charAt(me),T.test(r)?me++:(r=n,0===Pe&&$e(he)),r!==n)for(;r!==n;)e.push(r),r=t.charAt(me),T.test(r)?me++:(r=n,0===Pe&&$e(he));else e=n;return Pe--,e===n&&(r=n,0===Pe&&$e(ge)),e}var Ne=r.util.makeAST(function(){return Re(ve,me)},r);const Ue=(xe=u())!==n&&me===t.length;function Ie(){throw xe!==n&&me<t.length&&$e({type:"end"}),Oe(Ee,we<t.length?function(e=me){const r=t.codePointAt(e);return void 0===r?"":String.fromCodePoint(r)}(we):null,we<t.length?Re(we,we+1):Re(we,we))}return r.peg$library?{peg$result:xe,peg$currPos:me,peg$FAILED:n,peg$maxFailExpected:Ee,peg$maxFailPos:we,peg$success:Ue,peg$throw:Ue?void 0:Ie}:Ue?xe:void Ie()}}}(),JsonAsty=function(){return _createClass(function e(){_classCallCheck(this,e)},null,[{key:"parse",value:function(e){if("string"!=typeof e)throw new Error("invalid JSON argument (expected type string)");var t=new ASTY,r=PEGUtil.parse(PEGparser,e,{startRule:"json",makeAST:function(e,r,n,o){return t.create.apply(t,o).pos(e,r,n)}});if(null!==r.error)throw new Error("parse: JSON parsing failure:\n"+PEGUtil.errorMessage(r.error,!0).replace(/^/gm,"ERROR: ")+"\n");return r.ast}},{key:"dump",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(t=Object.assign({},{colors:!1},t)).colors?e.dump(1/0,function(e,t){switch(e){case"tree":t=chalk.grey(t);break;case"type":t=chalk.blue(t);break;case"value":t=chalk.yellow(t);break;case"position":t=chalk.grey(t)}return t}):e.dump(1/0)}},{key:"unparse",value:function(e){if("object"!==_typeof(e))throw new Error("generate: invalid AST argument (expected type object)");var t="";return e.walk(function(e,r,n,o){if("downward"===o){var l=e.get("prolog");void 0!==l&&(t+=l);var u=e.get("body");if(void 0!==u)t+=u;else{var a=e.get("value");void 0!==a&&(t+=JSON.stringify(a))}}else if("upward"===o){var i=e.get("epilog");void 0!==i&&(t+=i)}},"both"),t}}])}();module.exports=JsonAsty;
|
|
53
53
|
},{"asty-astq":2,"chalk":3,"pegjs-util":10}]},{},[12])(12)
|
|
54
54
|
});
|
package/lib/json-asty.node.js
CHANGED
|
@@ -41,6 +41,6 @@ const conversions=_dereq_("./conversions");function buildGraph(){const n={},e=Ob
|
|
|
41
41
|
},{}],9:[function(_dereq_,module,exports){
|
|
42
42
|
"use strict";module.exports={stdout:!1,stderr:!1};
|
|
43
43
|
},{}],10:[function(_dereq_,module,exports){
|
|
44
|
-
"use strict";const ASTY=_dereq_("asty-astq"),PEGUtil=_dereq_("pegjs-util"),chalk=_dereq_("chalk"),PEGparser=function(){class e extends SyntaxError{constructor(e,t,r,n){super(e),this.expected=t,this.found=r,this.location=n,this.name="SyntaxError"}format(e){let t="Error: "+this.message;if(this.location){let r=null;const n=e.find(e=>e.source===this.location.source);n&&(r=n.text.split(/\r\n|\n|\r/g));const l=this.location.start,o=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(l):l,s=this.location.source+":"+o.line+":"+o.column;if(r){const e=this.location.end,n="".padEnd(o.line.toString().length," "),a=r[l.line-1],u=(l.line===e.line?e.column:a.length+1)-l.column||1;t+="\n --\x3e "+s+"\n"+n+" |\n"+o.line+" | "+a+"\n"+n+" | "+"".padEnd(l.column-1," ")+"".padEnd(u,"^")}else t+="\n at "+s}return t}static buildMessage(e,t){function r(e){return e.codePointAt(0).toString(16).toUpperCase()}const n=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function l(e){return n?e.replace(n,e=>"\\u{"+r(e)+"}"):e}function o(e){return l(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}function s(e){return l(e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}const a={literal:e=>'"'+o(e.text)+'"',class(e){const t=e.parts.map(e=>Array.isArray(e)?s(e[0])+"-"+s(e[1]):s(e));return"["+(e.inverted?"^":"")+t.join("")+"]"+(e.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:e=>e.description};function u(e){return a[e.type](e)}return"Expected "+function(e){const t=e.map(u);if(t.sort(),t.length>0){let e=1;for(let r=1;r<t.length;r++)t[r-1]!==t[r]&&(t[e]=t[r],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+" or "+t[1];default:return t.slice(0,-1).join(", ")+", or "+t[t.length-1]}}(e)+" but "+function(e){return e?'"'+o(e)+'"':"end of input"}(t)+" found."}}return{StartRules:["json"],SyntaxError:e,parse:function(t,r){const n={},l=(r=void 0!==r?r:{}).grammarSource,o={json:Ge};let s=Ge;const a="{",u=",",c="}",i=":",p="[",g="]",f="-",h="0",d=".",A='"',b="\\",y="b",m="f",x="n",C="r",v="t",E="u",w="null",S="false",F="true",j=/^[1-9]/,k=/^[0-9]/,P=/^[eE]/,R=/^[+\-]/,$=/^[^\0-\x1F"\\]/,O=/^["\/\\]/,q=/^[0-9a-f]/i,G=/^[ \t\n\r]/,J=je("{",!1),M=je(",",!1),T=je("}",!1),U=je(":",!1),N=je("[",!1),I=je("]",!1),Y=Pe("number literal value"),D=je("-",!1),L=je("0",!1),z=ke([["1","9"]],!1,!1,!1),B=ke([["0","9"]],!1,!1,!1),H=je(".",!1),K=ke(["e","E"],!1,!1,!1),Q=ke(["+","-"],!1,!1,!1),V=Pe("quoted string literal value"),W=je('"',!1),X=ke([["\0",""],'"',"\\"],!0,!1,!1),Z=je("\\",!1),_=ke(['"',"/","\\"],!1,!1,!1),ee=je("b",!1),te=je("f",!1),re=je("n",!1),ne=je("r",!1),le=je("t",!1),oe=je("u",!1),se=ke([["0","9"],["a","f"]],!1,!0,!1),ae=Pe("object null literal value"),ue=je("null",!1),ce=Pe("boolean false literal value"),ie=je("false",!1),pe=Pe("boolean true literal value"),ge=je("true",!1),fe=Pe("whitespace"),he=ke([" ","\t","\n","\r"],!1,!1,!1),de=Pe("end of file"),Ae={type:"any"};function be(e){return String.fromCharCode(parseInt(e,16))}function ye(e){return e}let me=0|r.peg$currPos,xe=me;const Ce=[{line:1,column:1}];let ve,Ee=me,we=r.peg$maxFailExpected||[],Se=0|r.peg$silentFails;if(r.startRule){if(!(r.startRule in o))throw new Error("Can't start parsing from rule \""+r.startRule+'".');s=o[r.startRule]}function Fe(){return t.substring(xe,me)}function je(e,t){return{type:"literal",text:e,ignoreCase:t}}function ke(e,t,r,n){return{type:"class",parts:e,inverted:t,ignoreCase:r,unicode:n}}function Pe(e){return{type:"other",description:e}}function Re(e){let r,n=Ce[e];if(n)return n;if(e>=Ce.length)r=Ce.length-1;else for(r=e;!Ce[--r];);for(n={line:(n=Ce[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return Ce[e]=n,n}function $e(e,t,r){const n=Re(e),o=Re(t),s={source:l,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:o.line,column:o.column}};return r&&l&&"function"==typeof l.offset&&(s.start=l.offset(s.start),s.end=l.offset(s.end)),s}function Oe(e){me<Ee||(me>Ee&&(Ee=me,we=[]),we.push(e))}function qe(t,r,n){return new e(e.buildMessage(t,r),t,r,n)}function Ge(){let e,r,l,o,s;var a,u,c;return e=me,r=me,(l=Ue())===n&&(l=null),r=t.substring(r,me),(l=Je())!==n?(o=me,(s=Ue())===n&&(s=null),o=t.substring(o,me),(s=function(){let e,r;return Se++,e=me,Se++,t.length>me?(r=t.charAt(me),me++):(r=n,0===Se&&Oe(Ae)),Se--,r===n?e=void 0:(me=e,e=n),Se--,e===n&&(r=n,0===Se&&Oe(de)),e}())!==n?(xe=e,u=l,c=o,(a=r)&&u.set("prolog",a+(u.get("prolog")||"")),c&&u.set("epilog",(u.get("epilog")||"")+c),e=u):(me=e,e=n)):(me=e,e=n),e}function Je(){let e;return(e=function(){let e,r,l,o,s,i,p,g,f,h,d;if(e=me,r=me,l=me,(o=Ue())===n&&(o=null),123===t.charCodeAt(me)?(s=a,me++):(s=n,0===Se&&Oe(J)),s!==n?((i=Ue())===n&&(i=null),l=o=[o,s,i]):(me=l,l=n),(r=l!==n?t.substring(r,me):l)!==n){if(l=me,(o=Me())!==n){for(s=[],i=me,p=me,g=me,(f=Ue())===n&&(f=null),44===t.charCodeAt(me)?(h=u,me++):(h=n,0===Se&&Oe(M)),h!==n?((d=Ue())===n&&(d=null),g=f=[f,h,d]):(me=g,g=n),(p=g!==n?t.substring(p,me):g)!==n&&(g=Me())!==n?i=p=[p,g]:(me=i,i=n);i!==n;)s.push(i),i=me,p=me,g=me,(f=Ue())===n&&(f=null),44===t.charCodeAt(me)?(h=u,me++):(h=n,0===Se&&Oe(M)),h!==n?((d=Ue())===n&&(d=null),g=f=[f,h,d]):(me=g,g=n),(p=g!==n?t.substring(p,me):g)!==n&&(g=Me())!==n?i=p=[p,g]:(me=i,i=n);xe=l,m=o,l=s.reduce((e,t)=>{const r=e[e.length-1].get("epilog")||"";return e[e.length-1].set({epilog:r+t[0]}),e.concat([t[1]])},[m])}else me=l,l=n;l===n&&(l=null),o=me,s=me,(i=Ue())===n&&(i=null),125===t.charCodeAt(me)?(p=c,me++):(p=n,0===Se&&Oe(T)),p!==n?((g=Ue())===n&&(g=null),s=i=[i,p,g]):(me=s,s=n),(o=s!==n?t.substring(o,me):s)!==n?(xe=e,A=r,b=l,y=o,e=Ne("object").set({prolog:A}).set({epilog:y}).add(b)):(me=e,e=n)}else me=e,e=n;var A,b,y,m;return e}())===n&&(e=function(){let e,r,l,o,s,a,c,i,f,h,d;if(e=me,r=me,l=me,(o=Ue())===n&&(o=null),91===t.charCodeAt(me)?(s=p,me++):(s=n,0===Se&&Oe(N)),s!==n?((a=Ue())===n&&(a=null),l=o=[o,s,a]):(me=l,l=n),(r=l!==n?t.substring(r,me):l)!==n){if(l=me,(o=Je())!==n){for(s=[],a=me,c=me,i=me,(f=Ue())===n&&(f=null),44===t.charCodeAt(me)?(h=u,me++):(h=n,0===Se&&Oe(M)),h!==n?((d=Ue())===n&&(d=null),i=f=[f,h,d]):(me=i,i=n),(c=i!==n?t.substring(c,me):i)!==n&&(i=Je())!==n?a=c=[c,i]:(me=a,a=n);a!==n;)s.push(a),a=me,c=me,i=me,(f=Ue())===n&&(f=null),44===t.charCodeAt(me)?(h=u,me++):(h=n,0===Se&&Oe(M)),h!==n?((d=Ue())===n&&(d=null),i=f=[f,h,d]):(me=i,i=n),(c=i!==n?t.substring(c,me):i)!==n&&(i=Je())!==n?a=c=[c,i]:(me=a,a=n);xe=l,m=o,l=s.reduce((e,t)=>{const r=e[e.length-1].get("epilog")||"";return e[e.length-1].set({epilog:r+t[0]}),e.concat([t[1]])},[m])}else me=l,l=n;l===n&&(l=null),o=me,s=me,(a=Ue())===n&&(a=null),93===t.charCodeAt(me)?(c=g,me++):(c=n,0===Se&&Oe(I)),c!==n?((i=Ue())===n&&(i=null),s=a=[a,c,i]):(me=s,s=n),(o=s!==n?t.substring(o,me):s)!==n?(xe=e,A=r,b=l,y=o,e=Ne("array").set({prolog:A}).set({epilog:y}).add(b)):(me=e,e=n)}else me=e,e=n;var A,b,y,m;return e}())===n&&(e=function(){let e,r,l,o,s,a,u,c,i;if(Se++,e=me,45===t.charCodeAt(me)?(r=f,me++):(r=n,0===Se&&Oe(D)),r===n&&(r=null),48===t.charCodeAt(me)?(l=h,me++):(l=n,0===Se&&Oe(L)),l===n)if(l=me,o=t.charAt(me),j.test(o)?me++:(o=n,0===Se&&Oe(z)),o!==n){for(s=[],a=t.charAt(me),k.test(a)?me++:(a=n,0===Se&&Oe(B));a!==n;)s.push(a),a=t.charAt(me),k.test(a)?me++:(a=n,0===Se&&Oe(B));l=o=[o,s]}else me=l,l=n;if(l!==n){if(o=me,46===t.charCodeAt(me)?(s=d,me++):(s=n,0===Se&&Oe(H)),s!==n){if(a=[],u=t.charAt(me),k.test(u)?me++:(u=n,0===Se&&Oe(B)),u!==n)for(;u!==n;)a.push(u),u=t.charAt(me),k.test(u)?me++:(u=n,0===Se&&Oe(B));else a=n;a!==n?o=s=[s,a]:(me=o,o=n)}else me=o,o=n;if(o===n&&(o=null),s=me,a=t.charAt(me),P.test(a)?me++:(a=n,0===Se&&Oe(K)),a!==n){if(u=t.charAt(me),R.test(u)?me++:(u=n,0===Se&&Oe(Q)),u===n&&(u=null),c=[],i=t.charAt(me),k.test(i)?me++:(i=n,0===Se&&Oe(B)),i!==n)for(;i!==n;)c.push(i),i=t.charAt(me),k.test(i)?me++:(i=n,0===Se&&Oe(B));else c=n;c!==n?s=a=[a,u,c]:(me=s,s=n)}else me=s,s=n;s===n&&(s=null),xe=e,e=Ne("number").set({body:Fe(),value:parseFloat(Fe())})}else me=e,e=n;return Se--,e===n&&(r=n,0===Se&&Oe(Y)),e}())===n&&(e=Te())===n&&(e=function(){let e,r;return Se++,e=me,t.substr(me,4)===w?(r=w,me+=4):(r=n,0===Se&&Oe(ue)),r!==n&&(xe=e,r=Ne("null").set({body:Fe(),value:null})),Se--,(e=r)===n&&(r=n,0===Se&&Oe(ae)),e}())===n&&(e=function(){let e,r;return Se++,e=me,t.substr(me,5)===S?(r=S,me+=5):(r=n,0===Se&&Oe(ie)),r!==n&&(xe=e,r=Ne("boolean").set({body:Fe(),value:!1})),Se--,(e=r)===n&&(r=n,0===Se&&Oe(ce)),e}())===n&&(e=function(){let e,r;return Se++,e=me,t.substr(me,4)===F?(r=F,me+=4):(r=n,0===Se&&Oe(ge)),r!==n&&(xe=e,r=Ne("boolean").set({body:Fe(),value:!0})),Se--,(e=r)===n&&(r=n,0===Se&&Oe(pe)),e}()),e}function Me(){let e,r,l,o,s,a,u;var c,p,g;return e=me,(r=Te())!==n?(l=me,o=me,(s=Ue())===n&&(s=null),58===t.charCodeAt(me)?(a=i,me++):(a=n,0===Se&&Oe(U)),a!==n?((u=Ue())===n&&(u=null),o=s=[s,a,u]):(me=o,o=n),(l=o!==n?t.substring(l,me):o)!==n&&(o=Je())!==n?(xe=e,c=r,p=l,g=o,e=Ne("member").add(c.set({epilog:p}),g)):(me=e,e=n)):(me=e,e=n),e}function Te(){let e,r,l,o,s,a,u,c,i,p,g,f,h;if(Se++,e=me,34===t.charCodeAt(me)?(r=A,me++):(r=n,0===Se&&Oe(W)),r!==n){for(l=[],o=t.charAt(me),$.test(o)?me++:(o=n,0===Se&&Oe(X)),o===n&&(o=me,92===t.charCodeAt(me)?(s=b,me++):(s=n,0===Se&&Oe(Z)),s!==n?(a=t.charAt(me),O.test(a)?me++:(a=n,0===Se&&Oe(_)),a===n&&(a=me,98===t.charCodeAt(me)?(u=y,me++):(u=n,0===Se&&Oe(ee)),u!==n&&(xe=a,u="\b"),(a=u)===n&&(a=me,102===t.charCodeAt(me)?(u=m,me++):(u=n,0===Se&&Oe(te)),u!==n&&(xe=a,u="\f"),(a=u)===n&&(a=me,110===t.charCodeAt(me)?(u=x,me++):(u=n,0===Se&&Oe(re)),u!==n&&(xe=a,u="\n"),(a=u)===n&&(a=me,114===t.charCodeAt(me)?(u=C,me++):(u=n,0===Se&&Oe(ne)),u!==n&&(xe=a,u="\r"),(a=u)===n&&(a=me,116===t.charCodeAt(me)?(u=v,me++):(u=n,0===Se&&Oe(le)),u!==n&&(xe=a,u="\t"),(a=u)===n&&(a=me,117===t.charCodeAt(me)?(u=E,me++):(u=n,0===Se&&Oe(oe)),u!==n?(c=me,i=me,p=t.charAt(me),q.test(p)?me++:(p=n,0===Se&&Oe(se)),p!==n?(g=t.charAt(me),q.test(g)?me++:(g=n,0===Se&&Oe(se)),g!==n?(f=t.charAt(me),q.test(f)?me++:(f=n,0===Se&&Oe(se)),f!==n?(h=t.charAt(me),q.test(h)?me++:(h=n,0===Se&&Oe(se)),h!==n?i=p=[p,g,f,h]:(me=i,i=n)):(me=i,i=n)):(me=i,i=n)):(me=i,i=n),(c=i!==n?t.substring(c,me):i)!==n?(xe=a,a=be(c)):(me=a,a=n)):(me=a,a=n))))))),a!==n?(xe=o,o=ye(a)):(me=o,o=n)):(me=o,o=n));o!==n;)l.push(o),o=t.charAt(me),$.test(o)?me++:(o=n,0===Se&&Oe(X)),o===n&&(o=me,92===t.charCodeAt(me)?(s=b,me++):(s=n,0===Se&&Oe(Z)),s!==n?(a=t.charAt(me),O.test(a)?me++:(a=n,0===Se&&Oe(_)),a===n&&(a=me,98===t.charCodeAt(me)?(u=y,me++):(u=n,0===Se&&Oe(ee)),u!==n&&(xe=a,u="\b"),(a=u)===n&&(a=me,102===t.charCodeAt(me)?(u=m,me++):(u=n,0===Se&&Oe(te)),u!==n&&(xe=a,u="\f"),(a=u)===n&&(a=me,110===t.charCodeAt(me)?(u=x,me++):(u=n,0===Se&&Oe(re)),u!==n&&(xe=a,u="\n"),(a=u)===n&&(a=me,114===t.charCodeAt(me)?(u=C,me++):(u=n,0===Se&&Oe(ne)),u!==n&&(xe=a,u="\r"),(a=u)===n&&(a=me,116===t.charCodeAt(me)?(u=v,me++):(u=n,0===Se&&Oe(le)),u!==n&&(xe=a,u="\t"),(a=u)===n&&(a=me,117===t.charCodeAt(me)?(u=E,me++):(u=n,0===Se&&Oe(oe)),u!==n?(c=me,i=me,p=t.charAt(me),q.test(p)?me++:(p=n,0===Se&&Oe(se)),p!==n?(g=t.charAt(me),q.test(g)?me++:(g=n,0===Se&&Oe(se)),g!==n?(f=t.charAt(me),q.test(f)?me++:(f=n,0===Se&&Oe(se)),f!==n?(h=t.charAt(me),q.test(h)?me++:(h=n,0===Se&&Oe(se)),h!==n?i=p=[p,g,f,h]:(me=i,i=n)):(me=i,i=n)):(me=i,i=n)):(me=i,i=n),(c=i!==n?t.substring(c,me):i)!==n?(xe=a,a=be(c)):(me=a,a=n)):(me=a,a=n))))))),a!==n?(xe=o,o=ye(a)):(me=o,o=n)):(me=o,o=n));34===t.charCodeAt(me)?(o=A,me++):(o=n,0===Se&&Oe(W)),o!==n?(xe=e,d=l,e=Ne("string").set({body:Fe(),value:d.join("")})):(me=e,e=n)}else me=e,e=n;var d;return Se--,e===n&&(r=n,0===Se&&Oe(V)),e}function Ue(){let e,r;if(Se++,e=[],r=t.charAt(me),G.test(r)?me++:(r=n,0===Se&&Oe(he)),r!==n)for(;r!==n;)e.push(r),r=t.charAt(me),G.test(r)?me++:(r=n,0===Se&&Oe(he));else e=n;return Se--,e===n&&(r=n,0===Se&&Oe(fe)),e}var Ne=r.util.makeAST(function(){return $e(xe,me)},r);const Ie=(ve=s())!==n&&me===t.length;function Ye(){throw ve!==n&&me<t.length&&Oe({type:"end"}),qe(we,Ee<t.length?function(e=me){const r=t.codePointAt(e);return void 0===r?"":String.fromCodePoint(r)}(Ee):null,Ee<t.length?$e(Ee,Ee+1):$e(Ee,Ee))}return r.peg$library?{peg$result:ve,peg$currPos:me,peg$FAILED:n,peg$maxFailExpected:we,peg$maxFailPos:Ee,peg$success:Ie,peg$throw:Ie?void 0:Ye}:Ie?ve:void Ye()}}}();class JsonAsty{static parse(e){if("string"!=typeof e)throw new Error("invalid JSON argument (expected type string)");const t=new ASTY,r=PEGUtil.parse(PEGparser,e,{startRule:"json",makeAST:(e,r,n,l)=>t.create.apply(t,l).pos(e,r,n)});if(null!==r.error)throw new Error("parse: JSON parsing failure:\n"+PEGUtil.errorMessage(r.error,!0).replace(/^/gm,"ERROR: ")+"\n");return r.ast}static dump(e,t={}){let r;return r=(t=Object.assign({},{colors:!1},t)).colors?e.dump(1/0,(e,t)=>{switch(e){case"tree":t=chalk.grey(t);break;case"type":t=chalk.blue(t);break;case"value":t=chalk.yellow(t);break;case"position":t=chalk.grey(t)}return t}):e.dump(1/0)}static unparse(e){if("object"!=typeof e)throw new Error("generate: invalid AST argument (expected type object)");let t="";return e.walk((e,r,n,l)=>{if("downward"===l){const r=e.get("prolog");void 0!==r&&(t+=r);const n=e.get("body");if(void 0!==n)t+=n;else{const r=e.get("value");void 0!==r&&(t+=JSON.stringify(r))}}else if("upward"===l){const r=e.get("epilog");void 0!==r&&(t+=r)}},"both"),t}}module.exports=JsonAsty;
|
|
44
|
+
"use strict";const ASTY=_dereq_("asty-astq"),PEG={},PEGUtil=_dereq_("pegjs-util"),chalk=_dereq_("chalk"),PEGparser=function(){class e extends SyntaxError{constructor(e,t,r,n){super(e),this.expected=t,this.found=r,this.location=n,this.name="SyntaxError"}format(e){let t="Error: "+this.message;if(this.location){let r=null;const n=e.find(e=>e.source===this.location.source);n&&(r=n.text.split(/\r\n|\n|\r/g));const l=this.location.start,o=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(l):l,s=this.location.source+":"+o.line+":"+o.column;if(r){const e=this.location.end,n="".padEnd(o.line.toString().length," "),a=r[l.line-1],u=(l.line===e.line?e.column:a.length+1)-l.column||1;t+="\n --\x3e "+s+"\n"+n+" |\n"+o.line+" | "+a+"\n"+n+" | "+"".padEnd(l.column-1," ")+"".padEnd(u,"^")}else t+="\n at "+s}return t}static buildMessage(e,t){function r(e){return e.codePointAt(0).toString(16).toUpperCase()}const n=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function l(e){return n?e.replace(n,e=>"\\u{"+r(e)+"}"):e}function o(e){return l(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}function s(e){return l(e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}const a={literal:e=>'"'+o(e.text)+'"',class(e){const t=e.parts.map(e=>Array.isArray(e)?s(e[0])+"-"+s(e[1]):s(e));return"["+(e.inverted?"^":"")+t.join("")+"]"+(e.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:e=>e.description};function u(e){return a[e.type](e)}return"Expected "+function(e){const t=e.map(u);if(t.sort(),t.length>0){let e=1;for(let r=1;r<t.length;r++)t[r-1]!==t[r]&&(t[e]=t[r],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+" or "+t[1];default:return t.slice(0,-1).join(", ")+", or "+t[t.length-1]}}(e)+" but "+function(e){return e?'"'+o(e)+'"':"end of input"}(t)+" found."}}return{StartRules:["json"],SyntaxError:e,parse:function(t,r){const n={},l=(r=void 0!==r?r:{}).grammarSource,o={json:qe};let s=qe;const a="{",u=",",c="}",i=":",p="[",g="]",f="-",h="0",d=".",A='"',b="\\",y="b",m="f",x="n",C="r",v="t",E="u",w="null",S="false",F="true",j=/^[1-9]/,P=/^[0-9]/,k=/^[eE]/,R=/^[+\-]/,$=/^[^\0-\x1F"\\]/,O=/^["\/\\]/,G=/^[0-9a-f]/i,q=/^[ \t\n\r]/,J=je("{",!1),M=je(",",!1),T=je("}",!1),U=je(":",!1),N=je("[",!1),I=je("]",!1),Y=ke("number literal value"),D=je("-",!1),L=je("0",!1),z=Pe([["1","9"]],!1,!1,!1),B=Pe([["0","9"]],!1,!1,!1),H=je(".",!1),K=Pe(["e","E"],!1,!1,!1),Q=Pe(["+","-"],!1,!1,!1),V=ke("quoted string literal value"),W=je('"',!1),X=Pe([["\0",""],'"',"\\"],!0,!1,!1),Z=je("\\",!1),_=Pe(['"',"/","\\"],!1,!1,!1),ee=je("b",!1),te=je("f",!1),re=je("n",!1),ne=je("r",!1),le=je("t",!1),oe=je("u",!1),se=Pe([["0","9"],["a","f"]],!1,!0,!1),ae=ke("object null literal value"),ue=je("null",!1),ce=ke("boolean false literal value"),ie=je("false",!1),pe=ke("boolean true literal value"),ge=je("true",!1),fe=ke("whitespace"),he=Pe([" ","\t","\n","\r"],!1,!1,!1),de=ke("end of file"),Ae={type:"any"};function be(e){return String.fromCharCode(parseInt(e,16))}function ye(e){return e}let me=0|r.peg$currPos,xe=me;const Ce=[{line:1,column:1}];let ve,Ee=me,we=r.peg$maxFailExpected||[],Se=0|r.peg$silentFails;if(r.startRule){if(!(r.startRule in o))throw new Error("Can't start parsing from rule \""+r.startRule+'".');s=o[r.startRule]}function Fe(){return t.substring(xe,me)}function je(e,t){return{type:"literal",text:e,ignoreCase:t}}function Pe(e,t,r,n){return{type:"class",parts:e,inverted:t,ignoreCase:r,unicode:n}}function ke(e){return{type:"other",description:e}}function Re(e){let r,n=Ce[e];if(n)return n;if(e>=Ce.length)r=Ce.length-1;else for(r=e;!Ce[--r];);for(n={line:(n=Ce[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return Ce[e]=n,n}function $e(e,t,r){const n=Re(e),o=Re(t),s={source:l,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:o.line,column:o.column}};return r&&l&&"function"==typeof l.offset&&(s.start=l.offset(s.start),s.end=l.offset(s.end)),s}function Oe(e){me<Ee||(me>Ee&&(Ee=me,we=[]),we.push(e))}function Ge(t,r,n){return new e(e.buildMessage(t,r),t,r,n)}function qe(){let e,r,l,o,s;var a,u,c;return e=me,r=me,(l=Ue())===n&&(l=null),r=t.substring(r,me),(l=Je())!==n?(o=me,(s=Ue())===n&&(s=null),o=t.substring(o,me),(s=function(){let e,r;return Se++,e=me,Se++,t.length>me?(r=t.charAt(me),me++):(r=n,0===Se&&Oe(Ae)),Se--,r===n?e=void 0:(me=e,e=n),Se--,e===n&&(r=n,0===Se&&Oe(de)),e}())!==n?(xe=e,u=l,c=o,(a=r)&&u.set("prolog",a+(u.get("prolog")||"")),c&&u.set("epilog",(u.get("epilog")||"")+c),e=u):(me=e,e=n)):(me=e,e=n),e}function Je(){let e;return(e=function(){let e,r,l,o,s,i,p,g,f,h,d;if(e=me,r=me,l=me,(o=Ue())===n&&(o=null),123===t.charCodeAt(me)?(s=a,me++):(s=n,0===Se&&Oe(J)),s!==n?((i=Ue())===n&&(i=null),l=o=[o,s,i]):(me=l,l=n),(r=l!==n?t.substring(r,me):l)!==n){if(l=me,(o=Me())!==n){for(s=[],i=me,p=me,g=me,(f=Ue())===n&&(f=null),44===t.charCodeAt(me)?(h=u,me++):(h=n,0===Se&&Oe(M)),h!==n?((d=Ue())===n&&(d=null),g=f=[f,h,d]):(me=g,g=n),(p=g!==n?t.substring(p,me):g)!==n&&(g=Me())!==n?i=p=[p,g]:(me=i,i=n);i!==n;)s.push(i),i=me,p=me,g=me,(f=Ue())===n&&(f=null),44===t.charCodeAt(me)?(h=u,me++):(h=n,0===Se&&Oe(M)),h!==n?((d=Ue())===n&&(d=null),g=f=[f,h,d]):(me=g,g=n),(p=g!==n?t.substring(p,me):g)!==n&&(g=Me())!==n?i=p=[p,g]:(me=i,i=n);xe=l,m=o,l=s.reduce((e,t)=>{const r=e[e.length-1].get("epilog")||"";return e[e.length-1].set({epilog:r+t[0]}),e.concat([t[1]])},[m])}else me=l,l=n;l===n&&(l=null),o=me,s=me,(i=Ue())===n&&(i=null),125===t.charCodeAt(me)?(p=c,me++):(p=n,0===Se&&Oe(T)),p!==n?((g=Ue())===n&&(g=null),s=i=[i,p,g]):(me=s,s=n),(o=s!==n?t.substring(o,me):s)!==n?(xe=e,A=r,b=l,y=o,e=Ne("object").set({prolog:A}).set({epilog:y}).add(b)):(me=e,e=n)}else me=e,e=n;var A,b,y,m;return e}())===n&&(e=function(){let e,r,l,o,s,a,c,i,f,h,d;if(e=me,r=me,l=me,(o=Ue())===n&&(o=null),91===t.charCodeAt(me)?(s=p,me++):(s=n,0===Se&&Oe(N)),s!==n?((a=Ue())===n&&(a=null),l=o=[o,s,a]):(me=l,l=n),(r=l!==n?t.substring(r,me):l)!==n){if(l=me,(o=Je())!==n){for(s=[],a=me,c=me,i=me,(f=Ue())===n&&(f=null),44===t.charCodeAt(me)?(h=u,me++):(h=n,0===Se&&Oe(M)),h!==n?((d=Ue())===n&&(d=null),i=f=[f,h,d]):(me=i,i=n),(c=i!==n?t.substring(c,me):i)!==n&&(i=Je())!==n?a=c=[c,i]:(me=a,a=n);a!==n;)s.push(a),a=me,c=me,i=me,(f=Ue())===n&&(f=null),44===t.charCodeAt(me)?(h=u,me++):(h=n,0===Se&&Oe(M)),h!==n?((d=Ue())===n&&(d=null),i=f=[f,h,d]):(me=i,i=n),(c=i!==n?t.substring(c,me):i)!==n&&(i=Je())!==n?a=c=[c,i]:(me=a,a=n);xe=l,m=o,l=s.reduce((e,t)=>{const r=e[e.length-1].get("epilog")||"";return e[e.length-1].set({epilog:r+t[0]}),e.concat([t[1]])},[m])}else me=l,l=n;l===n&&(l=null),o=me,s=me,(a=Ue())===n&&(a=null),93===t.charCodeAt(me)?(c=g,me++):(c=n,0===Se&&Oe(I)),c!==n?((i=Ue())===n&&(i=null),s=a=[a,c,i]):(me=s,s=n),(o=s!==n?t.substring(o,me):s)!==n?(xe=e,A=r,b=l,y=o,e=Ne("array").set({prolog:A}).set({epilog:y}).add(b)):(me=e,e=n)}else me=e,e=n;var A,b,y,m;return e}())===n&&(e=function(){let e,r,l,o,s,a,u,c,i;if(Se++,e=me,45===t.charCodeAt(me)?(r=f,me++):(r=n,0===Se&&Oe(D)),r===n&&(r=null),48===t.charCodeAt(me)?(l=h,me++):(l=n,0===Se&&Oe(L)),l===n)if(l=me,o=t.charAt(me),j.test(o)?me++:(o=n,0===Se&&Oe(z)),o!==n){for(s=[],a=t.charAt(me),P.test(a)?me++:(a=n,0===Se&&Oe(B));a!==n;)s.push(a),a=t.charAt(me),P.test(a)?me++:(a=n,0===Se&&Oe(B));l=o=[o,s]}else me=l,l=n;if(l!==n){if(o=me,46===t.charCodeAt(me)?(s=d,me++):(s=n,0===Se&&Oe(H)),s!==n){if(a=[],u=t.charAt(me),P.test(u)?me++:(u=n,0===Se&&Oe(B)),u!==n)for(;u!==n;)a.push(u),u=t.charAt(me),P.test(u)?me++:(u=n,0===Se&&Oe(B));else a=n;a!==n?o=s=[s,a]:(me=o,o=n)}else me=o,o=n;if(o===n&&(o=null),s=me,a=t.charAt(me),k.test(a)?me++:(a=n,0===Se&&Oe(K)),a!==n){if(u=t.charAt(me),R.test(u)?me++:(u=n,0===Se&&Oe(Q)),u===n&&(u=null),c=[],i=t.charAt(me),P.test(i)?me++:(i=n,0===Se&&Oe(B)),i!==n)for(;i!==n;)c.push(i),i=t.charAt(me),P.test(i)?me++:(i=n,0===Se&&Oe(B));else c=n;c!==n?s=a=[a,u,c]:(me=s,s=n)}else me=s,s=n;s===n&&(s=null),xe=e,e=Ne("number").set({body:Fe(),value:parseFloat(Fe())})}else me=e,e=n;return Se--,e===n&&(r=n,0===Se&&Oe(Y)),e}())===n&&(e=Te())===n&&(e=function(){let e,r;return Se++,e=me,t.substr(me,4)===w?(r=w,me+=4):(r=n,0===Se&&Oe(ue)),r!==n&&(xe=e,r=Ne("null").set({body:Fe(),value:null})),Se--,(e=r)===n&&(r=n,0===Se&&Oe(ae)),e}())===n&&(e=function(){let e,r;return Se++,e=me,t.substr(me,5)===S?(r=S,me+=5):(r=n,0===Se&&Oe(ie)),r!==n&&(xe=e,r=Ne("boolean").set({body:Fe(),value:!1})),Se--,(e=r)===n&&(r=n,0===Se&&Oe(ce)),e}())===n&&(e=function(){let e,r;return Se++,e=me,t.substr(me,4)===F?(r=F,me+=4):(r=n,0===Se&&Oe(ge)),r!==n&&(xe=e,r=Ne("boolean").set({body:Fe(),value:!0})),Se--,(e=r)===n&&(r=n,0===Se&&Oe(pe)),e}()),e}function Me(){let e,r,l,o,s,a,u;var c,p,g;return e=me,(r=Te())!==n?(l=me,o=me,(s=Ue())===n&&(s=null),58===t.charCodeAt(me)?(a=i,me++):(a=n,0===Se&&Oe(U)),a!==n?((u=Ue())===n&&(u=null),o=s=[s,a,u]):(me=o,o=n),(l=o!==n?t.substring(l,me):o)!==n&&(o=Je())!==n?(xe=e,c=r,p=l,g=o,e=Ne("member").add(c.set({epilog:p}),g)):(me=e,e=n)):(me=e,e=n),e}function Te(){let e,r,l,o,s,a,u,c,i,p,g,f,h;if(Se++,e=me,34===t.charCodeAt(me)?(r=A,me++):(r=n,0===Se&&Oe(W)),r!==n){for(l=[],o=t.charAt(me),$.test(o)?me++:(o=n,0===Se&&Oe(X)),o===n&&(o=me,92===t.charCodeAt(me)?(s=b,me++):(s=n,0===Se&&Oe(Z)),s!==n?(a=t.charAt(me),O.test(a)?me++:(a=n,0===Se&&Oe(_)),a===n&&(a=me,98===t.charCodeAt(me)?(u=y,me++):(u=n,0===Se&&Oe(ee)),u!==n&&(xe=a,u="\b"),(a=u)===n&&(a=me,102===t.charCodeAt(me)?(u=m,me++):(u=n,0===Se&&Oe(te)),u!==n&&(xe=a,u="\f"),(a=u)===n&&(a=me,110===t.charCodeAt(me)?(u=x,me++):(u=n,0===Se&&Oe(re)),u!==n&&(xe=a,u="\n"),(a=u)===n&&(a=me,114===t.charCodeAt(me)?(u=C,me++):(u=n,0===Se&&Oe(ne)),u!==n&&(xe=a,u="\r"),(a=u)===n&&(a=me,116===t.charCodeAt(me)?(u=v,me++):(u=n,0===Se&&Oe(le)),u!==n&&(xe=a,u="\t"),(a=u)===n&&(a=me,117===t.charCodeAt(me)?(u=E,me++):(u=n,0===Se&&Oe(oe)),u!==n?(c=me,i=me,p=t.charAt(me),G.test(p)?me++:(p=n,0===Se&&Oe(se)),p!==n?(g=t.charAt(me),G.test(g)?me++:(g=n,0===Se&&Oe(se)),g!==n?(f=t.charAt(me),G.test(f)?me++:(f=n,0===Se&&Oe(se)),f!==n?(h=t.charAt(me),G.test(h)?me++:(h=n,0===Se&&Oe(se)),h!==n?i=p=[p,g,f,h]:(me=i,i=n)):(me=i,i=n)):(me=i,i=n)):(me=i,i=n),(c=i!==n?t.substring(c,me):i)!==n?(xe=a,a=be(c)):(me=a,a=n)):(me=a,a=n))))))),a!==n?(xe=o,o=ye(a)):(me=o,o=n)):(me=o,o=n));o!==n;)l.push(o),o=t.charAt(me),$.test(o)?me++:(o=n,0===Se&&Oe(X)),o===n&&(o=me,92===t.charCodeAt(me)?(s=b,me++):(s=n,0===Se&&Oe(Z)),s!==n?(a=t.charAt(me),O.test(a)?me++:(a=n,0===Se&&Oe(_)),a===n&&(a=me,98===t.charCodeAt(me)?(u=y,me++):(u=n,0===Se&&Oe(ee)),u!==n&&(xe=a,u="\b"),(a=u)===n&&(a=me,102===t.charCodeAt(me)?(u=m,me++):(u=n,0===Se&&Oe(te)),u!==n&&(xe=a,u="\f"),(a=u)===n&&(a=me,110===t.charCodeAt(me)?(u=x,me++):(u=n,0===Se&&Oe(re)),u!==n&&(xe=a,u="\n"),(a=u)===n&&(a=me,114===t.charCodeAt(me)?(u=C,me++):(u=n,0===Se&&Oe(ne)),u!==n&&(xe=a,u="\r"),(a=u)===n&&(a=me,116===t.charCodeAt(me)?(u=v,me++):(u=n,0===Se&&Oe(le)),u!==n&&(xe=a,u="\t"),(a=u)===n&&(a=me,117===t.charCodeAt(me)?(u=E,me++):(u=n,0===Se&&Oe(oe)),u!==n?(c=me,i=me,p=t.charAt(me),G.test(p)?me++:(p=n,0===Se&&Oe(se)),p!==n?(g=t.charAt(me),G.test(g)?me++:(g=n,0===Se&&Oe(se)),g!==n?(f=t.charAt(me),G.test(f)?me++:(f=n,0===Se&&Oe(se)),f!==n?(h=t.charAt(me),G.test(h)?me++:(h=n,0===Se&&Oe(se)),h!==n?i=p=[p,g,f,h]:(me=i,i=n)):(me=i,i=n)):(me=i,i=n)):(me=i,i=n),(c=i!==n?t.substring(c,me):i)!==n?(xe=a,a=be(c)):(me=a,a=n)):(me=a,a=n))))))),a!==n?(xe=o,o=ye(a)):(me=o,o=n)):(me=o,o=n));34===t.charCodeAt(me)?(o=A,me++):(o=n,0===Se&&Oe(W)),o!==n?(xe=e,d=l,e=Ne("string").set({body:Fe(),value:d.join("")})):(me=e,e=n)}else me=e,e=n;var d;return Se--,e===n&&(r=n,0===Se&&Oe(V)),e}function Ue(){let e,r;if(Se++,e=[],r=t.charAt(me),q.test(r)?me++:(r=n,0===Se&&Oe(he)),r!==n)for(;r!==n;)e.push(r),r=t.charAt(me),q.test(r)?me++:(r=n,0===Se&&Oe(he));else e=n;return Se--,e===n&&(r=n,0===Se&&Oe(fe)),e}var Ne=r.util.makeAST(function(){return $e(xe,me)},r);const Ie=(ve=s())!==n&&me===t.length;function Ye(){throw ve!==n&&me<t.length&&Oe({type:"end"}),Ge(we,Ee<t.length?function(e=me){const r=t.codePointAt(e);return void 0===r?"":String.fromCodePoint(r)}(Ee):null,Ee<t.length?$e(Ee,Ee+1):$e(Ee,Ee))}return r.peg$library?{peg$result:ve,peg$currPos:me,peg$FAILED:n,peg$maxFailExpected:we,peg$maxFailPos:Ee,peg$success:Ie,peg$throw:Ie?void 0:Ye}:Ie?ve:void Ye()}}}();class JsonAsty{static parse(e){if("string"!=typeof e)throw new Error("invalid JSON argument (expected type string)");const t=new ASTY,r=PEGUtil.parse(PEGparser,e,{startRule:"json",makeAST:(e,r,n,l)=>t.create.apply(t,l).pos(e,r,n)});if(null!==r.error)throw new Error("parse: JSON parsing failure:\n"+PEGUtil.errorMessage(r.error,!0).replace(/^/gm,"ERROR: ")+"\n");return r.ast}static dump(e,t={}){let r;return r=(t=Object.assign({},{colors:!1},t)).colors?e.dump(1/0,(e,t)=>{switch(e){case"tree":t=chalk.grey(t);break;case"type":t=chalk.blue(t);break;case"value":t=chalk.yellow(t);break;case"position":t=chalk.grey(t)}return t}):e.dump(1/0)}static unparse(e){if("object"!=typeof e)throw new Error("generate: invalid AST argument (expected type object)");let t="";return e.walk((e,r,n,l)=>{if("downward"===l){const r=e.get("prolog");void 0!==r&&(t+=r);const n=e.get("body");if(void 0!==n)t+=n;else{const r=e.get("value");void 0!==r&&(t+=JSON.stringify(r))}}else if("upward"===l){const r=e.get("epilog");void 0!==r&&(t+=r)}},"both"),t}}module.exports=JsonAsty;
|
|
45
45
|
},{"asty-astq":"asty-astq","chalk":2,"pegjs-util":"pegjs-util"}]},{},[10])(10)
|
|
46
46
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-asty",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "Lossless JSON-to-AST Parser and AST-to-JSON Generator",
|
|
5
5
|
"keywords": [ "json", "ast", "parse", "generate" ],
|
|
6
6
|
"browser": "lib/json-asty.browser.js",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"homepage": "https://github.com/rse/json-asty",
|
|
21
21
|
"bugs": "https://github.com/rse/json-asty/issues",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"asty-astq": "1.14.
|
|
24
|
-
"pegjs-otf": "2.0
|
|
25
|
-
"pegjs-util": "2.0
|
|
23
|
+
"asty-astq": "1.14.1",
|
|
24
|
+
"pegjs-otf": "2.1.0",
|
|
25
|
+
"pegjs-util": "2.1.0",
|
|
26
26
|
"chalk": "4.1.2",
|
|
27
27
|
"yargs": "18.0.0",
|
|
28
28
|
"cli-io": "0.9.13"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"babelify": "10.0.0",
|
|
41
41
|
"uglifyify": "5.0.2",
|
|
42
42
|
"browserify-header": "1.1.0",
|
|
43
|
-
"browserify-derequire": "1.
|
|
43
|
+
"browserify-derequire": "1.2.0",
|
|
44
44
|
"eslint": "8.57.0",
|
|
45
45
|
"eslint-config-standard": "17.1.0",
|
|
46
46
|
"eslint-plugin-promise": "6.6.0",
|
|
@@ -52,8 +52,11 @@
|
|
|
52
52
|
"mocha": "11.7.6",
|
|
53
53
|
"chai": "6.2.2"
|
|
54
54
|
},
|
|
55
|
+
"overrides": {
|
|
56
|
+
"escope": "4.0.0"
|
|
57
|
+
},
|
|
55
58
|
"allowScripts": {
|
|
56
|
-
"es5-ext":
|
|
59
|
+
"es5-ext": false
|
|
57
60
|
},
|
|
58
61
|
"upd": [ "!chalk", "!eslint", "!grunt-eslint" ],
|
|
59
62
|
"scripts": {
|
package/.ase/service.yaml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
port: 43331
|