Comparing version 0.1.2 to 0.2.0
/* Copyright (c) 2013-2015 Richard Rodger, MIT License, https://github.com/rjrodger/jsonic */ | ||
"use strict";(function(){var l=this,n=l.jsonic,u=l.jsonic=function(l){return l=""+l,"{"!=l[0]&&(l="{"+l+"}"),r.parse(l)};u.noConflict=function(){return l.previous_jsonic=n,self};var r=function(){function l(l){return'"'+l.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var n={parse:function(n,u){function r(l){B>q||(q>B&&(B=q,D=[]),D.push(l))}function t(){var l,n,u,r;return u=q,r=q,l=_(),null!==l?(n=e(),null!==n?l=[l,n]:(l=null,q=r)):(l=null,q=r),null!==l&&(l=function(l,n){return n}(u,l[1])),null===l&&(q=u),l}function e(){var l,u,t,e,c,i,a;return i=q,a=q,123===n.charCodeAt(q)?(l="{",q++):(l=null,0===M&&r('"{"')),null!==l?(u=_(),null!==u?(125===n.charCodeAt(q)?(t="}",q++):(t=null,0===M&&r('"}"')),null!==t?(e=_(),null!==e?l=[l,u,t,e]:(l=null,q=a)):(l=null,q=a)):(l=null,q=a)):(l=null,q=a),null!==l&&(l=function(){return{}}(i)),null===l&&(q=i),null===l&&(i=q,a=q,123===n.charCodeAt(q)?(l="{",q++):(l=null,0===M&&r('"{"')),null!==l?(u=_(),null!==u?(t=o(),null!==t?(125===n.charCodeAt(q)?(e="}",q++):(e=null,0===M&&r('"}"')),null!==e?(c=_(),null!==c?l=[l,u,t,e,c]:(l=null,q=a)):(l=null,q=a)):(l=null,q=a)):(l=null,q=a)):(l=null,q=a),null!==l&&(l=function(l,n){return n}(i,l[2])),null===l&&(q=i)),l}function o(){var l,u,t,e,o,i,a,f;if(i=q,a=q,l=c(),null!==l){for(u=[],f=q,44===n.charCodeAt(q)?(t=",",q++):(t=null,0===M&&r('","')),null!==t?(e=_(),null!==e?(o=c(),null!==o?t=[t,e,o]:(t=null,q=f)):(t=null,q=f)):(t=null,q=f);null!==t;)u.push(t),f=q,44===n.charCodeAt(q)?(t=",",q++):(t=null,0===M&&r('","')),null!==t?(e=_(),null!==e?(o=c(),null!==o?t=[t,e,o]:(t=null,q=f)):(t=null,q=f)):(t=null,q=f);null!==u?(44===n.charCodeAt(q)?(t=",",q++):(t=null,0===M&&r('","')),t=null!==t?t:"",null!==t?(e=_(),null!==e?l=[l,u,t,e]:(l=null,q=a)):(l=null,q=a)):(l=null,q=a)}else l=null,q=a;return null!==l&&(l=function(l,n,u){var r={};r[n[0]]=$(n[1]);for(var t=0;t<u.length;t++)r[u[t][2][0]]=$(u[t][2][1]);return r}(i,l[0],l[1])),null===l&&(q=i),l}function c(){var l,u,t,e,o,c;return o=q,c=q,l=b(),null!==l?(58===n.charCodeAt(q)?(u=":",q++):(u=null,0===M&&r('":"')),null!==u?(t=_(),null!==t?(e=f(),null!==e?l=[l,u,t,e]:(l=null,q=c)):(l=null,q=c)):(l=null,q=c)):(l=null,q=c),null!==l&&(l=function(l,n,u){return[n,u]}(o,l[0],l[3])),null===l&&(q=o),l}function i(){var l,u,t,e,o,c,i;return c=q,i=q,91===n.charCodeAt(q)?(l="[",q++):(l=null,0===M&&r('"["')),null!==l?(u=_(),null!==u?(93===n.charCodeAt(q)?(t="]",q++):(t=null,0===M&&r('"]"')),null!==t?(e=_(),null!==e?l=[l,u,t,e]:(l=null,q=i)):(l=null,q=i)):(l=null,q=i)):(l=null,q=i),null!==l&&(l=function(){return[]}(c)),null===l&&(q=c),null===l&&(c=q,i=q,91===n.charCodeAt(q)?(l="[",q++):(l=null,0===M&&r('"["')),null!==l?(u=_(),null!==u?(t=a(),null!==t?(93===n.charCodeAt(q)?(e="]",q++):(e=null,0===M&&r('"]"')),null!==e?(o=_(),null!==o?l=[l,u,t,e,o]:(l=null,q=i)):(l=null,q=i)):(l=null,q=i)):(l=null,q=i)):(l=null,q=i),null!==l&&(l=function(l,n){return n}(c,l[2])),null===l&&(q=c)),l}function a(){var l,u,t,e,o,c,i,a;if(c=q,i=q,l=f(),null!==l){for(u=[],a=q,44===n.charCodeAt(q)?(t=",",q++):(t=null,0===M&&r('","')),null!==t?(e=_(),null!==e?(o=f(),null!==o?t=[t,e,o]:(t=null,q=a)):(t=null,q=a)):(t=null,q=a);null!==t;)u.push(t),a=q,44===n.charCodeAt(q)?(t=",",q++):(t=null,0===M&&r('","')),null!==t?(e=_(),null!==e?(o=f(),null!==o?t=[t,e,o]:(t=null,q=a)):(t=null,q=a)):(t=null,q=a);null!==u?l=[l,u]:(l=null,q=i)}else l=null,q=i;return null!==l&&(l=function(l,n,u){for(var r=[$(n)],t=0;t<u.length;t++)r.push($(u[t][2]));return r}(c,l[0],l[1])),null===l&&(q=c),l}function f(){var l,u,t,o;return l=s(),null===l&&(l=h(),null===l&&(l=g(),null===l&&(l=e(),null===l&&(l=i(),null===l&&(t=q,o=q,"true"===n.substr(q,4)?(l="true",q+=4):(l=null,0===M&&r('"true"')),null!==l?(u=_(),null!==u?l=[l,u]:(l=null,q=o)):(l=null,q=o),null!==l&&(l=function(){return!0}(t)),null===l&&(q=t),null===l&&(t=q,o=q,"false"===n.substr(q,5)?(l="false",q+=5):(l=null,0===M&&r('"false"')),null!==l?(u=_(),null!==u?l=[l,u]:(l=null,q=o)):(l=null,q=o),null!==l&&(l=function(){return!1}(t)),null===l&&(q=t),null===l&&(t=q,o=q,"null"===n.substr(q,4)?(l="null",q+=4):(l=null,0===M&&r('"null"')),null!==l?(u=_(),null!==u?l=[l,u]:(l=null,q=o)):(l=null,q=o),null!==l&&(l=function(){return O}(t)),null===l&&(q=t),null===l&&(t=q,l=C(),null!==l&&(l=function(l,n){return n.join("")}(t,l)),null===l&&(q=t))))))))),l}function s(){var l,u,t,e,o,c;return M++,o=q,c=q,34===n.charCodeAt(q)?(l='"',q++):(l=null,0===M&&r('"\\""')),null!==l?(34===n.charCodeAt(q)?(u='"',q++):(u=null,0===M&&r('"\\""')),null!==u?(t=_(),null!==t?l=[l,u,t]:(l=null,q=c)):(l=null,q=c)):(l=null,q=c),null!==l&&(l=function(){return""}(o)),null===l&&(q=o),null===l&&(o=q,c=q,34===n.charCodeAt(q)?(l='"',q++):(l=null,0===M&&r('"\\""')),null!==l?(u=A(),null!==u?(34===n.charCodeAt(q)?(t='"',q++):(t=null,0===M&&r('"\\""')),null!==t?(e=_(),null!==e?l=[l,u,t,e]:(l=null,q=c)):(l=null,q=c)):(l=null,q=c)):(l=null,q=c),null!==l&&(l=function(l,n){return n}(o,l[1])),null===l&&(q=o)),M--,0===M&&null===l&&r("double-quote string"),l}function h(){var l,u,t,e,o,c;return M++,o=q,c=q,39===n.charCodeAt(q)?(l="'",q++):(l=null,0===M&&r('"\'"')),null!==l?(39===n.charCodeAt(q)?(u="'",q++):(u=null,0===M&&r('"\'"')),null!==u?(t=_(),null!==t?l=[l,u,t]:(l=null,q=c)):(l=null,q=c)):(l=null,q=c),null!==l&&(l=function(){return""}(o)),null===l&&(q=o),null===l&&(o=q,c=q,39===n.charCodeAt(q)?(l="'",q++):(l=null,0===M&&r('"\'"')),null!==l?(u=p(),null!==u?(39===n.charCodeAt(q)?(t="'",q++):(t=null,0===M&&r('"\'"')),null!==t?(e=_(),null!==e?l=[l,u,t,e]:(l=null,q=c)):(l=null,q=c)):(l=null,q=c)):(l=null,q=c),null!==l&&(l=function(l,n){return n}(o,l[1])),null===l&&(q=o)),M--,0===M&&null===l&&r("single-quote string"),l}function A(){var l,n,u;if(u=q,n=d(),null!==n)for(l=[];null!==n;)l.push(n),n=d();else l=null;return null!==l&&(l=function(l,n){return n.join("")}(u,l)),null===l&&(q=u),l}function d(){var l,u,t,e,o,c,i;return/^[^"\\\0-\x1F]/.test(n.charAt(q))?(l=n.charAt(q),q++):(l=null,0===M&&r('[^"\\\\\\0-\\x1F]')),null===l&&(c=q,'\\"'===n.substr(q,2)?(l='\\"',q+=2):(l=null,0===M&&r('"\\\\\\""')),null!==l&&(l=function(){return'"'}(c)),null===l&&(q=c),null===l&&(c=q,"\\\\"===n.substr(q,2)?(l="\\\\",q+=2):(l=null,0===M&&r('"\\\\\\\\"')),null!==l&&(l=function(){return"\\"}(c)),null===l&&(q=c),null===l&&(c=q,"\\/"===n.substr(q,2)?(l="\\/",q+=2):(l=null,0===M&&r('"\\\\/"')),null!==l&&(l=function(){return"/"}(c)),null===l&&(q=c),null===l&&(c=q,"\\b"===n.substr(q,2)?(l="\\b",q+=2):(l=null,0===M&&r('"\\\\b"')),null!==l&&(l=function(){return"\b"}(c)),null===l&&(q=c),null===l&&(c=q,"\\f"===n.substr(q,2)?(l="\\f",q+=2):(l=null,0===M&&r('"\\\\f"')),null!==l&&(l=function(){return"\f"}(c)),null===l&&(q=c),null===l&&(c=q,"\\n"===n.substr(q,2)?(l="\\n",q+=2):(l=null,0===M&&r('"\\\\n"')),null!==l&&(l=function(){return"\n"}(c)),null===l&&(q=c),null===l&&(c=q,"\\r"===n.substr(q,2)?(l="\\r",q+=2):(l=null,0===M&&r('"\\\\r"')),null!==l&&(l=function(){return"\r"}(c)),null===l&&(q=c),null===l&&(c=q,"\\t"===n.substr(q,2)?(l="\\t",q+=2):(l=null,0===M&&r('"\\\\t"')),null!==l&&(l=function(){return" "}(c)),null===l&&(q=c),null===l&&(c=q,i=q,"\\u"===n.substr(q,2)?(l="\\u",q+=2):(l=null,0===M&&r('"\\\\u"')),null!==l?(u=S(),null!==u?(t=S(),null!==t?(e=S(),null!==e?(o=S(),null!==o?l=[l,u,t,e,o]:(l=null,q=i)):(l=null,q=i)):(l=null,q=i)):(l=null,q=i)):(l=null,q=i),null!==l&&(l=function(l,n,u,r,t){return String.fromCharCode(parseInt("0x"+n+u+r+t))}(c,l[1],l[2],l[3],l[4])),null===l&&(q=c)))))))))),l}function p(){var l,n,u;if(u=q,n=v(),null!==n)for(l=[];null!==n;)l.push(n),n=v();else l=null;return null!==l&&(l=function(l,n){return n.join("")}(u,l)),null===l&&(q=u),l}function v(){var l,u,t,e,o,c,i;return/^[^'\\\0-\x1F]/.test(n.charAt(q))?(l=n.charAt(q),q++):(l=null,0===M&&r("[^'\\\\\\0-\\x1F]")),null===l&&(c=q,"\\'"===n.substr(q,2)?(l="\\'",q+=2):(l=null,0===M&&r('"\\\\\'"')),null!==l&&(l=function(){return"'"}(c)),null===l&&(q=c),null===l&&(c=q,"\\\\"===n.substr(q,2)?(l="\\\\",q+=2):(l=null,0===M&&r('"\\\\\\\\"')),null!==l&&(l=function(){return"\\"}(c)),null===l&&(q=c),null===l&&(c=q,"\\/"===n.substr(q,2)?(l="\\/",q+=2):(l=null,0===M&&r('"\\\\/"')),null!==l&&(l=function(){return"/"}(c)),null===l&&(q=c),null===l&&(c=q,"\\b"===n.substr(q,2)?(l="\\b",q+=2):(l=null,0===M&&r('"\\\\b"')),null!==l&&(l=function(){return"\b"}(c)),null===l&&(q=c),null===l&&(c=q,"\\f"===n.substr(q,2)?(l="\\f",q+=2):(l=null,0===M&&r('"\\\\f"')),null!==l&&(l=function(){return"\f"}(c)),null===l&&(q=c),null===l&&(c=q,"\\n"===n.substr(q,2)?(l="\\n",q+=2):(l=null,0===M&&r('"\\\\n"')),null!==l&&(l=function(){return"\n"}(c)),null===l&&(q=c),null===l&&(c=q,"\\r"===n.substr(q,2)?(l="\\r",q+=2):(l=null,0===M&&r('"\\\\r"')),null!==l&&(l=function(){return"\r"}(c)),null===l&&(q=c),null===l&&(c=q,"\\t"===n.substr(q,2)?(l="\\t",q+=2):(l=null,0===M&&r('"\\\\t"')),null!==l&&(l=function(){return" "}(c)),null===l&&(q=c),null===l&&(c=q,i=q,"\\u"===n.substr(q,2)?(l="\\u",q+=2):(l=null,0===M&&r('"\\\\u"')),null!==l?(u=S(),null!==u?(t=S(),null!==t?(e=S(),null!==e?(o=S(),null!==o?l=[l,u,t,e,o]:(l=null,q=i)):(l=null,q=i)):(l=null,q=i)):(l=null,q=i)):(l=null,q=i),null!==l&&(l=function(l,n,u,r,t){return String.fromCharCode(parseInt("0x"+n+u+r+t))}(c,l[1],l[2],l[3],l[4])),null===l&&(q=c)))))))))),l}function b(){var l,u,t;if(M++,l=s(),null===l){if(t=q,/^[a-zA-Z0-9_$]/.test(n.charAt(q))?(u=n.charAt(q),q++):(u=null,0===M&&r("[a-zA-Z0-9_$]")),null!==u)for(l=[];null!==u;)l.push(u),/^[a-zA-Z0-9_$]/.test(n.charAt(q))?(u=n.charAt(q),q++):(u=null,0===M&&r("[a-zA-Z0-9_$]"));else l=null;null!==l&&(l=function(l,n){return n.join("")}(t,l)),null===l&&(q=t)}return M--,0===M&&null===l&&r("key"),l}function C(){var l,u;if(/^[^,}]/.test(n.charAt(q))?(u=n.charAt(q),q++):(u=null,0===M&&r("[^,}]")),null!==u)for(l=[];null!==u;)l.push(u),/^[^,}]/.test(n.charAt(q))?(u=n.charAt(q),q++):(u=null,0===M&&r("[^,}]"));else l=null;return l}function g(){var l,n,u,t,e,o;return M++,e=q,o=q,l=x(),null!==l?(n=m(),null!==n?(u=F(),null!==u?(t=_(),null!==t?l=[l,n,u,t]:(l=null,q=o)):(l=null,q=o)):(l=null,q=o)):(l=null,q=o),null!==l&&(l=function(l,n,u,r){return parseFloat(n+u+r)}(e,l[0],l[1],l[2])),null===l&&(q=e),null===l&&(e=q,o=q,l=x(),null!==l?(n=m(),null!==n?(u=_(),null!==u?l=[l,n,u]:(l=null,q=o)):(l=null,q=o)):(l=null,q=o),null!==l&&(l=function(l,n,u){return parseFloat(n+u)}(e,l[0],l[1])),null===l&&(q=e),null===l&&(e=q,o=q,l=x(),null!==l?(n=F(),null!==n?(u=_(),null!==u?l=[l,n,u]:(l=null,q=o)):(l=null,q=o)):(l=null,q=o),null!==l&&(l=function(l,n,u){return parseFloat(n+u)}(e,l[0],l[1])),null===l&&(q=e),null===l&&(e=q,o=q,l=x(),null!==l?(n=_(),null!==n?l=[l,n]:(l=null,q=o)):(l=null,q=o),null!==l&&(l=function(l,n){return parseFloat(n)}(e,l[0])),null===l&&(q=e)))),M--,0===M&&null===l&&r("number"),l}function x(){var l,u,t,e,o;return e=q,o=q,l=w(),null!==l?(u=j(),null!==u?l=[l,u]:(l=null,q=o)):(l=null,q=o),null!==l&&(l=function(l,n,u){return n+u}(e,l[0],l[1])),null===l&&(q=e),null===l&&(l=E(),null===l&&(e=q,o=q,45===n.charCodeAt(q)?(l="-",q++):(l=null,0===M&&r('"-"')),null!==l?(u=w(),null!==u?(t=j(),null!==t?l=[l,u,t]:(l=null,q=o)):(l=null,q=o)):(l=null,q=o),null!==l&&(l=function(l,n,u){return"-"+n+u}(e,l[1],l[2])),null===l&&(q=e),null===l&&(e=q,o=q,45===n.charCodeAt(q)?(l="-",q++):(l=null,0===M&&r('"-"')),null!==l?(u=E(),null!==u?l=[l,u]:(l=null,q=o)):(l=null,q=o),null!==l&&(l=function(l,n){return"-"+n}(e,l[1])),null===l&&(q=e)))),l}function m(){var l,u,t,e;return t=q,e=q,46===n.charCodeAt(q)?(l=".",q++):(l=null,0===M&&r('"."')),null!==l?(u=j(),null!==u?l=[l,u]:(l=null,q=e)):(l=null,q=e),null!==l&&(l=function(l,n){return"."+n}(t,l[1])),null===l&&(q=t),l}function F(){var l,n,u,r;return u=q,r=q,l=y(),null!==l?(n=j(),null!==n?l=[l,n]:(l=null,q=r)):(l=null,q=r),null!==l&&(l=function(l,n,u){return n+u}(u,l[0],l[1])),null===l&&(q=u),l}function j(){var l,n,u;if(u=q,n=E(),null!==n)for(l=[];null!==n;)l.push(n),n=E();else l=null;return null!==l&&(l=function(l,n){return n.join("")}(u,l)),null===l&&(q=u),l}function y(){var l,u,t,e;return t=q,e=q,/^[eE]/.test(n.charAt(q))?(l=n.charAt(q),q++):(l=null,0===M&&r("[eE]")),null!==l?(/^[+\-]/.test(n.charAt(q))?(u=n.charAt(q),q++):(u=null,0===M&&r("[+\\-]")),u=null!==u?u:"",null!==u?l=[l,u]:(l=null,q=e)):(l=null,q=e),null!==l&&(l=function(l,n,u){return n+u}(t,l[0],l[1])),null===l&&(q=t),l}function E(){var l;return/^[0-9]/.test(n.charAt(q))?(l=n.charAt(q),q++):(l=null,0===M&&r("[0-9]")),l}function w(){var l;return/^[1-9]/.test(n.charAt(q))?(l=n.charAt(q),q++):(l=null,0===M&&r("[1-9]")),l}function S(){var l;return/^[0-9a-fA-F]/.test(n.charAt(q))?(l=n.charAt(q),q++):(l=null,0===M&&r("[0-9a-fA-F]")),l}function _(){var l,n;for(M++,l=[],n=k();null!==n;)l.push(n),n=k();return M--,0===M&&null===l&&r("whitespace"),l}function k(){var l;return/^[ \t\n\r]/.test(n.charAt(q))?(l=n.charAt(q),q++):(l=null,0===M&&r("[ \\t\\n\\r]")),l}function z(l){l.sort();for(var n=null,u=[],r=0;r<l.length;r++)l[r]!==n&&(u.push(l[r]),n=l[r]);return u}function Z(){for(var l=1,u=1,r=!1,t=0;t<Math.max(q,B);t++){var e=n.charAt(t);"\n"===e?(r||l++,u=1,r=!1):"\r"===e||"\u2028"===e||"\u2029"===e?(l++,u=1,r=!0):(u++,r=!1)}return{line:l,column:u}}function $(l){return l===O?null:l}var I={start:t,object:e,members:o,pair:c,array:i,elements:a,value:f,string:s,single:h,chars:A,"char":d,schars:p,schar:v,key:b,literal:C,number:g,"int":x,frac:m,exp:F,digits:j,e:y,digit:E,digit19:w,hexDigit:S,_:_,whitespace:k};if(void 0!==u){if(void 0===I[u])throw new Error("Invalid rule name: "+l(u)+".")}else u="start";var q=0,M=0,B=0,D=[],O=new Object,G=I[u]();if(null===G||q!==n.length){var H=Math.max(q,B),J=H<n.length?n.charAt(H):null,K=Z();throw new this.SyntaxError(z(D),J,H,K.line,K.column)}return G},toSource:function(){return this._source}};return n.SyntaxError=function(n,u,r,t,e){function o(n,u){var r,t;switch(n.length){case 0:r="end of input";break;case 1:r=n[0];break;default:r=n.slice(0,n.length-1).join(", ")+" or "+n[n.length-1]}return t=u?l(u):"end of input","Expected "+r+" but "+t+" found."}this.name="SyntaxError",this.expected=n,this.found=u,this.message=o(n,u),this.offset=r,this.line=t,this.column=e},n.SyntaxError.prototype=Error.prototype,n}();"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=u),exports.jsonic=u):l.jsonic=u}).call(this); | ||
"use strict";(function(){function t(r,e,n){if(n++,null==r)return"null";if(e.custom){if(r.hasOwnProperty("toString"))return r.toString();if(r.hasOwnProperty("inspect"))return r.inspect()}var i,u,o,c=Object.prototype.toString.call(r).charAt(8),a=0;if("N"===c)return isNaN(r)?"null":r.toString();if("O"===c){if(i=[],n<=e.depth){u=0;for(a in r){if(u>=e.maxitems)break;u++;var s=!0;for(o=0;o<e.exclude.length&&s;o++)s=!~a.indexOf(e.exclude[o]);s=s&&!e.omit[a],s&&i.push(a+":"+t(r[a],e,n))}}return"{"+i.join(",")+"}"}if("A"===c){if(i=[],n<=e.depth)for(;a<r.length&&a<e.maxitems;a++)i.push(t(r[a],e,n));return"["+i.join(",")+"]"}var l=r.toString();return(~" \"'\r\n ,}]".indexOf(l[0])||!~l.match(/,}]/)||~" \r\n ".indexOf(l[l.length-1]))&&(l="'"+l.replace(/'/g,"\\'")+"'"),l}var r=this,e=r.jsonic,n=r.jsonic=function(t){if("[object String]"!==Object.prototype.toString.call(t)){if(Object.prototype.toString.call(t).match(/\[object (Object|Array)\]/))return t;throw new Error("Not an object, array or string: "+t)}return t=t.trim(),"{"!=t[0]&&"["!=t[0]&&(t="{"+t+"}"),i.parse(t)};n.noConflict=function(){return r.jsonic=e,self};var i=function(){function t(t,r){function e(){this.constructor=t}e.prototype=r.prototype,t.prototype=new e}function r(t,r,e,n,i,u){this.message=t,this.expected=r,this.found=e,this.offset=n,this.line=i,this.column=u,this.name="SyntaxError"}function e(t){function e(r){function e(r,e,n){var i,u;for(i=e;n>i;i++)u=t.charAt(i),"\n"===u?(r.seenCR||r.line++,r.column=1,r.seenCR=!1):"\r"===u||"\u2028"===u||"\u2029"===u?(r.line++,r.column=1,r.seenCR=!0):(r.column++,r.seenCR=!1)}return Ge!==r&&(Ge>r&&(Ge=0,He={line:1,column:1,seenCR:!1}),e(He,Ge,r),Ge=r),He}function n(t){Ke>Ue||(Ue>Ke&&(Ke=Ue,Le=[]),Le.push(t))}function i(n,i,u){function o(t){var r=1;for(t.sort(function(t,r){return t.description<r.description?-1:t.description>r.description?1:0});r<t.length;)t[r-1]===t[r]?t.splice(r,1):r++}function c(t,r){function e(t){function r(t){return t.charCodeAt(0).toString(16).toUpperCase()}return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(t){return"\\x0"+r(t)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(t){return"\\x"+r(t)}).replace(/[\u0180-\u0FFF]/g,function(t){return"\\u0"+r(t)}).replace(/[\u1080-\uFFFF]/g,function(t){return"\\u"+r(t)})}var n,i,u,o=new Array(t.length);for(u=0;u<t.length;u++)o[u]=t[u].description;return n=t.length>1?o.slice(0,-1).join(", ")+" or "+o[t.length-1]:o[0],i=r?'"'+e(r)+'"':"end of input","Expected "+n+" but "+i+" found."}var a=e(u),s=u<t.length?t.charAt(u):null;return null!==i&&o(i),new r(null!==n?n:c(i,s),i,s,u,a.line,a.column)}function u(){var t,r,e;return t=Ue,r=N(),r!==k?(e=o(),e!==k?(De=t,r=I(e),t=r):(Ue=t,t=B)):(Ue=t,t=B),t===k&&(t=Ue,r=N(),r!==k?(e=s(),e!==k?(De=t,r=J(e),t=r):(Ue=t,t=B)):(Ue=t,t=B)),t}function o(){var r,e,i,u,o,a;return r=Ue,123===t.charCodeAt(Ue)?(e=U,Ue++):(e=k,0===Me&&n(D)),e!==k?(i=N(),i!==k?(125===t.charCodeAt(Ue)?(u=G,Ue++):(u=k,0===Me&&n(H)),u!==k?(o=N(),o!==k?(De=r,e=K(),r=e):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B),r===k&&(r=Ue,123===t.charCodeAt(Ue)?(e=U,Ue++):(e=k,0===Me&&n(D)),e!==k?(i=N(),i!==k?(u=c(),u!==k?(125===t.charCodeAt(Ue)?(o=G,Ue++):(o=k,0===Me&&n(H)),o!==k?(a=N(),a!==k?(De=r,e=L(u),r=e):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)),r}function c(){var r,e,i,u,o,c,s,l;if(r=Ue,44===t.charCodeAt(Ue)?(e=Q,Ue++):(e=k,0===Me&&n(T)),e===k&&(e=M),e!==k)if(i=a(),i===k&&(i=M),i!==k){for(u=[],o=Ue,44===t.charCodeAt(Ue)?(c=Q,Ue++):(c=k,0===Me&&n(T)),c!==k?(s=N(),s!==k?(l=a(),l!==k?(c=[c,s,l],o=c):(Ue=o,o=B)):(Ue=o,o=B)):(Ue=o,o=B);o!==k;)u.push(o),o=Ue,44===t.charCodeAt(Ue)?(c=Q,Ue++):(c=k,0===Me&&n(T)),c!==k?(s=N(),s!==k?(l=a(),l!==k?(c=[c,s,l],o=c):(Ue=o,o=B)):(Ue=o,o=B)):(Ue=o,o=B);u!==k?(44===t.charCodeAt(Ue)?(o=Q,Ue++):(o=k,0===Me&&n(T)),o===k&&(o=M),o!==k?(c=N(),c!==k?(De=r,e=V(i,u),r=e):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)}else Ue=r,r=B;else Ue=r,r=B;return r}function a(){var r,e,i,u,o;return r=Ue,e=g(),e!==k?(58===t.charCodeAt(Ue)?(i=W,Ue++):(i=k,0===Me&&n(X)),i!==k?(u=N(),u!==k?(o=f(),o!==k?(De=r,e=Y(e,o),r=e):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B),r}function s(){var r,e,i,u,o,c;return r=Ue,91===t.charCodeAt(Ue)?(e=tr,Ue++):(e=k,0===Me&&n(rr)),e!==k?(i=N(),i!==k?(93===t.charCodeAt(Ue)?(u=er,Ue++):(u=k,0===Me&&n(nr)),u!==k?(o=N(),o!==k?(De=r,e=ir(),r=e):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B),r===k&&(r=Ue,91===t.charCodeAt(Ue)?(e=tr,Ue++):(e=k,0===Me&&n(rr)),e!==k?(i=N(),i!==k?(u=l(),u!==k?(93===t.charCodeAt(Ue)?(o=er,Ue++):(o=k,0===Me&&n(nr)),o!==k?(c=N(),c!==k?(De=r,e=ur(u),r=e):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)),r}function l(){var r,e,i,u,o,c,a,s;if(r=Ue,44===t.charCodeAt(Ue)?(e=Q,Ue++):(e=k,0===Me&&n(T)),e===k&&(e=M),e!==k)if(i=f(),i===k&&(i=M),i!==k){for(u=[],o=Ue,44===t.charCodeAt(Ue)?(c=Q,Ue++):(c=k,0===Me&&n(T)),c!==k?(a=N(),a!==k?(s=f(),s!==k?(c=[c,a,s],o=c):(Ue=o,o=B)):(Ue=o,o=B)):(Ue=o,o=B);o!==k;)u.push(o),o=Ue,44===t.charCodeAt(Ue)?(c=Q,Ue++):(c=k,0===Me&&n(T)),c!==k?(a=N(),a!==k?(s=f(),s!==k?(c=[c,a,s],o=c):(Ue=o,o=B)):(Ue=o,o=B)):(Ue=o,o=B);u!==k?(44===t.charCodeAt(Ue)?(o=Q,Ue++):(o=k,0===Me&&n(T)),o===k&&(o=M),o!==k?(c=N(),c!==k?(De=r,e=or(i,u),r=e):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)}else Ue=r,r=B;else Ue=r,r=B;return r}function f(){var r,e,i;return r=p(),r===k&&(r=h(),r===k&&(r=o(),r===k&&(r=s(),r===k&&(r=Ue,t.substr(Ue,4)===cr?(e=cr,Ue+=4):(e=k,0===Me&&n(ar)),e!==k?(i=N(),i!==k?(De=r,e=sr(),r=e):(Ue=r,r=B)):(Ue=r,r=B),r===k&&(r=Ue,t.substr(Ue,5)===lr?(e=lr,Ue+=5):(e=k,0===Me&&n(fr)),e!==k?(i=N(),i!==k?(De=r,e=pr(),r=e):(Ue=r,r=B)):(Ue=r,r=B),r===k&&(r=Ue,t.substr(Ue,4)===hr?(e=hr,Ue+=4):(e=k,0===Me&&n(dr)),e!==k?(i=N(),i!==k?(De=r,e=vr(),r=e):(Ue=r,r=B)):(Ue=r,r=B),r===k&&(r=b(),r===k&&(r=Ue,e=m(),e!==k&&(De=r,e=Ar(e)),r=e)))))))),r}function p(){var r,e,i,u,o;return Me++,r=Ue,34===t.charCodeAt(Ue)?(e=gr,Ue++):(e=k,0===Me&&n(mr)),e!==k?(34===t.charCodeAt(Ue)?(i=gr,Ue++):(i=k,0===Me&&n(mr)),i!==k?(u=N(),u!==k?(De=r,e=xr(),r=e):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B),r===k&&(r=Ue,34===t.charCodeAt(Ue)?(e=gr,Ue++):(e=k,0===Me&&n(mr)),e!==k?(i=d(),i!==k?(34===t.charCodeAt(Ue)?(u=gr,Ue++):(u=k,0===Me&&n(mr)),u!==k?(o=N(),o!==k?(De=r,e=br(i),r=e):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)),Me--,r===k&&(e=k,0===Me&&n(yr)),r}function h(){var r,e,i,u,o;return Me++,r=Ue,39===t.charCodeAt(Ue)?(e=Fr,Ue++):(e=k,0===Me&&n(jr)),e!==k?(39===t.charCodeAt(Ue)?(i=Fr,Ue++):(i=k,0===Me&&n(jr)),i!==k?(u=N(),u!==k?(De=r,e=xr(),r=e):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B),r===k&&(r=Ue,39===t.charCodeAt(Ue)?(e=Fr,Ue++):(e=k,0===Me&&n(jr)),e!==k?(i=A(),i!==k?(39===t.charCodeAt(Ue)?(u=Fr,Ue++):(u=k,0===Me&&n(jr)),u!==k?(o=N(),o!==k?(De=r,e=br(i),r=e):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)),Me--,r===k&&(e=k,0===Me&&n(Cr)),r}function d(){var t,r,e;if(t=Ue,r=[],e=v(),e!==k)for(;e!==k;)r.push(e),e=v();else r=B;return r!==k&&(De=t,r=wr(r)),t=r}function v(){var r,e,i,u,o,c;return Or.test(t.charAt(Ue))?(r=t.charAt(Ue),Ue++):(r=k,0===Me&&n(Rr)),r===k&&(r=Ue,t.substr(Ue,2)===Sr?(e=Sr,Ue+=2):(e=k,0===Me&&n(Er)),e!==k&&(De=r,e=Nr()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===$r?(e=$r,Ue+=2):(e=k,0===Me&&n(zr)),e!==k&&(De=r,e=Zr()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===_r?(e=_r,Ue+=2):(e=k,0===Me&&n(kr)),e!==k&&(De=r,e=qr()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===Pr?(e=Pr,Ue+=2):(e=k,0===Me&&n(Br)),e!==k&&(De=r,e=Ir()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===Jr?(e=Jr,Ue+=2):(e=k,0===Me&&n(Ur)),e!==k&&(De=r,e=Dr()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===Gr?(e=Gr,Ue+=2):(e=k,0===Me&&n(Hr)),e!==k&&(De=r,e=Kr()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===Lr?(e=Lr,Ue+=2):(e=k,0===Me&&n(Mr)),e!==k&&(De=r,e=Qr()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===Tr?(e=Tr,Ue+=2):(e=k,0===Me&&n(Vr)),e!==k&&(De=r,e=Wr()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===Xr?(e=Xr,Ue+=2):(e=k,0===Me&&n(Yr)),e!==k?(i=E(),i!==k?(u=E(),u!==k?(o=E(),o!==k?(c=E(),c!==k?(De=r,e=te(i,u,o,c),r=e):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)))))))))),r}function A(){var t,r,e;if(t=Ue,r=[],e=y(),e!==k)for(;e!==k;)r.push(e),e=y();else r=B;return r!==k&&(De=t,r=wr(r)),t=r}function y(){var r,e,i,u,o,c;return re.test(t.charAt(Ue))?(r=t.charAt(Ue),Ue++):(r=k,0===Me&&n(ee)),r===k&&(r=Ue,t.substr(Ue,2)===ne?(e=ne,Ue+=2):(e=k,0===Me&&n(ie)),e!==k&&(De=r,e=ue()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===$r?(e=$r,Ue+=2):(e=k,0===Me&&n(zr)),e!==k&&(De=r,e=Zr()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===_r?(e=_r,Ue+=2):(e=k,0===Me&&n(kr)),e!==k&&(De=r,e=qr()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===Pr?(e=Pr,Ue+=2):(e=k,0===Me&&n(Br)),e!==k&&(De=r,e=Ir()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===Jr?(e=Jr,Ue+=2):(e=k,0===Me&&n(Ur)),e!==k&&(De=r,e=Dr()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===Gr?(e=Gr,Ue+=2):(e=k,0===Me&&n(Hr)),e!==k&&(De=r,e=Kr()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===Lr?(e=Lr,Ue+=2):(e=k,0===Me&&n(Mr)),e!==k&&(De=r,e=Qr()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===Tr?(e=Tr,Ue+=2):(e=k,0===Me&&n(Vr)),e!==k&&(De=r,e=Wr()),r=e,r===k&&(r=Ue,t.substr(Ue,2)===Xr?(e=Xr,Ue+=2):(e=k,0===Me&&n(Yr)),e!==k?(i=E(),i!==k?(u=E(),u!==k?(o=E(),o!==k?(c=E(),c!==k?(De=r,e=te(i,u,o,c),r=e):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B)))))))))),r}function g(){var r,e,i;if(Me++,r=p(),r===k){if(r=Ue,e=[],ce.test(t.charAt(Ue))?(i=t.charAt(Ue),Ue++):(i=k,0===Me&&n(ae)),i!==k)for(;i!==k;)e.push(i),ce.test(t.charAt(Ue))?(i=t.charAt(Ue),Ue++):(i=k,0===Me&&n(ae));else e=B;e!==k&&(De=r,e=se(e)),r=e}return Me--,r===k&&(e=k,0===Me&&n(oe)),r}function m(){var t,r;if(t=[],r=x(),r!==k)for(;r!==k;)t.push(r),r=x();else t=B;return t}function x(){var r;return le.test(t.charAt(Ue))?(r=t.charAt(Ue),Ue++):(r=k,0===Me&&n(fe)),r}function b(){var t,r,e,i,u,o,c;if(Me++,t=Ue,r=C(),r!==k)if(e=F(),e!==k)if(i=j(),i!==k)if(u=N(),u!==k){for(o=[],c=x();c!==k;)o.push(c),c=x();o!==k?(De=t,r=he(r,e,i,o),t=r):(Ue=t,t=B)}else Ue=t,t=B;else Ue=t,t=B;else Ue=t,t=B;else Ue=t,t=B;if(t===k){if(t=Ue,r=C(),r!==k)if(e=F(),e!==k)if(i=N(),i!==k){for(u=[],o=x();o!==k;)u.push(o),o=x();u!==k?(De=t,r=de(r,e,u),t=r):(Ue=t,t=B)}else Ue=t,t=B;else Ue=t,t=B;else Ue=t,t=B;if(t===k){if(t=Ue,r=C(),r!==k)if(e=j(),e!==k)if(i=N(),i!==k){for(u=[],o=x();o!==k;)u.push(o),o=x();u!==k?(De=t,r=ve(r,e,u),t=r):(Ue=t,t=B)}else Ue=t,t=B;else Ue=t,t=B;else Ue=t,t=B;if(t===k)if(t=Ue,r=C(),r!==k)if(e=N(),e!==k){for(i=[],u=x();u!==k;)i.push(u),u=x();i!==k?(De=t,r=Ae(r,i),t=r):(Ue=t,t=B)}else Ue=t,t=B;else Ue=t,t=B}}return Me--,t===k&&(r=k,0===Me&&n(pe)),t}function C(){var r,e,i,u;return r=Ue,e=S(),e!==k?(i=w(),i!==k?(De=r,e=ye(e,i),r=e):(Ue=r,r=B)):(Ue=r,r=B),r===k&&(r=R(),r===k&&(r=Ue,45===t.charCodeAt(Ue)?(e=ge,Ue++):(e=k,0===Me&&n(me)),e!==k?(i=S(),i!==k?(u=w(),u!==k?(De=r,e=xe(i,u),r=e):(Ue=r,r=B)):(Ue=r,r=B)):(Ue=r,r=B),r===k&&(r=Ue,45===t.charCodeAt(Ue)?(e=ge,Ue++):(e=k,0===Me&&n(me)),e!==k?(i=R(),i!==k?(De=r,e=be(i),r=e):(Ue=r,r=B)):(Ue=r,r=B)))),r}function F(){var r,e,i;return r=Ue,46===t.charCodeAt(Ue)?(e=Ce,Ue++):(e=k,0===Me&&n(Fe)),e!==k?(i=w(),i!==k?(De=r,e=je(i),r=e):(Ue=r,r=B)):(Ue=r,r=B),r}function j(){var t,r,e;return t=Ue,r=O(),r!==k?(e=w(),e!==k?(De=t,r=we(r,e),t=r):(Ue=t,t=B)):(Ue=t,t=B),t}function w(){var t,r,e;if(t=Ue,r=[],e=R(),e!==k)for(;e!==k;)r.push(e),e=R();else r=B;return r!==k&&(De=t,r=Oe(r)),t=r}function O(){var r,e,i;return r=Ue,Re.test(t.charAt(Ue))?(e=t.charAt(Ue),Ue++):(e=k,0===Me&&n(Se)),e!==k?(Ee.test(t.charAt(Ue))?(i=t.charAt(Ue),Ue++):(i=k,0===Me&&n(Ne)),i===k&&(i=M),i!==k?(De=r,e=$e(e,i),r=e):(Ue=r,r=B)):(Ue=r,r=B),r}function R(){var r;return ze.test(t.charAt(Ue))?(r=t.charAt(Ue),Ue++):(r=k,0===Me&&n(Ze)),r}function S(){var r;return _e.test(t.charAt(Ue))?(r=t.charAt(Ue),Ue++):(r=k,0===Me&&n(ke)),r}function E(){var r;return qe.test(t.charAt(Ue))?(r=t.charAt(Ue),Ue++):(r=k,0===Me&&n(Pe)),r}function N(){var t,r;for(Me++,t=[],r=$();r!==k;)t.push(r),r=$();return Me--,t===k&&(r=k,0===Me&&n(Be)),t}function $(){var r;return Ie.test(t.charAt(Ue))?(r=t.charAt(Ue),Ue++):(r=k,0===Me&&n(Je)),r}function z(t){return t===Qe?null:t}var Z,_=arguments.length>1?arguments[1]:{},k={},q={start:u},P=u,B=k,I=function(t){return t},J=function(t){return t},U="{",D={type:"literal",value:"{",description:'"{"'},G="}",H={type:"literal",value:"}",description:'"}"'},K=function(){return{}},L=function(t){return t},M=null,Q=",",T={type:"literal",value:",",description:'","'},V=function(t,r){var e={};t&&(e[t[0]]=z(t[1]));for(var n=0;n<r.length;n++)e[r[n][2][0]]=z(r[n][2][1]);return e},W=":",X={type:"literal",value:":",description:'":"'},Y=function(t,r){return[t,r]},tr="[",rr={type:"literal",value:"[",description:'"["'},er="]",nr={type:"literal",value:"]",description:'"]"'},ir=function(){return[]},ur=function(t){return t},or=function(t,r){var e=[];t&&e.push(z(t));for(var n=0;n<r.length;n++)e.push(z(r[n][2]));return e},cr="true",ar={type:"literal",value:"true",description:'"true"'},sr=function(){return!0},lr="false",fr={type:"literal",value:"false",description:'"false"'},pr=function(){return!1},hr="null",dr={type:"literal",value:"null",description:'"null"'},vr=function(){return Qe},Ar=function(t){return t.join("").trim()},yr={type:"other",description:"double-quote string"},gr='"',mr={type:"literal",value:'"',description:'"\\""'},xr=function(){return""},br=function(t){return t},Cr={type:"other",description:"single-quote string"},Fr="'",jr={type:"literal",value:"'",description:'"\'"'},wr=function(t){return t.join("")},Or=/^[^"\\\0-\x1F]/,Rr={type:"class",value:'[^"\\\\\\0-\\x1F]',description:'[^"\\\\\\0-\\x1F]'},Sr='\\"',Er={type:"literal",value:'\\"',description:'"\\\\\\""'},Nr=function(){return'"'},$r="\\\\",zr={type:"literal",value:"\\\\",description:'"\\\\\\\\"'},Zr=function(){return"\\"},_r="\\/",kr={type:"literal",value:"\\/",description:'"\\\\/"'},qr=function(){return"/"},Pr="\\b",Br={type:"literal",value:"\\b",description:'"\\\\b"'},Ir=function(){return"\b"},Jr="\\f",Ur={type:"literal",value:"\\f",description:'"\\\\f"'},Dr=function(){return"\f"},Gr="\\n",Hr={type:"literal",value:"\\n",description:'"\\\\n"'},Kr=function(){return"\n"},Lr="\\r",Mr={type:"literal",value:"\\r",description:'"\\\\r"'},Qr=function(){return"\r"},Tr="\\t",Vr={type:"literal",value:"\\t",description:'"\\\\t"'},Wr=function(){return" "},Xr="\\u",Yr={type:"literal",value:"\\u",description:'"\\\\u"'},te=function(t,r,e,n){return String.fromCharCode(parseInt("0x"+t+r+e+n))},re=/^[^'\\\0-\x1F]/,ee={type:"class",value:"[^'\\\\\\0-\\x1F]",description:"[^'\\\\\\0-\\x1F]"},ne="\\'",ie={type:"literal",value:"\\'",description:'"\\\\\'"'},ue=function(){return"'"},oe={type:"other",description:"key"},ce=/^[a-zA-Z0-9_$]/,ae={type:"class",value:"[a-zA-Z0-9_$]",description:"[a-zA-Z0-9_$]"},se=function(t){return t.join("")},le=/^[^,}\]]/,fe={type:"class",value:"[^,}\\]]",description:"[^,}\\]]"},pe={type:"other",description:"number"},he=function(t,r,e,n){return 0===n.length?parseFloat(t+r+e):(t+r+e+n).trim()},de=function(t,r,e){return 0===e.length?parseFloat(t+r):(t+r+e).trim()},ve=function(t,r,e){return 0===e.length?parseFloat(t+r):(t+r+e).trim()},Ae=function(t,r){return 0===r.length?parseFloat(t):(t+r).trim()},ye=function(t,r){return t+r},ge="-",me={type:"literal",value:"-",description:'"-"'},xe=function(t,r){return"-"+t+r},be=function(t){return"-"+t},Ce=".",Fe={type:"literal",value:".",description:'"."'},je=function(t){return"."+t},we=function(t,r){return t+r},Oe=function(t){return t.join("")},Re=/^[eE]/,Se={type:"class",value:"[eE]",description:"[eE]"},Ee=/^[+\-]/,Ne={type:"class",value:"[+\\-]",description:"[+\\-]"},$e=function(t,r){return t+(r?r:"")},ze=/^[0-9]/,Ze={type:"class",value:"[0-9]",description:"[0-9]"},_e=/^[1-9]/,ke={type:"class",value:"[1-9]",description:"[1-9]"},qe=/^[0-9a-fA-F]/,Pe={type:"class",value:"[0-9a-fA-F]",description:"[0-9a-fA-F]"},Be={type:"other",description:"whitespace"},Ie=/^[ \t\n\r]/,Je={type:"class",value:"[ \\t\\n\\r]",description:"[ \\t\\n\\r]"},Ue=0,De=0,Ge=0,He={line:1,column:1,seenCR:!1},Ke=0,Le=[],Me=0;if("startRule"in _){if(!(_.startRule in q))throw new Error("Can't start parsing from rule \""+_.startRule+'".');P=q[_.startRule]}var Qe=new Object;if(Z=P(),Z!==k&&Ue===t.length)return Z;throw Z!==k&&Ue<t.length&&n({type:"end",description:"end of input"}),i(null,Le,Ke)}return t(r,Error),{SyntaxError:r,parse:e}}();n.stringify=function(r,e){try{var e=e||{},n={};n.custom=e.custom||e.c||!1,n.depth=e.depth||e.d||3,n.maxitems=e.maxitems||e.mi||11,n.maxchars=e.maxchars||e.mc||111,n.exclude=e.exclude||e.x||["$"];var i=e.omit||e.o||{};n.omit={};for(var u=0;u<i.length;u++)n.omit[i[u]]=!0;return t(r,n,0).substring(0,n.maxchars)}catch(o){return"ERROR: jsonic.stringify is only for plain objects: "+o+" input was: "+JSON.stringify(r)}},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=n),exports.jsonic=n):r.jsonic=n}).call(this); | ||
//# sourceMappingURL=jsonic-min.map |
3479
jsonic-parser.js
@@ -1,745 +0,929 @@ | ||
var jsonic_parser = (function(){ | ||
var jsonic_parser = (function() { | ||
/* | ||
* Generated by PEG.js 0.7.0. | ||
* Generated by PEG.js 0.8.0. | ||
* | ||
* http://pegjs.majda.cz/ | ||
*/ | ||
function quote(s) { | ||
/* | ||
* ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a | ||
* string literal except for the closing quote character, backslash, | ||
* carriage return, line separator, paragraph separator, and line feed. | ||
* Any character may appear in the form of an escape sequence. | ||
* | ||
* For portability, we also escape escape all control and non-ASCII | ||
* characters. Note that "\0" and "\v" escape sequences are not used | ||
* because JSHint does not like the first and IE the second. | ||
*/ | ||
return '"' + s | ||
.replace(/\\/g, '\\\\') // backslash | ||
.replace(/"/g, '\\"') // closing quote character | ||
.replace(/\x08/g, '\\b') // backspace | ||
.replace(/\t/g, '\\t') // horizontal tab | ||
.replace(/\n/g, '\\n') // line feed | ||
.replace(/\f/g, '\\f') // form feed | ||
.replace(/\r/g, '\\r') // carriage return | ||
.replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape) | ||
+ '"'; | ||
function peg$subclass(child, parent) { | ||
function ctor() { this.constructor = child; } | ||
ctor.prototype = parent.prototype; | ||
child.prototype = new ctor(); | ||
} | ||
var result = { | ||
/* | ||
* Parses the input with a generated parser. If the parsing is successfull, | ||
* returns a value explicitly or implicitly specified by the grammar from | ||
* which the parser was generated (see |PEG.buildParser|). If the parsing is | ||
* unsuccessful, throws |PEG.parser.SyntaxError| describing the error. | ||
*/ | ||
parse: function(input, startRule) { | ||
var parseFunctions = { | ||
"start": parse_start, | ||
"object": parse_object, | ||
"members": parse_members, | ||
"pair": parse_pair, | ||
"array": parse_array, | ||
"elements": parse_elements, | ||
"value": parse_value, | ||
"string": parse_string, | ||
"single": parse_single, | ||
"chars": parse_chars, | ||
"char": parse_char, | ||
"schars": parse_schars, | ||
"schar": parse_schar, | ||
"key": parse_key, | ||
"literal": parse_literal, | ||
"number": parse_number, | ||
"int": parse_int, | ||
"frac": parse_frac, | ||
"exp": parse_exp, | ||
"digits": parse_digits, | ||
"e": parse_e, | ||
"digit": parse_digit, | ||
"digit19": parse_digit19, | ||
"hexDigit": parse_hexDigit, | ||
"_": parse__, | ||
"whitespace": parse_whitespace | ||
}; | ||
if (startRule !== undefined) { | ||
if (parseFunctions[startRule] === undefined) { | ||
throw new Error("Invalid rule name: " + quote(startRule) + "."); | ||
function SyntaxError(message, expected, found, offset, line, column) { | ||
this.message = message; | ||
this.expected = expected; | ||
this.found = found; | ||
this.offset = offset; | ||
this.line = line; | ||
this.column = column; | ||
this.name = "SyntaxError"; | ||
} | ||
peg$subclass(SyntaxError, Error); | ||
function parse(input) { | ||
var options = arguments.length > 1 ? arguments[1] : {}, | ||
peg$FAILED = {}, | ||
peg$startRuleFunctions = { start: peg$parsestart }, | ||
peg$startRuleFunction = peg$parsestart, | ||
peg$c0 = peg$FAILED, | ||
peg$c1 = function(object) { return object; }, | ||
peg$c2 = function(array) { return array; }, | ||
peg$c3 = "{", | ||
peg$c4 = { type: "literal", value: "{", description: "\"{\"" }, | ||
peg$c5 = "}", | ||
peg$c6 = { type: "literal", value: "}", description: "\"}\"" }, | ||
peg$c7 = function() { return {}; }, | ||
peg$c8 = function(members) { return members; }, | ||
peg$c9 = null, | ||
peg$c10 = ",", | ||
peg$c11 = { type: "literal", value: ",", description: "\",\"" }, | ||
peg$c12 = [], | ||
peg$c13 = function(head, tail) { | ||
var result = {}; | ||
if( head ) { result[head[0]] = fixNull(head[1]); } | ||
for (var i = 0; i < tail.length; i++) { | ||
result[tail[i][2][0]] = fixNull(tail[i][2][1]); | ||
} | ||
return result; | ||
}, | ||
peg$c14 = ":", | ||
peg$c15 = { type: "literal", value: ":", description: "\":\"" }, | ||
peg$c16 = function(name, value) { return [name, value]; }, | ||
peg$c17 = "[", | ||
peg$c18 = { type: "literal", value: "[", description: "\"[\"" }, | ||
peg$c19 = "]", | ||
peg$c20 = { type: "literal", value: "]", description: "\"]\"" }, | ||
peg$c21 = function() { return []; }, | ||
peg$c22 = function(elements) { return elements; }, | ||
peg$c23 = function(head, tail) { | ||
var result = []; | ||
if( head ) { result.push( fixNull(head) ) } | ||
for (var i = 0; i < tail.length; i++) { | ||
result.push(fixNull(tail[i][2])); | ||
} | ||
return result; | ||
}, | ||
peg$c24 = "true", | ||
peg$c25 = { type: "literal", value: "true", description: "\"true\"" }, | ||
peg$c26 = function() { return true; }, | ||
peg$c27 = "false", | ||
peg$c28 = { type: "literal", value: "false", description: "\"false\"" }, | ||
peg$c29 = function() { return false; }, | ||
peg$c30 = "null", | ||
peg$c31 = { type: "literal", value: "null", description: "\"null\"" }, | ||
peg$c32 = function() { return null_; }, | ||
peg$c33 = function(lit) { return lit.join('').trim() }, | ||
peg$c34 = { type: "other", description: "double-quote string" }, | ||
peg$c35 = "\"", | ||
peg$c36 = { type: "literal", value: "\"", description: "\"\\\"\"" }, | ||
peg$c37 = function() { return ""; }, | ||
peg$c38 = function(chars) { return chars; }, | ||
peg$c39 = { type: "other", description: "single-quote string" }, | ||
peg$c40 = "'", | ||
peg$c41 = { type: "literal", value: "'", description: "\"'\"" }, | ||
peg$c42 = function(chars) { return chars.join(""); }, | ||
peg$c43 = /^[^"\\\0-\x1F]/, | ||
peg$c44 = { type: "class", value: "[^\"\\\\\\0-\\x1F]", description: "[^\"\\\\\\0-\\x1F]" }, | ||
peg$c45 = "\\\"", | ||
peg$c46 = { type: "literal", value: "\\\"", description: "\"\\\\\\\"\"" }, | ||
peg$c47 = function() { return '"'; }, | ||
peg$c48 = "\\\\", | ||
peg$c49 = { type: "literal", value: "\\\\", description: "\"\\\\\\\\\"" }, | ||
peg$c50 = function() { return "\\"; }, | ||
peg$c51 = "\\/", | ||
peg$c52 = { type: "literal", value: "\\/", description: "\"\\\\/\"" }, | ||
peg$c53 = function() { return "/"; }, | ||
peg$c54 = "\\b", | ||
peg$c55 = { type: "literal", value: "\\b", description: "\"\\\\b\"" }, | ||
peg$c56 = function() { return "\b"; }, | ||
peg$c57 = "\\f", | ||
peg$c58 = { type: "literal", value: "\\f", description: "\"\\\\f\"" }, | ||
peg$c59 = function() { return "\f"; }, | ||
peg$c60 = "\\n", | ||
peg$c61 = { type: "literal", value: "\\n", description: "\"\\\\n\"" }, | ||
peg$c62 = function() { return "\n"; }, | ||
peg$c63 = "\\r", | ||
peg$c64 = { type: "literal", value: "\\r", description: "\"\\\\r\"" }, | ||
peg$c65 = function() { return "\r"; }, | ||
peg$c66 = "\\t", | ||
peg$c67 = { type: "literal", value: "\\t", description: "\"\\\\t\"" }, | ||
peg$c68 = function() { return "\t"; }, | ||
peg$c69 = "\\u", | ||
peg$c70 = { type: "literal", value: "\\u", description: "\"\\\\u\"" }, | ||
peg$c71 = function(h1, h2, h3, h4) { | ||
return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4)); }, | ||
peg$c72 = /^[^'\\\0-\x1F]/, | ||
peg$c73 = { type: "class", value: "[^'\\\\\\0-\\x1F]", description: "[^'\\\\\\0-\\x1F]" }, | ||
peg$c74 = "\\'", | ||
peg$c75 = { type: "literal", value: "\\'", description: "\"\\\\'\"" }, | ||
peg$c76 = function() { return '\''; }, | ||
peg$c77 = { type: "other", description: "key" }, | ||
peg$c78 = /^[a-zA-Z0-9_$]/, | ||
peg$c79 = { type: "class", value: "[a-zA-Z0-9_$]", description: "[a-zA-Z0-9_$]" }, | ||
peg$c80 = function(chars) { return chars.join('') }, | ||
peg$c81 = /^[^,}\]]/, | ||
peg$c82 = { type: "class", value: "[^,}\\]]", description: "[^,}\\]]" }, | ||
peg$c83 = { type: "other", description: "number" }, | ||
peg$c84 = function(int_, frac, exp, suffix) { return 0 === suffix.length ? parseFloat(int_ + frac + exp) : (int_ + frac + exp + suffix).trim(); }, | ||
peg$c85 = function(int_, frac, suffix) { return 0 === suffix.length ? parseFloat(int_ + frac) : (int_ + frac + suffix).trim(); }, | ||
peg$c86 = function(int_, exp, suffix) { return 0 === suffix.length ? parseFloat(int_ + exp) : (int_ + exp + suffix).trim(); }, | ||
peg$c87 = function(int_, suffix) { return 0 === suffix.length ? parseFloat(int_) : (int_ + suffix).trim(); }, | ||
peg$c88 = function(digit19, digits) { return digit19 + digits; }, | ||
peg$c89 = "-", | ||
peg$c90 = { type: "literal", value: "-", description: "\"-\"" }, | ||
peg$c91 = function(digit19, digits) { return "-" + digit19 + digits; }, | ||
peg$c92 = function(digit) { return "-" + digit; }, | ||
peg$c93 = ".", | ||
peg$c94 = { type: "literal", value: ".", description: "\".\"" }, | ||
peg$c95 = function(digits) { return "." + digits; }, | ||
peg$c96 = function(e, digits) { return e + digits; }, | ||
peg$c97 = function(digits) { return digits.join(""); }, | ||
peg$c98 = /^[eE]/, | ||
peg$c99 = { type: "class", value: "[eE]", description: "[eE]" }, | ||
peg$c100 = /^[+\-]/, | ||
peg$c101 = { type: "class", value: "[+\\-]", description: "[+\\-]" }, | ||
peg$c102 = function(e, sign) { return e + (sign?sign:''); }, | ||
peg$c103 = /^[0-9]/, | ||
peg$c104 = { type: "class", value: "[0-9]", description: "[0-9]" }, | ||
peg$c105 = /^[1-9]/, | ||
peg$c106 = { type: "class", value: "[1-9]", description: "[1-9]" }, | ||
peg$c107 = /^[0-9a-fA-F]/, | ||
peg$c108 = { type: "class", value: "[0-9a-fA-F]", description: "[0-9a-fA-F]" }, | ||
peg$c109 = { type: "other", description: "whitespace" }, | ||
peg$c110 = /^[ \t\n\r]/, | ||
peg$c111 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" }, | ||
peg$currPos = 0, | ||
peg$reportedPos = 0, | ||
peg$cachedPos = 0, | ||
peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }, | ||
peg$maxFailPos = 0, | ||
peg$maxFailExpected = [], | ||
peg$silentFails = 0, | ||
peg$result; | ||
if ("startRule" in options) { | ||
if (!(options.startRule in peg$startRuleFunctions)) { | ||
throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); | ||
} | ||
peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; | ||
} | ||
function text() { | ||
return input.substring(peg$reportedPos, peg$currPos); | ||
} | ||
function offset() { | ||
return peg$reportedPos; | ||
} | ||
function line() { | ||
return peg$computePosDetails(peg$reportedPos).line; | ||
} | ||
function column() { | ||
return peg$computePosDetails(peg$reportedPos).column; | ||
} | ||
function expected(description) { | ||
throw peg$buildException( | ||
null, | ||
[{ type: "other", description: description }], | ||
peg$reportedPos | ||
); | ||
} | ||
function error(message) { | ||
throw peg$buildException(message, null, peg$reportedPos); | ||
} | ||
function peg$computePosDetails(pos) { | ||
function advance(details, startPos, endPos) { | ||
var p, ch; | ||
for (p = startPos; p < endPos; p++) { | ||
ch = input.charAt(p); | ||
if (ch === "\n") { | ||
if (!details.seenCR) { details.line++; } | ||
details.column = 1; | ||
details.seenCR = false; | ||
} else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { | ||
details.line++; | ||
details.column = 1; | ||
details.seenCR = true; | ||
} else { | ||
details.column++; | ||
details.seenCR = false; | ||
} | ||
} | ||
} else { | ||
startRule = "start"; | ||
} | ||
var pos = 0; | ||
var reportFailures = 0; | ||
var rightmostFailuresPos = 0; | ||
var rightmostFailuresExpected = []; | ||
function padLeft(input, padding, length) { | ||
var result = input; | ||
var padLength = length - input.length; | ||
for (var i = 0; i < padLength; i++) { | ||
result = padding + result; | ||
if (peg$cachedPos !== pos) { | ||
if (peg$cachedPos > pos) { | ||
peg$cachedPos = 0; | ||
peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }; | ||
} | ||
return result; | ||
advance(peg$cachedPosDetails, peg$cachedPos, pos); | ||
peg$cachedPos = pos; | ||
} | ||
function escape(ch) { | ||
var charCode = ch.charCodeAt(0); | ||
var escapeChar; | ||
var length; | ||
if (charCode <= 0xFF) { | ||
escapeChar = 'x'; | ||
length = 2; | ||
} else { | ||
escapeChar = 'u'; | ||
length = 4; | ||
return peg$cachedPosDetails; | ||
} | ||
function peg$fail(expected) { | ||
if (peg$currPos < peg$maxFailPos) { return; } | ||
if (peg$currPos > peg$maxFailPos) { | ||
peg$maxFailPos = peg$currPos; | ||
peg$maxFailExpected = []; | ||
} | ||
peg$maxFailExpected.push(expected); | ||
} | ||
function peg$buildException(message, expected, pos) { | ||
function cleanupExpected(expected) { | ||
var i = 1; | ||
expected.sort(function(a, b) { | ||
if (a.description < b.description) { | ||
return -1; | ||
} else if (a.description > b.description) { | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
}); | ||
while (i < expected.length) { | ||
if (expected[i - 1] === expected[i]) { | ||
expected.splice(i, 1); | ||
} else { | ||
i++; | ||
} | ||
} | ||
return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length); | ||
} | ||
function matchFailed(failure) { | ||
if (pos < rightmostFailuresPos) { | ||
return; | ||
function buildMessage(expected, found) { | ||
function stringEscape(s) { | ||
function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } | ||
return s | ||
.replace(/\\/g, '\\\\') | ||
.replace(/"/g, '\\"') | ||
.replace(/\x08/g, '\\b') | ||
.replace(/\t/g, '\\t') | ||
.replace(/\n/g, '\\n') | ||
.replace(/\f/g, '\\f') | ||
.replace(/\r/g, '\\r') | ||
.replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) | ||
.replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); }) | ||
.replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) | ||
.replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); | ||
} | ||
if (pos > rightmostFailuresPos) { | ||
rightmostFailuresPos = pos; | ||
rightmostFailuresExpected = []; | ||
var expectedDescs = new Array(expected.length), | ||
expectedDesc, foundDesc, i; | ||
for (i = 0; i < expected.length; i++) { | ||
expectedDescs[i] = expected[i].description; | ||
} | ||
rightmostFailuresExpected.push(failure); | ||
expectedDesc = expected.length > 1 | ||
? expectedDescs.slice(0, -1).join(", ") | ||
+ " or " | ||
+ expectedDescs[expected.length - 1] | ||
: expectedDescs[0]; | ||
foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input"; | ||
return "Expected " + expectedDesc + " but " + foundDesc + " found."; | ||
} | ||
function parse_start() { | ||
var result0, result1; | ||
var pos0, pos1; | ||
pos0 = pos; | ||
pos1 = pos; | ||
result0 = parse__(); | ||
if (result0 !== null) { | ||
result1 = parse_object(); | ||
if (result1 !== null) { | ||
result0 = [result0, result1]; | ||
var posDetails = peg$computePosDetails(pos), | ||
found = pos < input.length ? input.charAt(pos) : null; | ||
if (expected !== null) { | ||
cleanupExpected(expected); | ||
} | ||
return new SyntaxError( | ||
message !== null ? message : buildMessage(expected, found), | ||
expected, | ||
found, | ||
pos, | ||
posDetails.line, | ||
posDetails.column | ||
); | ||
} | ||
function peg$parsestart() { | ||
var s0, s1, s2; | ||
s0 = peg$currPos; | ||
s1 = peg$parse_(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parseobject(); | ||
if (s2 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c1(s2); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parse_(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsearray(); | ||
if (s2 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c2(s2); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, object) { return object; })(pos0, result0[1]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
return result0; | ||
} | ||
function parse_object() { | ||
var result0, result1, result2, result3, result4; | ||
var pos0, pos1; | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.charCodeAt(pos) === 123) { | ||
result0 = "{"; | ||
pos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"{\""); | ||
return s0; | ||
} | ||
function peg$parseobject() { | ||
var s0, s1, s2, s3, s4, s5; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 123) { | ||
s1 = peg$c3; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c4); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parse_(); | ||
if (s2 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 125) { | ||
s3 = peg$c5; | ||
peg$currPos++; | ||
} else { | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c6); } | ||
} | ||
} | ||
if (result0 !== null) { | ||
result1 = parse__(); | ||
if (result1 !== null) { | ||
if (input.charCodeAt(pos) === 125) { | ||
result2 = "}"; | ||
pos++; | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parse_(); | ||
if (s4 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c7(); | ||
s0 = s1; | ||
} else { | ||
result2 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"}\""); | ||
} | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result2 !== null) { | ||
result3 = parse__(); | ||
if (result3 !== null) { | ||
result0 = [result0, result1, result2, result3]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return {}; })(pos0); | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 123) { | ||
s1 = peg$c3; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c4); } | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.charCodeAt(pos) === 123) { | ||
result0 = "{"; | ||
pos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"{\""); | ||
} | ||
} | ||
if (result0 !== null) { | ||
result1 = parse__(); | ||
if (result1 !== null) { | ||
result2 = parse_members(); | ||
if (result2 !== null) { | ||
if (input.charCodeAt(pos) === 125) { | ||
result3 = "}"; | ||
pos++; | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parse_(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsemembers(); | ||
if (s3 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 125) { | ||
s4 = peg$c5; | ||
peg$currPos++; | ||
} else { | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c6); } | ||
} | ||
if (s4 !== peg$FAILED) { | ||
s5 = peg$parse_(); | ||
if (s5 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c8(s3); | ||
s0 = s1; | ||
} else { | ||
result3 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"}\""); | ||
} | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result3 !== null) { | ||
result4 = parse__(); | ||
if (result4 !== null) { | ||
result0 = [result0, result1, result2, result3, result4]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, members) { return members; })(pos0, result0[2]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
return result0; | ||
} | ||
function parse_members() { | ||
var result0, result1, result2, result3, result4; | ||
var pos0, pos1, pos2; | ||
pos0 = pos; | ||
pos1 = pos; | ||
result0 = parse_pair(); | ||
if (result0 !== null) { | ||
result1 = []; | ||
pos2 = pos; | ||
if (input.charCodeAt(pos) === 44) { | ||
result2 = ","; | ||
pos++; | ||
return s0; | ||
} | ||
function peg$parsemembers() { | ||
var s0, s1, s2, s3, s4, s5, s6, s7; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s1 = peg$c10; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c11); } | ||
} | ||
if (s1 === peg$FAILED) { | ||
s1 = peg$c9; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsepair(); | ||
if (s2 === peg$FAILED) { | ||
s2 = peg$c9; | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = []; | ||
s4 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s5 = peg$c10; | ||
peg$currPos++; | ||
} else { | ||
result2 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\",\""); | ||
} | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c11); } | ||
} | ||
if (result2 !== null) { | ||
result3 = parse__(); | ||
if (result3 !== null) { | ||
result4 = parse_pair(); | ||
if (result4 !== null) { | ||
result2 = [result2, result3, result4]; | ||
if (s5 !== peg$FAILED) { | ||
s6 = peg$parse_(); | ||
if (s6 !== peg$FAILED) { | ||
s7 = peg$parsepair(); | ||
if (s7 !== peg$FAILED) { | ||
s5 = [s5, s6, s7]; | ||
s4 = s5; | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
peg$currPos = s4; | ||
s4 = peg$c0; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
peg$currPos = s4; | ||
s4 = peg$c0; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
peg$currPos = s4; | ||
s4 = peg$c0; | ||
} | ||
while (result2 !== null) { | ||
result1.push(result2); | ||
pos2 = pos; | ||
if (input.charCodeAt(pos) === 44) { | ||
result2 = ","; | ||
pos++; | ||
while (s4 !== peg$FAILED) { | ||
s3.push(s4); | ||
s4 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s5 = peg$c10; | ||
peg$currPos++; | ||
} else { | ||
result2 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\",\""); | ||
} | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c11); } | ||
} | ||
if (result2 !== null) { | ||
result3 = parse__(); | ||
if (result3 !== null) { | ||
result4 = parse_pair(); | ||
if (result4 !== null) { | ||
result2 = [result2, result3, result4]; | ||
if (s5 !== peg$FAILED) { | ||
s6 = peg$parse_(); | ||
if (s6 !== peg$FAILED) { | ||
s7 = peg$parsepair(); | ||
if (s7 !== peg$FAILED) { | ||
s5 = [s5, s6, s7]; | ||
s4 = s5; | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
peg$currPos = s4; | ||
s4 = peg$c0; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
peg$currPos = s4; | ||
s4 = peg$c0; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
peg$currPos = s4; | ||
s4 = peg$c0; | ||
} | ||
} | ||
if (result1 !== null) { | ||
if (input.charCodeAt(pos) === 44) { | ||
result2 = ","; | ||
pos++; | ||
if (s3 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s4 = peg$c10; | ||
peg$currPos++; | ||
} else { | ||
result2 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\",\""); | ||
} | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c11); } | ||
} | ||
result2 = result2 !== null ? result2 : ""; | ||
if (result2 !== null) { | ||
result3 = parse__(); | ||
if (result3 !== null) { | ||
result0 = [result0, result1, result2, result3]; | ||
if (s4 === peg$FAILED) { | ||
s4 = peg$c9; | ||
} | ||
if (s4 !== peg$FAILED) { | ||
s5 = peg$parse_(); | ||
if (s5 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c13(s2, s3); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, head, tail) { | ||
var result = {}; | ||
result[head[0]] = fixNull(head[1]); | ||
for (var i = 0; i < tail.length; i++) { | ||
result[tail[i][2][0]] = fixNull(tail[i][2][1]); | ||
} | ||
return result; | ||
})(pos0, result0[0], result0[1]); | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
return s0; | ||
} | ||
function peg$parsepair() { | ||
var s0, s1, s2, s3, s4; | ||
s0 = peg$currPos; | ||
s1 = peg$parsekey(); | ||
if (s1 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 58) { | ||
s2 = peg$c14; | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c15); } | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parse_(); | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parsevalue(); | ||
if (s4 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c16(s1, s4); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
return result0; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
function parse_pair() { | ||
var result0, result1, result2, result3; | ||
var pos0, pos1; | ||
pos0 = pos; | ||
pos1 = pos; | ||
result0 = parse_key(); | ||
if (result0 !== null) { | ||
if (input.charCodeAt(pos) === 58) { | ||
result1 = ":"; | ||
pos++; | ||
return s0; | ||
} | ||
function peg$parsearray() { | ||
var s0, s1, s2, s3, s4, s5; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 91) { | ||
s1 = peg$c17; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c18); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parse_(); | ||
if (s2 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 93) { | ||
s3 = peg$c19; | ||
peg$currPos++; | ||
} else { | ||
result1 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\":\""); | ||
} | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c20); } | ||
} | ||
if (result1 !== null) { | ||
result2 = parse__(); | ||
if (result2 !== null) { | ||
result3 = parse_value(); | ||
if (result3 !== null) { | ||
result0 = [result0, result1, result2, result3]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parse_(); | ||
if (s4 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c21(); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, name, value) { return [name, value]; })(pos0, result0[0], result0[3]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
return result0; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
function parse_array() { | ||
var result0, result1, result2, result3, result4; | ||
var pos0, pos1; | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.charCodeAt(pos) === 91) { | ||
result0 = "["; | ||
pos++; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 91) { | ||
s1 = peg$c17; | ||
peg$currPos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"[\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c18); } | ||
} | ||
if (result0 !== null) { | ||
result1 = parse__(); | ||
if (result1 !== null) { | ||
if (input.charCodeAt(pos) === 93) { | ||
result2 = "]"; | ||
pos++; | ||
} else { | ||
result2 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"]\""); | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parse_(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parseelements(); | ||
if (s3 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 93) { | ||
s4 = peg$c19; | ||
peg$currPos++; | ||
} else { | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c20); } | ||
} | ||
} | ||
if (result2 !== null) { | ||
result3 = parse__(); | ||
if (result3 !== null) { | ||
result0 = [result0, result1, result2, result3]; | ||
if (s4 !== peg$FAILED) { | ||
s5 = peg$parse_(); | ||
if (s5 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c22(s3); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return []; })(pos0); | ||
} | ||
return s0; | ||
} | ||
function peg$parseelements() { | ||
var s0, s1, s2, s3, s4, s5, s6, s7; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s1 = peg$c10; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c11); } | ||
} | ||
if (s1 === peg$FAILED) { | ||
s1 = peg$c9; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsevalue(); | ||
if (s2 === peg$FAILED) { | ||
s2 = peg$c9; | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.charCodeAt(pos) === 91) { | ||
result0 = "["; | ||
pos++; | ||
if (s2 !== peg$FAILED) { | ||
s3 = []; | ||
s4 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s5 = peg$c10; | ||
peg$currPos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"[\""); | ||
} | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c11); } | ||
} | ||
if (result0 !== null) { | ||
result1 = parse__(); | ||
if (result1 !== null) { | ||
result2 = parse_elements(); | ||
if (result2 !== null) { | ||
if (input.charCodeAt(pos) === 93) { | ||
result3 = "]"; | ||
pos++; | ||
} else { | ||
result3 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"]\""); | ||
} | ||
} | ||
if (result3 !== null) { | ||
result4 = parse__(); | ||
if (result4 !== null) { | ||
result0 = [result0, result1, result2, result3, result4]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
if (s5 !== peg$FAILED) { | ||
s6 = peg$parse_(); | ||
if (s6 !== peg$FAILED) { | ||
s7 = peg$parsevalue(); | ||
if (s7 !== peg$FAILED) { | ||
s5 = [s5, s6, s7]; | ||
s4 = s5; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s4; | ||
s4 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s4; | ||
s4 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s4; | ||
s4 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, elements) { return elements; })(pos0, result0[2]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
} | ||
return result0; | ||
} | ||
function parse_elements() { | ||
var result0, result1, result2, result3, result4; | ||
var pos0, pos1, pos2; | ||
pos0 = pos; | ||
pos1 = pos; | ||
result0 = parse_value(); | ||
if (result0 !== null) { | ||
result1 = []; | ||
pos2 = pos; | ||
if (input.charCodeAt(pos) === 44) { | ||
result2 = ","; | ||
pos++; | ||
} else { | ||
result2 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\",\""); | ||
while (s4 !== peg$FAILED) { | ||
s3.push(s4); | ||
s4 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s5 = peg$c10; | ||
peg$currPos++; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c11); } | ||
} | ||
} | ||
if (result2 !== null) { | ||
result3 = parse__(); | ||
if (result3 !== null) { | ||
result4 = parse_value(); | ||
if (result4 !== null) { | ||
result2 = [result2, result3, result4]; | ||
if (s5 !== peg$FAILED) { | ||
s6 = peg$parse_(); | ||
if (s6 !== peg$FAILED) { | ||
s7 = peg$parsevalue(); | ||
if (s7 !== peg$FAILED) { | ||
s5 = [s5, s6, s7]; | ||
s4 = s5; | ||
} else { | ||
peg$currPos = s4; | ||
s4 = peg$c0; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
peg$currPos = s4; | ||
s4 = peg$c0; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
peg$currPos = s4; | ||
s4 = peg$c0; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
while (result2 !== null) { | ||
result1.push(result2); | ||
pos2 = pos; | ||
if (input.charCodeAt(pos) === 44) { | ||
result2 = ","; | ||
pos++; | ||
if (s3 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s4 = peg$c10; | ||
peg$currPos++; | ||
} else { | ||
result2 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\",\""); | ||
} | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c11); } | ||
} | ||
if (result2 !== null) { | ||
result3 = parse__(); | ||
if (result3 !== null) { | ||
result4 = parse_value(); | ||
if (result4 !== null) { | ||
result2 = [result2, result3, result4]; | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
} | ||
if (s4 === peg$FAILED) { | ||
s4 = peg$c9; | ||
} | ||
if (s4 !== peg$FAILED) { | ||
s5 = peg$parse_(); | ||
if (s5 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c23(s2, s3); | ||
s0 = s1; | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result2 = null; | ||
pos = pos2; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} | ||
if (result1 !== null) { | ||
result0 = [result0, result1]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, head, tail) { | ||
var result = [fixNull(head)]; | ||
for (var i = 0; i < tail.length; i++) { | ||
result.push(fixNull(tail[i][2])); | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
return s0; | ||
} | ||
function peg$parsevalue() { | ||
var s0, s1, s2; | ||
s0 = peg$parsestring(); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parsesingle(); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parseobject(); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parsearray(); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 4) === peg$c24) { | ||
s1 = peg$c24; | ||
peg$currPos += 4; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c25); } | ||
} | ||
return result; | ||
})(pos0, result0[0], result0[1]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
return result0; | ||
} | ||
function parse_value() { | ||
var result0, result1; | ||
var pos0, pos1; | ||
result0 = parse_string(); | ||
if (result0 === null) { | ||
result0 = parse_single(); | ||
if (result0 === null) { | ||
result0 = parse_number(); | ||
if (result0 === null) { | ||
result0 = parse_object(); | ||
if (result0 === null) { | ||
result0 = parse_array(); | ||
if (result0 === null) { | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.substr(pos, 4) === "true") { | ||
result0 = "true"; | ||
pos += 4; | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parse_(); | ||
if (s2 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c26(); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 5) === peg$c27) { | ||
s1 = peg$c27; | ||
peg$currPos += 5; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c28); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parse_(); | ||
if (s2 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c29(); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"true\""); | ||
} | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result1 = parse__(); | ||
if (result1 !== null) { | ||
result0 = [result0, result1]; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 4) === peg$c30) { | ||
s1 = peg$c30; | ||
peg$currPos += 4; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c31); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parse_(); | ||
if (s2 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c32(); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return true; })(pos0); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.substr(pos, 5) === "false") { | ||
result0 = "false"; | ||
pos += 5; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"false\""); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parsenumber(); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parseliteral(); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c33(s1); | ||
} | ||
s0 = s1; | ||
} | ||
if (result0 !== null) { | ||
result1 = parse__(); | ||
if (result1 !== null) { | ||
result0 = [result0, result1]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return false; })(pos0); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.substr(pos, 4) === "null") { | ||
result0 = "null"; | ||
pos += 4; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"null\""); | ||
} | ||
} | ||
if (result0 !== null) { | ||
result1 = parse__(); | ||
if (result1 !== null) { | ||
result0 = [result0, result1]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return null_; })(pos0); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
result0 = parse_literal(); | ||
if (result0 !== null) { | ||
result0 = (function(offset, lit) { return lit.join('') })(pos0, result0); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
} | ||
} | ||
} | ||
@@ -751,439 +935,370 @@ } | ||
} | ||
return result0; | ||
} | ||
function parse_string() { | ||
var result0, result1, result2, result3; | ||
var pos0, pos1; | ||
reportFailures++; | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.charCodeAt(pos) === 34) { | ||
result0 = "\""; | ||
pos++; | ||
return s0; | ||
} | ||
function peg$parsestring() { | ||
var s0, s1, s2, s3, s4; | ||
peg$silentFails++; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 34) { | ||
s1 = peg$c35; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c36); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 34) { | ||
s2 = peg$c35; | ||
peg$currPos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\"\""); | ||
} | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c36); } | ||
} | ||
if (result0 !== null) { | ||
if (input.charCodeAt(pos) === 34) { | ||
result1 = "\""; | ||
pos++; | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parse_(); | ||
if (s3 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c37(); | ||
s0 = s1; | ||
} else { | ||
result1 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\"\""); | ||
} | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result1 !== null) { | ||
result2 = parse__(); | ||
if (result2 !== null) { | ||
result0 = [result0, result1, result2]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return ""; })(pos0); | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 34) { | ||
s1 = peg$c35; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c36); } | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.charCodeAt(pos) === 34) { | ||
result0 = "\""; | ||
pos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\"\""); | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsechars(); | ||
if (s2 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 34) { | ||
s3 = peg$c35; | ||
peg$currPos++; | ||
} else { | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c36); } | ||
} | ||
} | ||
if (result0 !== null) { | ||
result1 = parse_chars(); | ||
if (result1 !== null) { | ||
if (input.charCodeAt(pos) === 34) { | ||
result2 = "\""; | ||
pos++; | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parse_(); | ||
if (s4 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c38(s2); | ||
s0 = s1; | ||
} else { | ||
result2 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\"\""); | ||
} | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result2 !== null) { | ||
result3 = parse__(); | ||
if (result3 !== null) { | ||
result0 = [result0, result1, result2, result3]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, chars) { return chars; })(pos0, result0[1]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
reportFailures--; | ||
if (reportFailures === 0 && result0 === null) { | ||
matchFailed("double-quote string"); | ||
} | ||
return result0; | ||
} | ||
function parse_single() { | ||
var result0, result1, result2, result3; | ||
var pos0, pos1; | ||
reportFailures++; | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.charCodeAt(pos) === 39) { | ||
result0 = "'"; | ||
pos++; | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c34); } | ||
} | ||
return s0; | ||
} | ||
function peg$parsesingle() { | ||
var s0, s1, s2, s3, s4; | ||
peg$silentFails++; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s1 = peg$c40; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c41); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s2 = peg$c40; | ||
peg$currPos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"'\""); | ||
} | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c41); } | ||
} | ||
if (result0 !== null) { | ||
if (input.charCodeAt(pos) === 39) { | ||
result1 = "'"; | ||
pos++; | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parse_(); | ||
if (s3 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c37(); | ||
s0 = s1; | ||
} else { | ||
result1 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"'\""); | ||
} | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result1 !== null) { | ||
result2 = parse__(); | ||
if (result2 !== null) { | ||
result0 = [result0, result1, result2]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return ""; })(pos0); | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s1 = peg$c40; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c41); } | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.charCodeAt(pos) === 39) { | ||
result0 = "'"; | ||
pos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"'\""); | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parseschars(); | ||
if (s2 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s3 = peg$c40; | ||
peg$currPos++; | ||
} else { | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c41); } | ||
} | ||
} | ||
if (result0 !== null) { | ||
result1 = parse_schars(); | ||
if (result1 !== null) { | ||
if (input.charCodeAt(pos) === 39) { | ||
result2 = "'"; | ||
pos++; | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parse_(); | ||
if (s4 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c38(s2); | ||
s0 = s1; | ||
} else { | ||
result2 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"'\""); | ||
} | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result2 !== null) { | ||
result3 = parse__(); | ||
if (result3 !== null) { | ||
result0 = [result0, result1, result2, result3]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, chars) { return chars; })(pos0, result0[1]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
reportFailures--; | ||
if (reportFailures === 0 && result0 === null) { | ||
matchFailed("single-quote string"); | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c39); } | ||
} | ||
return s0; | ||
} | ||
function peg$parsechars() { | ||
var s0, s1, s2; | ||
s0 = peg$currPos; | ||
s1 = []; | ||
s2 = peg$parsechar(); | ||
if (s2 !== peg$FAILED) { | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
s2 = peg$parsechar(); | ||
} | ||
return result0; | ||
} else { | ||
s1 = peg$c0; | ||
} | ||
function parse_chars() { | ||
var result0, result1; | ||
var pos0; | ||
pos0 = pos; | ||
result1 = parse_char(); | ||
if (result1 !== null) { | ||
result0 = []; | ||
while (result1 !== null) { | ||
result0.push(result1); | ||
result1 = parse_char(); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c42(s1); | ||
} | ||
s0 = s1; | ||
return s0; | ||
} | ||
function peg$parsechar() { | ||
var s0, s1, s2, s3, s4, s5; | ||
if (peg$c43.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c44); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c45) { | ||
s1 = peg$c45; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c46); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, chars) { return chars.join(""); })(pos0, result0); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c47(); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
return result0; | ||
} | ||
function parse_char() { | ||
var result0, result1, result2, result3, result4; | ||
var pos0, pos1; | ||
if (/^[^"\\\0-\x1F]/.test(input.charAt(pos))) { | ||
result0 = input.charAt(pos); | ||
pos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("[^\"\\\\\\0-\\x1F]"); | ||
} | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\\"") { | ||
result0 = "\\\""; | ||
pos += 2; | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c48) { | ||
s1 = peg$c48; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\\\\"\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c49); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return '"'; })(pos0); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c50(); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\\\") { | ||
result0 = "\\\\"; | ||
pos += 2; | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c51) { | ||
s1 = peg$c51; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\\\\\\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c52); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return "\\"; })(pos0); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c53(); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\/") { | ||
result0 = "\\/"; | ||
pos += 2; | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c54) { | ||
s1 = peg$c54; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\/\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c55); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return "/"; })(pos0); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c56(); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\b") { | ||
result0 = "\\b"; | ||
pos += 2; | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c57) { | ||
s1 = peg$c57; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\b\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c58); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return "\b"; })(pos0); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c59(); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\f") { | ||
result0 = "\\f"; | ||
pos += 2; | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c60) { | ||
s1 = peg$c60; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\f\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c61); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return "\f"; })(pos0); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c62(); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\n") { | ||
result0 = "\\n"; | ||
pos += 2; | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c63) { | ||
s1 = peg$c63; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\n\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c64); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return "\n"; })(pos0); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c65(); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\r") { | ||
result0 = "\\r"; | ||
pos += 2; | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c66) { | ||
s1 = peg$c66; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\r\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c67); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return "\r"; })(pos0); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c68(); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\t") { | ||
result0 = "\\t"; | ||
pos += 2; | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c69) { | ||
s1 = peg$c69; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\t\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c70); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return "\t"; })(pos0); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.substr(pos, 2) === "\\u") { | ||
result0 = "\\u"; | ||
pos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\u\""); | ||
} | ||
} | ||
if (result0 !== null) { | ||
result1 = parse_hexDigit(); | ||
if (result1 !== null) { | ||
result2 = parse_hexDigit(); | ||
if (result2 !== null) { | ||
result3 = parse_hexDigit(); | ||
if (result3 !== null) { | ||
result4 = parse_hexDigit(); | ||
if (result4 !== null) { | ||
result0 = [result0, result1, result2, result3, result4]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsehexDigit(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsehexDigit(); | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parsehexDigit(); | ||
if (s4 !== peg$FAILED) { | ||
s5 = peg$parsehexDigit(); | ||
if (s5 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c71(s2, s3, s4, s5); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, h1, h2, h3, h4) { | ||
return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4)); })(pos0, result0[1], result0[2], result0[3], result0[4]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
@@ -1198,227 +1313,192 @@ } | ||
} | ||
return result0; | ||
} | ||
function parse_schars() { | ||
var result0, result1; | ||
var pos0; | ||
pos0 = pos; | ||
result1 = parse_schar(); | ||
if (result1 !== null) { | ||
result0 = []; | ||
while (result1 !== null) { | ||
result0.push(result1); | ||
result1 = parse_schar(); | ||
} | ||
} else { | ||
result0 = null; | ||
return s0; | ||
} | ||
function peg$parseschars() { | ||
var s0, s1, s2; | ||
s0 = peg$currPos; | ||
s1 = []; | ||
s2 = peg$parseschar(); | ||
if (s2 !== peg$FAILED) { | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
s2 = peg$parseschar(); | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, chars) { return chars.join(""); })(pos0, result0); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
return result0; | ||
} else { | ||
s1 = peg$c0; | ||
} | ||
function parse_schar() { | ||
var result0, result1, result2, result3, result4; | ||
var pos0, pos1; | ||
if (/^[^'\\\0-\x1F]/.test(input.charAt(pos))) { | ||
result0 = input.charAt(pos); | ||
pos++; | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c42(s1); | ||
} | ||
s0 = s1; | ||
return s0; | ||
} | ||
function peg$parseschar() { | ||
var s0, s1, s2, s3, s4, s5; | ||
if (peg$c72.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c73); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c74) { | ||
s1 = peg$c74; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("[^'\\\\\\0-\\x1F]"); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c75); } | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\'") { | ||
result0 = "\\'"; | ||
pos += 2; | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c76(); | ||
} | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c48) { | ||
s1 = peg$c48; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\'\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c49); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return '\''; })(pos0); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c50(); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\\\") { | ||
result0 = "\\\\"; | ||
pos += 2; | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c51) { | ||
s1 = peg$c51; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\\\\\\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c52); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return "\\"; })(pos0); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c53(); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\/") { | ||
result0 = "\\/"; | ||
pos += 2; | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c54) { | ||
s1 = peg$c54; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\/\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c55); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return "/"; })(pos0); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c56(); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\b") { | ||
result0 = "\\b"; | ||
pos += 2; | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c57) { | ||
s1 = peg$c57; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\b\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c58); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return "\b"; })(pos0); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c59(); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\f") { | ||
result0 = "\\f"; | ||
pos += 2; | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c60) { | ||
s1 = peg$c60; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\f\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c61); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return "\f"; })(pos0); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c62(); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\n") { | ||
result0 = "\\n"; | ||
pos += 2; | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c63) { | ||
s1 = peg$c63; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\n\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c64); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return "\n"; })(pos0); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c65(); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\r") { | ||
result0 = "\\r"; | ||
pos += 2; | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c66) { | ||
s1 = peg$c66; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\r\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c67); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return "\r"; })(pos0); | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c68(); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (input.substr(pos, 2) === "\\t") { | ||
result0 = "\\t"; | ||
pos += 2; | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c69) { | ||
s1 = peg$c69; | ||
peg$currPos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\t\""); | ||
} | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c70); } | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset) { return "\t"; })(pos0); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.substr(pos, 2) === "\\u") { | ||
result0 = "\\u"; | ||
pos += 2; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"\\\\u\""); | ||
} | ||
} | ||
if (result0 !== null) { | ||
result1 = parse_hexDigit(); | ||
if (result1 !== null) { | ||
result2 = parse_hexDigit(); | ||
if (result2 !== null) { | ||
result3 = parse_hexDigit(); | ||
if (result3 !== null) { | ||
result4 = parse_hexDigit(); | ||
if (result4 !== null) { | ||
result0 = [result0, result1, result2, result3, result4]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsehexDigit(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsehexDigit(); | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parsehexDigit(); | ||
if (s4 !== peg$FAILED) { | ||
s5 = peg$parsehexDigit(); | ||
if (s5 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c71(s2, s3, s4, s5); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, h1, h2, h3, h4) { | ||
return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4)); })(pos0, result0[1], result0[2], result0[3], result0[4]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
@@ -1433,663 +1513,532 @@ } | ||
} | ||
return result0; | ||
} | ||
function parse_key() { | ||
var result0, result1; | ||
var pos0; | ||
reportFailures++; | ||
result0 = parse_string(); | ||
if (result0 === null) { | ||
pos0 = pos; | ||
if (/^[a-zA-Z0-9_$]/.test(input.charAt(pos))) { | ||
result1 = input.charAt(pos); | ||
pos++; | ||
} else { | ||
result1 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("[a-zA-Z0-9_$]"); | ||
} | ||
} | ||
if (result1 !== null) { | ||
result0 = []; | ||
while (result1 !== null) { | ||
result0.push(result1); | ||
if (/^[a-zA-Z0-9_$]/.test(input.charAt(pos))) { | ||
result1 = input.charAt(pos); | ||
pos++; | ||
} else { | ||
result1 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("[a-zA-Z0-9_$]"); | ||
} | ||
} | ||
} | ||
} else { | ||
result0 = null; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, chars) { return chars.join('') })(pos0, result0); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
} | ||
reportFailures--; | ||
if (reportFailures === 0 && result0 === null) { | ||
matchFailed("key"); | ||
} | ||
return result0; | ||
} | ||
function parse_literal() { | ||
var result0, result1; | ||
if (/^[^,}]/.test(input.charAt(pos))) { | ||
result1 = input.charAt(pos); | ||
pos++; | ||
return s0; | ||
} | ||
function peg$parsekey() { | ||
var s0, s1, s2; | ||
peg$silentFails++; | ||
s0 = peg$parsestring(); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = []; | ||
if (peg$c78.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
result1 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("[^,}]"); | ||
} | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c79); } | ||
} | ||
if (result1 !== null) { | ||
result0 = []; | ||
while (result1 !== null) { | ||
result0.push(result1); | ||
if (/^[^,}]/.test(input.charAt(pos))) { | ||
result1 = input.charAt(pos); | ||
pos++; | ||
if (s2 !== peg$FAILED) { | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
if (peg$c78.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
result1 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("[^,}]"); | ||
} | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c79); } | ||
} | ||
} | ||
} else { | ||
result0 = null; | ||
s1 = peg$c0; | ||
} | ||
return result0; | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c80(s1); | ||
} | ||
s0 = s1; | ||
} | ||
function parse_number() { | ||
var result0, result1, result2, result3; | ||
var pos0, pos1; | ||
reportFailures++; | ||
pos0 = pos; | ||
pos1 = pos; | ||
result0 = parse_int(); | ||
if (result0 !== null) { | ||
result1 = parse_frac(); | ||
if (result1 !== null) { | ||
result2 = parse_exp(); | ||
if (result2 !== null) { | ||
result3 = parse__(); | ||
if (result3 !== null) { | ||
result0 = [result0, result1, result2, result3]; | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c77); } | ||
} | ||
return s0; | ||
} | ||
function peg$parseliteral() { | ||
var s0, s1; | ||
s0 = []; | ||
s1 = peg$parselitchar(); | ||
if (s1 !== peg$FAILED) { | ||
while (s1 !== peg$FAILED) { | ||
s0.push(s1); | ||
s1 = peg$parselitchar(); | ||
} | ||
} else { | ||
s0 = peg$c0; | ||
} | ||
return s0; | ||
} | ||
function peg$parselitchar() { | ||
var s0; | ||
if (peg$c81.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c82); } | ||
} | ||
return s0; | ||
} | ||
function peg$parsenumber() { | ||
var s0, s1, s2, s3, s4, s5, s6; | ||
peg$silentFails++; | ||
s0 = peg$currPos; | ||
s1 = peg$parseint(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsefrac(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parseexp(); | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parse_(); | ||
if (s4 !== peg$FAILED) { | ||
s5 = []; | ||
s6 = peg$parselitchar(); | ||
while (s6 !== peg$FAILED) { | ||
s5.push(s6); | ||
s6 = peg$parselitchar(); | ||
} | ||
if (s5 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c84(s1, s2, s3, s5); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, int_, frac, exp) { return parseFloat(int_ + frac + exp); })(pos0, result0[0], result0[1], result0[2]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
pos1 = pos; | ||
result0 = parse_int(); | ||
if (result0 !== null) { | ||
result1 = parse_frac(); | ||
if (result1 !== null) { | ||
result2 = parse__(); | ||
if (result2 !== null) { | ||
result0 = [result0, result1, result2]; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parseint(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsefrac(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parse_(); | ||
if (s3 !== peg$FAILED) { | ||
s4 = []; | ||
s5 = peg$parselitchar(); | ||
while (s5 !== peg$FAILED) { | ||
s4.push(s5); | ||
s5 = peg$parselitchar(); | ||
} | ||
if (s4 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c85(s1, s2, s4); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, int_, frac) { return parseFloat(int_ + frac); })(pos0, result0[0], result0[1]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
pos1 = pos; | ||
result0 = parse_int(); | ||
if (result0 !== null) { | ||
result1 = parse_exp(); | ||
if (result1 !== null) { | ||
result2 = parse__(); | ||
if (result2 !== null) { | ||
result0 = [result0, result1, result2]; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parseint(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parseexp(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parse_(); | ||
if (s3 !== peg$FAILED) { | ||
s4 = []; | ||
s5 = peg$parselitchar(); | ||
while (s5 !== peg$FAILED) { | ||
s4.push(s5); | ||
s5 = peg$parselitchar(); | ||
} | ||
if (s4 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c86(s1, s2, s4); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, int_, exp) { return parseFloat(int_ + exp); })(pos0, result0[0], result0[1]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
pos1 = pos; | ||
result0 = parse_int(); | ||
if (result0 !== null) { | ||
result1 = parse__(); | ||
if (result1 !== null) { | ||
result0 = [result0, result1]; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parseint(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parse_(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = []; | ||
s4 = peg$parselitchar(); | ||
while (s4 !== peg$FAILED) { | ||
s3.push(s4); | ||
s4 = peg$parselitchar(); | ||
} | ||
if (s3 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c87(s1, s3); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, int_) { return parseFloat(int_); })(pos0, result0[0]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} | ||
} | ||
reportFailures--; | ||
if (reportFailures === 0 && result0 === null) { | ||
matchFailed("number"); | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c83); } | ||
} | ||
return s0; | ||
} | ||
function peg$parseint() { | ||
var s0, s1, s2, s3; | ||
s0 = peg$currPos; | ||
s1 = peg$parsedigit19(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsedigits(); | ||
if (s2 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c88(s1, s2); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
return result0; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
function parse_int() { | ||
var result0, result1, result2; | ||
var pos0, pos1; | ||
pos0 = pos; | ||
pos1 = pos; | ||
result0 = parse_digit19(); | ||
if (result0 !== null) { | ||
result1 = parse_digits(); | ||
if (result1 !== null) { | ||
result0 = [result0, result1]; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parsedigit(); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 45) { | ||
s1 = peg$c89; | ||
peg$currPos++; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c90); } | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, digit19, digits) { return digit19 + digits; })(pos0, result0[0], result0[1]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
result0 = parse_digit(); | ||
if (result0 === null) { | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.charCodeAt(pos) === 45) { | ||
result0 = "-"; | ||
pos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"-\""); | ||
} | ||
} | ||
if (result0 !== null) { | ||
result1 = parse_digit19(); | ||
if (result1 !== null) { | ||
result2 = parse_digits(); | ||
if (result2 !== null) { | ||
result0 = [result0, result1, result2]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsedigit19(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsedigits(); | ||
if (s3 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c91(s2, s3); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, digit19, digits) { return "-" + digit19 + digits; })(pos0, result0[1], result0[2]); | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 45) { | ||
s1 = peg$c89; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c90); } | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
if (result0 === null) { | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.charCodeAt(pos) === 45) { | ||
result0 = "-"; | ||
pos++; | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsedigit(); | ||
if (s2 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c92(s2); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\"-\""); | ||
} | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result1 = parse_digit(); | ||
if (result1 !== null) { | ||
result0 = [result0, result1]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, digit) { return "-" + digit; })(pos0, result0[1]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
} | ||
} | ||
return result0; | ||
} | ||
function parse_frac() { | ||
var result0, result1; | ||
var pos0, pos1; | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (input.charCodeAt(pos) === 46) { | ||
result0 = "."; | ||
pos++; | ||
return s0; | ||
} | ||
function peg$parsefrac() { | ||
var s0, s1, s2; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 46) { | ||
s1 = peg$c93; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c94); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsedigits(); | ||
if (s2 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c95(s2); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("\".\""); | ||
} | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result1 = parse_digits(); | ||
if (result1 !== null) { | ||
result0 = [result0, result1]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, digits) { return "." + digits; })(pos0, result0[1]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
return result0; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
function parse_exp() { | ||
var result0, result1; | ||
var pos0, pos1; | ||
pos0 = pos; | ||
pos1 = pos; | ||
result0 = parse_e(); | ||
if (result0 !== null) { | ||
result1 = parse_digits(); | ||
if (result1 !== null) { | ||
result0 = [result0, result1]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
return s0; | ||
} | ||
function peg$parseexp() { | ||
var s0, s1, s2; | ||
s0 = peg$currPos; | ||
s1 = peg$parsee(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsedigits(); | ||
if (s2 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c96(s1, s2); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, e, digits) { return e + digits; })(pos0, result0[0], result0[1]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
return result0; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
function parse_digits() { | ||
var result0, result1; | ||
var pos0; | ||
pos0 = pos; | ||
result1 = parse_digit(); | ||
if (result1 !== null) { | ||
result0 = []; | ||
while (result1 !== null) { | ||
result0.push(result1); | ||
result1 = parse_digit(); | ||
} | ||
} else { | ||
result0 = null; | ||
return s0; | ||
} | ||
function peg$parsedigits() { | ||
var s0, s1, s2; | ||
s0 = peg$currPos; | ||
s1 = []; | ||
s2 = peg$parsedigit(); | ||
if (s2 !== peg$FAILED) { | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
s2 = peg$parsedigit(); | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, digits) { return digits.join(""); })(pos0, result0); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
return result0; | ||
} else { | ||
s1 = peg$c0; | ||
} | ||
function parse_e() { | ||
var result0, result1; | ||
var pos0, pos1; | ||
pos0 = pos; | ||
pos1 = pos; | ||
if (/^[eE]/.test(input.charAt(pos))) { | ||
result0 = input.charAt(pos); | ||
pos++; | ||
if (s1 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c97(s1); | ||
} | ||
s0 = s1; | ||
return s0; | ||
} | ||
function peg$parsee() { | ||
var s0, s1, s2; | ||
s0 = peg$currPos; | ||
if (peg$c98.test(input.charAt(peg$currPos))) { | ||
s1 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c99); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
if (peg$c100.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("[eE]"); | ||
} | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c101); } | ||
} | ||
if (result0 !== null) { | ||
if (/^[+\-]/.test(input.charAt(pos))) { | ||
result1 = input.charAt(pos); | ||
pos++; | ||
} else { | ||
result1 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("[+\\-]"); | ||
} | ||
} | ||
result1 = result1 !== null ? result1 : ""; | ||
if (result1 !== null) { | ||
result0 = [result0, result1]; | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
} | ||
} else { | ||
result0 = null; | ||
pos = pos1; | ||
if (s2 === peg$FAILED) { | ||
s2 = peg$c9; | ||
} | ||
if (result0 !== null) { | ||
result0 = (function(offset, e, sign) { return e + sign; })(pos0, result0[0], result0[1]); | ||
} | ||
if (result0 === null) { | ||
pos = pos0; | ||
} | ||
return result0; | ||
} | ||
function parse_digit() { | ||
var result0; | ||
if (/^[0-9]/.test(input.charAt(pos))) { | ||
result0 = input.charAt(pos); | ||
pos++; | ||
if (s2 !== peg$FAILED) { | ||
peg$reportedPos = s0; | ||
s1 = peg$c102(s1, s2); | ||
s0 = s1; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("[0-9]"); | ||
} | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
return result0; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$c0; | ||
} | ||
function parse_digit19() { | ||
var result0; | ||
if (/^[1-9]/.test(input.charAt(pos))) { | ||
result0 = input.charAt(pos); | ||
pos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("[1-9]"); | ||
} | ||
} | ||
return result0; | ||
return s0; | ||
} | ||
function peg$parsedigit() { | ||
var s0; | ||
if (peg$c103.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c104); } | ||
} | ||
function parse_hexDigit() { | ||
var result0; | ||
if (/^[0-9a-fA-F]/.test(input.charAt(pos))) { | ||
result0 = input.charAt(pos); | ||
pos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("[0-9a-fA-F]"); | ||
} | ||
} | ||
return result0; | ||
return s0; | ||
} | ||
function peg$parsedigit19() { | ||
var s0; | ||
if (peg$c105.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c106); } | ||
} | ||
function parse__() { | ||
var result0, result1; | ||
reportFailures++; | ||
result0 = []; | ||
result1 = parse_whitespace(); | ||
while (result1 !== null) { | ||
result0.push(result1); | ||
result1 = parse_whitespace(); | ||
} | ||
reportFailures--; | ||
if (reportFailures === 0 && result0 === null) { | ||
matchFailed("whitespace"); | ||
} | ||
return result0; | ||
return s0; | ||
} | ||
function peg$parsehexDigit() { | ||
var s0; | ||
if (peg$c107.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c108); } | ||
} | ||
function parse_whitespace() { | ||
var result0; | ||
if (/^[ \t\n\r]/.test(input.charAt(pos))) { | ||
result0 = input.charAt(pos); | ||
pos++; | ||
} else { | ||
result0 = null; | ||
if (reportFailures === 0) { | ||
matchFailed("[ \\t\\n\\r]"); | ||
} | ||
} | ||
return result0; | ||
return s0; | ||
} | ||
function peg$parse_() { | ||
var s0, s1; | ||
peg$silentFails++; | ||
s0 = []; | ||
s1 = peg$parsewhitespace(); | ||
while (s1 !== peg$FAILED) { | ||
s0.push(s1); | ||
s1 = peg$parsewhitespace(); | ||
} | ||
function cleanupExpected(expected) { | ||
expected.sort(); | ||
var lastExpected = null; | ||
var cleanExpected = []; | ||
for (var i = 0; i < expected.length; i++) { | ||
if (expected[i] !== lastExpected) { | ||
cleanExpected.push(expected[i]); | ||
lastExpected = expected[i]; | ||
} | ||
} | ||
return cleanExpected; | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c109); } | ||
} | ||
function computeErrorPosition() { | ||
/* | ||
* The first idea was to use |String.split| to break the input up to the | ||
* error position along newlines and derive the line and column from | ||
* there. However IE's |split| implementation is so broken that it was | ||
* enough to prevent it. | ||
*/ | ||
var line = 1; | ||
var column = 1; | ||
var seenCR = false; | ||
for (var i = 0; i < Math.max(pos, rightmostFailuresPos); i++) { | ||
var ch = input.charAt(i); | ||
if (ch === "\n") { | ||
if (!seenCR) { line++; } | ||
column = 1; | ||
seenCR = false; | ||
} else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { | ||
line++; | ||
column = 1; | ||
seenCR = true; | ||
} else { | ||
column++; | ||
seenCR = false; | ||
} | ||
} | ||
return { line: line, column: column }; | ||
return s0; | ||
} | ||
function peg$parsewhitespace() { | ||
var s0; | ||
if (peg$c110.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c111); } | ||
} | ||
/* | ||
* We can't return |null| in the |value| rule because that would mean parse | ||
* failure. So we return a special object instead and convert it to |null| | ||
* later. | ||
*/ | ||
var null_ = new Object; | ||
function fixNull(value) { | ||
return value === null_ ? null : value; | ||
} | ||
var result = parseFunctions[startRule](); | ||
return s0; | ||
} | ||
/* | ||
* The parser is now in one of the following three states: | ||
* | ||
* 1. The parser successfully parsed the whole input. | ||
* | ||
* - |result !== null| | ||
* - |pos === input.length| | ||
* - |rightmostFailuresExpected| may or may not contain something | ||
* | ||
* 2. The parser successfully parsed only a part of the input. | ||
* | ||
* - |result !== null| | ||
* - |pos < input.length| | ||
* - |rightmostFailuresExpected| may or may not contain something | ||
* | ||
* 3. The parser did not successfully parse any part of the input. | ||
* | ||
* - |result === null| | ||
* - |pos === 0| | ||
* - |rightmostFailuresExpected| contains at least one failure | ||
* | ||
* All code following this comment (including called functions) must | ||
* handle these states. | ||
* We can't return |null| in the |value| rule because that would mean parse | ||
* failure. So we return a special object instead and convert it to |null| | ||
* later. | ||
*/ | ||
if (result === null || pos !== input.length) { | ||
var offset = Math.max(pos, rightmostFailuresPos); | ||
var found = offset < input.length ? input.charAt(offset) : null; | ||
var errorPosition = computeErrorPosition(); | ||
throw new this.SyntaxError( | ||
cleanupExpected(rightmostFailuresExpected), | ||
found, | ||
offset, | ||
errorPosition.line, | ||
errorPosition.column | ||
); | ||
var null_ = new Object; | ||
function fixNull(value) { | ||
return value === null_ ? null : value; | ||
} | ||
return result; | ||
}, | ||
/* Returns the parser source code. */ | ||
toSource: function() { return this._source; } | ||
}; | ||
/* Thrown when a parser encounters a syntax error. */ | ||
result.SyntaxError = function(expected, found, offset, line, column) { | ||
function buildMessage(expected, found) { | ||
var expectedHumanized, foundHumanized; | ||
switch (expected.length) { | ||
case 0: | ||
expectedHumanized = "end of input"; | ||
break; | ||
case 1: | ||
expectedHumanized = expected[0]; | ||
break; | ||
default: | ||
expectedHumanized = expected.slice(0, expected.length - 1).join(", ") | ||
+ " or " | ||
+ expected[expected.length - 1]; | ||
peg$result = peg$startRuleFunction(); | ||
if (peg$result !== peg$FAILED && peg$currPos === input.length) { | ||
return peg$result; | ||
} else { | ||
if (peg$result !== peg$FAILED && peg$currPos < input.length) { | ||
peg$fail({ type: "end", description: "end of input" }); | ||
} | ||
foundHumanized = found ? quote(found) : "end of input"; | ||
return "Expected " + expectedHumanized + " but " + foundHumanized + " found."; | ||
throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos); | ||
} | ||
this.name = "SyntaxError"; | ||
this.expected = expected; | ||
this.found = found; | ||
this.message = buildMessage(expected, found); | ||
this.offset = offset; | ||
this.line = line; | ||
this.column = column; | ||
} | ||
return { | ||
SyntaxError: SyntaxError, | ||
parse: parse | ||
}; | ||
result.SyntaxError.prototype = Error.prototype; | ||
return result; | ||
})(); |
{ | ||
"name": "jsonic", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "A JSON parser that isn't strict.", | ||
@@ -5,0 +5,0 @@ "main": "jsonic.js", |
@@ -39,6 +39,8 @@ # jsonic | ||
Current Version: 0.1.2 | ||
[![Gitter chat](https://badges.gitter.im/rjrodger/jsonic.png)](https://gitter.im/rjrodger/jsonic) | ||
Tested on: node 0.10.35, Chrome 40 | ||
Current Version: 0.2.0 | ||
Tested on: node 0.10, 0.11, 0.12, iojs, Chrome 43, Safari 7, Firefox 38 | ||
[![Build Status](https://travis-ci.org/rjrodger/jsonic.png?branch=master)](https://travis-ci.org/rjrodger/jsonic) | ||
@@ -75,3 +77,3 @@ | ||
* You don't need to quote strings with spaces: <code>foo:bar baz, red:255</code> | ||
* You _do_ need to quote strings if they contain a comma or closing brace: <code>icky:"_,_}_"</code> | ||
* You _do_ need to quote strings if they contain a comma or closing brace or square bracket: <code>icky:"_,}]_"</code> | ||
* You can use single quotes for strings: <code>Jules:'Cry "Havoc," and let slip the dogs of war!'</code> | ||
@@ -81,3 +83,33 @@ * You can have trailing commas: <code>foo:bar, red:255, </code> | ||
# Stringify | ||
The _jsonic_ module provides a `stringify` method: | ||
``` js | ||
console.log( jsonic.stringify( {a:"bc",d:1} ) ) // prints {a:bc,d:1} | ||
``` | ||
The `stringify` method converts a plain JavaScript object into a | ||
string that can be parsed by _jsonic_. It has two parameters: | ||
* `value`: plain object | ||
* `options`: optional options object | ||
For example, you can limit the depth of the object tree printed: | ||
``` js | ||
console.log( jsonic.stringify( {a:{b:{c:1}}}, {depth:2} ) ) // prints {a:{b:{}}} | ||
``` | ||
_NOTE: `jsonic.stringify` is intended for debug printing, not data exchange, so the defaults are conservative in the amount of data printed_ | ||
The options are: | ||
* _depth_: default: __3__; maximum depth of sub-objects printed; _NOTE: there is no infinite-cycle protection, just this finite depth_ | ||
* _maxitems_: default: __11__; maximum number of array elements or object key/value pairs printed | ||
* _maxchars_: default: __111__; maximum number of characters printed | ||
* _omit_: default:__[]__; omit listed keys from objects | ||
* _exclude_: default:__['$']__; omit keys from objects if they contain any of the listed values | ||
## How it Works | ||
@@ -84,0 +116,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
179546
126
4005