Refining syntax, reducing jslint warnings

This commit is contained in:
Tom MacWright 2011-08-22 17:19:11 -04:00
parent cbc34d3fbb
commit 19e77cd8ab
4 changed files with 32 additions and 14 deletions

View File

@ -1,10 +1,10 @@
#!/usr/bin/env node
var path = require('path');
var fs = require('fs');
var sys = require('sys');
var path = require('path'),
fs = require('fs'),
sys = require('sys'),
carto = require('carto');
var carto = require('carto');
var args = process.argv.slice(1);
var options = {};
@ -102,6 +102,10 @@ function compile(err, data) {
}
});
} catch (e) {
sys.error(e);
if (e.stack) {
sys.error(e.stack);
} else {
sys.error(e);
}
}
};

View File

@ -123,7 +123,8 @@ carto.Parser = function Parser(env) {
} else {
sync();
if (match = tok.exec(chunks[j])) {
match = tok.exec(chunks[j]);
if (match) {
length = match[0].length;
} else {
return null;
@ -187,7 +188,7 @@ carto.Parser = function Parser(env) {
err.line = (input.slice(0, err.index).match(/\n/g) || '').length + 1;
for (var n = err.index; n >= 0 && input.charAt(n) !== '\n'; n--) {
err.column++;
};
}
return new Error(_('<%=filename%>:<%=line%>:<%=column%> <%=message%>').template(err));
}

View File

@ -3,7 +3,7 @@
*/
module.exports.find = function (obj, fun) {
for (var i = 0, r; i < obj.length; i++) {
if (r = fun.call(obj, obj[i])) { return r }
if (r = fun.call(obj, obj[i])) { return r; }
}
return null;
};

View File

@ -13,13 +13,26 @@ tree.Zoom = function(op, value, index) {
};
}
var start = 0, end = Infinity, zoom = 0;
var start = 0,
end = Infinity,
zoom = 0;
switch (op) {
case '=': return 1 << value; break;
case '>': start = value + 1; break;
case '>=': start = value; break;
case '<': end = value - 1; break;
case '<=': end = value; break;
case '=':
return 1 << value;
break;
case '>':
start = value + 1;
break;
case '>=':
start = value;
break;
case '<':
end = value - 1;
break;
case '<=':
end = value;
break;
}
for (var i = 0; i <= tree.Zoom.maxZoom; i++) {
if (i >= start && i <= end) {