update worker dependencies

This commit is contained in:
nightwing 2012-08-31 14:02:02 +04:00
commit ec524419ce
9 changed files with 2703 additions and 1820 deletions

View file

@ -1,5 +1,5 @@
/* /**
* Copyright (c) 2011 Jeremy Ashkenas * Copyright (c) 2009-2012 Jeremy Ashkenas
* *
* Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation * obtaining a copy of this software and associated documentation
@ -24,9 +24,9 @@
*/ */
define(function(require, exports, module) { define(function(require, exports, module) {
// Generated by CoffeeScript 1.2.1-pre // Generated by CoffeeScript 1.3.3
var extend, flatten; var extend, flatten, _ref;
exports.starts = function(string, literal, start) { exports.starts = function(string, literal, start) {
return literal === string.substr(start, literal.length); return literal === string.substr(start, literal.length);
@ -43,7 +43,9 @@ define(function(require, exports, module) {
_results = []; _results = [];
for (_i = 0, _len = array.length; _i < _len; _i++) { for (_i = 0, _len = array.length; _i < _len; _i++) {
item = array[_i]; item = array[_i];
if (item) _results.push(item); if (item) {
_results.push(item);
}
} }
return _results; return _results;
}; };
@ -51,7 +53,9 @@ define(function(require, exports, module) {
exports.count = function(string, substr) { exports.count = function(string, substr) {
var num, pos; var num, pos;
num = pos = 0; num = pos = 0;
if (!substr.length) return 1 / 0; if (!substr.length) {
return 1 / 0;
}
while (pos = 1 + string.indexOf(substr, pos)) { while (pos = 1 + string.indexOf(substr, pos)) {
num++; num++;
} }
@ -96,5 +100,16 @@ define(function(require, exports, module) {
return array[array.length - (back || 0) - 1]; return array[array.length - (back || 0) - 1];
}; };
exports.some = (_ref = Array.prototype.some) != null ? _ref : function(fn) {
var e, _i, _len;
for (_i = 0, _len = this.length; _i < _len; _i++) {
e = this[_i];
if (fn(e)) {
return true;
}
}
return false;
};
});
});

View file

@ -1,5 +1,5 @@
/* /**
* Copyright (c) 2011 Jeremy Ashkenas * Copyright (c) 2009-2012 Jeremy Ashkenas
* *
* Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation * obtaining a copy of this software and associated documentation
@ -24,7 +24,7 @@
*/ */
define(function(require, exports, module) { define(function(require, exports, module) {
// Generated by CoffeeScript 1.2.1-pre // Generated by CoffeeScript 1.3.3
var BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, key, last, starts, _ref, _ref1, var BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, key, last, starts, _ref, _ref1,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
@ -35,14 +35,16 @@ define(function(require, exports, module) {
exports.Lexer = Lexer = (function() { exports.Lexer = Lexer = (function() {
Lexer.name = 'Lexer';
function Lexer() {} function Lexer() {}
Lexer.prototype.tokenize = function(code, opts) { Lexer.prototype.tokenize = function(code, opts) {
var i, tag; var i, tag;
if (opts == null) opts = {}; if (opts == null) {
if (WHITESPACE.test(code)) code = "\n" + code; opts = {};
}
if (WHITESPACE.test(code)) {
code = "\n" + code;
}
code = code.replace(/\r/g, '').replace(TRAILING_SPACES, ''); code = code.replace(/\r/g, '').replace(TRAILING_SPACES, '');
this.code = code; this.code = code;
this.line = opts.line || 0; this.line = opts.line || 0;
@ -57,14 +59,20 @@ define(function(require, exports, module) {
i += this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.heredocToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken(); i += this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.heredocToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken();
} }
this.closeIndentation(); this.closeIndentation();
if (tag = this.ends.pop()) this.error("missing " + tag); if (tag = this.ends.pop()) {
if (opts.rewrite === false) return this.tokens; this.error("missing " + tag);
}
if (opts.rewrite === false) {
return this.tokens;
}
return (new Rewriter).rewrite(this.tokens); return (new Rewriter).rewrite(this.tokens);
}; };
Lexer.prototype.identifierToken = function() { Lexer.prototype.identifierToken = function() {
var colon, forcedIdentifier, id, input, match, prev, tag, _ref2, _ref3; var colon, forcedIdentifier, id, input, match, prev, tag, _ref2, _ref3;
if (!(match = IDENTIFIER.exec(this.chunk))) return 0; if (!(match = IDENTIFIER.exec(this.chunk))) {
return 0;
}
input = match[0], id = match[1], colon = match[2]; input = match[0], id = match[1], colon = match[2];
if (id === 'own' && this.tag() === 'FOR') { if (id === 'own' && this.tag() === 'FOR') {
this.token('OWN', id); this.token('OWN', id);
@ -105,7 +113,9 @@ define(function(require, exports, module) {
} }
} }
if (!forcedIdentifier) { if (!forcedIdentifier) {
if (__indexOf.call(COFFEE_ALIASES, id) >= 0) id = COFFEE_ALIAS_MAP[id]; if (__indexOf.call(COFFEE_ALIASES, id) >= 0) {
id = COFFEE_ALIAS_MAP[id];
}
tag = (function() { tag = (function() {
switch (id) { switch (id) {
case '!': case '!':
@ -118,8 +128,6 @@ define(function(require, exports, module) {
return 'LOGIC'; return 'LOGIC';
case 'true': case 'true':
case 'false': case 'false':
case 'null':
case 'undefined':
return 'BOOL'; return 'BOOL';
case 'break': case 'break':
case 'continue': case 'continue':
@ -130,29 +138,33 @@ define(function(require, exports, module) {
})(); })();
} }
this.token(tag, id); this.token(tag, id);
if (colon) this.token(':', ':'); if (colon) {
this.token(':', ':');
}
return input.length; return input.length;
}; };
Lexer.prototype.numberToken = function() { Lexer.prototype.numberToken = function() {
var binaryLiteral, lexedLength, match, number, octalLiteral; var binaryLiteral, lexedLength, match, number, octalLiteral;
if (!(match = NUMBER.exec(this.chunk))) return 0; if (!(match = NUMBER.exec(this.chunk))) {
return 0;
}
number = match[0]; number = match[0];
if (/E/.test(number)) { if (/^0[BOX]/.test(number)) {
this.error("exponential notation '" + number + "' must be indicated with a lowercase 'e'");
} else if (/[BOX]/.test(number)) {
this.error("radix prefix '" + number + "' must be lowercase"); this.error("radix prefix '" + number + "' must be lowercase");
} else if (/^0[89]/.test(number)) { } else if (/E/.test(number) && !/^0x/.test(number)) {
this.error("exponential notation '" + number + "' must be indicated with a lowercase 'e'");
} else if (/^0\d*[89]/.test(number)) {
this.error("decimal literal '" + number + "' must not be prefixed with '0'"); this.error("decimal literal '" + number + "' must not be prefixed with '0'");
} else if (/^0[0-7]/.test(number)) { } else if (/^0\d+/.test(number)) {
this.error("octal literal '" + number + "' must be prefixed with '0o'"); this.error("octal literal '" + number + "' must be prefixed with '0o'");
} }
lexedLength = number.length; lexedLength = number.length;
if (octalLiteral = /0o([0-7]+)/.exec(number)) { if (octalLiteral = /^0o([0-7]+)/.exec(number)) {
number = (parseInt(octalLiteral[1], 8)).toString(); number = '0x' + (parseInt(octalLiteral[1], 8)).toString(16);
} }
if (binaryLiteral = /0b([01]+)/.exec(number)) { if (binaryLiteral = /^0b([01]+)/.exec(number)) {
number = (parseInt(binaryLiteral[1], 2)).toString(); number = '0x' + (parseInt(binaryLiteral[1], 2)).toString(16);
} }
this.token('NUMBER', number); this.token('NUMBER', number);
return lexedLength; return lexedLength;
@ -162,11 +174,15 @@ define(function(require, exports, module) {
var match, octalEsc, string; var match, octalEsc, string;
switch (this.chunk.charAt(0)) { switch (this.chunk.charAt(0)) {
case "'": case "'":
if (!(match = SIMPLESTR.exec(this.chunk))) return 0; if (!(match = SIMPLESTR.exec(this.chunk))) {
return 0;
}
this.token('STRING', (string = match[0]).replace(MULTILINER, '\\\n')); this.token('STRING', (string = match[0]).replace(MULTILINER, '\\\n'));
break; break;
case '"': case '"':
if (!(string = this.balancedString(this.chunk, '"'))) return 0; if (!(string = this.balancedString(this.chunk, '"'))) {
return 0;
}
if (0 < string.indexOf('#{', 1)) { if (0 < string.indexOf('#{', 1)) {
this.interpolateString(string.slice(1, -1)); this.interpolateString(string.slice(1, -1));
} else { } else {
@ -176,7 +192,7 @@ define(function(require, exports, module) {
default: default:
return 0; return 0;
} }
if (octalEsc = /^(?:\\.|[^\\])*\\[0-7]/.test(string)) { if (octalEsc = /^(?:\\.|[^\\])*\\(?:0[0-7]|[1-7])/.test(string)) {
this.error("octal escape sequences " + string + " are not allowed"); this.error("octal escape sequences " + string + " are not allowed");
} }
this.line += count(string, '\n'); this.line += count(string, '\n');
@ -185,7 +201,9 @@ define(function(require, exports, module) {
Lexer.prototype.heredocToken = function() { Lexer.prototype.heredocToken = function() {
var doc, heredoc, match, quote; var doc, heredoc, match, quote;
if (!(match = HEREDOC.exec(this.chunk))) return 0; if (!(match = HEREDOC.exec(this.chunk))) {
return 0;
}
heredoc = match[0]; heredoc = match[0];
quote = heredoc.charAt(0); quote = heredoc.charAt(0);
doc = this.sanitizeHeredoc(match[2], { doc = this.sanitizeHeredoc(match[2], {
@ -205,7 +223,9 @@ define(function(require, exports, module) {
Lexer.prototype.commentToken = function() { Lexer.prototype.commentToken = function() {
var comment, here, match; var comment, here, match;
if (!(match = this.chunk.match(COMMENT))) return 0; if (!(match = this.chunk.match(COMMENT))) {
return 0;
}
comment = match[0], here = match[1]; comment = match[0], here = match[1];
if (here) { if (here) {
this.token('HERECOMMENT', this.sanitizeHeredoc(here, { this.token('HERECOMMENT', this.sanitizeHeredoc(here, {
@ -223,12 +243,15 @@ define(function(require, exports, module) {
return 0; return 0;
} }
this.token('JS', (script = match[0]).slice(1, -1)); this.token('JS', (script = match[0]).slice(1, -1));
this.line += count(script, '\n');
return script.length; return script.length;
}; };
Lexer.prototype.regexToken = function() { Lexer.prototype.regexToken = function() {
var flags, length, match, prev, regex, _ref2, _ref3; var flags, length, match, prev, regex, _ref2, _ref3;
if (this.chunk.charAt(0) !== '/') return 0; if (this.chunk.charAt(0) !== '/') {
return 0;
}
if (match = HEREGEX.exec(this.chunk)) { if (match = HEREGEX.exec(this.chunk)) {
length = this.heregexToken(match); length = this.heregexToken(match);
this.line += count(match[0], '\n'); this.line += count(match[0], '\n');
@ -238,12 +261,16 @@ define(function(require, exports, module) {
if (prev && (_ref2 = prev[0], __indexOf.call((prev.spaced ? NOT_REGEX : NOT_SPACED_REGEX), _ref2) >= 0)) { if (prev && (_ref2 = prev[0], __indexOf.call((prev.spaced ? NOT_REGEX : NOT_SPACED_REGEX), _ref2) >= 0)) {
return 0; return 0;
} }
if (!(match = REGEX.exec(this.chunk))) return 0; if (!(match = REGEX.exec(this.chunk))) {
return 0;
}
_ref3 = match, match = _ref3[0], regex = _ref3[1], flags = _ref3[2]; _ref3 = match, match = _ref3[0], regex = _ref3[1], flags = _ref3[2];
if (regex.slice(0, 2) === '/*') { if (regex.slice(0, 2) === '/*') {
this.error('regular expressions cannot begin with `*`'); this.error('regular expressions cannot begin with `*`');
} }
if (regex === '//') regex = '/(?:)/'; if (regex === '//') {
regex = '/(?:)/';
}
this.token('REGEX', "" + regex + flags); this.token('REGEX', "" + regex + flags);
return match.length; return match.length;
}; };
@ -270,7 +297,9 @@ define(function(require, exports, module) {
if (tag === 'TOKENS') { if (tag === 'TOKENS') {
tokens.push.apply(tokens, value); tokens.push.apply(tokens, value);
} else { } else {
if (!(value = value.replace(HEREGEX_OMIT, ''))) continue; if (!(value = value.replace(HEREGEX_OMIT, ''))) {
continue;
}
value = value.replace(/\\/g, '\\\\'); value = value.replace(/\\/g, '\\\\');
tokens.push(['STRING', this.makeString(value, '"', true)]); tokens.push(['STRING', this.makeString(value, '"', true)]);
} }
@ -281,18 +310,21 @@ define(function(require, exports, module) {
this.tokens.push(['STRING', '""'], ['+', '+']); this.tokens.push(['STRING', '""'], ['+', '+']);
} }
(_ref5 = this.tokens).push.apply(_ref5, tokens); (_ref5 = this.tokens).push.apply(_ref5, tokens);
if (flags) this.tokens.push([',', ','], ['STRING', '"' + flags + '"']); if (flags) {
this.tokens.push([',', ','], ['STRING', '"' + flags + '"']);
}
this.token(')', ')'); this.token(')', ')');
return heregex.length; return heregex.length;
}; };
Lexer.prototype.lineToken = function() { Lexer.prototype.lineToken = function() {
var diff, indent, match, noNewlines, prev, size; var diff, indent, match, noNewlines, size;
if (!(match = MULTI_DENT.exec(this.chunk))) return 0; if (!(match = MULTI_DENT.exec(this.chunk))) {
return 0;
}
indent = match[0]; indent = match[0];
this.line += count(indent, '\n'); this.line += count(indent, '\n');
this.seenFor = false; this.seenFor = false;
prev = last(this.tokens, 1);
size = indent.length - 1 - indent.lastIndexOf('\n'); size = indent.length - 1 - indent.lastIndexOf('\n');
noNewlines = this.unfinished(); noNewlines = this.unfinished();
if (size - this.indebt === this.indent) { if (size - this.indebt === this.indent) {
@ -342,7 +374,9 @@ define(function(require, exports, module) {
this.token('OUTDENT', dent); this.token('OUTDENT', dent);
} }
} }
if (dent) this.outdebt -= moveOut; if (dent) {
this.outdebt -= moveOut;
}
while (this.value() === ';') { while (this.value() === ';') {
this.tokens.pop(); this.tokens.pop();
} }
@ -358,7 +392,9 @@ define(function(require, exports, module) {
return 0; return 0;
} }
prev = last(this.tokens); prev = last(this.tokens);
if (prev) prev[match ? 'spaced' : 'newLine'] = true; if (prev) {
prev[match ? 'spaced' : 'newLine'] = true;
}
if (match) { if (match) {
return match[0].length; return match[0].length;
} else { } else {
@ -370,12 +406,16 @@ define(function(require, exports, module) {
while (this.value() === ';') { while (this.value() === ';') {
this.tokens.pop(); this.tokens.pop();
} }
if (this.tag() !== 'TERMINATOR') this.token('TERMINATOR', '\n'); if (this.tag() !== 'TERMINATOR') {
this.token('TERMINATOR', '\n');
}
return this; return this;
}; };
Lexer.prototype.suppressNewlines = function() { Lexer.prototype.suppressNewlines = function() {
if (this.value() === '\\') this.tokens.pop(); if (this.value() === '\\') {
this.tokens.pop();
}
return this; return this;
}; };
@ -383,7 +423,9 @@ define(function(require, exports, module) {
var match, prev, tag, value, _ref2, _ref3, _ref4, _ref5; var match, prev, tag, value, _ref2, _ref3, _ref4, _ref5;
if (match = OPERATOR.exec(this.chunk)) { if (match = OPERATOR.exec(this.chunk)) {
value = match[0]; value = match[0];
if (CODE.test(value)) this.tagParameters(); if (CODE.test(value)) {
this.tagParameters();
}
} else { } else {
value = this.chunk.charAt(0); value = this.chunk.charAt(0);
} }
@ -416,7 +458,9 @@ define(function(require, exports, module) {
tag = 'LOGIC'; tag = 'LOGIC';
} else if (prev && !prev.spaced) { } else if (prev && !prev.spaced) {
if (value === '(' && (_ref4 = prev[0], __indexOf.call(CALLABLE, _ref4) >= 0)) { if (value === '(' && (_ref4 = prev[0], __indexOf.call(CALLABLE, _ref4) >= 0)) {
if (prev[0] === '?') prev[0] = 'FUNC_EXIST'; if (prev[0] === '?') {
prev[0] = 'FUNC_EXIST';
}
tag = 'CALL_START'; tag = 'CALL_START';
} else if (value === '[' && (_ref5 = prev[0], __indexOf.call(INDEXABLE, _ref5) >= 0)) { } else if (value === '[' && (_ref5 = prev[0], __indexOf.call(INDEXABLE, _ref5) >= 0)) {
tag = 'INDEX_START'; tag = 'INDEX_START';
@ -448,7 +492,9 @@ define(function(require, exports, module) {
if (HEREDOC_ILLEGAL.test(doc)) { if (HEREDOC_ILLEGAL.test(doc)) {
this.error("block comment cannot contain \"*/\", starting"); this.error("block comment cannot contain \"*/\", starting");
} }
if (doc.indexOf('\n') <= 0) return doc; if (doc.indexOf('\n') <= 0) {
return doc;
}
} else { } else {
while (match = HEREDOC_INDENT.exec(doc)) { while (match = HEREDOC_INDENT.exec(doc)) {
attempt = match[1]; attempt = match[1];
@ -457,14 +503,20 @@ define(function(require, exports, module) {
} }
} }
} }
if (indent) doc = doc.replace(RegExp("\\n" + indent, "g"), '\n'); if (indent) {
if (!herecomment) doc = doc.replace(/^\n/, ''); doc = doc.replace(RegExp("\\n" + indent, "g"), '\n');
}
if (!herecomment) {
doc = doc.replace(/^\n/, '');
}
return doc; return doc;
}; };
Lexer.prototype.tagParameters = function() { Lexer.prototype.tagParameters = function() {
var i, stack, tok, tokens; var i, stack, tok, tokens;
if (this.tag() !== ')') return this; if (this.tag() !== ')') {
return this;
}
stack = []; stack = [];
tokens = this.tokens; tokens = this.tokens;
i = tokens.length; i = tokens.length;
@ -508,7 +560,9 @@ define(function(require, exports, module) {
continue; continue;
case end: case end:
stack.pop(); stack.pop();
if (!stack.length) return str.slice(0, i + 1 || 9e9); if (!stack.length) {
return str.slice(0, +i + 1 || 9e9);
}
end = stack[stack.length - 1]; end = stack[stack.length - 1];
continue; continue;
} }
@ -528,7 +582,9 @@ define(function(require, exports, module) {
Lexer.prototype.interpolateString = function(str, options) { Lexer.prototype.interpolateString = function(str, options) {
var expr, heredoc, i, inner, interpolated, len, letter, nested, pi, regex, tag, tokens, value, _i, _len, _ref2, _ref3, _ref4; var expr, heredoc, i, inner, interpolated, len, letter, nested, pi, regex, tag, tokens, value, _i, _len, _ref2, _ref3, _ref4;
if (options == null) options = {}; if (options == null) {
options = {};
}
heredoc = options.heredoc, regex = options.regex; heredoc = options.heredoc, regex = options.regex;
tokens = []; tokens = [];
pi = 0; pi = 0;
@ -541,7 +597,9 @@ define(function(require, exports, module) {
if (!(letter === '#' && str.charAt(i + 1) === '{' && (expr = this.balancedString(str.slice(i + 1), '}')))) { if (!(letter === '#' && str.charAt(i + 1) === '{' && (expr = this.balancedString(str.slice(i + 1), '}')))) {
continue; continue;
} }
if (pi < i) tokens.push(['NEOSTRING', str.slice(pi, i)]); if (pi < i) {
tokens.push(['NEOSTRING', str.slice(pi, i)]);
}
inner = expr.slice(1, -1); inner = expr.slice(1, -1);
if (inner.length) { if (inner.length) {
nested = new Lexer().tokenize(inner, { nested = new Lexer().tokenize(inner, {
@ -563,28 +621,44 @@ define(function(require, exports, module) {
i += expr.length; i += expr.length;
pi = i + 1; pi = i + 1;
} }
if ((i > pi && pi < str.length)) tokens.push(['NEOSTRING', str.slice(pi)]); if ((i > pi && pi < str.length)) {
if (regex) return tokens; tokens.push(['NEOSTRING', str.slice(pi)]);
if (!tokens.length) return this.token('STRING', '""'); }
if (tokens[0][0] !== 'NEOSTRING') tokens.unshift(['', '']); if (regex) {
if (interpolated = tokens.length > 1) this.token('(', '('); return tokens;
}
if (!tokens.length) {
return this.token('STRING', '""');
}
if (tokens[0][0] !== 'NEOSTRING') {
tokens.unshift(['', '']);
}
if (interpolated = tokens.length > 1) {
this.token('(', '(');
}
for (i = _i = 0, _len = tokens.length; _i < _len; i = ++_i) { for (i = _i = 0, _len = tokens.length; _i < _len; i = ++_i) {
_ref3 = tokens[i], tag = _ref3[0], value = _ref3[1]; _ref3 = tokens[i], tag = _ref3[0], value = _ref3[1];
if (i) this.token('+', '+'); if (i) {
this.token('+', '+');
}
if (tag === 'TOKENS') { if (tag === 'TOKENS') {
(_ref4 = this.tokens).push.apply(_ref4, value); (_ref4 = this.tokens).push.apply(_ref4, value);
} else { } else {
this.token('STRING', this.makeString(value, '"', heredoc)); this.token('STRING', this.makeString(value, '"', heredoc));
} }
} }
if (interpolated) this.token(')', ')'); if (interpolated) {
this.token(')', ')');
}
return tokens; return tokens;
}; };
Lexer.prototype.pair = function(tag) { Lexer.prototype.pair = function(tag) {
var size, wanted; var size, wanted;
if (tag !== (wanted = last(this.ends))) { if (tag !== (wanted = last(this.ends))) {
if ('OUTDENT' !== wanted) this.error("unmatched " + tag); if ('OUTDENT' !== wanted) {
this.error("unmatched " + tag);
}
this.indent -= size = last(this.indents); this.indent -= size = last(this.indents);
this.outdentToken(size, true); this.outdentToken(size, true);
return this.pair(tag); return this.pair(tag);
@ -616,7 +690,9 @@ define(function(require, exports, module) {
}; };
Lexer.prototype.makeString = function(body, quote, heredoc) { Lexer.prototype.makeString = function(body, quote, heredoc) {
if (!body) return quote + quote; if (!body) {
return quote + quote;
}
body = body.replace(/\\([\s\S])/g, function(match, contents) { body = body.replace(/\\([\s\S])/g, function(match, contents) {
if (contents === '\n' || contents === quote) { if (contents === '\n' || contents === quote) {
return contents; return contents;
@ -663,7 +739,7 @@ define(function(require, exports, module) {
COFFEE_KEYWORDS = COFFEE_KEYWORDS.concat(COFFEE_ALIASES); COFFEE_KEYWORDS = COFFEE_KEYWORDS.concat(COFFEE_ALIASES);
RESERVED = ['case', 'default', 'function', 'var', 'void', 'with', 'const', 'let', 'enum', 'export', 'import', 'native', '__hasProp', '__extends', '__slice', '__bind', '__indexOf', 'implements', 'interface', 'let', 'package', 'private', 'protected', 'public', 'static', 'yield']; RESERVED = ['case', 'default', 'function', 'var', 'void', 'with', 'const', 'let', 'enum', 'export', 'import', 'native', '__hasProp', '__extends', '__slice', '__bind', '__indexOf', 'implements', 'interface', 'package', 'private', 'protected', 'public', 'static', 'yield'];
STRICT_PROSCRIBED = ['arguments', 'eval']; STRICT_PROSCRIBED = ['arguments', 'eval'];
@ -723,17 +799,17 @@ define(function(require, exports, module) {
RELATION = ['IN', 'OF', 'INSTANCEOF']; RELATION = ['IN', 'OF', 'INSTANCEOF'];
BOOL = ['TRUE', 'FALSE', 'NULL', 'UNDEFINED']; BOOL = ['TRUE', 'FALSE'];
NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', '++', '--', ']']; NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', 'NULL', 'UNDEFINED', '++', '--', ']'];
NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING'); NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING');
CALLABLE = ['IDENTIFIER', 'STRING', 'REGEX', ')', ']', '}', '?', '::', '@', 'THIS', 'SUPER']; CALLABLE = ['IDENTIFIER', 'STRING', 'REGEX', ')', ']', '}', '?', '::', '@', 'THIS', 'SUPER'];
INDEXABLE = CALLABLE.concat('NUMBER', 'BOOL'); INDEXABLE = CALLABLE.concat('NUMBER', 'BOOL', 'NULL', 'UNDEFINED');
LINE_BREAK = ['INDENT', 'OUTDENT', 'TERMINATOR']; LINE_BREAK = ['INDENT', 'OUTDENT', 'TERMINATOR'];
}); });

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
/* /**
* Copyright (c) 2011 Jeremy Ashkenas * Copyright (c) 2009-2012 Jeremy Ashkenas
* *
* Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation * obtaining a copy of this software and associated documentation
@ -24,7 +24,7 @@
*/ */
define(function(require, exports, module) { define(function(require, exports, module) {
// Generated by CoffeeScript 1.2.1-pre // Generated by CoffeeScript 1.3.3
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, left, rite, _i, _len, _ref, var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, left, rite, _i, _len, _ref,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
@ -32,8 +32,6 @@ define(function(require, exports, module) {
exports.Rewriter = (function() { exports.Rewriter = (function() {
Rewriter.name = 'Rewriter';
function Rewriter() {} function Rewriter() {}
Rewriter.prototype.rewrite = function(tokens) { Rewriter.prototype.rewrite = function(tokens) {
@ -67,7 +65,9 @@ define(function(require, exports, module) {
if (levels === 0 && condition.call(this, token, i)) { if (levels === 0 && condition.call(this, token, i)) {
return action.call(this, token, i); return action.call(this, token, i);
} }
if (!token || levels < 0) return action.call(this, token, i - 1); if (!token || levels < 0) {
return action.call(this, token, i - 1);
}
if (_ref = token[0], __indexOf.call(EXPRESSION_START, _ref) >= 0) { if (_ref = token[0], __indexOf.call(EXPRESSION_START, _ref) >= 0) {
levels += 1; levels += 1;
} else if (_ref1 = token[0], __indexOf.call(EXPRESSION_END, _ref1) >= 0) { } else if (_ref1 = token[0], __indexOf.call(EXPRESSION_END, _ref1) >= 0) {
@ -83,9 +83,13 @@ define(function(require, exports, module) {
_ref = this.tokens; _ref = this.tokens;
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) { for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
tag = _ref[i][0]; tag = _ref[i][0];
if (tag !== 'TERMINATOR') break; if (tag !== 'TERMINATOR') {
break;
}
}
if (i) {
return this.tokens.splice(0, i);
} }
if (i) return this.tokens.splice(0, i);
}; };
Rewriter.prototype.removeMidExpressionNewlines = function() { Rewriter.prototype.removeMidExpressionNewlines = function() {
@ -109,7 +113,9 @@ define(function(require, exports, module) {
return this.tokens[token[0] === 'OUTDENT' ? i - 1 : i][0] = 'CALL_END'; return this.tokens[token[0] === 'OUTDENT' ? i - 1 : i][0] = 'CALL_END';
}; };
return this.scanTokens(function(token, i) { return this.scanTokens(function(token, i) {
if (token[0] === 'CALL_START') this.detectEnd(i + 1, condition, action); if (token[0] === 'CALL_START') {
this.detectEnd(i + 1, condition, action);
}
return 1; return 1;
}); });
}; };
@ -124,25 +130,32 @@ define(function(require, exports, module) {
return token[0] = 'INDEX_END'; return token[0] = 'INDEX_END';
}; };
return this.scanTokens(function(token, i) { return this.scanTokens(function(token, i) {
if (token[0] === 'INDEX_START') this.detectEnd(i + 1, condition, action); if (token[0] === 'INDEX_START') {
this.detectEnd(i + 1, condition, action);
}
return 1; return 1;
}); });
}; };
Rewriter.prototype.addImplicitBraces = function() { Rewriter.prototype.addImplicitBraces = function() {
var action, condition, sameLine, stack, start, startIndent, startsLine; var action, condition, sameLine, stack, start, startIndent, startIndex, startsLine;
stack = []; stack = [];
start = null; start = null;
startsLine = null; startsLine = null;
sameLine = true; sameLine = true;
startIndent = 0; startIndent = 0;
startIndex = 0;
condition = function(token, i) { condition = function(token, i) {
var one, tag, three, two, _ref, _ref1; var one, tag, three, two, _ref, _ref1;
_ref = this.tokens.slice(i + 1, (i + 3) + 1 || 9e9), one = _ref[0], two = _ref[1], three = _ref[2]; _ref = this.tokens.slice(i + 1, +(i + 3) + 1 || 9e9), one = _ref[0], two = _ref[1], three = _ref[2];
if ('HERECOMMENT' === (one != null ? one[0] : void 0)) return false; if ('HERECOMMENT' === (one != null ? one[0] : void 0)) {
return false;
}
tag = token[0]; tag = token[0];
if (__indexOf.call(LINEBREAKS, tag) >= 0) sameLine = false; if (__indexOf.call(LINEBREAKS, tag) >= 0) {
return (((tag === 'TERMINATOR' || tag === 'OUTDENT') || (__indexOf.call(IMPLICIT_END, tag) >= 0 && sameLine)) && ((!startsLine && this.tag(i - 1) !== ',') || !((two != null ? two[0] : void 0) === ':' || (one != null ? one[0] : void 0) === '@' && (three != null ? three[0] : void 0) === ':'))) || (tag === ',' && one && ((_ref1 = one[0]) !== 'IDENTIFIER' && _ref1 !== 'NUMBER' && _ref1 !== 'STRING' && _ref1 !== '@' && _ref1 !== 'TERMINATOR' && _ref1 !== 'OUTDENT')); sameLine = false;
}
return (((tag === 'TERMINATOR' || tag === 'OUTDENT') || (__indexOf.call(IMPLICIT_END, tag) >= 0 && sameLine && !(i - startIndex === 1))) && ((!startsLine && this.tag(i - 1) !== ',') || !((two != null ? two[0] : void 0) === ':' || (one != null ? one[0] : void 0) === '@' && (three != null ? three[0] : void 0) === ':'))) || (tag === ',' && one && ((_ref1 = one[0]) !== 'IDENTIFIER' && _ref1 !== 'NUMBER' && _ref1 !== 'STRING' && _ref1 !== '@' && _ref1 !== 'TERMINATOR' && _ref1 !== 'OUTDENT'));
}; };
action = function(token, i) { action = function(token, i) {
var tok; var tok;
@ -163,6 +176,7 @@ define(function(require, exports, module) {
return 1; return 1;
} }
sameLine = true; sameLine = true;
startIndex = i + 1;
stack.push(['{']); stack.push(['{']);
idx = ago === '@' ? i - 2 : i - 1; idx = ago === '@' ? i - 2 : i - 1;
while (this.tag(idx - 2) === 'HERECOMMENT') { while (this.tag(idx - 2) === 'HERECOMMENT') {
@ -185,7 +199,9 @@ define(function(require, exports, module) {
condition = function(token, i) { condition = function(token, i) {
var post, tag, _ref, _ref1; var post, tag, _ref, _ref1;
tag = token[0]; tag = token[0];
if (!seenSingle && token.fromThen) return true; if (!seenSingle && token.fromThen) {
return true;
}
if (tag === 'IF' || tag === 'ELSE' || tag === 'CATCH' || tag === '->' || tag === '=>' || tag === 'CLASS') { if (tag === 'IF' || tag === 'ELSE' || tag === 'CATCH' || tag === '->' || tag === '=>' || tag === 'CLASS') {
seenSingle = true; seenSingle = true;
} }
@ -206,19 +222,27 @@ define(function(require, exports, module) {
if (tag === 'CLASS' || tag === 'IF' || tag === 'FOR' || tag === 'WHILE') { if (tag === 'CLASS' || tag === 'IF' || tag === 'FOR' || tag === 'WHILE') {
noCall = true; noCall = true;
} }
_ref = tokens.slice(i - 1, (i + 1) + 1 || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2]; _ref = tokens.slice(i - 1, +(i + 1) + 1 || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2];
callObject = !noCall && tag === 'INDENT' && next && next.generated && next[0] === '{' && prev && (_ref1 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref1) >= 0); callObject = !noCall && tag === 'INDENT' && next && next.generated && next[0] === '{' && prev && (_ref1 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref1) >= 0);
seenSingle = false; seenSingle = false;
seenControl = false; seenControl = false;
if (__indexOf.call(LINEBREAKS, tag) >= 0) noCall = false; if (__indexOf.call(LINEBREAKS, tag) >= 0) {
if (prev && !prev.spaced && tag === '?') token.call = true; noCall = false;
if (token.fromThen) return 1; }
if (prev && !prev.spaced && tag === '?') {
token.call = true;
}
if (token.fromThen) {
return 1;
}
if (!(callObject || (prev != null ? prev.spaced : void 0) && (prev.call || (_ref2 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref2) >= 0)) && (__indexOf.call(IMPLICIT_CALL, tag) >= 0 || !(token.spaced || token.newLine) && __indexOf.call(IMPLICIT_UNSPACED_CALL, tag) >= 0))) { if (!(callObject || (prev != null ? prev.spaced : void 0) && (prev.call || (_ref2 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref2) >= 0)) && (__indexOf.call(IMPLICIT_CALL, tag) >= 0 || !(token.spaced || token.newLine) && __indexOf.call(IMPLICIT_UNSPACED_CALL, tag) >= 0))) {
return 1; return 1;
} }
tokens.splice(i, 0, this.generate('CALL_START', '(', token[2])); tokens.splice(i, 0, this.generate('CALL_START', '(', token[2]));
this.detectEnd(i + 1, condition, action); this.detectEnd(i + 1, condition, action);
if (prev[0] === '?') prev[0] = 'FUNC_EXIST'; if (prev[0] === '?') {
prev[0] = 'FUNC_EXIST';
}
return 2; return 2;
}); });
}; };
@ -251,10 +275,14 @@ define(function(require, exports, module) {
if (__indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) { if (__indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) {
starter = tag; starter = tag;
_ref1 = this.indentation(token, true), indent = _ref1[0], outdent = _ref1[1]; _ref1 = this.indentation(token, true), indent = _ref1[0], outdent = _ref1[1];
if (starter === 'THEN') indent.fromThen = true; if (starter === 'THEN') {
indent.fromThen = true;
}
tokens.splice(i + 1, 0, indent); tokens.splice(i + 1, 0, indent);
this.detectEnd(i + 2, condition, action); this.detectEnd(i + 2, condition, action);
if (tag === 'THEN') tokens.splice(i, 1); if (tag === 'THEN') {
tokens.splice(i, 1);
}
return 1; return 1;
} }
return 1; return 1;
@ -274,7 +302,9 @@ define(function(require, exports, module) {
} }
}; };
return this.scanTokens(function(token, i) { return this.scanTokens(function(token, i) {
if (token[0] !== 'IF') return 1; if (token[0] !== 'IF') {
return 1;
}
original = token; original = token;
this.detectEnd(i + 1, condition, action); this.detectEnd(i + 1, condition, action);
return 1; return 1;
@ -283,10 +313,14 @@ define(function(require, exports, module) {
Rewriter.prototype.indentation = function(token, implicit) { Rewriter.prototype.indentation = function(token, implicit) {
var indent, outdent; var indent, outdent;
if (implicit == null) implicit = false; if (implicit == null) {
implicit = false;
}
indent = ['INDENT', 2, token[2]]; indent = ['INDENT', 2, token[2]];
outdent = ['OUTDENT', 2, token[2]]; outdent = ['OUTDENT', 2, token[2]];
if (implicit) indent.generated = outdent.generated = true; if (implicit) {
indent.generated = outdent.generated = true;
}
return [indent, outdent]; return [indent, outdent];
}; };
@ -324,7 +358,7 @@ define(function(require, exports, module) {
IMPLICIT_FUNC = ['IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@', 'THIS']; IMPLICIT_FUNC = ['IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@', 'THIS'];
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'UNARY', 'SUPER', '@', '->', '=>', '[', '(', '{', '--', '++']; IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'NULL', 'UNDEFINED', 'UNARY', 'SUPER', '@', '->', '=>', '[', '(', '{', '--', '++'];
IMPLICIT_UNSPACED_CALL = ['+', '-']; IMPLICIT_UNSPACED_CALL = ['+', '-'];
@ -339,4 +373,4 @@ define(function(require, exports, module) {
LINEBREAKS = ['TERMINATOR', 'INDENT', 'OUTDENT']; LINEBREAKS = ['TERMINATOR', 'INDENT', 'OUTDENT'];
}); });

View file

@ -1,5 +1,5 @@
/* /**
* Copyright (c) 2011 Jeremy Ashkenas * Copyright (c) 2009-2012 Jeremy Ashkenas
* *
* Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation * obtaining a copy of this software and associated documentation
@ -24,7 +24,7 @@
*/ */
define(function(require, exports, module) { define(function(require, exports, module) {
// Generated by CoffeeScript 1.2.1-pre // Generated by CoffeeScript 1.3.3
var Scope, extend, last, _ref; var Scope, extend, last, _ref;
@ -32,8 +32,6 @@ define(function(require, exports, module) {
exports.Scope = Scope = (function() { exports.Scope = Scope = (function() {
Scope.name = 'Scope';
Scope.root = null; Scope.root = null;
function Scope(parent, expressions, method) { function Scope(parent, expressions, method) {
@ -47,11 +45,15 @@ define(function(require, exports, module) {
} }
]; ];
this.positions = {}; this.positions = {};
if (!this.parent) Scope.root = this; if (!this.parent) {
Scope.root = this;
}
} }
Scope.prototype.add = function(name, type, immediate) { Scope.prototype.add = function(name, type, immediate) {
if (this.shared && !immediate) return this.parent.add(name, type, immediate); if (this.shared && !immediate) {
return this.parent.add(name, type, immediate);
}
if (Object.prototype.hasOwnProperty.call(this.positions, name)) { if (Object.prototype.hasOwnProperty.call(this.positions, name)) {
return this.variables[this.positions[name]].type = type; return this.variables[this.positions[name]].type = type;
} else { } else {
@ -62,22 +64,31 @@ define(function(require, exports, module) {
} }
}; };
Scope.prototype.find = function(name, options) { Scope.prototype.namedMethod = function() {
if (this.check(name, options)) return true; if (this.method.name || !this.parent) {
return this.method;
}
return this.parent.namedMethod();
};
Scope.prototype.find = function(name) {
if (this.check(name)) {
return true;
}
this.add(name, 'var'); this.add(name, 'var');
return false; return false;
}; };
Scope.prototype.parameter = function(name) { Scope.prototype.parameter = function(name) {
if (this.shared && this.parent.check(name, true)) return; if (this.shared && this.parent.check(name, true)) {
return;
}
return this.add(name, 'param'); return this.add(name, 'param');
}; };
Scope.prototype.check = function(name, immediate) { Scope.prototype.check = function(name) {
var found, _ref1; var _ref1;
found = !!this.type(name); return !!(this.type(name) || ((_ref1 = this.parent) != null ? _ref1.check(name) : void 0));
if (found || immediate) return found;
return !!((_ref1 = this.parent) != null ? _ref1.check(name) : void 0);
}; };
Scope.prototype.temporary = function(name, index) { Scope.prototype.temporary = function(name, index) {
@ -93,19 +104,25 @@ define(function(require, exports, module) {
_ref1 = this.variables; _ref1 = this.variables;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
v = _ref1[_i]; v = _ref1[_i];
if (v.name === name) return v.type; if (v.name === name) {
return v.type;
}
} }
return null; return null;
}; };
Scope.prototype.freeVariable = function(name, reserve) { Scope.prototype.freeVariable = function(name, reserve) {
var index, temp; var index, temp;
if (reserve == null) reserve = true; if (reserve == null) {
reserve = true;
}
index = 0; index = 0;
while (this.check((temp = this.temporary(name, index)))) { while (this.check((temp = this.temporary(name, index)))) {
index++; index++;
} }
if (reserve) this.add(temp, 'var', true); if (reserve) {
this.add(temp, 'var', true);
}
return temp; return temp;
}; };
@ -141,7 +158,9 @@ define(function(require, exports, module) {
_results = []; _results = [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
v = _ref1[_i]; v = _ref1[_i];
if (v.type.assigned) _results.push("" + v.name + " = " + v.type.value); if (v.type.assigned) {
_results.push("" + v.name + " = " + v.type.value);
}
} }
return _results; return _results;
}; };
@ -151,4 +170,4 @@ define(function(require, exports, module) {
})(); })();
}); });

View file

@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
/* Build time: 2-March-2012 02:47:11 */ /* Build time: 14-May-2012 10:24:48 */
/*! /*!
Parser-Lib Parser-Lib
@ -47,7 +47,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
/* Version v0.1.6, Build time: 2-March-2012 02:44:32 */ /* Version v0.1.7, Build time: 4-May-2012 03:57:04 */
var parserlib = {}; var parserlib = {};
(function(){ (function(){
@ -957,7 +957,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
/* Version v0.1.6, Build time: 2-March-2012 02:44:32 */ /* Version v0.1.7, Build time: 4-May-2012 03:57:04 */
(function(){ (function(){
var EventTarget = parserlib.util.EventTarget, var EventTarget = parserlib.util.EventTarget,
TokenStreamBase = parserlib.util.TokenStreamBase, TokenStreamBase = parserlib.util.TokenStreamBase,
@ -2666,7 +2666,8 @@ Parser.prototype = function(){
expr = null, expr = null,
prio = null, prio = null,
error = null, error = null,
invalid = null; invalid = null,
propertyName= "";
property = this._property(); property = this._property();
if (property !== null){ if (property !== null){
@ -2683,8 +2684,20 @@ Parser.prototype = function(){
prio = this._prio(); prio = this._prio();
/*
* If hacks should be allowed, then only check the root
* property. If hacks should not be allowed, treat
* _property or *property as invalid properties.
*/
propertyName = property.toString();
if (this.options.starHack && property.hack == "*" ||
this.options.underscoreHack && property.hack == "_") {
propertyName = property.text;
}
try { try {
this._validateProperty(property, expr); this._validateProperty(propertyName, expr);
} catch (ex) { } catch (ex) {
invalid = ex; invalid = ex;
} }
@ -3525,6 +3538,7 @@ var Properties = {
"background-repeat" : { multi: "<repeat-style>" }, "background-repeat" : { multi: "<repeat-style>" },
"background-size" : { multi: "<bg-size>", comma: true }, "background-size" : { multi: "<bg-size>", comma: true },
"baseline-shift" : "baseline | sub | super | <percentage> | <length>", "baseline-shift" : "baseline | sub | super | <percentage> | <length>",
"behavior" : 1,
"binding" : 1, "binding" : 1,
"bleed" : "<length>", "bleed" : "<length>",
"bookmark-label" : "<content> | <attr> | <string>", "bookmark-label" : "<content> | <attr> | <string>",
@ -3871,6 +3885,7 @@ var Properties = {
"text-justify" : "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida", "text-justify" : "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida",
"text-outline" : 1, "text-outline" : 1,
"text-overflow" : 1, "text-overflow" : 1,
"text-rendering" : "auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit",
"text-shadow" : 1, "text-shadow" : 1,
"text-transform" : "capitalize | uppercase | lowercase | none | inherit", "text-transform" : "capitalize | uppercase | lowercase | none | inherit",
"text-wrap" : "normal | none | avoid", "text-wrap" : "normal | none | avoid",
@ -5950,7 +5965,7 @@ var ValidationTypes = {
i, len, found = false; i, len, found = false;
for (i=0,len=args.length; i < len && !found; i++){ for (i=0,len=args.length; i < len && !found; i++){
if (text == args[i]){ if (text == args[i].toLowerCase()){
found = true; found = true;
} }
} }
@ -6042,7 +6057,7 @@ var ValidationTypes = {
}, },
"<gradient>": function(part) { "<gradient>": function(part) {
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial|linear)\-gradient/i.test(part); return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);
}, },
"<box>": function(part){ "<box>": function(part){
@ -6134,6 +6149,18 @@ var ValidationTypes = {
part, part,
i, len; i, len;
/*
<position> = [
[ left | center | right | top | bottom | <percentage> | <length> ]
|
[ left | center | right | <percentage> | <length> ]
[ top | center | bottom | <percentage> | <length> ]
|
[ center | [ left | right ] [ <percentage> | <length> ]? ] &&
[ center | [ top | bottom ] [ <percentage> | <length> ]? ]
]
*/
if (ValidationTypes.isAny(expression, "top | bottom")) { if (ValidationTypes.isAny(expression, "top | bottom")) {
result = true; result = true;
@ -6306,7 +6333,7 @@ var CSSLint = (function(){
formatters = [], formatters = [],
api = new parserlib.util.EventTarget(); api = new parserlib.util.EventTarget();
api.version = "0.9.7"; api.version = "0.9.8";
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// Rule Management // Rule Management
@ -7633,7 +7660,7 @@ CSSLint.addRule({
parser.addListener("endstylesheet", function(){ parser.addListener("endstylesheet", function(){
reporter.stat("important", count); reporter.stat("important", count);
if (count >= 10){ if (count >= 10){
reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specifity issues.", rule); reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specificity issues.", rule);
} }
}); });
} }
@ -8290,8 +8317,35 @@ CSSLint.addRule({
}); });
/* /*
* Rule: Don't use text-indent for image replacement if you need to support rtl. * Rule: Don't use properties with a star prefix.
* *
*/
/*global CSSLint*/
CSSLint.addRule({
//rule information
id: "star-property-hack",
name: "Disallow properties with a star prefix",
desc: "Checks for the star property hack (targets IE6/7)",
browsers: "All",
//initialization
init: function(parser, reporter){
var rule = this;
//check if property name starts with "*"
parser.addListener("property", function(event){
var property = event.property;
if (property.hack == "*") {
reporter.report("Property with star prefix found.", event.property.line, event.property.col, rule);
}
});
}
});
/*
* Rule: Don't use text-indent for image replacement if you need to support rtl.
*
*/ */
/*global CSSLint*/ /*global CSSLint*/
CSSLint.addRule({ CSSLint.addRule({
@ -8301,27 +8355,29 @@ CSSLint.addRule({
name: "Disallow negative text-indent", name: "Disallow negative text-indent",
desc: "Checks for text indent less than -99px", desc: "Checks for text indent less than -99px",
browsers: "All", browsers: "All",
//initialization //initialization
init: function(parser, reporter){ init: function(parser, reporter){
var rule = this, var rule = this,
textIndent = false; textIndent,
direction;
function startRule(event){ function startRule(event){
textIndent = false; textIndent = false;
direction = "inherit";
} }
//event handler for end of rules //event handler for end of rules
function endRule(event){ function endRule(event){
if (textIndent){ if (textIndent && direction != "ltr"){
reporter.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.", textIndent.line, textIndent.col, rule); reporter.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.", textIndent.line, textIndent.col, rule);
} }
} }
parser.addListener("startrule", startRule); parser.addListener("startrule", startRule);
parser.addListener("startfontface", startRule); parser.addListener("startfontface", startRule);
//check for use of "font-size" //check for use of "font-size"
parser.addListener("property", function(event){ parser.addListener("property", function(event){
var name = event.property.toString().toLowerCase(), var name = event.property.toString().toLowerCase(),
@ -8330,16 +8386,43 @@ CSSLint.addRule({
if (name == "text-indent" && value.parts[0].value < -99){ if (name == "text-indent" && value.parts[0].value < -99){
textIndent = event.property; textIndent = event.property;
} else if (name == "direction" && value == "ltr"){ } else if (name == "direction" && value == "ltr"){
textIndent = false; direction = "ltr";
} }
}); });
parser.addListener("endrule", endRule); parser.addListener("endrule", endRule);
parser.addListener("endfontface", endRule); parser.addListener("endfontface", endRule);
} }
}); });
/*
* Rule: Don't use properties with a underscore prefix.
*
*/
/*global CSSLint*/
CSSLint.addRule({
//rule information
id: "underscore-property-hack",
name: "Disallow properties with an underscore prefix",
desc: "Checks for the underscore property hack (targets IE6)",
browsers: "All",
//initialization
init: function(parser, reporter){
var rule = this;
//check if property name starts with "_"
parser.addListener("property", function(event){
var property = event.property;
if (property.hack == "_") {
reporter.report("Property with underscore prefix found.", event.property.line, event.property.col, rule);
}
});
}
});
/* /*
* Rule: Headings (h1-h6) should be defined only once. * Rule: Headings (h1-h6) should be defined only once.
*/ */
@ -8669,85 +8752,114 @@ CSSLint.addRule({
}); });
/*global CSSLint*/ /*global CSSLint*/
CSSLint.addFormatter({ (function() {
//format information
id: "checkstyle-xml",
name: "Checkstyle XML format",
/** /**
* Return opening root XML tag. * Replace special characters before write to output.
* @return {String} to prepend before all results *
* Rules:
* - single quotes is the escape sequence for double-quotes
* - &amp; is the escape sequence for &
* - &lt; is the escape sequence for <
* - &gt; is the escape sequence for >
*
* @param {String} message to escape
* @return escaped message as {String}
*/ */
startFormat: function(){ var xmlEscape = function(str) {
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>"; if (!str || str.constructor !== String) {
}, return "";
/**
* Return closing root XML tag.
* @return {String} to append after all results
*/
endFormat: function(){
return "</checkstyle>";
},
/**
* Given CSS Lint results for a file, return output for this format.
* @param results {Object} with error and warning messages
* @param filename {String} relative file path
* @param options {Object} (UNUSED for now) specifies special handling of output
* @return {String} output for results
*/
formatResults: function(results, filename, options) {
var messages = results.messages,
output = [];
/**
* Generate a source string for a rule.
* Checkstyle source strings usually resemble Java class names e.g
* net.csslint.SomeRuleName
* @param {Object} rule
* @return rule source as {String}
*/
var generateSource = function(rule) {
if (!rule || !('name' in rule)) {
return "";
}
return 'net.csslint.' + rule.name.replace(/\s/g,'');
};
/**
* Replace special characters before write to output.
*
* Rules:
* - single quotes is the escape sequence for double-quotes
* - &lt; is the escape sequence for <
* - &gt; is the escape sequence for >
*
* @param {String} message to escape
* @return escaped message as {String}
*/
var escapeSpecialCharacters = function(str) {
if (!str || str.constructor !== String) {
return "";
}
return str.replace(/\"/g, "'").replace(/</g, "&lt;").replace(/>/g, "&gt;");
};
if (messages.length > 0) {
output.push("<file name=\""+filename+"\">");
CSSLint.Util.forEach(messages, function (message, i) {
//ignore rollups for now
if (!message.rollup) {
output.push("<error line=\"" + message.line + "\" column=\"" + message.col + "\" severity=\"" + message.type + "\"" +
" message=\"" + escapeSpecialCharacters(message.message) + "\" source=\"" + generateSource(message.rule) +"\"/>");
}
});
output.push("</file>");
} }
return str.replace(/[\"&><]/g, function(match) {
switch (match) {
case "\"":
return "&quot;";
case "&":
return "&amp;";
case "<":
return "&lt;";
case ">":
return "&gt;";
}
});
};
return output.join(""); CSSLint.addFormatter({
} //format information
}); id: "checkstyle-xml",
name: "Checkstyle XML format",
/**
* Return opening root XML tag.
* @return {String} to prepend before all results
*/
startFormat: function(){
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>";
},
/**
* Return closing root XML tag.
* @return {String} to append after all results
*/
endFormat: function(){
return "</checkstyle>";
},
/**
* Returns message when there is a file read error.
* @param {String} filename The name of the file that caused the error.
* @param {String} message The error message
* @return {String} The error message.
*/
readError: function(filename, message) {
return "<file name=\"" + xmlEscape(filename) + "\"><error line=\"0\" column=\"0\" severty=\"error\" message=\"" + xmlEscape(message) + "\"></error></file>";
},
/**
* Given CSS Lint results for a file, return output for this format.
* @param results {Object} with error and warning messages
* @param filename {String} relative file path
* @param options {Object} (UNUSED for now) specifies special handling of output
* @return {String} output for results
*/
formatResults: function(results, filename, options) {
var messages = results.messages,
output = [];
/**
* Generate a source string for a rule.
* Checkstyle source strings usually resemble Java class names e.g
* net.csslint.SomeRuleName
* @param {Object} rule
* @return rule source as {String}
*/
var generateSource = function(rule) {
if (!rule || !('name' in rule)) {
return "";
}
return 'net.csslint.' + rule.name.replace(/\s/g,'');
};
if (messages.length > 0) {
output.push("<file name=\""+filename+"\">");
CSSLint.Util.forEach(messages, function (message, i) {
//ignore rollups for now
if (!message.rollup) {
output.push("<error line=\"" + message.line + "\" column=\"" + message.col + "\" severity=\"" + message.type + "\"" +
" message=\"" + xmlEscape(message.message) + "\" source=\"" + generateSource(message.rule) +"\"/>");
}
});
output.push("</file>");
}
return output.join("");
}
});
}());
/*global CSSLint*/ /*global CSSLint*/
CSSLint.addFormatter({ CSSLint.addFormatter({
//format information //format information
@ -8845,6 +8957,7 @@ CSSLint.addFormatter({
* *
* Rules: * Rules:
* - single quotes is the escape sequence for double-quotes * - single quotes is the escape sequence for double-quotes
* - &amp; is the escape sequence for &
* - &lt; is the escape sequence for < * - &lt; is the escape sequence for <
* - &gt; is the escape sequence for > * - &gt; is the escape sequence for >
* *
@ -8855,7 +8968,7 @@ CSSLint.addFormatter({
if (!str || str.constructor !== String) { if (!str || str.constructor !== String) {
return ""; return "";
} }
return str.replace(/\"/g, "'").replace(/</g, "&lt;").replace(/>/g, "&gt;"); return str.replace(/\"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}; };
if (messages.length > 0) { if (messages.length > 0) {
@ -8912,6 +9025,7 @@ CSSLint.addFormatter({
* *
* Rules: * Rules:
* - single quotes is the escape sequence for double-quotes * - single quotes is the escape sequence for double-quotes
* - &amp; is the escape sequence for &
* - &lt; is the escape sequence for < * - &lt; is the escape sequence for <
* - &gt; is the escape sequence for > * - &gt; is the escape sequence for >
* *
@ -8922,7 +9036,7 @@ CSSLint.addFormatter({
if (!str || str.constructor !== String) { if (!str || str.constructor !== String) {
return ""; return "";
} }
return str.replace(/\"/g, "'").replace(/</g, "&lt;").replace(/>/g, "&gt;"); return str.replace(/\"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}; };
if (messages.length > 0) { if (messages.length > 0) {

File diff suppressed because it is too large Load diff

View file

@ -8,11 +8,13 @@ var rootDir = __dirname + "/../lib/ace/"
var deps = [{ var deps = [{
path: "worker/jshint.js", path: "worker/jshint.js",
url: "https://raw.github.com/jshint/jshint/master/jshint.js", url: "https://raw.github.com/jshint/jshint/master/jshint.js",
needsFixup: true needsFixup: true,
}, { postProcess: function(t) {
path: "worker/jslint.js", return t.replace(
url: "https://raw.github.com/douglascrockford/JSLint/master/jslint.js", /"Expected a conditional expression and instead saw an assignment."/g,
needsFixup: true '"Assignment in conditional expression"'
);
}
}, { }, {
path: "mode/css/csslint.js", path: "mode/css/csslint.js",
url: "https://raw.github.com/stubbornella/csslint/master/release/csslint-node.js", url: "https://raw.github.com/stubbornella/csslint/master/release/csslint-node.js",
@ -43,7 +45,9 @@ var getDep = function(dep) {
data = "define(function(require, exports, module) {\n" data = "define(function(require, exports, module) {\n"
+ data + data
+ "\n});" + "\n});"
if (dep.postProcess)
data = dep.postProcess(data)
fs.writeFile(rootDir + dep.path, data, "utf-8", function(err){ fs.writeFile(rootDir + dep.path, data, "utf-8", function(err){
if (err) throw err if (err) throw err
console.log("File " + dep.path + " saved.") console.log("File " + dep.path + " saved.")