/*
	Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/

//>>built
define("dojo/json5/parse",["../string","./util"],function(A,k){function J(b,h,p){var v=b[h];if(null!=v&&"object"===typeof v)for(var E in v){var K=J(v,E,p);void 0===K?delete v[E]:v[E]=K}return p.call(b,h,v)}function q(){if(F[B])return A.fromCodePoint(A.codePointAt(F,B))}function a(){var b=q();"\n"===b?(u++,m=0):b?m+=b.length:m++;b&&(B+=b.length);return b}function f(b,h){return{type:b,value:h,line:u,column:m}}function w(b){for(var h=0;h<b.length;h++){var p=b[h];if(q()!==p)throw g(a());a()}}function N(){switch(q()){case "b":return a(),
"\b";case "f":return a(),"\f";case "n":return a(),"\n";case "r":return a(),"\r";case "t":return a(),"\t";case "v":return a(),"\v";case "0":a();if(k.isDigit(q()))throw g(a());return"\x00";case "x":a();var b="",h=q();if(!k.isHexDigit(h))throw g(a());b+=a();h=q();if(!k.isHexDigit(h))throw g(a());b+=a();return A.fromCodePoint(parseInt(b,16));case "u":return a(),G();case "\n":case "\u2028":case "\u2029":return a(),"";case "\r":return a(),"\n"===q()&&a(),"";case "1":case "2":case "3":case "4":case "5":case "6":case "7":case "8":case "9":throw g(a());
case void 0:throw g(a());}return a()}function G(){for(var b="",h=4;0<h--;){var p=q();if(!k.isHexDigit(p))throw g(a());b+=a()}return A.fromCodePoint(parseInt(b,16))}function H(){switch(l.type){case "punctuator":switch(l.value){case "{":var b={};break;case "[":b=[]}break;case "null":case "boolean":case "numeric":case "string":b=l.value}if(void 0===y)y=b;else{var h=r[r.length-1];Array.isArray(h)?h.push(b):h[I]=b}null!==b&&"object"===typeof b?(r.push(b),n=Array.isArray(b)?"beforeArrayValue":"beforePropertyName"):
(b=r[r.length-1],n=null==b?"end":Array.isArray(b)?"afterArrayValue":"afterPropertyValue")}function C(){r.pop();var b=r[r.length-1];n=null==b?"end":Array.isArray(b)?"afterArrayValue":"afterPropertyValue"}function g(b){if(void 0===b)b=D("JSON5: invalid end of input at "+u+":"+m);else{var h={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\x00":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};h[b]?b=h[b]:" ">b&&(b=b.charCodeAt(0).toString(16),b="\\x"+("00"+
b).substring(b.length));b=D("JSON5: invalid character '"+b+"' at "+u+":"+m)}return b}function x(){return D("JSON5: invalid end of input at "+u+":"+m)}function L(){m-=5;return D("JSON5: invalid identifier character at "+u+":"+m)}function D(b){b=new SyntaxError(b);b.lineNumber=u;b.columnNumber=m;return b}var F,n,r,B,u,m,l,I,y,d,c,z,t,e,M={"default":function(){switch(e){case "\t":case "\v":case "\f":case " ":case "\u00a0":case "\ufeff":case "\n":case "\r":case "\u2028":case "\u2029":a();return;case "/":a();
d="comment";return;case void 0:return a(),f("eof")}if(k.isSpaceSeparator(e))a();else return M[n]()},comment:function(){switch(e){case "*":a();d="multiLineComment";return;case "/":a();d="singleLineComment";return}throw g(a());},multiLineComment:function(){switch(e){case "*":a();d="multiLineCommentAsterisk";return;case void 0:throw g(a());}a()},multiLineCommentAsterisk:function(){switch(e){case "*":a();return;case "/":a();d="default";return;case void 0:throw g(a());}a();d="multiLineComment"},singleLineComment:function(){switch(e){case "\n":case "\r":case "\u2028":case "\u2029":a();
d="default";return;case void 0:return a(),f("eof")}a()},value:function(){switch(e){case "{":case "[":return f("punctuator",a());case "n":return a(),w("ull"),f("null",null);case "t":return a(),w("rue"),f("boolean",!0);case "f":return a(),w("alse"),f("boolean",!1);case "-":case "+":"-"===a()&&(t=-1);d="sign";return;case ".":c=a();d="decimalPointLeading";return;case "0":c=a();d="zero";return;case "1":case "2":case "3":case "4":case "5":case "6":case "7":case "8":case "9":c=a();d="decimalInteger";return;
case "I":return a(),w("nfinity"),f("numeric",Infinity);case "N":return a(),w("aN"),f("numeric",NaN);case '"':case "'":z='"'===a();c="";d="string";return}throw g(a());},identifierNameStartEscape:function(){if("u"!==e)throw g(a());a();var b=G();switch(b){case "$":case "_":break;default:if(!k.isIdStartChar(b))throw L();}c+=b;d="identifierName"},identifierName:function(){switch(e){case "$":case "_":case "\u200c":case "\u200d":c+=a();return;case "\\":a();d="identifierNameEscape";return}if(k.isIdContinueChar(e))c+=
a();else return f("identifier",c)},identifierNameEscape:function(){if("u"!==e)throw g(a());a();var b=G();switch(b){case "$":case "_":case "\u200c":case "\u200d":break;default:if(!k.isIdContinueChar(b))throw L();}c+=b;d="identifierName"},sign:function(){switch(e){case ".":c=a();d="decimalPointLeading";return;case "0":c=a();d="zero";return;case "1":case "2":case "3":case "4":case "5":case "6":case "7":case "8":case "9":c=a();d="decimalInteger";return;case "I":return a(),w("nfinity"),f("numeric",Infinity*
t);case "N":return a(),w("aN"),f("numeric",NaN)}throw g(a());},zero:function(){switch(e){case ".":c+=a();d="decimalPoint";return;case "e":case "E":c+=a();d="decimalExponent";return;case "x":case "X":c+=a();d="hexadecimal";return}return f("numeric",0*t)},decimalInteger:function(){switch(e){case ".":c+=a();d="decimalPoint";return;case "e":case "E":c+=a();d="decimalExponent";return}if(k.isDigit(e))c+=a();else return f("numeric",t*Number(c))},decimalPointLeading:function(){if(k.isDigit(e))c+=a(),d="decimalFraction";
else throw g(a());},decimalPoint:function(){switch(e){case "e":case "E":c+=a();d="decimalExponent";return}if(k.isDigit(e))c+=a(),d="decimalFraction";else return f("numeric",t*Number(c))},decimalFraction:function(){switch(e){case "e":case "E":c+=a();d="decimalExponent";return}if(k.isDigit(e))c+=a();else return f("numeric",t*Number(c))},decimalExponent:function(){switch(e){case "+":case "-":c+=a();d="decimalExponentSign";return}if(k.isDigit(e))c+=a(),d="decimalExponentInteger";else throw g(a());},decimalExponentSign:function(){if(k.isDigit(e))c+=
a(),d="decimalExponentInteger";else throw g(a());},decimalExponentInteger:function(){if(k.isDigit(e))c+=a();else return f("numeric",t*Number(c))},hexadecimal:function(){if(k.isHexDigit(e))c+=a(),d="hexadecimalInteger";else throw g(a());},hexadecimalInteger:function(){if(k.isHexDigit(e))c+=a();else return f("numeric",t*Number(c))},string:function(){switch(e){case "\\":a();c+=N();return;case '"':if(z)return a(),f("string",c);c+=a();return;case "'":if(!z)return a(),f("string",c);c+=a();return;case "\n":case "\r":throw g(a());
case void 0:throw g(a());}c+=a()},start:function(){switch(e){case "{":case "[":return f("punctuator",a())}d="value"},beforePropertyName:function(){switch(e){case "$":case "_":c=a();d="identifierName";return;case "\\":a();d="identifierNameStartEscape";return;case "}":return f("punctuator",a());case '"':case "'":z='"'===a();d="string";return}if(k.isIdStartChar(e))c+=a(),d="identifierName";else throw g(a());},afterPropertyName:function(){if(":"===e)return f("punctuator",a());throw g(a());},beforePropertyValue:function(){d=
"value"},afterPropertyValue:function(){switch(e){case ",":case "}":return f("punctuator",a())}throw g(a());},beforeArrayValue:function(){if("]"===e)return f("punctuator",a());d="value"},afterArrayValue:function(){switch(e){case ",":case "]":return f("punctuator",a())}throw g(a());},end:function(){throw g(a());}},O={start:function(){if("eof"===l.type)throw x();H()},beforePropertyName:function(){switch(l.type){case "identifier":case "string":I=l.value;n="afterPropertyName";break;case "punctuator":C();
break;case "eof":throw x();}},afterPropertyName:function(){if("eof"===l.type)throw x();n="beforePropertyValue"},beforePropertyValue:function(){if("eof"===l.type)throw x();H()},beforeArrayValue:function(){if("eof"===l.type)throw x();"punctuator"===l.type&&"]"===l.value?C():H()},afterPropertyValue:function(){if("eof"===l.type)throw x();switch(l.value){case ",":n="beforePropertyName";break;case "}":C()}},afterArrayValue:function(){if("eof"===l.type)throw x();switch(l.value){case ",":n="beforeArrayValue";
break;case "]":C()}},end:function(){}};return function(b,h){F=String(b);n="start";r=[];B=0;u=1;m=0;y=I=l=void 0;do{a:for(d="default",c="",z=!1,t=1;;){e=q();var p=M[d]();if(p){l=p;break a}}O[n]()}while("eof"!==l.type);return"function"===typeof h?J({"":y},"",h):y}});