Skip to content
Browse files

jslint console

  • Loading branch information...
0 parents commit 16fc0139a8fb02c6c36e27ea8e6dda45aa1eb410 Jorge Falcão committed Oct 31, 2010
Showing with 10,331 additions and 0 deletions.
  1. +13 −0 README.txt
  2. +15 −0 convert_to_h.rb
  3. +5,725 −0 fulljslint.js
  4. +132 −0 fulljslint.packed.js
  5. +171 −0 jslint.cpp
  6. +4,241 −0 jslint.h
  7. +23 −0 v8.h
  8. +11 −0 v8.js
13 README.txt
@@ -0,0 +1,13 @@
+
+Jslint v8 command
+=================
+
+This work was inspired by jsbeautify implementation.
+
+Compile:
+ g++ -o jslint jslint.cpp -I<V8_BASEDIR>/include/ -lv8 -L<V8_BASEDIR>/lib -lpthread
+
+Running
+=======
+
+ jslint file.js
15 convert_to_h.rb
@@ -0,0 +1,15 @@
+
+# TODO: V8 has one in python.
+
+h = "const char #{ARGV[0].split('.')[0]}_code[] = {"
+c = 0
+
+File.new(ARGV[0], "r").each_byte do |ch|
+ h << "0x%X," % ch
+ h << "\n" if c % 16 == 0
+ c = c.succ
+end
+h << "0x00\n";
+
+h << "\n};"
+puts h
5,725 fulljslint.js
5,725 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
132 fulljslint.packed.js
@@ -0,0 +1,132 @@
+var JSLINT=function(){var R,ja,sa,Qa,Da,Bb={media:true,"font-face":true,page:true},Cb={"<":true,"<=":true,"==":true,"===":true,"!==":true,"!=":true,">":true,">=":true,"+":true,"-":true,"*":true,"/":true,"%":true},Ra={arguments:true,callee:true,caller:true,constructor:true,eval:true,prototype:true,stack:true,unwatch:true,valueOf:true,watch:true},Db={adsafe:true,bitwise:true,browser:true,cap:true,css:true,debug:true,devel:true,eqeqeq:true,es5:true,evil:true,forin:true,fragment:true,immed:true,laxbreak:true,
+newcap:true,nomen:true,on:true,onevar:true,passfail:true,plusplus:true,regexp:true,rhino:true,undef:true,safe:true,windows:true,strict:true,sub:true,white:true,widget:true},Eb={addEventListener:false,blur:false,clearInterval:false,clearTimeout:false,close:false,closed:false,defaultStatus:false,document:false,event:false,focus:false,frames:false,getComputedStyle:false,history:false,Image:false,length:false,location:false,moveBy:false,moveTo:false,name:false,navigator:false,onbeforeunload:true,onblur:true,
+onerror:true,onfocus:true,onload:true,onresize:true,onunload:true,open:false,opener:false,Option:false,parent:false,print:false,removeEventListener:false,resizeBy:false,resizeTo:false,screen:false,scroll:false,scrollBy:false,scrollTo:false,setInterval:false,setTimeout:false,status:false,top:false,XMLHttpRequest:false},Ea,Sa,Fb={aliceblue:true,antiquewhite:true,aqua:true,aquamarine:true,azure:true,beige:true,bisque:true,black:true,blanchedalmond:true,blue:true,blueviolet:true,brown:true,burlywood:true,
+cadetblue:true,chartreuse:true,chocolate:true,coral:true,cornflowerblue:true,cornsilk:true,crimson:true,cyan:true,darkblue:true,darkcyan:true,darkgoldenrod:true,darkgray:true,darkgreen:true,darkkhaki:true,darkmagenta:true,darkolivegreen:true,darkorange:true,darkorchid:true,darkred:true,darksalmon:true,darkseagreen:true,darkslateblue:true,darkslategray:true,darkturquoise:true,darkviolet:true,deeppink:true,deepskyblue:true,dimgray:true,dodgerblue:true,firebrick:true,floralwhite:true,forestgreen:true,
+fuchsia:true,gainsboro:true,ghostwhite:true,gold:true,goldenrod:true,gray:true,green:true,greenyellow:true,honeydew:true,hotpink:true,indianred:true,indigo:true,ivory:true,khaki:true,lavender:true,lavenderblush:true,lawngreen:true,lemonchiffon:true,lightblue:true,lightcoral:true,lightcyan:true,lightgoldenrodyellow:true,lightgreen:true,lightpink:true,lightsalmon:true,lightseagreen:true,lightskyblue:true,lightslategray:true,lightsteelblue:true,lightyellow:true,lime:true,limegreen:true,linen:true,magenta:true,
+maroon:true,mediumaquamarine:true,mediumblue:true,mediumorchid:true,mediumpurple:true,mediumseagreen:true,mediumslateblue:true,mediumspringgreen:true,mediumturquoise:true,mediumvioletred:true,midnightblue:true,mintcream:true,mistyrose:true,moccasin:true,navajowhite:true,navy:true,oldlace:true,olive:true,olivedrab:true,orange:true,orangered:true,orchid:true,palegoldenrod:true,palegreen:true,paleturquoise:true,palevioletred:true,papayawhip:true,peachpuff:true,peru:true,pink:true,plum:true,powderblue:true,
+purple:true,red:true,rosybrown:true,royalblue:true,saddlebrown:true,salmon:true,sandybrown:true,seagreen:true,seashell:true,sienna:true,silver:true,skyblue:true,slateblue:true,slategray:true,snow:true,springgreen:true,steelblue:true,tan:true,teal:true,thistle:true,tomato:true,turquoise:true,violet:true,wheat:true,white:true,whitesmoke:true,yellow:true,yellowgreen:true},W,ta,ob={"%":true,cm:true,em:true,ex:true,"in":true,mm:true,pc:true,pt:true,px:true},ka,Gb={alert:false,confirm:false,console:false,
+Debug:false,opera:false,prompt:false},Hb={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"/":"\\/","\\":"\\\\"},n,ua=["closure","exception","global","label","outer","unused","var"],va,pb,Ta={a:{},abbr:{},acronym:{},address:{},applet:{},area:{empty:true,parent:" map "},article:{},aside:{},audio:{},b:{},base:{empty:true,parent:" head "},bdo:{},big:{},blockquote:{},body:{parent:" html noframes "},br:{empty:true},button:{},canvas:{parent:" body p div th td "},caption:{parent:" table "},
+center:{},cite:{},code:{},col:{empty:true,parent:" table colgroup "},colgroup:{parent:" table "},command:{parent:" menu "},datalist:{},dd:{parent:" dl "},del:{},details:{},dialog:{},dfn:{},dir:{},div:{},dl:{},dt:{parent:" dl "},em:{},embed:{},fieldset:{},figure:{},font:{},footer:{},form:{},frame:{empty:true,parent:" frameset "},frameset:{parent:" html frameset "},h1:{},h2:{},h3:{},h4:{},h5:{},h6:{},head:{parent:" html "},header:{},hgroup:{},hr:{empty:true},"hta:application":{empty:true,parent:" head "},
+html:{parent:"*"},i:{},iframe:{},img:{empty:true},input:{empty:true},ins:{},kbd:{},keygen:{},label:{},legend:{parent:" details fieldset figure "},li:{parent:" dir menu ol ul "},link:{empty:true,parent:" head "},map:{},mark:{},menu:{},meta:{empty:true,parent:" head noframes noscript "},meter:{},nav:{},noframes:{parent:" html body "},noscript:{parent:" body head noframes "},object:{},ol:{},optgroup:{parent:" select "},option:{parent:" optgroup select "},output:{},p:{},param:{empty:true,parent:" applet object "},
+pre:{},progress:{},q:{},rp:{},rt:{},ruby:{},samp:{},script:{empty:true,parent:" body div frame head iframe p pre span "},section:{},select:{},small:{},span:{},source:{},strong:{},style:{parent:" head ",empty:true},sub:{},sup:{},table:{},tbody:{parent:" table "},td:{parent:" tr "},textarea:{},tfoot:{parent:" table "},th:{parent:" tr "},thead:{parent:" table "},time:{},title:{parent:" head "},tr:{parent:" table tbody thead tfoot "},tt:{},u:{},ul:{},"var":{},video:{}},Fa,aa,wa,C,la,xa,Ga,fa,ga,b,Ua,
+j,A,Va,F,Ib={defineClass:false,deserialize:false,gc:false,help:false,load:false,loadClass:false,print:false,quit:false,readFile:false,readUrl:false,runCommand:false,seal:false,serialize:false,spawn:false,sync:false,toint32:false,version:false},B,Jb={ActiveXObject:false,CScript:false,Debug:false,Enumerator:false,System:false,VBArray:false,WScript:false},Ha,J,Kb={Array:false,Boolean:false,Date:false,decodeURI:false,decodeURIComponent:false,encodeURI:false,encodeURIComponent:false,Error:false,eval:false,
+EvalError:false,Function:false,hasOwnProperty:false,isFinite:false,isNaN:false,JSON:false,Math:false,Number:false,Object:false,parseInt:false,parseFloat:false,RangeError:false,ReferenceError:false,RegExp:false,String:false,SyntaxError:false,TypeError:false,URIError:false},Lb={E:true,LN2:true,LN10:true,LOG2E:true,LOG10E:true,PI:true,SQRT1_2:true,SQRT2:true,MAX_VALUE:true,MIN_VALUE:true,NEGATIVE_INFINITY:true,POSITIVE_INFINITY:true},Ia,O={},Wa,i,ya,Xa,Mb={alert:true,animator:true,appleScript:true,beep:true,
+bytesToUIString:true,Canvas:true,chooseColor:true,chooseFile:true,chooseFolder:true,closeWidget:true,COM:true,convertPathToHFS:true,convertPathToPlatform:true,CustomAnimation:true,escape:true,FadeAnimation:true,filesystem:true,Flash:true,focusWidget:true,form:true,FormField:true,Frame:true,HotKey:true,Image:true,include:true,isApplicationRunning:true,iTunes:true,konfabulatorVersion:true,log:true,md5:true,MenuItem:true,MoveAnimation:true,openURL:true,play:true,Point:true,popupMenu:true,preferenceGroups:true,
+preferences:true,print:true,prompt:true,random:true,Rectangle:true,reloadWidget:true,ResizeAnimation:true,resolvePath:true,resumeUpdates:true,RotateAnimation:true,runCommand:true,runCommandInBg:true,saveAs:true,savePreferences:true,screen:true,ScrollBar:true,showWidgetPreferences:true,sleep:true,speak:true,Style:true,suppressUpdates:true,system:true,tellWidget:true,Text:true,TextArea:true,Timer:true,unescape:true,updateNow:true,URL:true,Web:true,widget:true,Window:true,XMLDOM:true,XMLHttpRequest:true,
+yahooCheckLogin:true,yahooLogin:true,yahooLogout:true},q,P,Ya=/@cc|<\/?|script|\]*s\]|<\s*!|&lt/i,Nb=/[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,Ob=/^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jslint|members?|global)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/;W=/^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-:]*|[0-9]+|--)/;
+var Pb=/[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,Qb=/[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,Rb=/[>&]|<[\/!]?|--/,Sb=/\*\/|\/\*/,qb=/^([a-zA-Z_$][a-zA-Z0-9_$]*)$/,Za=/^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i,rb=/&|\+|\u00AD|\.\.|\/\*|%[^;]|base64|url|expression|data|mailto/i;ta=/^\s*([{:#%.=,>+\[\]@()"';]|\*=?|\$=|\|=|\^=|~=|[a-zA-Z_][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/;
+ka=/^\s*([@#!"'};:\-%.=,+\[\]()*_]|[a-zA-Z][a-zA-Z0-9._\-]*|\/\*?|\d+(?:\.\d+)?|<\/)/;var Tb=/[^a-zA-Z0-9+\-_\/ ]/,Ub=/[\[\]\/\\"'*<>.&:(){}+=#]/,Vb={outer:W,html:W,style:ta,styleproperty:ka};function sb(){}if(typeof Object.create!=="function")Object.create=function(a){sb.prototype=a;return new sb};function T(a,c){return Object.prototype.hasOwnProperty.call(a,c)}function za(a,c){var d;for(d in c)if(T(c,d))a[d]=c[d]}String.prototype.entityify=function(){return this.replace(/&/g,"&amp;").replace(/</g,
+"&lt;").replace(/>/g,"&gt;")};String.prototype.isAlpha=function(){return this>="a"&&this<="z\uffff"||this>="A"&&this<="Z\uffff"};String.prototype.isDigit=function(){return this>="0"&&this<="9"};String.prototype.supplant=function(a){return this.replace(/\{([^{}]*)\}/g,function(c,d){d=a[d];return typeof d==="string"||typeof d==="number"?d:c})};String.prototype.name=function(){if(qb.test(this))return this;if(Pb.test(this))return'"'+this.replace(Qb,function(a){var c=Hb[a];if(c)return c;return"\\u"+("0000"+
+a.charCodeAt().toString(16)).slice(-4)})+'"';return'"'+this+'"'};function $a(){if(!j.safe){j.rhino&&za(A,Ib);j.devel&&za(A,Gb);j.browser&&za(A,Eb);j.windows&&za(A,Jb);j.widget&&za(A,Mb)}}function ab(a,c,d){throw{name:"JSLintError",line:c,character:d,message:a+" ("+Math.floor(c/xa.length*100)+"% scanned)."};}function e(a,c,d,g,h,m){var u;c=c||b;if(c.id==="(end)")c=i;u=c.line||0;c=c.from||0;d={id:"(error)",raw:a,evidence:xa[u-1]||"",line:u,character:c,a:d,b:g,c:h,d:m};d.reason=a.supplant(d);JSLINT.errors.push(d);
+j.passfail&&ab("Stopping. ",u,c);Xa+=1;Xa>=j.maxerr&&ab("Too many errors.",u,c);return d}function r(a,c,d,g,h,m,u){return e(a,{line:c,from:d},g,h,m,u)}function o(a,c,d,g,h,m){a=e(a,c,d,g,h,m);ab("Stopping, unable to continue.",a.line,a.character)}function L(a,c,d,g,h,m,u){return o(a,{line:c,from:d},g,h,m,u)}var X=function a(){var c,d,g,h;function m(){var p;if(g>=xa.length)return false;c=1;h=xa[g];g+=1;p=h.search(/ \t/);p>=0&&r("Mixed spaces and tabs.",g,p+1);h=h.replace(/\t/g,Wa);p=h.search(Nb);p>=
+0&&r("Unsafe character.",g,p);j.maxlen&&j.maxlen<h.length&&r("Line too long.",g,h.length);return true}function u(p,k){var s;s=p==="(color)"||p==="(range)"?{type:p}:p==="(punctuator)"||p==="(identifier)"&&T(O,k)?O[k]||O["(error)"]:O[p];s=Object.create(s);if(p==="(string)"||p==="(range)")Za.test(k)&&r("Script URL.",g,d);if(p==="(identifier)"){s.identifier=true;if(k==="__iterator__"||k==="__proto__")L("Reserved name '{a}'.",g,d,k);else if(j.nomen&&(k.charAt(0)==="_"||k.charAt(k.length-1)==="_"))r("Unexpected {a} in '{b}'.",
+g,d,"dangling '_'",k)}s.value=k;s.line=g;s.character=c;s.from=d;p=s.id;if(p!=="(endline)")Va=p&&("(,=:[!&|?{};".indexOf(p.charAt(p.length-1))>=0||p==="return");return s}return{init:function(p){xa=typeof p==="string"?p.replace(/\r\n/g,"\n").replace(/\r/g,"\n").split("\n"):p;g=0;m();d=1},range:function(p,k){var s="";d=c;for(h.charAt(0)!==p&&L("Expected '{a}' and instead saw '{b}'.",g,c,p,h.charAt(0));;){h=h.slice(1);c+=1;p=h.charAt(0);switch(p){case "":L("Missing '{a}'.",g,c,p);break;case k:h=h.slice(1);
+c+=1;return u("(range)",s);case P:case "\\":r("Unexpected '{a}'.",g,c,p)}s+=p}},token:function(){var p,k,s,v,l,w;function Wb(M){if(M=M.exec(h)){l=M[0].length;M=M[1];k=M.charAt(0);h=h.substr(l);d=c+l-M.length;c+=l;return M}}function Xb(M){var G,D,tb="";la&&M!=='"'&&r("Strings must use doublequote.",g,c);if(P===M||q==="scriptstring"&&!P)return u("(punctuator)",M);function ub(bb){var ma=parseInt(h.substr(D+1,bb),16);D+=bb;ma>=32&&ma<=126&&ma!==34&&ma!==92&&ma!==39&&r("Unnecessary escapement.",g,c);c+=
+bb;G=String.fromCharCode(ma)}for(D=0;;){for(;D>=h.length;){D=0;if(q!=="html"||!m())L("Unclosed string.",g,d)}G=h.charAt(D);if(G===M){c+=1;h=h.substr(D+1);return u("(string)",tb,M)}if(G<" "){if(G==="\n"||G==="\r")break;r("Control character in string: {a}.",g,c+D,h.slice(0,D))}else if(G===P)r("Bad HTML string",g,c+D);else if(G==="<")if(j.safe&&q==="html")r("ADsafe string violation.",g,c+D);else if(h.charAt(D+1)==="/"&&(q||j.safe))r("Expected '<\\/' and instead saw '</'.",g,c);else{if(h.charAt(D+1)===
+"!"&&(q||j.safe))r("Unexpected '<!' in a string.",g,c)}else if(G==="\\")if(q==="html")j.safe&&r("ADsafe string violation.",g,c+D);else if(q==="styleproperty"){D+=1;c+=1;G=h.charAt(D);G!==M&&r("Escapement in style string.",g,c+D)}else{D+=1;c+=1;G=h.charAt(D);switch(G){case P:r("Bad HTML string",g,c+D);break;case "\\":case "'":case '"':case "/":break;case "b":G="\u0008";break;case "f":G="\u000c";break;case "n":G="\n";break;case "r":G="\r";break;case "t":G="\t";break;case "u":ub(4);break;case "v":G=
+"\u000b";break;case "x":la&&r("Avoid \\x-.",g,c);ub(2);break;default:r("Bad escapement.",g,c)}}tb+=G;c+=1;D+=1}}for(;;){if(!h)return u(m()?"(endline)":"(end)","");for(;q==="outer";){v=h.search(Rb);if(v===0)break;else if(v>0){c+=1;h=h.slice(v);break}else if(!m())return u("(end)","")}if(s=Wb(Vb[q]||Ob)){if(k.isAlpha()||k==="_"||k==="$")return u("(identifier)",s);if(k.isDigit()){q!=="style"&&!isFinite(Number(s))&&r("Bad number '{a}'.",g,c,s);q!=="style"&&q!=="styleproperty"&&h.substr(0,1).isAlpha()&&
+r("Missing space after '{a}'.",g,c,s);if(k==="0"){v=s.substr(1,1);if(v.isDigit())i.id!=="."&&q!=="styleproperty"&&r("Don't use extra leading zeros '{a}'.",g,c,s);else if(la&&(v==="x"||v==="X"))r("Avoid 0x-. '{a}'.",g,c,s)}s.substr(s.length-1)==="."&&r("A trailing decimal point can be confused with a dot '{a}'.",g,c,s);return u("(number)",s)}switch(s){case '"':case "'":return Xb(s);case "//":if(Ha||q&&q!=="script")r("Unexpected comment.",g,c);else if(q==="script"&&/<\s*\//i.test(h))r("Unexpected </ in comment.",
+g,c);else if((j.safe||q==="script")&&Ya.test(h))r("Dangerous comment.",g,c);h="";i.comment=true;break;case "/*":if(Ha||q&&q!=="script"&&q!=="style"&&q!=="styleproperty")r("Unexpected comment.",g,c);for(j.safe&&Ya.test(h)&&r("ADsafe comment violation.",g,c);;){v=h.search(Sb);if(v>=0)break;if(m())j.safe&&Ya.test(h)&&r("ADsafe comment violation.",g,c);else L("Unclosed comment.",g,c)}c+=v+2;h.substr(v,1)==="/"&&L("Nested comment.",g,c);h=h.substr(v+2);i.comment=true;break;case "/*members":case "/*member":case "/*jslint":case "/*global":case "*/":return{value:s,
+type:"special",line:g,character:c,from:d};case "":break;case "/":i.id==="/="&&L("A regular expression literal can be confused with '/='.",g,d);if(Va){for(l=s=v=0;;){p=true;k=h.charAt(l);l+=1;switch(k){case "":L("Unclosed regular expression.",g,d);return;case "/":v>0&&r("Unescaped '{a}'.",g,d+l,"/");k=h.substr(0,l-1);for(w={g:true,i:true,m:true};w[h.charAt(l)]===true;){w[h.charAt(l)]=false;l+=1}c+=l;h=h.substr(l);w=h.charAt(0);if(w==="/"||w==="*")L("Confusing regular expression.",g,d);return u("(regexp)",
+k);case "\\":k=h.charAt(l);if(k<" ")r("Unexpected control character in regular expression.",g,d+l);else k==="<"&&r("Unexpected escaped character '{a}' in regular expression.",g,d+l,k);l+=1;break;case "(":v+=1;p=false;if(h.charAt(l)==="?"){l+=1;switch(h.charAt(l)){case ":":case "=":case "!":l+=1;break;default:r("Expected '{a}' and instead saw '{b}'.",g,d+l,":",h.charAt(l))}}else s+=1;break;case "|":p=false;break;case ")":if(v===0)r("Unescaped '{a}'.",g,d+l,")");else v-=1;break;case " ":for(w=1;h.charAt(l)===
+" ";){l+=1;w+=1}w>1&&r("Spaces are hard to count. Use {{a}}.",g,d+l,w);break;case "[":k=h.charAt(l);if(k==="^"){l+=1;if(j.regexp)r("Insecure '{a}'.",g,d+l,k);else h.charAt(l)==="]"&&L("Unescaped '{a}'.",g,d+l,"^")}w=false;if(k==="]"){r("Empty class.",g,d+l-1);w=true}a:do{k=h.charAt(l);l+=1;switch(k){case "[":case "^":r("Unescaped '{a}'.",g,d+l,k);w=true;break;case "-":if(w)w=false;else{r("Unescaped '{a}'.",g,d+l,"-");w=true}break;case "]":w||r("Unescaped '{a}'.",g,d+l-1,"-");break a;case "\\":k=h.charAt(l);
+if(k<" ")r("Unexpected control character in regular expression.",g,d+l);else k==="<"&&r("Unexpected escaped character '{a}' in regular expression.",g,d+l,k);l+=1;w=true;break;case "/":r("Unescaped '{a}'.",g,d+l-1,"/");w=true;break;case "<":if(q==="script"){k=h.charAt(l);if(k==="!"||k==="/")r("HTML confusion in regular expression '<{a}'.",g,d+l,k)}w=true;break;default:w=true}}while(k);break;case ".":j.regexp&&r("Insecure '{a}'.",g,d+l,k);break;case "]":case "?":case "{":case "}":case "+":case "*":r("Unescaped '{a}'.",
+g,d+l,k);break;case "<":if(q==="script"){k=h.charAt(l);if(k==="!"||k==="/")r("HTML confusion in regular expression '<{a}'.",g,d+l,k)}}if(p)switch(h.charAt(l)){case "?":case "+":case "*":l+=1;if(h.charAt(l)==="?")l+=1;break;case "{":l+=1;k=h.charAt(l);if(k<"0"||k>"9")r("Expected a number and instead saw '{a}'.",g,d+l,k);l+=1;for(w=+k;;){k=h.charAt(l);if(k<"0"||k>"9")break;l+=1;w=+k+w*10}p=w;if(k===","){l+=1;p=Infinity;k=h.charAt(l);if(k>="0"&&k<="9"){l+=1;for(p=+k;;){k=h.charAt(l);if(k<"0"||k>"9")break;
+l+=1;p=+k+p*10}}}if(h.charAt(l)!=="}")r("Expected '{a}' and instead saw '{b}'.",g,d+l,"}",k);else l+=1;if(h.charAt(l)==="?")l+=1;w>p&&r("'{a}' should not be greater than '{b}'.",g,d+l,w,p)}}k=h.substr(0,l-1);c+=l;h=h.substr(l);return u("(regexp)",k)}return u("(punctuator)",s);case "<!--":l=g;for(k=c;;){v=h.indexOf("--");if(v>=0)break;v=h.indexOf("<!");v>=0&&L("Nested HTML comment.",g,c+v);m()||L("Unclosed HTML comment.",l,k)}l=h.indexOf("<!");l>=0&&l<v&&L("Nested HTML comment.",g,c+l);c+=v;h[v+2]!==
+">"&&L("Expected --\>.",g,c);c+=3;h=h.slice(v+3);break;case "#":if(q==="html"||q==="styleproperty"){for(;;){k=h.charAt(0);if((k<"0"||k>"9")&&(k<"a"||k>"f")&&(k<"A"||k>"F"))break;c+=1;h=h.substr(1);s+=k}s.length!==4&&s.length!==7&&r("Bad hex color '{a}'.",g,d+l,s);return u("(color)",s)}return u("(punctuator)",s);default:if(q==="outer"&&k==="&"){c+=1;for(h=h.substr(1);;){k=h.charAt(0);c+=1;h=h.substr(1);if(k===";")break;k>="0"&&k<="9"||k>="a"&&k<="z"||k==="#"||L("Bad entity",g,d+l,c)}break}return u("(punctuator)",
+s)}}else{for(k=s="";h&&h<"!";)h=h.substr(1);if(h)if(q==="html")return u("(error)",h.charAt(0));else L("Unexpected '{a}'.",g,c,h.substr(0,1))}}}}}();function ha(a,c){if(j.safe&&n["(global)"]&&typeof A[a]!=="boolean")e("ADsafe global: "+a+".",i);else a==="hasOwnProperty"&&e("'hasOwnProperty' is a really bad name.");if(T(n,a)&&!n["(global)"])e(n[a]===true?"'{a}' was used before it was defined.":"'{a}' is already defined.",b,a);n[a]=c;if(n["(global)"]){pb[a]=n;if(T(aa,a)){e("'{a}' was used before it was defined.",
+b,a);delete aa[a]}}else B[a]=n}function Yb(){var a,c,d,g=b.value,h;switch(g){case "*/":o("Unbegun comment.");break;case "/*members":case "/*member":g="/*members";ga||(ga={});c=ga;break;case "/*jslint":j.safe&&e("ADsafe restriction.");c=j;d=Db;break;case "/*global":j.safe&&e("ADsafe restriction.");c=A;break;default:}a=X.token();a:for(;;){for(;;){if(a.type==="special"&&a.value==="*/")break a;if(a.id!=="(endline)"&&a.id!==",")break;a=X.token()}a.type!=="(string)"&&a.type!=="(identifier)"&&g!=="/*members"&&
+o("Bad option.",a);h=X.token();if(h.id===":"){h=X.token();c===ga&&o("Expected '{a}' and instead saw '{b}'.",a,"*/",":");if(a.value==="indent"&&g==="/*jslint"){a=+h.value;if(typeof a!=="number"||!isFinite(a)||a<=0||Math.floor(a)!==a)o("Expected a small integer and instead saw '{a}'.",h,h.value);c.white=true;c.indent=a}else if(a.value==="maxerr"&&g==="/*jslint"){a=+h.value;if(typeof a!=="number"||!isFinite(a)||a<=0||Math.floor(a)!==a)o("Expected a small integer and instead saw '{a}'.",h,h.value);c.maxerr=
+a}else if(a.value==="maxlen"&&g==="/*jslint"){a=+h.value;if(typeof a!=="number"||!isFinite(a)||a<=0||Math.floor(a)!==a)o("Expected a small integer and instead saw '{a}'.",h,h.value);c.maxlen=a}else if(h.value==="true")c[a.value]=true;else if(h.value==="false")c[a.value]=false;else o("Bad option value.",h);a=X.token()}else{g==="/*jslint"&&o("Missing option value.",a);c[a.value]=false;a=h}}d&&$a()}function N(a){a=a||0;for(var c=0,d;c<=a;){(d=Ga[c])||(d=Ga[c]=X.token());c+=1}return d}function f(a,c){switch(i.id){case "(number)":b.id===
+"."&&e("A dot following a number can be confused with a decimal point.",i);break;case "-":if(b.id==="-"||b.id==="--")e("Confusing minusses.");break;case "+":if(b.id==="+"||b.id==="++")e("Confusing plusses.");break}if(i.type==="(string)"||i.identifier)Qa=i.value;if(a&&b.id!==a)if(c)b.id==="(end)"?e("Unmatched '{a}'.",c,c.id):e("Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",b,a,c.id,c.line,b.value);else if(b.type!=="(identifier)"||b.value!==a)e("Expected '{a}' and instead saw '{b}'.",
+b,a,b.value);F=i;for(i=b;;){b=Ga.shift()||X.token();if(b.id==="(end)"||b.id==="(error)")return;if(b.type==="special")Yb();else if(b.id!=="(endline)")break}}function t(a,c){var d;b.id==="(end)"&&o("Unexpected early end of program.",i);f();j.safe&&typeof A[i.value]==="boolean"&&b.id!=="("&&b.id!=="."&&e("ADsafe violation.",i);if(c){Qa="anonymous";n["(verb)"]=i.value}if(c===true&&i.fud)d=i.fud();else{if(i.nud)d=i.nud();else if(b.type==="(number)"&&i.id==="."){e("A leading decimal point can be confused with a dot: '.{a}'.",
+i,b.value);f();return i}else o("Expected an identifier and instead saw '{a}'.",i,i.id);for(;a<b.lbp;){f();if(i.led)d=i.led(d);else o("Expected an operator and instead saw '{a}'.",i,i.id)}}return d}function H(a,c){a=a||i;c=c||b;if(j.white||q==="styleproperty"||q==="style")a.character!==c.from&&a.line===c.line&&e("Unexpected space after '{a}'.",c,a.value)}function cb(a,c){a=a||i;c=c||b;if(a.character!==c.from||a.line!==c.line)e("Unexpected space before '{a}'.",c,c.value)}function I(a,c){a=a||i;c=c||
+b;j.white&&!a.comment&&a.line===c.line&&H(a,c)}function y(a,c){if(j.white){a=a||i;c=c||b;a.line===c.line&&a.character===c.from&&e("Missing space after '{a}'.",b,a.value)}}function vb(a,c){a=a||i;c=c||b;if(!j.laxbreak&&a.line!==c.line)e("Bad line breaking before '{a}'.",c,c.id);else if(j.white){a=a||i;c=c||b;a.character===c.from&&e("Missing space after '{a}'.",b,a.value)}}function U(a){if(j.white&&b.id!=="(end)"){a=C+(a||0);b.from!==a&&e("Expected '{a}' to have an indentation at {b} instead at {c}.",
+b,b.value,a,b.from)}}function ba(a){a=a||i;a.line!==b.line&&e("Line breaking error '{a}'.",a,a.value)}function S(){if(i.line!==b.line)j.laxbreak||e("Bad line breaking before '{a}'.",i,b.id);else i.character!==b.from&&j.white&&e("Unexpected space after '{a}'.",b,i.value);f(",");y(i,b)}function ca(a,c){var d=O[a];if(!d||typeof d!=="object")O[a]=d={id:a,lbp:c,value:a};return d}function E(a){return ca(a,0)}function da(a,c){a=E(a);a.identifier=a.reserved=true;a.fud=c;return a}function na(a,c){a=da(a,c);
+a.block=true;return a}function db(a){var c=a.id.charAt(0);if(c>="a"&&c<="z"||c>="A"&&c<="Z")a.identifier=a.reserved=true;return a}function Q(a,c){a=ca(a,150);db(a);a.nud=typeof c==="function"?c:function(){this.right=t(150);this.arity="unary";if(this.id==="++"||this.id==="--")if(j.plusplus)e("Unexpected use of '{a}'.",this,this.id);else if((!this.right.identifier||this.right.reserved)&&this.right.id!=="."&&this.right.id!=="[")e("Bad operand.",this);return this};return a}function Ja(a,c){var d=E(a);
+d.type=a;d.nud=c;return d}function z(a,c){a=Ja(a,c);a.identifier=a.reserved=true;return a}function Y(a,c){return z(a,function(){typeof c==="function"&&c(this);return this})}function K(a,c,d,g){a=ca(a,d);db(a);a.led=function(h){if(!g){vb(F,i);y(i,b)}if(typeof c==="function")return c(h,this);else{this.left=h;this.right=t(d);return this}};return a}function ea(a,c){a=ca(a,100);a.led=function(d){vb(F,i);y(i,b);var g=t(100);if(d&&d.id==="NaN"||g&&g.id==="NaN")e("Use the isNaN function to compare with NaN.",
+this);else c&&c.apply(this,[d,g]);d.id==="!"&&e("Confusing use of '{a}'.",d,"!");g.id==="!"&&e("Confusing use of '{a}'.",d,"!");this.left=d;this.right=g;return this};return a}function Ka(a){return a&&(a.type==="(number)"&&+a.value===0||a.type==="(string)"&&a.value===""||a.type==="true"||a.type==="false"||a.type==="undefined"||a.type==="null")}function oa(a){ca(a,20).exps=true;return K(a,function(c,d){var g;d.left=c;if(A[c.value]===false&&B[c.value]["(global)"]===true)e("Read only.",c);else c["function"]&&
+e("'{a}' is a function.",c,c.value);if(j.safe){g=c;do{typeof A[g.value]==="boolean"&&e("ADsafe violation.",g);g=g.left}while(g)}if(c){if(c.id==="."||c.id==="["){if(!c.left||c.left.value==="arguments")e("Bad assignment.",d);d.right=t(19);return d}else if(c.identifier&&!c.reserved){n[c.value]==="exception"&&e("Do not assign to the exception parameter.",c);d.right=t(19);return d}c===O["function"]&&e("Expected an identifier in an assignment and instead saw a function invocation.",i)}o("Bad assignment.",
+d)},20)}function pa(a,c,d){a=ca(a,d);db(a);a.led=typeof c==="function"?c:function(g){j.bitwise&&e("Unexpected use of '{a}'.",this,this.id);this.left=g;this.right=t(d);return this};return a}function qa(a){ca(a,20).exps=true;return K(a,function(c,d){j.bitwise&&e("Unexpected use of '{a}'.",d,d.id);y(F,i);y(i,b);if(c){if(c.id==="."||c.id==="["||c.identifier&&!c.reserved){t(19);return d}c===O["function"]&&e("Expected an identifier in an assignment, and instead saw a function invocation.",i);return d}o("Bad assignment.",
+d)},20)}function wb(a){a=ca(a,150);a.led=function(c){if(j.plusplus)e("Unexpected use of '{a}'.",this,this.id);else if((!c.identifier||c.reserved)&&c.id!=="."&&c.id!=="[")e("Bad operand.",this);this.left=c;return this};return a}function eb(){if(b.identifier){f();if(j.safe&&Ra[i.value])e("ADsafe violation: '{a}'.",i,i.value);else i.reserved&&!j.es5&&e("Expected an identifier and instead saw '{a}' (a reserved word).",i,i.id);return i.value}}function Aa(){var a=eb();if(a)return a;i.id==="function"&&b.id===
+"("?e("Missing name in function statement."):o("Expected an identifier and instead saw '{a}'.",b,b.value)}function La(a){var c=0,d;if(!(b.id!==";"||Ua))for(;;){d=N(c);if(d.reach)return;if(d.id!=="(endline)"){if(d.id==="function"){e("Inner functions should be listed at the top of the outer function.",d);break}e("Unreachable '{a}' after '{b}'.",d,d.value,a);break}c+=1}}function fb(a){var c=C,d=B,g=b;if(g.id===";"){e("Unnecessary semicolon.",g);f(";")}else{if(g.identifier&&!g.reserved&&N().id===":"){f();
+f(":");B=Object.create(d);ha(g.value,"label");b.labelled||e("Label '{a}' on {b} statement.",b,g.value,b.value);Za.test(g.value+":")&&e("Label '{a}' looks like a javascript url.",g,g.value);b.label=g.value;g=b}a||U();a=t(0,true);if(!g.block){if(!a||!a.exps)e("Expected an assignment or function call and instead saw an expression.",i);else a.id==="("&&a.left.id==="new"&&e("Do not use 'new' for side effects.");if(b.id!==";")r("Missing semicolon.",i.line,i.from+i.value.length);else{H(i,b);f(";");y(i,b)}}C=
+c;B=d;return a}}function xb(){if(b.value==="use strict"){f();f(";");Ia=true;j.newcap=true;return j.undef=true}else return false}function Ba(a){var c=[],d;a&&!xb()&&j.strict&&e('Missing "use strict" statement.',b);if(j.adsafe)switch(a){case "script":if(!ja)if(b.value!=="ADSAFE"||N(0).id!=="."||N(1).value!=="id"&&N(1).value!=="go")o("ADsafe violation: Missing ADSAFE.id or ADSAFE.go.",b);if(b.value==="ADSAFE"&&N(0).id==="."&&N(1).value==="id"){ja&&o("ADsafe violation.",b);f("ADSAFE");f(".");f("id");
+f("(");b.value!==R&&o("ADsafe violation: id does not match.",b);f("(string)");f(")");f(";");ja=true}break;case "lib":if(b.value==="ADSAFE"){f("ADSAFE");f(".");f("lib");f("(");f("(string)");S();a=t(0);a.id!=="function"&&o("The second argument to lib must be a function.",a);(d=(d=a.funct["(params)"])&&d.join(", "))&&d!=="lib"&&o("Expected '{a}' and instead saw '{b}'.",a,"(lib)","("+d+")");f(")");f(";");return c}else o("ADsafe lib violation.")}for(;!b.reach&&b.id!=="(end)";)if(b.id===";"){e("Unnecessary semicolon.");
+f(";")}else c.push(fb());return c}function V(a){var c,d=wa,g=C,h=B,m;wa=a;B=Object.create(B);y(i,b);m=b;if(b.id==="{"){f("{");if(b.id!=="}"||i.line!==b.line){for(C+=j.indent;!a&&b.from>C;)C+=j.indent;a||xb();c=Ba();C-=j.indent;U()}f("}",m);C=g}else{e("Expected '{a}' and instead saw '{b}'.",b,"{",b.value);Ua=true;c=[fb()];Ua=false}n["(verb)"]=null;B=h;wa=d;if(a&&(!c||c.length===0))e("Empty block.");return c}function Ma(a){ga&&typeof ga[a]!=="boolean"&&e("Unexpected /*member '{a}'.",i,a);if(typeof fa[a]===
+"number")fa[a]+=1;else fa[a]=1}function gb(a){var c=a.value;a=a.line;var d=aa[c];if(typeof d==="function")d=false;if(d)d[d.length-1]!==a&&d.push(a);else{d=[a];aa[c]=d}}function hb(){if(b.identifier){f();return true}}function Na(){if(b.id==="-"){f("-");H();ba()}if(b.type==="(number)"){f("(number)");return true}}function ib(){if(b.type==="(string)"){f();return true}}function Z(){var a,c,d;if(b.identifier){d=b.value;if(d==="rgb"||d==="rgba"){f();f("(");for(a=0;a<3;a+=1){a&&f(",");c=b.value;if(b.type!==
+"(number)"||c<0){e("Expected a positive number and instead saw '{a}'",b,c);f()}else{f();if(b.id==="%"){f("%");c>100&&e("Expected a percentage and instead saw '{a}'",i,c)}else c>255&&e("Expected a small number and instead saw '{a}'",i,c)}}if(d==="rgba"){f(",");c=+b.value;if(b.type!=="(number)"||c<0||c>1)e("Expected a number between 0 and 1 and instead saw '{a}'",b,c);f();if(b.id==="%"){e("Unexpected '%'.");f("%")}}f(")");return true}else if(Fb[b.value]===true){f();return true}}else if(b.type==="(color)"){f();
+return true}return false}function x(){if(b.id==="-"){f("-");H();ba()}if(b.type==="(number)"){f();if(b.type!=="(string)"&&ob[b.value]===true){H();f()}else+i.value!==0&&e("Expected a linear unit and instead saw '{a}'.",b,b.value);return true}return false}function Zb(){if(b.id==="-"){f("-");H()}if(b.type==="(number)"){f();if(b.type!=="(string)"&&ob[b.value]===true){H();f()}return true}return false}function ra(){if(b.identifier)switch(b.value){case "thin":case "medium":case "thick":f();return true}else return x()}
+function Ca(){if(b.identifier){if(b.value==="auto"){f();return true}}else return x()}function $b(){if(b.identifier&&b.value==="attr"){f();f("(");b.identifier||e("Expected a name and instead saw '{a}'.",b,b.value);f();f(")");return true}return false}function ac(){for(;b.id!==";";){!hb()&&!ib()&&e("Expected a name and instead saw '{a}'.",b,b.value);if(b.id!==",")return true;S()}}function bc(){if(b.identifier&&b.value==="counter"){f();f("(");f();if(b.id===","){S();b.type!=="(string)"&&e("Expected a string and instead saw '{a}'.",
+b,b.value);f()}f(")");return true}if(b.identifier&&b.value==="counters"){f();f("(");b.identifier||e("Expected a name and instead saw '{a}'.",b,b.value);f();if(b.id===","){S();b.type!=="(string)"&&e("Expected a string and instead saw '{a}'.",b,b.value);f()}if(b.id===","){S();b.type!=="(string)"&&e("Expected a string and instead saw '{a}'.",b,b.value);f()}f(")");return true}return false}function cc(){var a;if(b.identifier&&b.value==="rect"){f();f("(");for(a=0;a<4;a+=1)if(!x()){e("Expected a number and instead saw '{a}'.",
+b,b.value);break}f(")");return true}return false}function ia(){var a,c;if(b.identifier&&b.value==="url"){b=X.range("(",")");c=b.value;a=c.charAt(0);if(a==='"'||a==="'")if(c.slice(-1)!==a)e("Bad url string.");else{c=c.slice(1,-1);c.indexOf(a)>=0&&e("Bad url string.")}c||e("Missing url.");f();j.safe&&rb.test(c)&&o("ADsafe URL violation.");ya.push(c);return true}return false}Sa=[ia,function(){for(;;)if(b.identifier)switch(b.value.toLowerCase()){case "url":ia();break;case "expression":e("Unexpected expression '{a}'.",
+b,b.value);f();break;default:f()}else{if(b.id===";"||b.id==="!"||b.id==="(end)"||b.id==="}")return true;f()}}];W=["none","hidden","dotted","dashed","solid","double","ridge","inset","outset"];ta=["auto","always","avoid","left","right"];ka=["auto","hidden","scroll","visible"];Ea={background:[true,"background-attachment","background-color","background-image","background-position","background-repeat"],"background-attachment":["scroll","fixed"],"background-color":["transparent",Z],"background-image":["none",
+ia],"background-position":[2,[x,"top","bottom","left","right","center"]],"background-repeat":["repeat","repeat-x","repeat-y","no-repeat"],border:[true,"border-color","border-style","border-width"],"border-bottom":[true,"border-bottom-color","border-bottom-style","border-bottom-width"],"border-bottom-color":Z,"border-bottom-style":W,"border-bottom-width":ra,"border-collapse":["collapse","separate"],"border-color":["transparent",4,Z],"border-left":[true,"border-left-color","border-left-style","border-left-width"],
+"border-left-color":Z,"border-left-style":W,"border-left-width":ra,"border-right":[true,"border-right-color","border-right-style","border-right-width"],"border-right-color":Z,"border-right-style":W,"border-right-width":ra,"border-spacing":[2,x],"border-style":[4,W],"border-top":[true,"border-top-color","border-top-style","border-top-width"],"border-top-color":Z,"border-top-style":W,"border-top-width":ra,"border-width":[4,ra],bottom:[x,"auto"],"caption-side":["bottom","left","right","top"],clear:["both",
+"left","none","right"],clip:[cc,"auto"],color:Z,content:["open-quote","close-quote","no-open-quote","no-close-quote",ib,ia,bc,$b],"counter-increment":[hb,"none"],"counter-reset":[hb,"none"],cursor:[ia,"auto","crosshair","default","e-resize","help","move","n-resize","ne-resize","nw-resize","pointer","s-resize","se-resize","sw-resize","w-resize","text","wait"],direction:["ltr","rtl"],display:["block","compact","inline","inline-block","inline-table","list-item","marker","none","run-in","table","table-caption",
+"table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group"],"empty-cells":["show","hide"],"float":["left","none","right"],font:["caption","icon","menu","message-box","small-caption","status-bar",true,"font-size","font-style","font-weight","font-family"],"font-family":ac,"font-size":["xx-small","x-small","small","medium","large","x-large","xx-large","larger","smaller",x],"font-size-adjust":["none",Na],"font-stretch":["normal","wider","narrower",
+"ultra-condensed","extra-condensed","condensed","semi-condensed","semi-expanded","expanded","extra-expanded"],"font-style":["normal","italic","oblique"],"font-variant":["normal","small-caps"],"font-weight":["normal","bold","bolder","lighter",Na],height:[x,"auto"],left:[x,"auto"],"letter-spacing":["normal",x],"line-height":["normal",Zb],"list-style":[true,"list-style-image","list-style-position","list-style-type"],"list-style-image":["none",ia],"list-style-position":["inside","outside"],"list-style-type":["circle",
+"disc","square","decimal","decimal-leading-zero","lower-roman","upper-roman","lower-greek","lower-alpha","lower-latin","upper-alpha","upper-latin","hebrew","katakana","hiragana-iroha","katakana-oroha","none"],margin:[4,Ca],"margin-bottom":Ca,"margin-left":Ca,"margin-right":Ca,"margin-top":Ca,"marker-offset":[x,"auto"],"max-height":[x,"none"],"max-width":[x,"none"],"min-height":x,"min-width":x,opacity:Na,outline:[true,"outline-color","outline-style","outline-width"],"outline-color":["invert",Z],"outline-style":["dashed",
+"dotted","double","groove","inset","none","outset","ridge","solid"],"outline-width":ra,overflow:ka,"overflow-x":ka,"overflow-y":ka,padding:[4,x],"padding-bottom":x,"padding-left":x,"padding-right":x,"padding-top":x,"page-break-after":ta,"page-break-before":ta,position:["absolute","fixed","relative","static"],quotes:[8,ib],right:[x,"auto"],"table-layout":["auto","fixed"],"text-align":["center","justify","left","right"],"text-decoration":["none","underline","overline","line-through","blink"],"text-indent":x,
+"text-shadow":["none",4,[Z,x]],"text-transform":["capitalize","uppercase","lowercase","none"],top:[x,"auto"],"unicode-bidi":["normal","embed","bidi-override"],"vertical-align":["baseline","bottom","sub","super","top","text-top","middle","text-bottom",x],visibility:["visible","hidden","collapse"],"white-space":["normal","nowrap","pre","pre-line","pre-wrap","inherit"],width:[x,"auto"],"word-spacing":["normal",x],"word-wrap":["break-word","normal"],"z-index":["auto",Na]};function dc(){for(var a;b.id===
+"*"||b.id==="#"||b.value==="_";){j.css||e("Unexpected '{a}'.",b,b.value);f()}if(b.id==="-"){j.css||e("Unexpected '{a}'.",b,b.value);f("-");b.identifier||e("Expected a non-standard style attribute and instead saw '{a}'.",b,b.value);f();return Sa}else{if(b.identifier)if(T(Ea,b.value))a=Ea[b.value];else{a=Sa;j.css||e("Unrecognized style attribute '{a}'.",b,b.value)}else e("Excepted a style attribute, and instead saw '{a}'.",b,b.value);f();return a}}function jb(a){var c=0,d,g,h,m=0;switch(typeof a){case "function":return a();
+case "string":if(b.identifier&&b.value===a){f();return true}return false}for(;;){if(c>=a.length)return false;h=a[c];c+=1;if(h===true)break;else if(typeof h==="number"){d=h;h=a[c];c+=1}else d=1;for(g=false;d>0;)if(jb(h)){g=true;d-=1}else break;if(g)return true}m=c;for(d=[];;){h=false;for(c=m;c<a.length;c+=1)if(!d[c])if(jb(Ea[a[c]])){h=g=true;d[c]=true;break}if(!h)return g}}function ec(){if(b.id==="(number)"){f();if(b.value==="n"&&b.identifier){H();f();if(b.id==="+"){H();f("+");H();f("(number)")}}}else{switch(b.value){case "odd":case "even":if(b.identifier){f();
+return}}e("Unexpected token '{a}'.",b,b.value)}}function yb(){for(var a;;){if(b.id==="}"||b.id==="(end)"||P&&b.id===P)return;for(;b.id===";";){e("Misplaced ';'.");f(";")}a=dc();f(":");if(b.identifier&&b.value==="inherit")f();else if(!jb(a)){e("Unexpected token '{a}'.",b,b.value);f()}if(b.id==="!"){f("!");H();b.identifier&&b.value==="important"?f():e("Expected '{a}' and instead saw '{b}'.",b,"important",b.value)}b.id==="}"||b.id===P?e("Missing '{a}'.",b,";"):f(";")}}function kb(){if(b.identifier){T(Ta,
+j.cap?b.value.toLowerCase():b.value)||e("Expected a tagName, and instead saw {a}.",b,b.value);f()}else switch(b.id){case ">":case "+":f();kb();break;case ":":f(":");switch(b.value){case "active":case "after":case "before":case "checked":case "disabled":case "empty":case "enabled":case "first-child":case "first-letter":case "first-line":case "first-of-type":case "focus":case "hover":case "last-child":case "last-of-type":case "link":case "only-of-type":case "root":case "target":case "visited":f();break;
+case "lang":f();f("(");b.identifier||e("Expected a lang code, and instead saw :{a}.",b,b.value);f(")");break;case "nth-child":case "nth-last-child":case "nth-last-of-type":case "nth-of-type":f();f("(");ec();f(")");break;case "not":f();f("(");b.id===":"&&N(0).value==="not"&&e("Nested not.");kb();f(")");break;default:e("Expected a pseudo, and instead saw :{a}.",b,b.value)}break;case "#":f("#");b.identifier||e("Expected an id, and instead saw #{a}.",b,b.value);f();break;case "*":f("*");break;case ".":f(".");
+b.identifier||e("Expected a class, and instead saw #.{a}.",b,b.value);f();break;case "[":f("[");b.identifier||e("Expected an attribute, and instead saw [{a}].",b,b.value);f();if(b.id==="="||b.value==="~="||b.value==="$="||b.value==="|="||b.id==="*="||b.id==="^="){f();b.type!=="(string)"&&e("Expected a string, and instead saw {a}.",b,b.value);f()}f("]");break;default:o("Expected a CSS selector, and instead saw {a}.",b,b.value)}}function fc(){var a;if(b.id==="{")e("Expected a style pattern, and instead saw '{a}'.",
+b,b.id);else if(b.id==="@"){f("@");a=b.value;if(b.identifier&&Bb[a]===true){f();return a}e("Expected an at-rule, and instead saw @{a}.",b,a)}for(;;){kb();if(b.id==="</"||b.id==="{"||b.id==="(end)")return"";b.id===","&&S()}}function zb(){for(var a;b.id==="@";){a=N();if(a.identifier&&a.value==="import"){f("@");f();if(!ia()){e("Expected '{a}' and instead saw '{b}'.",b,"url",b.value);f()}f(";")}else break}for(;b.id!=="</"&&b.id!=="(end)";){fc();q="styleproperty";if(b.id===";")f(";");else{f("{");yb();
+q="style";f("}")}}}function gc(a){if(a!=="html"&&!j.fragment)a==="div"&&j.adsafe?o("ADSAFE: Use the fragment option."):o("Expected '{a}' and instead saw '{b}'.",i,"html",a);if(j.adsafe){a==="html"&&o("Currently, ADsafe does not operate on whole HTML documents. It operates on <div> fragments and .js files.",i);if(j.fragment)a!=="div"&&o("ADsafe violation: Wrap the widget in a div.",i);else o("Use the fragment option.",i)}j.browser=true;$a()}function hc(a,c,d){var g;if(c==="id"){g=typeof d==="string"?
+d.toUpperCase():"";Fa[g]===true&&e("Duplicate id='{a}'.",b,d);if(/^[A-Za-z][A-Za-z0-9._:\-]*$/.test(d)){if(j.adsafe)if(R)if(d.slice(0,R.length)!==R)e("ADsafe violation: An id must have a '{a}' prefix",b,R);else/^[A-Z]+_[A-Z]+$/.test(d)||e("ADSAFE violation: bad id.");else{R=d;/^[A-Z]+_$/.test(d)||e("ADSAFE violation: bad id.")}}else e("Bad id: '{a}'.",b,d);a=d.search(Ub);a>=0&&e("Unexpected character '{a}' in {b}.",i,d.charAt(a),c);Fa[g]=true}else if(c==="class"||c==="type"||c==="name"){a=d.search(Tb);
+a>=0&&e("Unexpected character '{a}' in {b}.",i,d.charAt(a),c);Fa[g]=true}else if(c==="href"||c==="background"||c==="content"||c==="data"||c.indexOf("src")>=0||c.indexOf("url")>=0){j.safe&&rb.test(d)&&o("ADsafe URL violation.");ya.push(d)}else if(c==="for"){if(j.adsafe)if(R)if(d.slice(0,R.length)!==R)e("ADsafe violation: An id must have a '{a}' prefix",b,R);else/^[A-Z]+_[A-Z]+$/.test(d)||e("ADSAFE violation: bad id.");else e("ADSAFE violation: bad id.")}else c==="name"&&j.adsafe&&d.indexOf("_")>=0&&
+e("ADsafe name violation.")}function ic(a,c){var d;d=Ta[a];Ha=false;d||o("Unrecognized tag '<{a}>'.",b,a===a.toLowerCase()?a:a+" (capitalization error)");if(J.length>0){a==="html"&&o("Too many <html> tags.",i);if(d=d.parent)d.indexOf(" "+J[J.length-1].name+" ")<0&&o("A '<{a}>' must be within '<{b}>'.",i,a,d);else if(!j.adsafe&&!j.fragment){d=J.length;do{d<=0&&o("A '<{a}>' must be within '<{b}>'.",i,a,"body");d-=1}while(J[d].name!=="body")}}switch(a){case "div":j.adsafe&&J.length===1&&!R&&e("ADSAFE violation: missing ID_.");
+break;case "script":q="script";f(">");C=b.from;c.lang&&e("lang is deprecated.",i);j.adsafe&&J.length!==1&&e("ADsafe script placement violation.",i);if(c.src){if(j.adsafe&&(!ja||!Da[c.src]))e("ADsafe unapproved script source.",i);c.type&&e("type is unnecessary.",i)}else{sa&&o("ADsafe script violation.",i);Ba("script")}q="html";f("</");!b.identifier&&b.value!=="script"&&e("Expected '{a}' and instead saw '{b}'.",b,"script",b.value);f();q="outer";break;case "style":q="style";f(">");zb();q="html";f("</");
+!b.identifier&&b.value!=="style"&&e("Expected '{a}' and instead saw '{b}'.",b,"style",b.value);f();q="outer";break;case "input":switch(c.type){case "radio":case "checkbox":case "button":case "reset":case "submit":break;case "text":case "file":case "password":case "file":case "hidden":case "image":j.adsafe&&c.autocomplete!=="off"&&e("ADsafe autocomplete violation.");break;default:e("Bad input type.")}break;case "applet":case "body":case "embed":case "frame":case "frameset":case "head":case "iframe":case "noembed":case "noframes":case "object":case "param":j.adsafe&&
+e("ADsafe violation: Disallowed tag: "+a);break}}function Oa(a){return"</"+a+">"}function jc(){var a,c,d,g,h,m,u=j.white,p;q="html";P="";for(J=null;;){switch(b.value){case "<":q="html";f("<");c={};m=b;m.identifier||e("Bad identifier {a}.",m,m.value);g=m.value;if(j.cap)g=g.toLowerCase();m.name=g;f();if(!J){J=[];gc(g)}h=Ta[g];typeof h!=="object"&&o("Unrecognized tag '<{a}>'.",m,g);d=h.empty;for(m.type=g;;){if(b.id==="/"){f("/");b.id!==">"&&e("Expected '{a}' and instead saw '{b}'.",b,">",b.value);break}if(b.id&&
+b.id.substr(0,1)===">")break;if(!b.identifier){if(b.id==="(end)"||b.id==="(error)")o("Missing '>'.",b);e("Bad identifier.")}j.white=true;y(i,b);a=b.value;j.white=u;f();!j.cap&&a!==a.toLowerCase()&&e("Attribute '{a}' not all lower case.",b,a);a=a.toLowerCase();P="";T(c,a)&&e("Attribute '{a}' repeated.",b,a);if(a.slice(0,2)==="on"){j.on||e("Avoid HTML event handlers.");q="scriptstring";f("=");h=b.id;h!=='"'&&h!=="'"&&o("Missing quote.");P=h;p=j.white;j.white=false;f(h);Ba("on");j.white=p;b.id!==h&&
+o("Missing close quote on script attribute.");q="html";P="";f(h);h=false}else if(a==="style"){q="scriptstring";f("=");h=b.id;h!=='"'&&h!=="'"&&o("Missing quote.");q="styleproperty";P=h;f(h);yb();q="html";P="";f(h);h=false}else if(b.id==="="){f("=");h=b.value;!b.identifier&&b.id!=='"'&&b.id!=="'"&&b.type!=="(string)"&&b.type!=="(number)"&&b.type!=="(color)"&&e("Expected an attribute value and instead saw '{a}'.",i,a);f()}else h=true;c[a]=h;hc(g,a,h)}ic(g,c);d||J.push(m);q="outer";f(">");break;case "</":q=
+"html";f("</");b.identifier||e("Bad identifier.");g=b.value;if(j.cap)g=g.toLowerCase();f();J||o("Unexpected '{a}'.",b,Oa(g));(m=J.pop())||o("Unexpected '{a}'.",b,Oa(g));m.name!==g&&o("Expected '{a}' and instead saw '{b}'.",b,Oa(m.name),Oa(g));b.id!==">"&&o("Missing '{a}'.",b,">");q="outer";f(">");break;case "<!":j.safe&&e("ADsafe HTML violation.");for(q="html";;){f();if(b.id===">"||b.id==="(end)")break;b.value.indexOf("--")>=0&&o("Unexpected --.");b.value.indexOf("<")>=0&&o("Unexpected <.");b.value.indexOf(">")>=
+0&&o("Unexpected >.")}q="outer";f(">");break;case "(end)":return;default:b.id==="(end)"?o("Missing '{a}'.",b,"</"+J[J.length-1].value+">"):f()}if(J&&J.length===0&&(j.adsafe||!j.fragment||b.id==="(end)"))break}b.id!=="(end)"&&o("Unexpected material after the end.")}Ja("(number)",function(){return this});Ja("(string)",function(){return this});O["(identifier)"]={type:"(identifier)",lbp:0,identifier:true,nud:function(){var a=this.value,c=B[a],d;if(typeof c==="function")c=undefined;else if(typeof c===
+"boolean"){d=n;n=va[0];ha(a,"var");c=n;n=d}if(n===c)switch(n[a]){case "unused":n[a]="var";break;case "unction":n[a]="function";this["function"]=true;break;case "function":this["function"]=true;break;case "label":e("'{a}' is a statement label.",i,a);break}else if(n["(global)"]){j.undef&&A[a]!=="boolean"&&e("'{a}' is not defined.",i,a);gb(i)}else switch(n[a]){case "closure":case "function":case "var":case "unused":e("'{a}' used out of scope.",i,a);break;case "label":e("'{a}' is a statement label.",
+i,a);break;case "outer":case "global":break;default:if(c===true)n[a]=true;else if(c===null){e("'{a}' is not allowed.",i,a);gb(i)}else if(typeof c!=="object"){if(j.undef)e("'{a}' is not defined.",i,a);else n[a]=true;gb(i)}else switch(c[a]){case "function":case "unction":this["function"]=true;c[a]="closure";n[a]=c["(global)"]?"global":"outer";break;case "var":case "unused":c[a]="closure";n[a]=c["(global)"]?"global":"outer";break;case "closure":case "parameter":n[a]=c["(global)"]?"global":"outer";break;
+case "label":e("'{a}' is a statement label.",i,a)}}return this},led:function(){o("Expected an operator and instead saw '{a}'.",b,b.value)}};Ja("(regexp)",function(){return this});E("(endline)");E("(begin)");E("(end)").reach=true;E("</").reach=true;E("<!");E("<!--");E("--\>");E("(error)").reach=true;E("}").reach=true;E(")");E("]");E('"').reach=true;E("'").reach=true;E(";");E(":").reach=true;E(",");E("#");E("@");z("else");z("case").reach=true;z("catch");z("default").reach=true;z("finally");Y("arguments",
+function(a){if(Ia&&n["(global)"])e("Strict violation.",a);else j.safe&&e("ADsafe violation.",a)});Y("eval",function(a){j.safe&&e("ADsafe violation.",a)});Y("false");Y("Infinity");Y("NaN");Y("null");Y("this",function(a){if(Ia&&(n["(statement)"]&&n["(name)"].charAt(0)>"Z"||n["(global)"]))e("Strict violation.",a);else j.safe&&e("ADsafe violation.",a)});Y("true");Y("undefined");oa("=","assign",20);oa("+=","assignadd",20);oa("-=","assignsub",20);oa("*=","assignmult",20);oa("/=","assigndiv",20).nud=function(){o("A regular expression literal can be confused with '/='.")};
+oa("%=","assignmod",20);qa("&=","assignbitand",20);qa("|=","assignbitor",20);qa("^=","assignbitxor",20);qa("<<=","assignshiftleft",20);qa(">>=","assignshiftright",20);qa(">>>=","assignshiftrightunsigned",20);K("?",function(a,c){c.left=a;c.right=t(10);f(":");c["else"]=t(10);return c},30);K("||","or",40);K("&&","and",50);pa("|","bitor",70);pa("^","bitxor",80);pa("&","bitand",90);ea("==",function(a,c){if(j.eqeqeq)e("Expected '{a}' and instead saw '{b}'.",this,"===","==");else if(Ka(a))e("Use '{a}' to compare with '{b}'.",
+this,"===",a.value);else Ka(c)&&e("Use '{a}' to compare with '{b}'.",this,"===",c.value);return this});ea("===");ea("!=",function(a,c){if(j.eqeqeq)e("Expected '{a}' and instead saw '{b}'.",this,"!==","!=");else if(Ka(a))e("Use '{a}' to compare with '{b}'.",this,"!==",a.value);else Ka(c)&&e("Use '{a}' to compare with '{b}'.",this,"!==",c.value);return this});ea("!==");ea("<");ea(">");ea("<=");ea(">=");pa("<<","shiftleft",120);pa(">>","shiftright",120);pa(">>>","shiftrightunsigned",120);K("in","in",
+120);K("instanceof","instanceof",120);K("+",function(a,c){var d=t(130);if(a&&d&&a.id==="(string)"&&d.id==="(string)"){a.value+=d.value;a.character=d.character;Za.test(a.value)&&e("JavaScript URL.",a);return a}c.left=a;c.right=d;return c},130);Q("+","num");Q("+++",function(){e("Confusing pluses.");this.right=t(150);this.arity="unary";return this});K("+++",function(a){e("Confusing pluses.");this.left=a;this.right=t(130);return this},130);K("-","sub",130);Q("-","neg");Q("---",function(){e("Confusing minuses.");
+this.right=t(150);this.arity="unary";return this});K("---",function(a){e("Confusing minuses.");this.left=a;this.right=t(130);return this},130);K("*","mult",140);K("/","div",140);K("%","mod",140);wb("++","postinc");Q("++","preinc");O["++"].exps=true;wb("--","postdec");Q("--","predec");O["--"].exps=true;Q("delete",function(){var a=t(0);if(!a||a.id!=="."&&a.id!=="[")e("Variables should not be deleted.");this.first=a;return this}).exps=true;Q("~",function(){j.bitwise&&e("Unexpected '{a}'.",this,"~");
+t(150);return this});Q("!",function(){this.right=t(150);this.arity="unary";Cb[this.right.id]===true&&e("Confusing use of '{a}'.",this,"!");return this});Q("typeof","typeof");Q("new",function(){var a=t(155),c;if(a&&a.id!=="function")if(a.identifier){a["new"]=true;switch(a.value){case "Object":e("Use the object literal notation {}.",i);break;case "Array":if(b.id!=="(")e("Use the array literal notation [].",i);else{f("(");if(b.id===")")e("Use the array literal notation [].",i);else{c=t(0);a.dimension=
+c;if(c.id==="(number)"&&/[.+\-Ee]/.test(c.value)||c.id==="-"&&!c.right||c.id==="(string)"||c.id==="["||c.id==="{"||c.id==="true"||c.id==="false"||c.id==="null"||c.id==="undefined"||c.id==="Infinity")e("Use the array literal notation [].",i);b.id!==")"&&o("Use the array literal notation [].",i)}f(")")}this.first=a;return this;case "Number":case "String":case "Boolean":case "Math":case "JSON":e("Do not use {a} as a constructor.",i,a.value);break;case "Function":j.evil||e("The Function constructor is eval.");
+break;case "Date":case "RegExp":break;default:if(a.id!=="function"){c=a.value.substr(0,1);if(j.newcap&&(c<"A"||c>"Z"))e("A constructor name should start with an uppercase letter.",i)}}}else a.id!=="."&&a.id!=="["&&a.id!=="("&&e("Bad constructor.",i);else e("Weird construction. Delete 'new'.",this);H(i,b);b.id!=="("&&e("Missing '()' invoking a constructor.");this.first=a;return this});O["new"].exps=true;K(".",function(a,c){H(F,i);cb();var d=Aa();typeof d==="string"&&Ma(d);c.left=a;c.right=d;if(a&&
+a.value==="arguments"&&(d==="callee"||d==="caller"))e("Avoid arguments.{a}.",a,d);else if(!j.evil&&a&&a.value==="document"&&(d==="write"||d==="writeln"))e("document.write can be a form of eval.",a);else if(j.adsafe)if(a&&a.value==="ADSAFE")if(d==="id"||d==="lib")e("ADsafe violation.",c);else if(d==="go"){if(q!=="script")e("ADsafe violation.",c);else if(sa||b.id!=="("||N(0).id!=="(string)"||N(0).value!==R||N(1).id!==",")o("ADsafe violation: go.",c);sa=true;ja=false}if(!j.evil&&(d==="eval"||d==="execScript"))e("eval is evil.");
+else if(j.safe)for(;;){Ra[d]===true&&e("ADsafe restricted word '{a}'.",i,d);if(typeof A[a.value]!=="boolean"||b.id==="(")break;if(Lb[d]===true){b.id==="."&&e("ADsafe violation.",c);break}if(b.id!=="."){e("ADsafe violation.",c);break}f(".");i.left=c;i.right=d;c=i;d=Aa();typeof d==="string"&&Ma(d)}return c},160,true);K("(",function(a,c){F.id!=="}"&&F.id!==")"&&cb(F,i);I();j.immed&&!a.immed&&a.id==="function"&&e("Wrap an immediate function invocation in parentheses to assist the reader in understanding that the expression is the result of a function, and not the function itself.");
+var d=0,g=[];if(a)if(a.type==="(identifier)"){if(a.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/))if(a.value!=="Number"&&a.value!=="String"&&a.value!=="Boolean"&&a.value!=="Date")if(a.value==="Math")e("Math is not a function.",a);else j.newcap&&e("Missing 'new' prefix when invoking a constructor.",a)}else a.id==="."&&j.safe&&a.left.value==="Math"&&a.right==="random"&&e("ADsafe violation.",a);if(b.id!==")")for(;;){g[g.length]=t(10);d+=1;if(b.id!==",")break;S()}f(")");I(F,i);if(typeof a===
+"object"){a.value==="parseInt"&&d===1&&e("Missing radix parameter.",a);if(!j.evil)if(a.value==="eval"||a.value==="Function"||a.value==="execScript")e("eval is evil.",a);else if(g[0]&&g[0].id==="(string)"&&(a.value==="setTimeout"||a.value==="setInterval"))e("Implied eval is evil. Pass a function instead of a string.",a);!a.identifier&&a.id!=="."&&a.id!=="["&&a.id!=="("&&a.id!=="&&"&&a.id!=="||"&&a.id!=="?"&&e("Bad invocation.",a)}c.left=a;return c},155,true).exps=true;Q("(",function(){I();if(b.id===
+"function")b.immed=true;var a=t(0);f(")",this);I(F,i);if(j.immed&&a.id==="function")b.id==="("?e("Move the invocation into the parens that contain the function.",b):e("Do not wrap function literals in parens unless they are to be immediately invoked.",this);return a});K("[",function(a,c){cb(F,i);I();var d=t(0),g;if(d&&d.type==="(string)"){if(j.safe&&Ra[d.value]===true)e("ADsafe restricted word '{a}'.",c,d.value);else if(!j.evil&&(d.value==="eval"||d.value==="execScript"))e("eval is evil.",c);else if(j.safe&&
+(d.value.charAt(0)==="_"||d.value.charAt(0)==="-"))e("ADsafe restricted subscript '{a}'.",c,d.value);Ma(d.value);if(!j.sub&&qb.test(d.value)){g=O[d.value];if(!g||!g.reserved)e("['{a}'] is better written in dot notation.",d,d.value)}}else if(!d||d.type!=="(number)"||d.value<0)j.safe&&e("ADsafe subscripting.");f("]",c);I(F,i);c.left=a;c.right=d;return c},160,true);Q("[",function(){var a=i.line!==b.line;this.first=[];if(a){C+=j.indent;if(b.from===C+j.indent)C+=j.indent}for(;b.id!=="(end)";){for(;b.id===
+",";){e("Extra comma.");f(",")}if(b.id==="]")break;a&&i.line!==b.line&&U();this.first.push(t(10));if(b.id===","){S();if(b.id==="]"&&!j.es5){e("Extra comma.",i);break}}else break}if(a){C-=j.indent;U()}f("]",this);return this},160);function lb(){var a=eb(true);if(!a)if(b.id==="(string)"){a=b.value;if(j.adsafe&&(a.charAt(0)==="_"||a.charAt(a.length-1)==="_"))e("Unexpected {a} in '{b}'.",i,"dangling '_'",a);f()}else if(b.id==="(number)"){a=b.value.toString();f()}return a}function kc(){var a,c=b,d=[];
+f("(");I();if(b.id===")"){f(")");I(F,i)}else for(;;){a=Aa();d.push(a);ha(a,"parameter");if(b.id===",")S();else{f(")",c);I(F,i);return d}}}function Pa(a,c){var d=B;B=Object.create(d);c=n={"(name)":a||'"'+Qa+'"',"(line)":b.line,"(context)":n,"(breakage)":0,"(loopage)":0,"(scope)":B,"(statement)":c};i.funct=n;va.push(n);a&&ha(a,"function");n["(params)"]=kc();V(false);B=d;n["(last)"]=i.line;n=n["(context)"];return c}(function(a){a.nud=function(){var c,d,g,h,m={};if(c=i.line!==b.line){C+=j.indent;if(b.from===
+C+j.indent)C+=j.indent}for(;;){if(b.id==="}")break;c&&U();if(b.value==="get"&&N().id!==":"){f("get");j.es5||o("get/set are ES5 features.");(g=lb())||o("Missing property name.");h=b;H(i,b);d=Pa(g);n["(loopage)"]&&e("Don't make functions within a loop.",h);(d=d["(params)"])&&e("Unexpected parameter '{a}' in get {b} function.",h,d[0],g);H(i,b);f(",");U();f("set");h=lb();g!==h&&o("Expected {a} and instead saw {b}.",i,g,h);h=b;H(i,b);d=Pa(g);d=d["(params)"];if(!d||d.length!==1||d[0]!=="value")e("Expected (value) in set {a} function.",
+h,g)}else{g=lb();if(typeof g!=="string")break;f(":");y(i,b);t(10)}m[g]===true&&e("Duplicate member '{a}'.",b,g);m[g]=true;Ma(g);if(b.id===","){S();if(b.id===",")e("Extra comma.",i);else b.id==="}"&&!j.es5&&e("Extra comma.",i)}else break}if(c){C-=j.indent;U()}f("}",this);return this};a.fud=function(){o("Expected to see a statement and instead saw a block.",i)}})(E("{"));function mb(a){var c,d;if(n["(onevar)"]&&j.onevar)e("Too many var statements.");else n["(global)"]||(n["(onevar)"]=true);for(this.first=
+[];;){y(i,b);c=Aa();n["(global)"]&&A[c]===false&&e("Redefinition of '{a}'.",i,c);ha(c,"unused");if(a)break;d=i;this.first.push(i);if(b.id==="="){y(i,b);f("=");y(i,b);b.id==="undefined"&&e("It is not necessary to initialize '{a}' to 'undefined'.",i,c);N(0).id==="="&&b.identifier&&o("Variable {a} was not declared correctly.",b,b.value);c=t(0);d.first=c}if(b.id!==",")break;S()}return this}da("var",mb).exps=true;na("function",function(){wa&&e("Function statements cannot be placed in blocks. Use a function expression or move the statement to the top of the outer function.",
+i);var a=Aa();H(i,b);ha(a,"unction");Pa(a,true);b.id==="("&&b.line===i.line&&o("Function statements are not invocable. Wrap the whole function invocation in parens.");return this});Q("function",function(){var a=eb();a?H(i,b):y(i,b);Pa(a);n["(loopage)"]&&e("Don't make functions within a loop.");return this});na("if",function(){var a=b;f("(");y(this,a);I();t(20);if(b.id==="="){e("Expected a conditional expression and instead saw an assignment.");f("=");t(20)}f(")",a);I(F,i);V(true);if(b.id==="else"){y(i,
+b);f("else");b.id==="if"||b.id==="switch"?fb(true):V(true)}return this});na("try",function(){var a,c;j.adsafe&&e("ADsafe try violation.",this);V(false);if(b.id==="catch"){f("catch");y(i,b);f("(");c=B;B=Object.create(c);a=b.value;b.type!=="(identifier)"?e("Expected an identifier and instead saw '{a}'.",b,a):ha(a,"exception");f();f(")");V(false);a=true;B=c}if(b.id==="finally"){f("finally");V(false)}else{a||o("Expected '{a}' and instead saw '{b}'.",b,"catch",b.value);return this}});na("while",function(){var a=
+b;n["(breakage)"]+=1;n["(loopage)"]+=1;f("(");y(this,a);I();t(20);if(b.id==="="){e("Expected a conditional expression and instead saw an assignment.");f("=");t(20)}f(")",a);I(F,i);V(true);n["(breakage)"]-=1;n["(loopage)"]-=1;return this}).labelled=true;z("with");na("switch",function(){var a=b,c=false;n["(breakage)"]+=1;f("(");y(this,a);I();this.condition=t(20);f(")",a);I(F,i);y(i,b);a=b;f("{");y(i,b);C+=j.indent;for(this.cases=[];;)switch(b.id){case "case":switch(n["(verb)"]){case "break":case "case":case "continue":case "return":case "switch":case "throw":break;
+default:e("Expected a 'break' statement before 'case'.",i)}U(-j.indent);f("case");this.cases.push(t(20));c=true;f(":");n["(verb)"]="case";break;case "default":switch(n["(verb)"]){case "break":case "continue":case "return":case "throw":break;default:e("Expected a 'break' statement before 'default'.",i)}U(-j.indent);f("default");c=true;f(":");break;case "}":C-=j.indent;U();f("}",a);if(this.cases.length===1||this.condition.id==="true"||this.condition.id==="false")e("This 'switch' should be an 'if'.",
+this);n["(breakage)"]-=1;n["(verb)"]=undefined;return;case "(end)":o("Missing '{a}'.",b,"}");return;default:if(c)switch(i.id){case ",":o("Each value should have its own case label.");return;case ":":Ba();break;default:o("Missing ':' on a case clause.",i)}else o("Expected '{a}' and instead saw '{b}'.",b,"case",b.value)}}).labelled=true;da("debugger",function(){j.debug||e("All 'debugger' statements should be removed.");return this}).exps=true;(function(){var a=da("do",function(){n["(breakage)"]+=1;
+n["(loopage)"]+=1;this.first=V(true);f("while");var c=b;y(i,c);f("(");I();t(20);if(b.id==="="){e("Expected a conditional expression and instead saw an assignment.");f("=");t(20)}f(")",c);I(F,i);n["(breakage)"]-=1;n["(loopage)"]-=1;return this});a.labelled=true;a.exps=true})();na("for",function(){var a=j.forin,c;c=b;n["(breakage)"]+=1;n["(loopage)"]+=1;f("(");y(this,c);I();if(N(b.id==="var"?1:0).id==="in"){if(b.id==="var"){f("var");mb(true)}else{switch(n[b.value]){case "unused":n[b.value]="var";break;
+case "var":break;default:e("Bad for in variable '{a}'.",b,b.value)}f()}f("in");t(20);f(")",c);c=V(true);if(!a&&(c.length>1||typeof c[0]!=="object"||c[0].value!=="if"))e("The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.",this)}else{if(b.id!==";")if(b.id==="var"){f("var");mb()}else for(;;){t(0,"for");if(b.id!==",")break;S()}ba(i);f(";");if(b.id!==";"){t(20);if(b.id==="="){e("Expected a conditional expression and instead saw an assignment.");
+f("=");t(20)}}ba(i);f(";");b.id===";"&&o("Expected '{a}' and instead saw '{b}'.",b,")",";");if(b.id!==")")for(;;){t(0,"for");if(b.id!==",")break;S()}f(")",c);I(F,i);V(true)}n["(breakage)"]-=1;n["(loopage)"]-=1;return this}).labelled=true;da("break",function(){var a=b.value;n["(breakage)"]===0&&e("Unexpected '{a}'.",b,this.value);ba(this);if(b.id!==";")if(i.line===b.line){if(n[a]!=="label")e("'{a}' is not a statement label.",b,a);else B[a]!==n&&e("'{a}' is out of scope.",b,a);this.first=b;f()}La("break");
+return this}).exps=true;da("continue",function(){var a=b.value;n["(breakage)"]===0&&e("Unexpected '{a}'.",b,this.value);ba(this);if(b.id!==";"){if(i.line===b.line){if(n[a]!=="label")e("'{a}' is not a statement label.",b,a);else B[a]!==n&&e("'{a}' is out of scope.",b,a);this.first=b;f()}}else n["(loopage)"]||e("Unexpected '{a}'.",b,this.value);La("continue");return this}).exps=true;da("return",function(){ba(this);b.id==="(regexp)"&&e("Wrap the /regexp/ literal in parens to disambiguate the slash operator.");
+if(b.id!==";"&&!b.reach){y(i,b);this.first=t(20)}La("return");return this}).exps=true;da("throw",function(){ba(this);y(i,b);this.first=t(20);La("throw");return this}).exps=true;z("void");z("class");z("const");z("enum");z("export");z("extends");z("import");z("super");z("let");z("yield");z("implements");z("interface");z("package");z("private");z("protected");z("public");z("static");function nb(){function a(){var d={},g=b;f("{");if(b.id!=="}")for(;;){if(b.id==="(end)")o("Missing '}' to match '{' from line {a}.",
+b,g.line);else if(b.id==="}"){e("Unexpected comma.",i);break}else if(b.id===",")o("Unexpected comma.",b);else b.id!=="(string)"&&e("Expected a string and instead saw {a}.",b,b.value);if(d[b.value]===true)e("Duplicate key '{a}'.",b,b.value);else if(b.value==="__proto__")e("Stupid key '{a}'.",b,b.value);else d[b.value]=true;f();f(":");nb();if(b.id!==",")break;f(",")}f("}")}function c(){var d=b;f("[");if(b.id!=="]")for(;;){if(b.id==="(end)")o("Missing ']' to match '[' from line {a}.",b,d.line);else if(b.id===
+"]"){e("Unexpected comma.",i);break}else b.id===","&&o("Unexpected comma.",b);nb();if(b.id!==",")break;f(",")}f("]")}switch(b.id){case "{":a();break;case "[":c();break;case "true":case "false":case "null":case "(number)":case "(string)":f();break;case "-":f("-");i.character!==b.from&&e("Unexpected space after '-'.",i);H(i,b);f("(number)");break;default:o("Expected a JSON value.",b)}}function $(a,c){var d,g;JSLINT.errors=[];A=Object.create(Kb);if(c){d=c.predef;if(d instanceof Array)for(g=0;g<d.length;g+=
+1)A[d[g]]=true;if(c.adsafe)c.safe=true;if(c.safe){c.browser=c.css=c.debug=c.devel=c.evil=c.forin=c.on=c.rhino=c.windows=c.sub=c.widget=false;c.eqeqeq=c.nomen=c.safe=c.strict=c.undef=true;A.Date=A.eval=A.Function=A.Object=null;A.ADSAFE=A.lib=false}j=c}else j={};j.indent=j.indent||4;j.maxerr=j.maxerr||50;R="";sa=ja=false;Da={};if(j.approved)for(g=0;g<j.approved.length;g+=1)Da[j.approved[g]]=j.approved[g];else Da.test="test";Wa="";for(g=0;g<j.indent;g+=1)Wa+=" ";C=1;B=pb=Object.create(A);n={"(global)":true,
+"(name)":"(global)","(scope)":B,"(breakage)":0,"(loopage)":0};va=[n];Fa={};ya=[];q=Ha=false;J=null;fa={};ga=null;aa={};wa=false;Ga=[];la=false;Xa=0;X.init(a);Va=true;Ia=false;F=i=b=O["(begin)"];$a();try{f();if(b.value.charAt(0)==="<"){jc();j.adsafe&&!sa&&e("ADsafe violation: Missing ADSAFE.go.",this)}else switch(b.id){case "{":case "[":la=j.laxbreak=true;nb();break;case "@":case "*":case "#":case ".":case ":":q="style";f();if(i.id!=="@"||!b.identifier||b.value!=="charset"||i.line!==1||i.from!==1)o("A css file should begin with @charset 'UTF-8';");
+f();b.type!=="(string)"&&b.value!=="UTF-8"&&o("A css file should begin with @charset 'UTF-8';");f();f(";");zb();break;default:j.adsafe&&j.fragment&&o("Expected '{a}' and instead saw '{b}'.",b,"<div>",b.value);Ba("lib")}f("(end)")}catch(h){if(h)JSLINT.errors.push({reason:h.message,line:h.line||b.line,character:h.character||b.from},null)}return JSLINT.errors.length===0}function lc(a){return Object.prototype.toString.apply(a)==="[object Array]"}function Ab(a){var c=[],d;for(d in a)T(a,d)&&c.push(d);
+return c}$.data=function(){var a={functions:[]},c;c=[];var d,g,h,m,u=[];if($.errors.length)a.errors=$.errors;if(la)a.json=true;for(m in aa)T(aa,m)&&c.push({name:m,line:aa[m]});if(c.length>0)a.implieds=c;if(ya.length>0)a.urls=ya;c=Ab(B);if(c.length>0)a.globals=c;for(g=1;g<va.length;g+=1){d=va[g];c={};for(h=0;h<ua.length;h+=1)c[ua[h]]=[];for(m in d)if(T(d,m)&&m.charAt(0)!=="("){h=d[m];if(h==="unction")h="unused";if(lc(c[h])){c[h].push(m);h==="unused"&&u.push({name:m,line:d["(line)"],"function":d["(name)"]})}}for(h=
+0;h<ua.length;h+=1)c[ua[h]].length===0&&delete c[ua[h]];c.name=d["(name)"];c.param=d["(params)"];c.line=d["(line)"];c.last=d["(last)"];a.functions.push(c)}if(u.length>0)a.unused=u;for(m in fa)if(typeof fa[m]==="number"){a.member=fa;break}return a};$.report=function(a){var c=$.data(),d=[],g,h,m;g="";var u,p=[];function k(s,v){var l,w;if(v){p.push("<div><i>"+s+"</i> ");v=v.sort();for(s=0;s<v.length;s+=1)if(v[s]!==w){w=v[s];p.push((l?", ":"")+w);l=true}p.push("</div>")}}if(c.errors||c.implieds||c.unused){h=
+true;p.push("<div id=errors><i>Error:</i>");if(c.errors)for(m=0;m<c.errors.length;m+=1)if(d=c.errors[m]){g=d.evidence||"";p.push("<p>Problem"+(isFinite(d.line)?" at line "+d.line+" character "+d.character:"")+": "+d.reason.entityify()+"</p><p class=evidence>"+(g&&(g.length>80?g.slice(0,77)+"...":g).entityify())+"</p>")}if(c.implieds){d=[];for(m=0;m<c.implieds.length;m+=1)d[m]="<code>"+c.implieds[m].name+"</code>&nbsp;<i>"+c.implieds[m].line+"</i>";p.push("<p><i>Implied global:</i> "+d.join(", ")+
+"</p>")}if(c.unused){d=[];for(m=0;m<c.unused.length;m+=1)d[m]="<code><u>"+c.unused[m].name+"</u></code>&nbsp;<i>"+c.unused[m].line+"</i> <code>"+c.unused[m]["function"]+"</code>";p.push("<p><i>Unused variable:</i> "+d.join(", ")+"</p>")}c.json&&p.push("<p>JSON: bad.</p>");p.push("</div>")}if(!a){p.push("<br><div id=functions>");c.urls&&k("URLs<br>",c.urls,"<br>");if(q==="style")p.push("<p>CSS.</p>");else if(c.json&&!h)p.push("<p>JSON: good.</p>");else c.globals?p.push("<div><i>Global</i> "+c.globals.sort().join(", ")+
+"</div>"):p.push("<div><i>No new global variables introduced.</i></div>");for(m=0;m<c.functions.length;m+=1){a=c.functions[m];p.push("<br><div class=function><i>"+a.line+"-"+a.last+"</i> "+(a.name||"")+"("+(a.param?a.param.join(", "):"")+")</div>");k("<big><b>Unused</b></big>",a.unused);k("Closure",a.closure);k("Variable",a["var"]);k("Exception",a.exception);k("Outer",a.outer);k("Global",a.global);k("Label",a.label)}if(c.member){d=Ab(c.member);if(d.length){d=d.sort();g="<br><pre id=members>/*members ";
+h=10;for(m=0;m<d.length;m+=1){a=d[m];u=a.name();if(h+u.length>72){p.push(g+"<br>");g=" ";h=1}h+=u.length+2;if(c.member[a]===1)u="<i>"+u+"</i>";if(m<d.length-1)u+=", ";g+=u}p.push(g+"<br>*/</pre>")}p.push("</div>")}}return p.join("")};$.jslint=$;$.edition="2010-10-26";return $}();
171 jslint.cpp
@@ -0,0 +1,171 @@
+/*
+ Copyright (c) 2010 Jorge Falcão basead in js-beautify code
+ */
+
+#include <v8.h>
+
+#include <string.h>
+
+#include "jslint.h"
+#include "v8.h"
+
+using namespace v8;
+
+Handle<String> readFile(const char* name) {
+ FILE* file = fopen(name, "rb");
+
+ if (file == NULL) {
+ return Handle<String>();
+ }
+
+ fseek(file, 0, SEEK_END);
+ int len = ftell(file);
+ rewind(file);
+
+ char* buf = new char[len + 1];
+ buf[len] = '\0';
+
+ fread(buf, 1, len, file);
+
+ fclose(file);
+
+ Handle<String> result = String::New(buf);
+
+ delete[] buf;
+
+ return result;
+}
+
+// Extracts a C string from a V8 Utf8Value.
+const char* ToCString(const v8::String::Utf8Value& value) {
+ return *value ? *value : "<string conversion failed>";
+}
+
+// The callback that is invoked by v8 whenever the JavaScript 'print'
+// function is called. Prints its arguments on stdout separated by
+// spaces and ending with a newline.
+v8::Handle<v8::Value> Print(const v8::Arguments& args) {
+ bool first = true;
+ for (int i = 0; i < args.Length(); i++) {
+ v8::HandleScope handle_scope;
+ if (first) {
+ first = false;
+ } else {
+ printf(" ");
+ }
+ v8::String::Utf8Value str(args[i]);
+ const char* cstr = ToCString(str);
+ printf("%s", cstr);
+ }
+ printf("\n");
+ fflush(stdout);
+ return v8::Undefined();
+}
+
+
+static void usage(char* progname)
+{
+
+ printf("Usage: %s [options] source-file\n", progname);
+ printf("See: http://www.JSLint.com/lint.html\n");
+ printf("default selected: --bitwise --eqeqeq --immed --newcap --nomen --onevar --regexp --undef --white\n");
+ printf("[options]\n");
+ printf(" --adsafe : ADsafe\n");
+ printf(" --bitwise : Disallow bitwise operator.\n");
+ printf(" --browser : Assume a browser.\n");
+ printf(" --cap : Tolerate HTML case.\n");
+ printf(" --css : Tolerate CSS workarounds.\n");
+ printf(" --debug : Tolerate debugger statements.\n");
+ printf(" --devel : Assume console, alert, ...\n");
+ printf(" --eqeqeq : Disallow == and !=\n");
+ printf(" --es5 : Tolerate ES5 syntax\n");
+ printf(" --evil : Tolerate eval\n");
+ printf(" --forin : Tolerate unfiltered for in.\n");
+ printf(" --fragment : Tolerate HTML fragments.\n");
+ printf(" --immed : Require parens around immediate invocations.\n");
+ printf(" --indent : Strict white space indentation.\n");
+ printf(" --laxbreak : Tolerate sloppy line breaking.\n");
+ printf(" --maxerr : Maximum number of errors.\n");
+ printf(" --maxlen : Maximum line length.\n");
+ printf(" --nomen : Disallow dangling _ in identifiers.\n");
+ printf(" --newcap : Require Initial Caps for constructors on Tolerate HTML event handlers.\n");
+ printf(" --onevar : Allow one var statement per function.\n");
+ printf(" --passfail : Stop on first error.\n");
+ printf(" --plusplus : Disallow ++ and --.\n");
+ printf(" --predef : Predefined ( , separated).\n");
+ printf(" --regexp : Disallow insecure . and [^...]. in /RegExp/.\n");
+ printf(" --rhino : Assume Rhino.\n");
+ printf(" --safe : Safe Subset .\n");
+ printf(" --strict : Require \"use strict\";.\n");
+ printf(" --sub : Tolerate inefficient subscripting.\n");
+ printf(" --undef : Disallow undefined variables.\n");
+ printf(" --white : Strict white space.\n");
+ printf(" --widget : Assume a Yahoo Widget.\n");
+ printf(" --windows : AssumeWindows.\n");
+}
+
+int main(int argc, char* argv[])
+{
+ Handle<String> source;
+ HandleScope handle_scope;
+
+ Handle<ObjectTemplate> global = ObjectTemplate::New();
+ Handle<ObjectTemplate> options = ObjectTemplate::New();
+
+ bool overwrite = false;
+ const char* output = 0;
+ bool some_parameter = false;
+
+ for (int argpos = 1; argpos < argc; ++argpos) {
+ if (argv[argpos][0] != '-') {
+ source = readFile(argv[argpos]);
+ output = argv[argpos];
+
+ } else if (strcmp(argv[argpos], "--help") == 0 ||
+ strcmp(argv[argpos], "-h") == 0) {
+ usage(argv[0]);
+ return -1;
+ } else if (strncmp(argv[argpos], "--", 2) == 0) {
+ // TODO: check if is valid.
+ some_parameter = true;
+ options->Set(argv[argpos]+2, Boolean::New(true));
+ }
+ }
+
+ if (source.IsEmpty()) {
+ usage(argv[0]);
+ return -1;
+ }
+
+ if (!some_parameter) {
+ options->Set("bitwise", Boolean::New(true));
+ options->Set("eqeqeq", Boolean::New(true));
+ options->Set("immed", Boolean::New(true));
+ options->Set("newcap", Boolean::New(true));
+ options->Set("nomen", Boolean::New(true));
+ options->Set("onevar", Boolean::New(true));
+ options->Set("regexp", Boolean::New(true));
+ options->Set("undef", Boolean::New(true));
+ options->Set("white", Boolean::New(true));
+ }
+
+ global->Set(v8::String::New("print"), v8::FunctionTemplate::New(Print));
+ global->Set("source", source);
+ global->Set("options", options);
+
+ Handle<Context> context = Context::New(NULL, global);
+
+ Context::Scope context_scope(context);
+
+ Handle<Script> beautifyScript = Script::Compile(String::New(jslint_code));
+ beautifyScript->Run();
+
+ Handle<Script> runnerScript = Script::Compile(String::New("JSLINT(source, options);"));
+ Handle<Value> result = runnerScript->Run();
+
+ Handle<Script> printScript = Script::Compile(String::New(v8_code));
+ printScript->Run();
+
+ return 0;
+}
+
4,241 jslint.h
4,241 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
23 v8.h
@@ -0,0 +1,23 @@
+const char v8_code[] = {0xA,
+0x66,0x6F,0x72,0x20,0x28,0x69,0x20,0x3D,0x20,0x30,0x3B,0x20,0x69,0x20,0x3C,0x20,
+0x4A,0x53,0x4C,0x49,0x4E,0x54,0x2E,0x65,0x72,0x72,0x6F,0x72,0x73,0x2E,0x6C,0x65,
+0x6E,0x67,0x74,0x68,0x3B,0x20,0x69,0x20,0x2B,0x3D,0x20,0x31,0x29,0x20,0x7B,0xA,
+0x20,0x20,0x20,0x20,0x65,0x20,0x3D,0x20,0x4A,0x53,0x4C,0x49,0x4E,0x54,0x2E,0x65,
+0x72,0x72,0x6F,0x72,0x73,0x5B,0x69,0x5D,0x3B,0xA,0x20,0x20,0x20,0x20,0x69,0x66,
+0x20,0x28,0x65,0x29,0x20,0x7B,0xA,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x70,
+0x72,0x69,0x6E,0x74,0x28,0x27,0x4C,0x69,0x6E,0x74,0x20,0x61,0x74,0x20,0x6C,0x69,
+0x6E,0x65,0x20,0x27,0x20,0x2B,0x20,0x65,0x2E,0x6C,0x69,0x6E,0x65,0x20,0x2B,0x20,
+0x27,0x20,0x63,0x68,0x61,0x72,0x61,0x63,0x74,0x65,0x72,0x20,0x27,0x20,0x2B,0xA,
+0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
+0x65,0x2E,0x63,0x68,0x61,0x72,0x61,0x63,0x74,0x65,0x72,0x20,0x2B,0x20,0x27,0x3A,
+0x20,0x27,0x20,0x2B,0x20,0x65,0x2E,0x72,0x65,0x61,0x73,0x6F,0x6E,0x29,0x3B,0xA,
+0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x70,0x72,0x69,0x6E,0x74,0x28,0x28,0x65,
+0x2E,0x65,0x76,0x69,0x64,0x65,0x6E,0x63,0x65,0x20,0x7C,0x7C,0x20,0x27,0x27,0x29,
+0x2E,0xA,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
+0x20,0x20,0x72,0x65,0x70,0x6C,0x61,0x63,0x65,0x28,0x2F,0x5E,0x5C,0x73,0x2A,0x28,
+0x5C,0x53,0x2A,0x28,0x5C,0x73,0x2B,0x5C,0x53,0x2B,0x29,0x2A,0x29,0x5C,0x73,0x2A,
+0x24,0x2F,0x2C,0x20,0x22,0x24,0x31,0x22,0x29,0x29,0x3B,0xA,0x20,0x20,0x20,0x20,
+0x20,0x20,0x20,0x20,0x70,0x72,0x69,0x6E,0x74,0x28,0x27,0x27,0x29,0x3B,0xA,0x20,
+0x20,0x20,0x20,0x7D,0xA,0x7D,0xA,0x00
+
+};
11 v8.js
@@ -0,0 +1,11 @@
+
+for (i = 0; i < JSLINT.errors.length; i += 1) {
+ e = JSLINT.errors[i];
+ if (e) {
+ print('Lint at line ' + e.line + ' character ' +
+ e.character + ': ' + e.reason);
+ print((e.evidence || '').
+ replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"));
+ print('');
+ }
+}

0 comments on commit 16fc013

Please sign in to comment.
Something went wrong with that request. Please try again.