(function(){if(!this.Crunchy)this.Crunchy={}})();Crunchy.error=function(a){console.error(a)};Crunchy.crunch=function(a,b){if(b){var c=Crunchy.settings;Crunchy.settings=b}try{var d=Crunchy.parse(a);Crunchy.runHooks(d);Crunchy.renameVariables(d);return Crunchy.write(d)}finally{if(b)Crunchy.settings=c}};if(!this.console)this.console={};if(!console.log)console.log=function(){};if(!console.error)console.error=function(){};new function(){var a={concat:function(){for(var a=[],b=0,c;b<arguments.length;++b){c=arguments[b];if(typeof c==Object&&c.constructor==Array)for(var d=0;d<c.length;++d)a[a.length]=c[d];else a[a.length]=c}return a},every:function(a,b){for(var c=0,d=a.length;c<d;++c)if(!b(a[c],c,a))return false;return true},filter:function(a,b){for(var c=[],d=0,e=a.length;d<e;++d)if(b(a[d],d,a))c[c.length]=a[d];return c},forEach:function(a,b){for(var c=0,d=a.length;c<d;++c)b(a[c],c,a)},indexOf:function(a,b){for(b=c(a,b);b<a.length;++b)if(a[b]===obj)return b;return-1},lastIndexOf:function(a,b){for(b=c(a,b);b>=0;--b)if(a[b]===obj)return b;return-1},map:function(a,b){for(var c=[],d=0,e=a.length;d<e;++d)c[d]=b(a[d],d,a);return c},slice:function(a,b,d){b=c(b);d=c(d);for(var e=[];b<d;++b)e[e.length]=a[b];return e},some:function(a,b){for(var c=0,d=a.length;c<d;++c)if(b(a[c],c,a))return true;return false},pop:function(a){if(a.length){var b=a[a.length];--a.length;return b}else return undefined},push:function(a){for(var b=1;b!=arguments.length;++b)a[a.length]=arguments[b];return a},shift:function(a){var b=a[0];for(var c=1;c<a.length;++c)a[c-1]=a[c];--a.length;return b}};function c(a,b){return b==null?0:b>0?b:Math.max(b+a.length,0)}for(var b in a){if(!Array[b])Array[b]=a[b];if(!Array.prototype[b])Array.prototype[b]=d(a[b])}b=a=null;function d(a){return function(){var b=arguments;switch(b.length){case 0:return a(this);case 1:return a(this,b[0]);case 2:return a(this,b[0],b[1]);case 3:return a(this,b[0],b[1],b[2]);case 4:return a(this,b[0],b[1],b[2],b[3]);case 5:return a(this,b[0],b[1],b[2],b[3],b[4]);case 6:return a(this,b[0],b[1],b[2],b[3],b[4],b[5]);case 7:return a(this,b[0],b[1],b[2],b[3],b[4],b[5],b[6]);case 8:return a(this,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7]);case 9:return a(this,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8]);default:throw"Too many parameters."}}}function e(a){return function(){arguments.shift=Array.prototype.shift;return a.apply(arguments.shift(),arguments)}}};Array.prototype.top=function(){return this.length&&this[this.length-1]};String.prototype.repeat=function(a){var b="",c=this+b;while(--a>=0)b+=c;return b};Crunchy.tokens=["END","\n",";",";;;",",","=","?",":","CONDITIONAL","||","&&","|","^","&","==","!=","===","!==","<","<=",">=",">","<<",">>",">>>","+","-","*","/","%","!","~","UNARY_PLUS","UNARY_MINUS","++","--",".","[","]","{","}","(",")","SCRIPT","BLOCK","LABEL","FOR_IN","CALL","NEW_WITH_ARGS","INDEX","ARRAY_INIT","OBJECT_INIT","PROPERTY_INIT","GETTER","SETTER","GROUP","LIST","IDENTIFIER","MEMBER_IDENTIFIER","NUMBER","STRING","REGEXP","EMPTY","break","case","catch","continue","default","delete","do","else","finally","for","function","if","in","instanceof","new","return","switch","this","throw","try","typeof","var","void","while","with","true","false","null"];Crunchy.contextuallyReservedTokens=["class","enum","extends","super","const","debugger","double","final","implements","import","int","interface","native","package","private","protected","public","static","goto"];Crunchy.opTypeNames={"\n":"NEWLINE",";":"SEMICOLON",";;;":"DEBUG_SEMICOLON",",":"COMMA","?":"HOOK",":":"COLON","||":"OR","&&":"AND","|":"BITWISE_OR","^":"BITWISE_XOR","&":"BITWISE_AND","===":"STRICT_EQ","==":"EQ","=":"ASSIGN","!==":"STRICT_NE","!=":"NE","<<":"LSH","<=":"LE","<":"LT",">>>":"URSH",">>":"RSH",">=":"GE",">":"GT","++":"INCREMENT","--":"DECREMENT","+":"PLUS","-":"MINUS","*":"MUL","/":"DIV","%":"MOD","!":"NOT","~":"BITWISE_NOT",".":"DOT","[":"LEFT_BRACKET","]":"RIGHT_BRACKET","{":"LEFT_CURLY","}":"RIGHT_CURLY","(":"LEFT_PAREN",")":"RIGHT_PAREN"};Crunchy.opPrecedence={INDEX:-1,CALL:-1,GROUP:-1,NEW_WITH_ARGS:-1,SEMICOLON:0,COMMA:1,ASSIGN:2,HOOK:2,COLON:2,CONDITIONAL:2,OR:4,AND:5,BITWISE_OR:6,BITWISE_XOR:7,BITWISE_AND:8,EQ:9,NE:9,STRICT_EQ:9,STRICT_NE:9,LT:10,LE:10,GE:10,GT:10,IN:10,INSTANCEOF:10,LSH:11,RSH:11,URSH:11,PLUS:12,MINUS:12,MUL:13,DIV:13,MOD:13,DELETE:14,VOID:14,TYPEOF:14,NOT:14,BITWISE_NOT:14,UNARY_PLUS:14,UNARY_MINUS:14,INCREMENT:15,DECREMENT:15,NEW:16,DOT:17};Crunchy.opArity={COMMA:-2,ASSIGN:2,CONDITIONAL:3,OR:2,AND:2,BITWISE_OR:2,BITWISE_XOR:2,BITWISE_AND:2,EQ:2,NE:2,STRICT_EQ:2,STRICT_NE:2,LT:2,LE:2,GE:2,GT:2,IN:2,INSTANCEOF:2,LSH:2,RSH:2,URSH:2,PLUS:2,MINUS:2,MUL:2,DIV:2,MOD:2,DELETE:1,VOID:1,TYPEOF:1,NOT:1,BITWISE_NOT:1,UNARY_PLUS:1,UNARY_MINUS:1,INCREMENT:1,DECREMENT:1,NEW:1,NEW_WITH_ARGS:2,DOT:2,INDEX:2,CALL:2,ARRAY_INIT:1,OBJECT_INIT:1,GROUP:1};Crunchy.contextuallyReservedKeywords={};Crunchy.contextuallyReservedTokens.forEach(function(a){Crunchy.tokens.push(a);Crunchy.contextuallyReservedKeywords[a]=a.toUpperCase()});var keywords={};for(var i=0,j=Crunchy.tokens.length;i<j;i++){var t=Crunchy.tokens[i];if(/^[a-z]/.test(t)){var tt=t.toUpperCase();keywords[t]=tt}else var tt=/^\W/.test(t)?Crunchy.opTypeNames[t]:t;Crunchy.tokens[t]=tt;Crunchy.tokens[tt]=t}Crunchy.tokens["GETTER"]="get";Crunchy.tokens["SETTER"]="set";Crunchy.lookupKeyword=function(a){return keywords[a]||false};Crunchy.assignOps=["|","^","&","<<",">>",">>>","+","-","*","/","%"];for(i=0,j=Crunchy.assignOps.length;i<j;i++){t=Crunchy.assignOps[i];Crunchy.assignOps[t+"="]=Crunchy.tokens[t]}Crunchy.Tokenizer=function(a,b,c){for(var d in this)this[d]=this[d];this.source=String(a);this.filename=b||"";this.lineno=c||1;this._cursor=0;this._tokens=[false,false,false,false];this._tokenIndex=0;this._lookahead=0;this._scanNewlines=false};Crunchy.Tokenizer.prototype={token:function(){return this._tokens[this._tokenIndex]},matchOperand:function(a){return this.getToken(true)==a||this.unget()},matchOperator:function(a){return this.getToken(false)==a||this.unget()},mustMatchOperand:function(a){if(!this.matchOperand(a))throw this.newSyntaxError("Missing "+Crunchy.tokens[a].toLowerCase());return this.token()},mustMatchOperator:function(a){if(!this.matchOperator(a))throw this.newSyntaxError("Missing "+Crunchy.tokens[a].toLowerCase());return this.token()},peekOperand:function(){return this._peek(true)},peekOperator:function(){return this._peek(false)},_peek:function(a){var b=this.getToken2(a);this.unget();return b},peekOnSameLine:function(){this._scanNewlines=true;var a=this._peek(true);this._scanNewlines=false;return a},_newToken:function(a,b,c){this._tokenIndex=this._tokenIndex+1&3;var d=this._tokens[this._tokenIndex];if(!d)this._tokens[this._tokenIndex]=d={};d.type=a;d.text=b;d.value=typeof c==="string"?c:b;d.assignOp=null;d.isProperty=false;d.scanOperand=null;return d},_matchRegExp:function(a){a.lastIndex=this._cursor;var b=a.exec(this.source);return b&&b.index==this._cursor?b:null},_getKeyword:function(a,b){var c=a._newToken(Crunchy.lookupKeyword(b),b);c.isProperty=!!Crunchy.contextuallyReservedKeywords[b];return c},_getIdentifier:function(a,b){var c=a._newToken("IDENTIFIER",b);c.isProperty=true;return c},_getNumber:function(a,b){return a._newToken("NUMBER",b)},_getDotNumber:function(a,b){if(b.length==1)return a._getOp(a,b);else return a._newToken("NUMBER",b,parseFloat(b))},_getString:function(a,b){var c=b.substr(1,b.length-2).replace(/\\x[0-9a-fA-F][0-9a-fA-F]|\\.|\\\n|\\\r\n?/g,function(a){if(a.length==4)return String.fromCharCode(parseInt(a.substr(2),16));else switch(a[1]){case"\\":return"\\";case"b":return"\b";case"t":return"\t";case"n":return"\n";case"v":return"\v";case"f":return"\f";case"r":return"\r";case"\n":return"";case"\r":return"";default:return a[1]}});return a._newToken("STRING",b,c)},_getCommentBlock:function(a){var b=a.source.indexOf("*/",a._cursor+2);b=b!=-1?b+2:a.source.length;for(var c=a.source.indexOf("\n",a._cursor);c!=-1&&c<b;c=a.source.indexOf("\n",c+1))++a.lineno;a._cursor=b},_getCommentLine:function(a,b){var c=a.source.indexOf("\n",a._cursor);if(c==-1)a._cursor=a.source.length;else{++a.lineno;a._cursor=c+1}},_getSlash:function(a,b,c){if(c){var d=a._matchRegExp(/\/(\\.|\[[^\]]*\]|[^\/\[])+\/[a-z]*/g);var e=a._newToken("REGEXP",d[0],d[0])}else var e=a._getOp(a,b);e.scanOperand=c;return e},_getOp:function(a,b){if(Crunchy.assignOps[b]){var c=a._newToken("ASSIGN",b);c.assignOp=Crunchy.assignOps[b];return c}else return a._newToken(Crunchy.opTypeNames[b],b)},_getWhiteSpace:function(a,b){if(!a._scanNewlines){var c=b.match(/\n/g);if(c)a.lineno+=c.length;a._cursor+=b.length}else{var d=/^[ \t]+/.exec(b);var e=d?d[0].length:0;a._cursor+=e;if(e<b.length){a.lineno+=1;return a._newToken("NEWLINE","\n")}}return undefined},getOperand:function(){return this.getToken(true)},getOperator:function(){return this.getToken(false)},getToken:function(a){return this.getToken2(a).type},getToken2:function(a){while(this._lookahead){--this._lookahead;this._tokenIndex=this._tokenIndex+1&3;var b=this._tokens[this._tokenIndex];if(b.type!="NEWLINE"||this._scanNewlines){if(b.scanOperand!=null&&b.scanOperand!=a)console.info("Invalid scanOperand");return b}}do{if(this._cursor>=this.source.length){var b=this._newToken("END");return b}var c=this._matchRegExp(Crunchy._tokenRegExp);this._cursor+=c[1].length;var d=c[2];var b=(this._getTokenizers["$"+d]||this._subTokenizers[d.charAt(0)]||this._getWhiteSpace)(this,d,a)}while(!b);this._cursor+=b.text.length;b.lineno=this.lineno;return b},unget:function(){do{if(++this._lookahead==4)throw"PANIC: too much lookahead!";this._tokenIndex=this._tokenIndex-1&3}while(this._tokens[this._tokenIndex]&&this._tokens[this._tokenIndex].type=="NEWLINE")},newSyntaxError:function(a){throw{message:a,filename:this.filename,lineno:this.lineno,source:this.source,cursor:this._cursor,toString:function(){return a}}}};(function(){var a=Crunchy.Tokenizer.prototype,b=a._getTokenizers={},c=a._subTokenizers={};function g(a,b,d){for(var e=a.charCodeAt(0),f=b.charCodeAt(0);e<=f;++e)c[String.fromCharCode(e)]=d}g("A","Z",a._getIdentifier);g("a","z",a._getIdentifier);c["_"]=a._getIdentifier;c["$"]=a._getIdentifier;g("0","9",a._getNumber);c["."]=a._getDotNumber;c["'"]=a._getString;c['"']=a._getString;b["$//"]=a._getCommentLine;b["$/*"]=a._getCommentBlock;for(var d=0;d<Crunchy.tokens.length;++d){var e=Crunchy.tokens[d];if(/^[a-z]/.test(e))b["$"+e]=a._getKeyword;else if(/^[^A-Z\n]/.test(e))b["$"+e]=e[0]=="/"?a._getSlash:a._getOp}for(var d=0;d<Crunchy.assignOps.length;++d){e=Crunchy.assignOps[d];b["$"+e+"="]=e[0]=="/"?a._getSlash:a._getOp}var f=["[a-zA-Z_$][\\w$]*","[\n\r][\\s\n\r]*",";(?:;;)?","\\.\\d*(?:[eE][-+]?\\d+)?","\\/[=\\/\\*]?","\\+[+=]?","-[-=]?","<<=?",">>>?=?","[*%<>^]=?","\\|[|=]?","&[&=]?","[!=]=?=?","'(?:\\\\.|[^'])*'",'"(?:\\\\.|[^"])*"',"0[xX][\\da-fA-F]+","\\d+\\.?\\d*(?:[eE][-+]?\\d+)?","."];Crunchy._tokenRegExp=new RegExp("([ \t]*)("+f.join("|")+")","mg")})();(function(){function CompilerContext(a){this.inFunction=a;this.nestedLevel=0;this.funDecls=[];this.varDecls=[]}var CCp=CompilerContext.prototype;CCp.bracketLevel=CCp.curlyLevel=CCp.parenLevel=CCp.hookLevel=0;CCp.inForLoopInit=false;CCp.ecmaStrictMode=false;function Script(a){var b=new Node(a,"SCRIPT");b.setBody(ParseCompilerContext(a,b,false));return b}function ParseCompilerContext(a,b,c){var d=new CompilerContext(c),e=Statements(a,d);b.funDecls=d.funDecls;b.varDecls=d.varDecls;return e}var NodeTypes={SCRIPT:["body"],IF:["condition","thenPart","elsePart"],SWITCH:["discriminant","cases"],CASE:["caseLabel","statements"],DEFAULT:["statements"],FOR:["setup","condition","update","body"],FOR_IN:["iterator","object","body"],WHILE:["condition","body"],DO:["body","condition"],BREAK:[],CONTINUE:[],TRY:["tryBlock","catchClauses","finallyBlock"],CATCH:["guard","block"],THROW:["exception"],RETURN:["returnValue"],WITH:["object","body"],DEBUGGER:[],LABEL:["statement"],SEMICOLON:["expression"],DEBUG_SEMICOLON:["statement"],FUNCTION:["body"],VAR:[],CONST:[],IDENTIFIER:["initializer"],GOTO:[],GETTER:["body"],SETTER:["body"]};function getNodeType(info){var result={};for(var i=0;i<info.length;++i){var name=info[i];eval("result.set"+name.charAt(0).toUpperCase()+name.substr(1)+" = function(n) { this."+name+" = n;this.children["+i+"] = n}")}return result}for(var i in NodeTypes)NodeTypes[i]=getNodeType(NodeTypes[i]);function Node(a,b){var c=a.token();if(c){this.type=typeof b=="string"?b:c.type;this.value=c.value}else this.type=b;this.tokenizer=a;this.children=[];var d=NodeTypes[this.type];if(this.type&&d)for(var e in d)this[e]=d[e]}var Np=Node.prototype;Np.setType=function(a){if(this.type)throw"Type already set";var b=NodeTypes[a];if(b)for(var c in b)this[c]=b[c];this.type=a};var OperatorNode=Node;Np.pushOperand=function(a){return this.children.push(a)};Np.forChildren=function(a){for(var b=0;b<this.children.length;++b){var c=this.children[b];if(c)if(c.constructor==Array)for(var d=0;d<c.length;++d)a(c[d]);else a(c)}};Node.indentLevel=0;function tokenstr(a){var b=Crunchy.tokens[a];return b?/^\W/.test(b)?Crunchy.opTypeNames[b]:b.toUpperCase():"(null)"}Np.toString=function(){var a=[];for(var b in this)if(this.hasOwnProperty(b)&&b!="type")a.push({id:b,value:this[b]});a.sort(function(a,b){return(a.id>b.id)-(a.id<b.id)});var c="    ",d=++Node.indentLevel,e="{\n"+c.repeat(d)+"type: "+tokenstr(this.type);for(b=0;b<a.length;b++)e+=",\n"+c.repeat(d)+a[b].id+": "+a[b].value;d=--Node.indentLevel;e+="\n"+c.repeat(d)+"}";return e};Np.filename=function(){return this.tokenizer.filename};function Statements(a,b){var c,d=[];while((c=a.peekOperand().type)!="END"&&c!="RIGHT_CURLY")d=d.concat(Statement(a,b));return d}function Block(a,b){if(a.peekOperand().type!="LEFT_CURLY")throw a.newSyntaxError("Code block expected.");return OptionalBlock(a,b)}function OptionalBlock(a,b){++b.nestedLevel;var c=Statement(a,b);--b.nestedLevel;return c}Crunchy.DECLARED_FORM=0;Crunchy.EXPRESSED_FORM=1;Crunchy.STATEMENT_FORM=2;function Statement(a,b){return(StatementMethods[a.getOperand()]||StatementMethods["default"])(a,b)}var StatementMethods={FUNCTION:function(a,b){return[FunctionDefinition(a,b,true,b.nestedLevel>0?Crunchy.STATEMENT_FORM:Crunchy.DECLARED_FORM)]},LEFT_CURLY:function(a,b){++b.nestedLevel;var c=Statements(a,b);--b.nestedLevel;a.mustMatchOperator("RIGHT_CURLY");if(b.nestedLevel==0){var d=new Node(a,"BLOCK");d.children=c;return[d]}else return c},IF:function(a,b){var c=new Node(a,"IF");c.setCondition(ParenExpression(a,b));c.setThenPart(OptionalBlock(a,b));c.setElsePart(a.matchOperator("ELSE")?OptionalBlock(a,b):null);return[c]},SWITCH:function(a,b){var c,d=new Node(a);a.mustMatchOperator("LEFT_PAREN");d.setDiscriminant(Expression(a,b));a.mustMatchOperator("RIGHT_PAREN");var e=[];a.mustMatchOperand("LEFT_CURLY");++b.nestedLevel;while((c=a.getOperand())!="RIGHT_CURLY"){var f=new Node(a);if(c=="CASE")f.setCaseLabel(Expression(a,b,"COLON"));else if(c!="DEFAULT")throw a.newSyntaxError("Invalid switch case");a.mustMatchOperand("COLON");var g=[];while((c=a.peekOperand().type)!="CASE"&&c!="DEFAULT"&&c!="RIGHT_CURLY")g=g.concat(Statement(a,b));f.setStatements(g);e.push(f)}--b.nestedLevel;d.setCases(e);return[d]},FOR:function(a,b){var c=new Node(a,"");c.isLoop=true;a.mustMatchOperator("LEFT_PAREN");var d,e;if((d=a.peekOperand().type)!="SEMICOLON"){b.inForLoopInit=true;if(d=="VAR"||d=="CONST"){a.getOperand();e=Variables(a,b)}else e=Expression(a,b);b.inForLoopInit=false}if(e&&a.matchOperator("IN")){c.setType("FOR_IN");c.isLoop=true;if(e.type=="VAR"&&e.children.length!=1)throw a.newSyntaxError("Invalid for..in left-hand side");c.setIterator(e);c.setObject(Expression(a,b))}else{c.setType("FOR");c.setSetup(e||null);a.mustMatchOperator("SEMICOLON");c.setCondition(a.peekOperand().type=="SEMICOLON"?null:Expression(a,b));a.mustMatchOperator("SEMICOLON");c.setUpdate(a.peekOperand().type=="RIGHT_PAREN"?null:Expression(a,b))}a.mustMatchOperator("RIGHT_PAREN");c.setBody(OptionalBlock(a,b));return[c]},WHILE:function(a,b){var c=new Node(a);c.isLoop=true;c.setCondition(ParenExpression(a,b));c.setBody(OptionalBlock(a,b));return[c]},DO:function(a,b){var c=new Node(a);c.isLoop=true;c.setBody(OptionalBlock(a,b));a.mustMatchOperand("WHILE");c.setCondition(ParenExpression(a,b));if(b.ecmaStrictMode)StatementEnd(a,b);else a.matchOperand("SEMICOLON");return[c]},BREAK:function(a,b){var c=new Node(a);if(a.peekOnSameLine().isProperty){a.getOperand();c.label=a.token().value}StatementEnd(a,b);return[c]},CONTINUE:function(a,b){var c=new Node(a);if(a.peekOnSameLine().isProperty){a.getOperand();c.label=a.token().value}StatementEnd(a,b);return[c]},TRY:function(a,b){var c=new Node(a);c.setTryBlock(Block(a,b));var d=[];while(a.matchOperand("CATCH")){var e=new Node(a);a.mustMatchOperator("LEFT_PAREN");e.varName=a.mustMatchOperand("IDENTIFIER").value;if(a.matchOperand("IF")){if(b.ecmaStrictMode)throw a.newSyntaxError("Illegal catch guard");if(d.length&&!d.top().guard)throw a.newSyntaxError("Guarded catch after unguarded");e.setGuard(Expression(a,b))}else e.setGuard(null);a.mustMatchOperator("RIGHT_PAREN");e.setBlock(Block(a,b));d.push(e)}c.setCatchClauses(d);if(a.matchOperand("FINALLY"))c.setFinallyBlock(Block(a,b));if(!c.catchClauses.length&&!c.finallyBlock)throw a.newSyntaxError("Invalid try statement");return[c]},CATCH:function(a,b){throw a.newSyntaxError("catch without preceding try")},FINALLY:function(a,b){throw a.newSyntaxError("finally without preceding try")},THROW:function(a,b){var c=new Node(a);c.setException(Expression(a,b));StatementEnd(a,b);return[c]},RETURN:function(a,b){if(!b.inFunction)throw a.newSyntaxError("Invalid return");var c=new Node(a),d=a.peekOnSameLine().type;if(d!="END"&&d!="NEWLINE"&&d!="SEMICOLON"&&d!="DEBUG_SEMICOLON"&&d!="RIGHT_CURLY")c.setReturnValue(Expression(a,b));StatementEnd(a,b);return[c]},WITH:function(a,b){var c=new Node(a);c.setObject(ParenExpression(a,b));c.setBody(OptionalBlock(a,b));return[c]},VAR:function(a,b){var c=Variables(a,b);StatementEnd(a,b);return[c]},CONST:function(a,b){var c=Variables(a,b);StatementEnd(a,b);return[c]},DEBUGGER:function(a,b){var c=new Node(a);StatementEnd(a,b);return[c]},NEWLINE:function(a,b){return[]},SEMICOLON:function(a,b){return[]},DEBUG_SEMICOLON:function(a,b){var c=new Node(a);c.setStatement(Statement(a,b));return[c]},"default":function(a,b){if(a.token().isProperty&&a.peekOperator().type=="COLON"){var c=a.token().value;a.getOperand();var d=new Node(a,"LABEL");d.label=c;d.setStatement(Statement(a,b));return[d]}else{var d=new Node(a,"SEMICOLON");a.unget();d.setExpression(Expression(a,b));StatementEnd(a,b);return[d]}},GOTO:function(a,b){var c=a.peekOnSameLine();if(c.isProperty){var d=new Node(a);a.getOperand();d.label=a.token().value;StatementEnd(a,b);return[d]}else return StatementMethods["default"](a,b)}};function StatementEnd(a,b){if(a.lineno==a.token().lineno){tt=a.peekOnSameLine().type;if(tt!="END"&&tt!="NEWLINE"&&tt!="SEMICOLON"&&tt!="DEBUG_SEMICOLON"&&tt!="RIGHT_CURLY")throw a.newSyntaxError("Missing ; before statement")}a.matchOperand("SEMICOLON")}function FunctionDefinition(a,b,c,d){var e=a.token();if(e.type=="FUNCTION")var f="FUNCTION";else if(e.value=="get")var f="GETTER";else if(e.value=="set")var f="SETTER";else throw"Invalid function.";var g=new Node(a,f);if(a.matchOperand("IDENTIFIER"))g.name=a.token().value;else if(c)throw a.newSyntaxError("Missing function identifier");a.mustMatchOperator("LEFT_PAREN");var h=[],i;while((i=a.getOperand())!="RIGHT_PAREN"){if(i!="IDENTIFIER")throw a.newSyntaxError("Missing formal parameter");h.push(a.token().value);if(a.peekOperator().type!="RIGHT_PAREN")a.mustMatchOperator("COMMA")}g.params=h;a.mustMatchOperator("LEFT_CURLY");g.setBody(ParseCompilerContext(a,g,true));a.mustMatchOperand("RIGHT_CURLY");g.functionForm=d;if(d==Crunchy.DECLARED_FORM)b.funDecls.push(g);return g}function Variables(a,b){var c=new OperatorNode(a);do{a.mustMatchOperand("IDENTIFIER");var d=new Node(a);d.name=d.value;if(a.matchOperator("ASSIGN")){if(a.token().assignOp)throw a.newSyntaxError("Invalid variable initialization");d.setInitializer(Expression(a,b,"COMMA"))}d.readOnly=c.type=="CONST";c.pushOperand(d);b.varDecls.push(d)}while(a.matchOperator("COMMA"));return c}function ParenExpression(a,b){a.mustMatchOperator("LEFT_PAREN");var c=Expression(a,b);a.mustMatchOperator("RIGHT_PAREN");return c}function Expression(a,b,c){var d,e=[],f=[],g={bl:b.bracketLevel,cl:b.curlyLevel,pl:b.parenLevel,hl:b.hookLevel,scanOperand:true};do{d=a.getToken(g.scanOperand);if(d==c&&b.bracketLevel==g.bl&&b.curlyLevel==g.cl&&b.parenLevel==g.pl&&b.hookLevel==g.hl)break;var h=(g.scanOperand?OperandMethods:OperatorMethods)[d]}while(h&&h(a,b,d,g,e,f));if(b.hookLevel!=g.hl)throw a.newSyntaxError("Missing : after ?");if(b.parenLevel!=g.pl)throw a.newSyntaxError("Missing ) in parenthetical");if(b.bracketLevel!=g.bl)throw a.newSyntaxError("Missing ] in index expression");if(g.scanOperand)throw a.newSyntaxError("Missing operand");a.unget();while(e.length)ReduceExpression(a,e,f);return f.pop()}var OperandMethods={PLUS:ExpressionUnaryOperator,MINUS:ExpressionUnaryOperator,DELETE:ExpressionUnaryOperator,VOID:ExpressionUnaryOperator,TYPEOF:ExpressionUnaryOperator,NOT:ExpressionUnaryOperator,BITWISE_NOT:ExpressionUnaryOperator,NEW:ExpressionUnaryOperator,INCREMENT:ExpressionUnaryOperator,DECREMENT:ExpressionUnaryOperator,FUNCTION:ExpressionFunction,NULL:ExpressionOperand,THIS:ExpressionOperand,TRUE:ExpressionOperand,FALSE:ExpressionOperand,IDENTIFIER:ExpressionOperand,NUMBER:ExpressionOperand,STRING:ExpressionOperand,REGEXP:ExpressionOperand,LEFT_BRACKET:ExpressionArrayInit,LEFT_CURLY:ExpressionLeftCurly,RIGHT_CURLY:ExpressionRightCurly,LEFT_PAREN:ExpressionGroup};function ExpressionUnaryOperator(a,b,c,d,e,f){if(c=="PLUS"||c=="MINUS")c="UNARY_"+c;e.push(new OperatorNode(a,c));return true}function ExpressionFunction(a,b,c,d,e,f){f.push(FunctionDefinition(a,b,false,Crunchy.EXPRESSED_FORM));d.scanOperand=false;return true}function ExpressionOperand(a,b,c,d,e,f){f.push(new Node(a));d.scanOperand=false;return true}function ExpressionArrayInit(a,b,c,d,e,f){var g=new OperatorNode(a,"ARRAY_INIT");while((c=a.peekOperand().type)!="RIGHT_BRACKET"){if(c=="COMMA"){a.getOperand();g.pushOperand(new Node(a,"EMPTY"));continue}g.pushOperand(Expression(a,b,"COMMA"));if(!a.matchOperator("COMMA"))break}a.mustMatchOperator("RIGHT_BRACKET");f.push(g);d.scanOperand=false;return true}function ExpressionLeftCurly(a,b,c,d,e,f){++b.curlyLevel;var g=new OperatorNode(a,"OBJECT_INIT");objectInit:if(!a.matchOperand("RIGHT_CURLY")){do{c=a.getOperand();if((a.token().value=="get"||a.token().value=="set")&&a.peekOperand().type=="IDENTIFIER"){if(b.ecmaStrictMode)throw a.newSyntaxError("Illegal property accessor");g.pushOperand(FunctionDefinition(a,b,true,Crunchy.EXPRESSED_FORM))}else{switch(c){case"IDENTIFIER":var h=new Node(a,"MEMBER_IDENTIFIER");break;case"NUMBER":case"STRING":var h=new Node(a);break;case"RIGHT_CURLY":if(b.ecmaStrictMode)throw a.newSyntaxError("Illegal trailing ,");break objectInit;default:throw a.newSyntaxError("Invalid property name")}a.mustMatchOperator("COLON");var i=new OperatorNode(a,"PROPERTY_INIT");i.pushOperand(h);i.pushOperand(Expression(a,b,"COMMA"));g.pushOperand(i)}}while(a.matchOperand("COMMA"));a.mustMatchOperand("RIGHT_CURLY")}f.push(g);d.scanOperand=false;--b.curlyLevel;return true}function ExpressionRightCurly(a,b,c,d,e,f){if(b.curlyLevel!=d.cl)throw"PANIC: right curly botch";return false}function ExpressionGroup(a,b,c,d,e,f){e.push(new OperatorNode(a,"GROUP"));++b.parenLevel;return true}var OperatorMethods={ASSIGN:ExpressionRightAssociative,HOOK:ExpressionRightAssociative,COLON:ExpressionColon,IN:ExpressionBinaryOperator,COMMA:ExpressionBinaryOperator,OR:ExpressionBinaryOperator,AND:ExpressionBinaryOperator,BITWISE_OR:ExpressionBinaryOperator,BITWISE_XOR:ExpressionBinaryOperator,BITWISE_AND:ExpressionBinaryOperator,EQ:ExpressionBinaryOperator,NE:ExpressionBinaryOperator,STRICT_EQ:ExpressionBinaryOperator,STRICT_NE:ExpressionBinaryOperator,LT:ExpressionBinaryOperator,LE:ExpressionBinaryOperator,GE:ExpressionBinaryOperator,GT:ExpressionBinaryOperator,INSTANCEOF:ExpressionBinaryOperator,LSH:ExpressionBinaryOperator,RSH:ExpressionBinaryOperator,URSH:ExpressionBinaryOperator,PLUS:ExpressionBinaryOperator,MINUS:ExpressionBinaryOperator,MUL:ExpressionBinaryOperator,DIV:ExpressionBinaryOperator,MOD:ExpressionBinaryOperator,DOT:ExpressionBinaryOperator,INCREMENT:ExpressionPostOperator,DECREMENT:ExpressionPostOperator,LEFT_BRACKET:ExpressionIndex,RIGHT_BRACKET:ExpressionRightBracket,LEFT_PAREN:ExpressionCall,RIGHT_PAREN:ExpressionRightParen};function ExpressionRightAssociative(a,b,c,d,e,f){while(e.length&&Crunchy.opPrecedence[e.top().type]>Crunchy.opPrecedence[c])ReduceExpression(a,e,f);e.push(new OperatorNode(a));if(c=="ASSIGN")f.top().assignOp=a.token().assignOp;else++b.hookLevel;d.scanOperand=true;return true}function ExpressionColon(a,b,c,d,e,f){while(e.length&&(Crunchy.opPrecedence[e.top().type]>Crunchy.opPrecedence[c]||e.top().type=="CONDITIONAL"||e.top().type=="ASSIGN"))ReduceExpression(a,e,f);var g=e.top();if(!g||g.type!="HOOK")throw a.newSyntaxError("Invalid label");g.type="CONDITIONAL";--b.hookLevel;d.scanOperand=true;return true}function ExpressionBinaryOperator(a,b,c,d,e,f){if(c=="IN"&&(b.inForLoopInit&&!b.hookLevel&&!b.bracketLevel&&!b.curlyLevel&&!b.parenLevel))return false;while(e.length&&Crunchy.opPrecedence[e.top().type]>=Crunchy.opPrecedence[c])ReduceExpression(a,e,f);if(c=="DOT"){var g=new OperatorNode(a,"DOT");g.pushOperand(f.pop());a.mustMatchOperand("IDENTIFIER");g.pushOperand(new Node(a,"MEMBER_IDENTIFIER"));f.push(g)}else{e.push(new OperatorNode(a));d.scanOperand=true}return true}function ExpressionPostOperator(a,b,c,d,e,f){while(e.length&&Crunchy.opPrecedence[e.top().type]>Crunchy.opPrecedence[c])ReduceExpression(a,e,f);var g=new OperatorNode(a,c);g.pushOperand(f.pop());g.postfix=true;f.push(g);return true}function ExpressionIndex(a,b,c,d,e,f){e.push(new OperatorNode(a,"INDEX"));d.scanOperand=true;++b.bracketLevel;return true}function ExpressionRightBracket(a,b,c,d,e,f){if(b.bracketLevel==d.bl)return false;while(ReduceExpression(a,e,f).type!="INDEX");--b.bracketLevel;return true}function ExpressionCall(a,b,c,d,e,f){while(e.length&&Crunchy.opPrecedence[e.top().type]>Crunchy.opPrecedence["NEW"])ReduceExpression(a,e,f);var g=e.top();d.scanOperand=true;if(a.matchOperand("RIGHT_PAREN")){if(g&&g.type=="NEW"){--e.length;g.pushOperand(f.pop())}else{g=new OperatorNode(a,"CALL");g.pushOperand(f.pop());g.pushOperand(new OperatorNode(a,"LIST"))}f.push(g);d.scanOperand=false;return true}if(g&&g.type=="NEW")g.type="NEW_WITH_ARGS";else e.push(new OperatorNode(a,"CALL"));++b.parenLevel;return true}function ExpressionRightParen(a,b,c,d,e,f){if(b.parenLevel==d.pl)return false;while((c=ReduceExpression(a,e,f).type)!="GROUP"&&c!="CALL"&&c!="NEW_WITH_ARGS");if(c!="GROUP"){var g=f.top();var h=g.children.length-1;var i=g.children[h];if(i.type!="COMMA"){g.children[h]=new OperatorNode(a,"LIST");g.children[h].pushOperand(i)}else g.children[h].type="LIST"}else{var g=f.top();if(g.type!="GROUP")throw"Expecting GROUP.";if(g.children.length!=1)throw"Expecting GROUP with one child.";f[f.length-1]=g.children[0]}--b.parenLevel;return true}function ReduceExpression(a,b,c){var d=b.pop(),e=d.type,f=Crunchy.opArity[e],g=f;if(f==-2){var h=c.length>=2&&c[c.length-2];if(h.type==e){var i=c.pop();h.pushOperand(i);return h}f=2}var j=c.splice(c.length-f,f);if(g==2&&j[0].type==e){d=j[0];d.pushOperand(j[1])}else for(var k=0;k<f;k++)d.pushOperand(j[k]);c.push(d);return d}function parse(a,b,c){var d=new Crunchy.Tokenizer(a,b,c),e=Script(d);if(d.peekOperand().type!="END")throw d.newSyntaxError("Syntax error");return e}Crunchy.tokenstr=tokenstr;Crunchy.parse=parse})();(function(){function c(a){var b=a.body.top();if(b&&b.type=="CONTINUE"&&!b.label)--a.body.length}function d(a){var b=0,c=false;while(b<a.body.length){var d=a.body[b];if(c&&c.type==d.type){d.children=c.children.concat(d.children);a.body.splice(b-1,1)}else if(c&&d.type=="FOR"&&d.setup&&d.setup.type==c){d.setup.children=c.children.concat(d.setup.children);a.body.splice(b-1,1)}else++b;c=d.type=="VAR"||d.type=="CONST"?d:false}}var a={},b={};function e(a,b,c){for(var d=0;d<b.length;++d)if(a[b[d]])a[b[d]].push(c);else a[b[d]]=[c]}e(a,["FOR_IN","FOR","WHILE","DO"],c);e(a,["SCRIPT","FUNCTION"],d);e(b,["PLUS"],function(a){var b=0;while(b<a.children.length-1)if(a.children[b].type=="STRING"&&a.children[b+1].type=="STRING"){a.children[b].value=a.children[b].value+a.children[b+1].value;a.children.splice(b+1,1)}else++b;if(a.children.length==1){a.type="STRING";a.value=a.children[0].value}});Crunchy.runHooks=function(c){var d=a[c.type];if(d)for(var e=0;e<d.length;++e)d[e](c);c.forChildren(Crunchy.runHooks);var d=b[c.type];if(d)for(var e=0;e<d.length;++e)d[e](c)}})();(function(){Crunchy.Hash=function(){this.hash={}};Crunchy.Hash.prototype={prefix:"$ crunchy $",genIndex:function(a){return this.prefix+a},isIndex:function(a){return a.indexOf(this.prefix)==0},removePrefix:function(a){return this.isIndex(a)?a.substr(this.prefix.length):null},contains:function(a){return!!this.hash[this.genIndex(a)]},get:function(a){return this.hash[this.genIndex(a)]?this.hash[this.genIndex(a)]:false},set:function(a,b){return this.hash[this.genIndex(a)]=b},insert:function(a,b){var c=this.genIndex(a);if(this.hash[c])throw"Duplicate insertion into crunchy.Hash: "+a;else this.hash[c]=b;return b},forEach:function(a){for(var b in this.hash){var c=this.removePrefix(b);if(c)a(c,this.hash[b])}}};Crunchy.MultiHash=function(){this.hashConstructor()};var a=Crunchy.MultiHash.prototype,b=Crunchy.Hash.prototype;a.hashConstructor=Crunchy.Hash;for(var c in b)if(c!="set")a[c]=b[c];a.insert=function(a,b){var c=this.genIndex(a);if(this.hash[c])this.hash[c].push(b);else this.hash[c]=[b];return b}})();Crunchy.renameVariables=function(a){Crunchy.renameVariables.findVariables(a);Crunchy.renameVariables.rename(a)};Crunchy.renameVariables.ScopeVar=function(a,b){if(!b)Crunchy.error("Creating ScopeVar without scope.");this.name=a;this.scopes=[b];this.fixed=b.fixVariableNames};Crunchy.renameVariables.Scope=function(a,b){this.parent=a;this.fixVariableNames=b;this.decls=new Crunchy.Hash;this.refs=new Crunchy.Hash};Crunchy.renameVariables.Scope.prototype={setVars:function(a){var b=this.decls,c=this;function d(a){if(!b.contains(a.name))b.insert(a.name,new Crunchy.renameVariables.ScopeVar(a.name,c))}a.varDecls.forEach(d);a.funDecls.forEach(d)},setParams:function(a){var b=[];for(var c=0;c<a.length;++c){var d=new Crunchy.renameVariables.ScopeVar(a[c],this);b[c]=d;this.decls.insert(a[c],d)}return b},refVar:function(a){var b=this.decls.get(a)||this.refs.get(a);if(!b)if(this.parent){b=this.refs.insert(a,this.parent.refVar(a));b.scopes.push(this);b.fixed=b.fixed||this.fixVariableNames}else b=this.decls.insert(a,new Crunchy.renameVariables.ScopeVar(a,this));return b},setMutable:function(){this.decls.forEach(function(a,b){b.fixed=true});this.refs.forEach(function(a,b){b.fixed=true})}};Crunchy.renameVariables.findVariables=function(a){a.scopeList=[];this.findVariablesLoop(a,{currentScope:null,ScopeList:a.scopeList})};Crunchy.renameVariables.findVariablesLoop=function(a,b,c){if(!a)return;if(a.constructor==Array){for(var d=0;d<a.length;++d)this.findVariablesLoop(a[d],b);return}switch(a.type){case"SCRIPT":a.scope=new this.Scope(b.currentScope,true);b.ScopeList.push(a.scope);a.scope.setVars(a);break;case"FUNCTION":case"GETTER":case"SETTER":a.scope=new this.Scope(b.currentScope,false);b.ScopeList.push(a.scope);if(a.type=="FUNCTION"&&a.name)if(a.functionForm==Crunchy.EXPRESSED_FORM){a.name2=new this.ScopeVar(a.name,a.scope);a.scope.decls.insert(a.name,a.name2)}else a.name2=b.currentScope.refVar(a.name);a.params2=a.scope.setParams(a.params);a.scope.setVars(a);break;case"IDENTIFIER":a.ref=b.currentScope.refVar(a.value);break;case"CALL":if(a.children[0].type=="IDENTIFIER"&&a.children[0].value=="eval")for(var d=b.currentScope;d;d=d.parent)d.setMutable();break;case"WITH":a.scope=new this.Scope(b.currentScope,true);this.findVariablesLoop(a.object,b);b.ScopeList.push(a.scope);var e=b.currentScope;b.currentScope=a.scope;this.findVariablesLoop(a.body,b);b.currentScope=e;return;case"CATCH":a.scope=new this.Scope(b.currentScope);b.ScopeList.push(a.scope);a.varRef=new this.ScopeVar(a.varName,a.scope);a.scope.decls.insert(a.varName,a.varRef);break;default:this.findVariablesLoop(a.children,b);return}if(a.scope){var e=b.currentScope;b.currentScope=a.scope}this.findVariablesLoop(a.children,b);if(e)b.currentScope=e};(function(){function c(a,b,c){for(var d=a.charCodeAt(0),e=b.charCodeAt(0);d<=e;++d)c.push(String.fromCharCode(d))}var a=[];c("a","z",a);c("A","Z",a);var b=a.slice();c("0","9",b);Crunchy.renameVariables.chars1=a;Crunchy.renameVariables.chars2=b})();Crunchy.renameVariables.genName=function(a){var b="",c=a%this.chars1.length;b+=this.chars1[c];a=(a-c)/this.chars1.length-1;while(a>=0){c=a%this.chars2.length;b+=this.chars2[c];a=(a-c)/this.chars2.length-1}return b};Crunchy.renameVariables.rename=function(a){var b=a.scopeList;if(!b){Crunchy.error("renameVariables called for node without a scope list.");return}var c=[],d=new Crunchy.MultiHash;for(var e=0;e<b.length;++e)b[e].decls.forEach(function(a,b){if(b.fixed||b.name==="arguments")d.insert(a,b);else{b.oldName=b.name;delete b.name;b["Crunchy::rename::mark"]=-1;c.push(b)}});for(var f=0;c.length>0;++f){var g=this.genName(f);if(Crunchy.lookupKeyword(g))continue;function markClashes(a){for(var b=0;b<a.length;++b){a[b].decls.forEach(function(a,b){b["Crunchy::rename::mark"]=f});a[b].refs.forEach(function(a,b){b["Crunchy::rename::mark"]=f})}}if(d.contains(g))d.get(g).forEach(function(a){markClashes(a.scopes)});var e=0;while(e<c.length)if(!c[e].name&&c[e]["Crunchy::rename::mark"]!=f){c[e].name=g;markClashes(c[e].scopes);c.splice(e,1)}else++e}};Crunchy.write=function(a){var b=new Crunchy.Writer;b.writeStatement(a);return b.result.join("")};Crunchy.Writer=function(a){for(var b in this)this[b]=this[b];this.result=[]};Crunchy.Writer.prototype={prev:false,prevNone:"",prevString:"a",prevNumber:"0",invalidOp:null,statementStart:false,ended:true,addInvalidOp:function(a,b){var c=this.invalidOp;this.invalidOp=a;try{b.apply(this)}finally{this.invalidOp=c}},clearInvalidOps:function(a){var b=this.invalidOp;this.invalidOp=null;try{a.apply(this)}finally{this.invalidOp=b}},writeIsIdChar:/^[a-zA-Z0-9_$]$/,write:function(a){this.ended=false;this.statementStart=false;this.result.push(a);this.prev=this.prevNone},writePlusMinus:function(a){this.ended=false;this.statementStart=false;switch(this.prev){case"+":if(a.charAt(0)=="+")this.result.push(" ");break;case"-":if(a.charAt(0)=="-")this.result.push(" ");break;case"0":if(a.charAt(0)==".")this.result.push(" ");break}this.result.push(a);this.prev=a.charAt(a.length-1)},writeWord:function(a){this.ended=false;this.statementStart=false;if(this.prev===this.prevString||this.prev===this.prevNumber)this.result.push(" ");this.result.push(a);this.prev=this.prevString},writeNumber:function(a){this.ended=false;this.statementStart=false;var b=String(a);if(this.prev===this.prevString||this.prev===this.prevNumber)this.result.push(" ");this.result.push(b);this.prev=this.prevNumber},endStatement:function(){this.ended=true},seperateStatement:function(){if(!this.ended){this.write(";");this.ended=true}},writeStatements:function(a){for(var b=0;b<a.length;++b){if(b!=0)this.seperateStatement();this.writeStatement(a[b])}},writeStatement:function(a){if(this.invalidOp=="IF"&&a.type=="IF"&&!a.elsePart){this.writeBlock([a],true);return}switch(a.type){case"SCRIPT":this.writeStatements(a.body);break;case"FUNCTION":this.writeFunction(a);break;case"BLOCK":this.writeBlock(a.children,true);break;case"IF":this.writeWord("if");this.writeBracketed(a.condition,"(",")");if(a.elsePart){this.addInvalidOp("IF",function(){this.writeBlock(a.thenPart,false)});this.seperateStatement();this.writeWord("else");this.writeBlock(a.elsePart,false)}else this.writeBlock(a.thenPart,false);break;case"SWITCH":this.writeWord("switch");this.writeBracketed(a.discriminant,"(",")");this.write("{");for(var b=0;b<a.cases.length;++b){if(b!=0)this.seperateStatement();switch(a.cases[b].type){case"CASE":this.writeWord("case");this.writeExpression(a.cases[b].caseLabel);this.write(":");this.endStatement();break;case"DEFAULT":this.writeWord("default");this.write(":");this.endStatement();break;default:Crunchy.error("Unrecognized switch clause: "+strToken(a.cases[b].type));break}this.writeStatements(a.cases[b].statements)}this.write("}");this.endStatement();break;case"FOR":this.writeWord("for");this.write("(");if(a.setup)this.addInvalidOp("IN",function(){this.writeExpressionOrVar(a.setup)});this.write(";");if(a.condition)this.writeExpression(a.condition);this.write(";");if(a.update)this.writeExpression(a.update);this.write(")");this.writeBlock(a.body);break;case"FOR_IN":this.writeWord("for");this.write("(");this.addInvalidOp("IN",function(){this.writeExpressionOrVar(a.iterator)});this.writeWord("in");this.writeExpression(a.object);this.write(")");this.writeBlock(a.body);break;case"WHILE":this.writeWord("while");this.write("(");this.writeExpression(a.condition);this.write(")");this.writeBlock(a.body);break;case"DO":this.writeWord("do");this.writeBlock(a.body,true);this.seperateStatement();this.writeWord("while");this.write("(");this.writeExpression(a.condition);this.write(")");break;case"BREAK":case"CONTINUE":case"GOTO":this.writeWord(Crunchy.tokens[a.type]);if(a.label)this.writeWord(a.label);break;case"TRY":this.writeWord("try");this.writeBlock(a.tryBlock,true);for(var b=0;b<a.catchClauses.length;++b){this.writeWord("catch");this.write("(");this.writeWord(a.catchClauses[b].varRef?a.catchClauses[b].varRef.name:a.catchClauses[b].varName);if(a.catchClauses[b].guard){this.writeWord("if");this.writeExpression(a.catchClauses[b].guard)}this.write(")");this.writeBlock(a.catchClauses[b].block,true)}if(a.finallyBlock){this.writeWord("finally");this.writeBlock(a.finallyBlock,true)}break;case"THROW":this.writeWord("throw");this.writeExpression(a.exception);break;case"RETURN":this.writeWord("return");if(a.returnValue)this.writeExpression(a.returnValue);break;case"WITH":this.writeWord("with");this.write("(");this.writeExpression(a.object);this.write(")");this.writeBlock(a.body);break;case"VAR":case"CONST":this.writeVar(a);break;case"DEBUGGER":this.writeWord("debugger");break;case"SEMICOLON":if(!a.expression)Crunchy.error("Empty semicolon");else{this.statementStart=true;this.writeExpression(a.expression)}break;case"LABEL":this.writeWord(a.label);this.write(":");this.writeBlock(a.statement);break;case"DEBUG_SEMICOLON":break;default:Crunchy.error("Unrecognized statement node type: "+Crunchy.tokenstr(a.type))}},writeExpressionOrVar:function(a){return a.type=="VAR"||a.type=="CONST"?this.writeVar(a):this.writeExpression(a)},writeBracketed:function(a,b,c){this.clearInvalidOps(function(){this.write(b);if(a.constructor==Array){for(var d=0;d<a.length;++d){if(d!=0)this.write(",");this.addInvalidOp("COMMA",function(){this.writeExpression(a[d])})}if(a.length&&a.top().type=="EMPTY")this.write(",")}else this.writeExpression(a);this.write(c)})},writeExpression:function(a,b){b=b||0;if(this.invalidOp==a.type){this.clearInvalidOps(function(){this.writeBracketed(a,"(",")")});return}var c=Crunchy.tokens[a.type].toLowerCase();switch(a.type){case"FUNCTION":case"GETTER":case"SETTER":this.writeFunction(a);break;case"EMPTY":break;case"IDENTIFIER":case"MEMBER_IDENTIFIER":this.writeWord(a.ref?a.ref.name:a.value);break;case"NULL":case"THIS":case"TRUE":case"FALSE":this.writeWord(a.value);break;case"NUMBER":this.writeNumber(a.value);break;case"REGEXP":this.write(a.value);break;case"STRING":this.write(Crunchy.stringEscape(a.value));break;case"CONDITIONAL":this.clearInvalidOps(function(){if(b>Crunchy.opPrecedence["CONDITIONAL"])this.write("(");this.writeExpression(a.children[0],a.children[0].type=="ASSIGN"?Crunchy.opPrecedence["ASSIGN"]+1:Crunchy.opPrecedence["CONDITIONAL"]);this.write("?");this.writeExpression(a.children[1],Crunchy.opPrecedence["CONDITIONAL"]);this.write(":");this.writeExpression(a.children[2],Crunchy.opPrecedence["CONDITIONAL"]);if(b>Crunchy.opPrecedence["CONDITIONAL"])this.write(")")});break;case"NEW_WITH_ARGS":case"CALL":if(a.type=="NEW_WITH_ARGS")for(var d=1;d<a.children.length;++d)this.writeWord("new");this.writeExpression(a.children[0],Crunchy.opPrecedence["DOT"]);for(var d=1;d<a.children.length;++d)if(a.children[d].type!="LIST"){Crunchy.error("Suprise operand type for CALL.");this.writeBracketed([],"(",")")}else this.writeBracketed(a.children[d].children,"(",")");break;case"INDEX":this.writeExpression(a.children[0],Crunchy.opPrecedence["DOT"]);for(var d=1;d<a.children.length;++d)this.writeBracketed(a.children[d],"[","]");break;case"OBJECT_INIT":this.writeBracketed(a.children,"{","}");break;case"PROPERTY_INIT":if(a.children[0].type=="STRING"&&/^[a-zA-Z$_][a-zA-Z0-9$_]*$/.test(a.children[0].value)&&!Crunchy.lookupKeyword(a.children[0].value))this.writeWord(a.children[0].value);else this.writeExpression(a.children[0]);this.write(":");this.writeExpression(a.children[1]);break;case"ARRAY_INIT":this.writeBracketed(a.children,"[","]");break;case"ASSIGN":if(a.children[0].assignOp)c=Crunchy.tokens[a.children[0].assignOp]+c;if(b>Crunchy.opPrecedence[a.type])this.write("(");this.writeExpression(a.children[0],Crunchy.opPrecedence[a.type]+1);for(var d=1;d<a.children.length;++d){this.write(c);this.writeExpression(a.children[1],Crunchy.opPrecedence[a.type])}if(b>Crunchy.opPrecedence[a.type])this.write(")");break;case"COMMA":case"OR":case"AND":case"BITWISE_OR":case"BITWISE_XOR":case"BITWISE_AND":case"EQ":case"NE":case"STRICT_EQ":case"STRICT_NE":case"LT":case"LE":case"GE":case"GT":case"LSH":case"RSH":case"URSH":case"MUL":case"DIV":case"MOD":if(b>Crunchy.opPrecedence[a.type])this.write("(");this.writeExpression(a.children[0],Crunchy.opPrecedence[a.type]);for(var d=1;d<a.children.length;++d){this.write(c);this.writeExpression(a.children[d],Crunchy.opPrecedence[a.type]+1)}if(b>Crunchy.opPrecedence[a.type])this.write(")");break;case"IN":case"INSTANCEOF":if(b>Crunchy.opPrecedence[a.type])this.write("(");this.writeExpression(a.children[0],Crunchy.opPrecedence[a.type]);for(var d=1;d<a.children.length;++d){this.writeWord(c);this.writeExpression(a.children[d],Crunchy.opPrecedence[a.type]+1)}if(b>Crunchy.opPrecedence[a.type])this.write(")");break;case"DOT":case"PLUS":case"MINUS":if(b>Crunchy.opPrecedence[a.type])this.write("(");this.writeExpression(a.children[0],Crunchy.opPrecedence[a.type]);for(var d=1;d<a.children.length;++d){this.writePlusMinus(c);this.writeExpression(a.children[d],Crunchy.opPrecedence[a.type]+1)}if(b>Crunchy.opPrecedence[a.type])this.write(")");break;case"INCREMENT":case"DECREMENT":if(b>Crunchy.opPrecedence[a.type])this.write("(");if(!a.postfix)this.writePlusMinus(c);this.writeExpression(a.children[0],Crunchy.opPrecedence[a.type]);if(a.postfix)this.writePlusMinus(c);if(b>Crunchy.opPrecedence[a.type])this.write(")");break;case"UNARY_PLUS":if(b>Crunchy.opPrecedence[a.type])this.write("(");this.writePlusMinus("+");this.writeExpression(a.children[0],Crunchy.opPrecedence[a.type]);if(b>Crunchy.opPrecedence[a.type])this.write(")");break;case"UNARY_MINUS":if(b>Crunchy.opPrecedence[a.type])this.write("(");this.writePlusMinus("-");this.writeExpression(a.children[0],Crunchy.opPrecedence[a.type]);if(b>Crunchy.opPrecedence[a.type])this.write(")");break;case"NOT":case"BITWISE_NOT":if(b>Crunchy.opPrecedence[a.type])this.write("(");this.write(c);this.writeExpression(a.children[0],Crunchy.opPrecedence[a.type]);if(b>Crunchy.opPrecedence[a.type])this.write(")");break;case"NEW":case"DELETE":case"VOID":case"TYPEOF":if(b>Crunchy.opPrecedence[a.type])this.write("(");this.writeWord(c);this.writeExpression(a.children[0],Crunchy.opPrecedence[a.type]);if(b>Crunchy.opPrecedence[a.type])this.write(")");break;default:Crunchy.error("Unrecognized expression node type: "+Crunchy.tokenstr(a.type))}},writeFunction:function(a){var b=a.functionForm==Crunchy.EXPRESSED_FORM&&this.statementStart;if(b)this.write("(");this.writeWord(Crunchy.tokens[a.type]);if(a.name2)this.writeWord(a.name2.name);else if(a.name)this.writeWord(a.name);this.write("(");for(var c=0;c<a.params2.length;++c){if(c!=0)this.write(",");this.writeWord(a.params2[c].name)}this.write(")");this.write("{");this.writeStatements(a.body);this.write("}");if(b)this.write(")");this.ended=a.functionForm!=Crunchy.EXPRESSED_FORM},writeVar:function(a){this.writeWord(a.type=="VAR"?"var":"const");for(var b=0;b<a.children.length;++b){if(b!=0)this.write(",");var c=a.children[b];this.writeExpression(c,Crunchy.opPrecedence["ASSIGN"]+1);if(c.initializer){this.write("=");this.writeExpression(c.initializer,Crunchy.opPrecedence["ASSIGN"])}}},writeBlock:function(a,b){if(a.length==0)if(b){this.write("{}");this.endStatement()}else{this.write(";");this.endStatement()}else if(b||a.length>1||a[0].type=="DO"||a[0].type=="FUNCTION"){var c=this.invalidOp;this.invalidOp=null;this.write("{");this.writeStatements(a);this.write("}");this.endStatement();this.invalidOp=c}else this.writeStatements(a)}};(function(){var a={"\\":"\\\\","\b":"\\b","\t":"\\t","\n":"\\n","\v":"\\v","\f":"\\f","\r":"\\r"},b=/[\\\x08\x09\x0a\x0b\x0c\x0d]/g;Crunchy.stringEscape=function(c){c=c.replace(b,function(b){return a[b]||b});var d=c.match(/'/g),e=c.match(/"/g);if(e&&(!d||d.length<e.length))return"'"+c.replace(/'/g,"\\'")+"'";else return'"'+c.replace(/"/g,'\\"')+'"'}})();if(!window.Crunchy)window.Crunchy={};var DomBuilder={IE_TRANSLATIONS:{"class":"className","for":"htmlFor"},ieAttrSet:function(a,b,c){var d;if(d=this.IE_TRANSLATIONS[b])c[d]=a[b];else if(b=="style")c.style.cssText=a[b];else if(b.match(/^on/))c[b]=new Function(a[b]);else c.setAttribute(b,a[b])},apply:function(a){a=a||{};var b="p|div|span|strong|em|img|table|tr|td|th|thead|tbody|tfoot|pre|code|h1|h2|h3|h4|h5|h6|ul|ol|li|form|input|textarea|legend|fieldset|select|option|blockquote|cite|br|hr|dd|dl|dt|address|a|button|abbr|acronym|script|link|style|bdo|ins|del|object|param|col|colgroup|optgroup|caption|label|dfn|kbd|samp|var".split("|"),c,d=0;while(c=b[d++])a[c.toUpperCase()]=DomBuilder.tagFunc(c);return a},tagFunc:function(a){return function(){var b=arguments,c,d;if(b.length>0)if(b[0].nodeName||typeof b[0]=="string")d=b;else{c=b[0];d=Array.prototype.slice.call(b,1)}return DomBuilder.elem(a,c,d)}},elem:function(a,b,c){b=b||{};c=c||[];var d=navigator.userAgent.match(/MSIE/),e=document.createElement(d&&b.name?"<"+a+" name="+b.name+">":a);for(var f in b)if(typeof b[f]!="function")if(d)this.ieAttrSet(b,f,e);else e.setAttribute(f,b[f]);for(var f=0;f<c.length;f++){if(typeof c[f]=="string"||c[f].constructor==String)c[f]=document.createTextNode(c[f]);e.appendChild(c[f])}return e}};Crunchy.webInterface=function(){var a,b,c,d,e,f=DomBuilder.apply();a=f.DIV({},f.DIV(b=f.TEXTAREA({cols:80,rows:20})),f.DIV(c=f.INPUT({type:"submit",value:"crunch"})),f.DIV(d=f.TEXTAREA({cols:80,rows:20})),e=f.DIV());c.onclick=function(){d.value="";e.innerHTML="<i>Working....</i>";setTimeout(c.go,0)};c.go=function(){var a=b.value;a=a.replace(/\r*\n/g,"\n").replace(/\r/g,"\n");var c=new Date;try{var f=Crunchy.crunch(a)}catch(a){if(a.source){var g=(a.source.substring(0,a.cursor).match(/\r\n?|\n/g)||[]).length+1;alert("Line "+g+": "+a.toString());f=""}else throw a}var h=new Date;d.value=f;e.innerHTML=a.length+" =&gt; "+f.length+"(time = "+(h-c)+")"};return a}
