/*
 JavaScript Preprocessor v0.33

 Licensed under the new BSD License.
 Copyright 2009, Bram Stein
 All rights reserved.
*/
var preprocess=function(b,e){var l=[],m=function(g){function f(h,o,n){return{id:h,value:o,position:n,toString:function(){return this.id+' = "'+this.value+'", at: '+this.position+"\n"}}}var c=/^\s*#(ifdef|ifndef|endif|else|define|undef|.*)\s*(\w*)$/,d=0,j;return{hasNext:function(){return d<g.length},next:function(){if(d<g.length){j=c.exec(g[d]);d+=1;return j?f(j[1],j[2],d):f("line",g[d-1],d)}return false}}};l=typeof b==="string"?b.replace(/\r\n/g,"\n").replace(/\r/g,"\n").split("\n"):b;return function(g,
f){function c(){for(var i=0,p=k.length,s=true;i<p;i+=1)s=s&&k[i];return s}function d(){var i=a.id==="ifndef",p=a.value;!i&&q[p]||i&&!q[p]?k.push(true):k.push(false);n();k.pop();if(a.id==="else"){!i&&!q[p]||i&&q[p]?k.push(true):k.push(false);n();k.pop()}if(a.id==="endif")return true;throw"Missing #endif at line: "+r.position;}function j(){var i=a.value;if(a.id==="define"&&c())q[i]=true;else c()&&delete q[i];return true}function h(){c()&&t.push(a.value);return true}function o(){r=a;if(a=u.next())if(a.id===
"ifdef"||a.id==="ifndef")return d();else if(a.id==="define"||a.id==="undef")return j();else if(a.id==="line")return h();return false}function n(){for(;o(););return true}var r,a,u=m(g),t=[],k=[],q=Object.prototype.toString.apply(f)==="[object Object]"&&f||{};return{parse:function(){k.push(true);n();if(u.hasNext()||a.id==="else")throw'Unexpected statement: "'+a.id+'" at line: '+a.position;k.pop();return t}}}(l,e).parse()};
if(typeof self!=="undefined"&&typeof self.getTaskName!=="undefined"&&self.getTaskName()+""==="preprocess"){var ant=function(){importClass(java.io.FileWriter);importClass(java.io.File);importClass(Packages.org.apache.tools.ant.util.FileUtils);importClass(java.io.FileReader);var b=attributes.get("defines"),e=attributes.get("todir"),l=attributes.get("file"),m=attributes.get("tofile"),g=elements.get("fileset"),f=[],c=0,d=0,j=0,h=[],o={},n=function(a){return""+FileUtils.readFully(new FileReader(a)).toString()};
h=[];for(b=(b+"").split(/,\s?/);j<b.length;j+=1)o[b[j]]=true;if(l)m||e?f.push({src:new File(project.getBaseDir(),l),dst:new File(project.getBaseDir(),m||e)}):self.fail('Please specify a destination using either the "tofile" or "todir" attribute.');else if(g)if(e)for(;c<g.size();c+=1){b=g.get(c);for(h=b.getDirectoryScanner(project).getIncludedFiles();d<h.length;d+=1)f.push({src:new File(b.getDir(project),h[d]),dst:new File(new File(project.getBaseDir(),e),h[d])})}else self.fail('Please specify a destination using the "todir" attribute.');
for(c=0;c<f.length;c+=1){h=[];self.log("Preprocessing: "+f[c].dst.toString());try{h=preprocess(n(f[c].src),o)}catch(r){self.fail(r)}f[c].dst.getParentFile().mkdirs();e=new FileWriter(f[c].dst);e.write(h.join("\n"));e.close()}};ant()}
if(typeof arguments!=="undefined"&&typeof readFile!=="undefined"){var cmd=function(b){var e,l={},m=1;if(!b[0]){print("Usage: js-preprocess.js file.js [defines, ...]");return 1}e=readFile(b[0]);if(!e){print("preprocess: Couldn't open file \""+b[0]+'".');return 1}for(;m<b.length;m+=1)l[b[m]]=true;try{print(preprocess(e,l).join("\n"))}catch(g){print(g);return 2}return 0};cmd(arguments)};

