1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Removing extraneous semicolon, adding back in final break -- src now lints cleanly.

This commit is contained in:
Jeremy Ashkenas 2010-10-24 20:51:55 -04:00
parent 5b16d4790c
commit c2da8c2d54
8 changed files with 50 additions and 47 deletions

View file

@ -110,7 +110,7 @@
} else {
t.output = CoffeeScript.compile(t.input, t.options);
CoffeeScript.emit('success', task);
return o.print ? console.log(t.output.trim()) : o.compile ? writeJs(t.file, t.output, base) : o.lint ? lint(t.output) : undefined;
return o.print ? console.log(t.output.trim()) : o.compile ? writeJs(t.file, t.output, base) : o.lint ? lint(t.file, t.output) : undefined;
}
} catch (err) {
CoffeeScript.emit('failure', err, task);
@ -170,10 +170,10 @@
return exists ? compile() : exec("mkdir -p " + dir, compile);
});
};
lint = function(js) {
lint = function(file, js) {
var conf, jsl, printIt;
printIt = function(buffer) {
return console.log(buffer.toString().trim());
return console.log(file + ':\t' + buffer.toString().trim());
};
conf = __dirname + '/../extras/jsl.conf';
jsl = spawn('jsl', ['-nologo', '-stdin', '-conf', conf]);

View file

@ -1,7 +1,9 @@
(function() {
var ASSIGNED, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LEADING_SPACES, LINE_BREAK, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NEXT_CHARACTER, NEXT_ELLIPSIS, NOT_REGEX, NO_NEWLINE, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, TRAILING_SPACES, UNARY, WHITESPACE, _ref, compact, count, last, op, starts;
var __indexOf = Array.prototype.indexOf || function(item) {
for (var i = 0, l = this.length; i < l; i++) if (this[i] === item) return i;
for (var i = 0, l = this.length; i < l; i++) {
if (this[i] === item) return i;
}
return -1;
};
Rewriter = require('./rewriter').Rewriter;
@ -10,7 +12,7 @@
Lexer = (function() {
function Lexer() {
return this;
};
}
return Lexer;
})();
Lexer.prototype.tokenize = function(code, options) {
@ -375,6 +377,7 @@
break;
case '::':
prev[0] = 'INDEX_PROTO';
break;
}
}
}

View file

@ -24,7 +24,7 @@
function Base() {
this.tags = {};
return this;
};
}
return Base;
})();
Base.prototype.compile = function(o, lvl) {
@ -173,7 +173,7 @@
Expressions.__super__.constructor.call(this);
this.expressions = compact(flatten(nodes || []));
return this;
};
}
return Expressions;
})();
__extends(Expressions, Base);
@ -269,7 +269,7 @@
this.value = _arg;
Literal.__super__.constructor.call(this);
return this;
};
}
return Literal;
})();
__extends(Literal, Base);
@ -301,7 +301,7 @@
this.expression = _arg;
Return.__super__.constructor.call(this);
return this;
};
}
return Return;
})();
__extends(Return, Base);
@ -331,7 +331,7 @@
this.properties = props || [];
this.tags = tag ? (_obj = {}, _obj[tag] = true, _obj) : {};
return this;
};
}
return Value;
})();
__extends(Value, Base);
@ -449,7 +449,7 @@
this.comment = _arg;
Comment.__super__.constructor.call(this);
return this;
};
}
return Comment;
})();
__extends(Comment, Base);
@ -471,7 +471,7 @@
this.variable = this.isSuper ? null : variable;
this.args || (this.args = []);
return this;
};
}
return Call;
})();
__extends(Call, Base);
@ -598,7 +598,7 @@
this.child = _arg;
Extends.__super__.constructor.call(this);
return this;
};
}
return Extends;
})();
__extends(Extends, Base);
@ -616,7 +616,7 @@
this.proto = tag === 'prototype' ? '.prototype' : '';
this.soakNode = tag === 'soak';
return this;
};
}
return Accessor;
})();
__extends(Accessor, Base);
@ -635,7 +635,7 @@
this.index = _arg;
Index.__super__.constructor.call(this);
return this;
};
}
return Index;
})();
__extends(Index, Base);
@ -654,7 +654,7 @@
Obj.__super__.constructor.call(this);
this.objects = this.properties = props || [];
return this;
};
}
return Obj;
})();
__extends(Obj, Base);
@ -742,7 +742,7 @@
Arr.__super__.constructor.call(this);
this.objects = objs || [];
return this;
};
}
return Arr;
})();
__extends(Arr, Base);
@ -789,7 +789,7 @@
this.properties = props || [];
this.returns = false;
return this;
};
}
return Class;
})();
__extends(Class, Base);
@ -887,7 +887,7 @@
this.variable = _arg;
Assign.__super__.constructor.call(this);
return this;
};
}
return Assign;
})();
__extends(Assign, Base);
@ -1010,7 +1010,7 @@
this.context = 'this';
}
return this;
};
}
return Code;
})();
__extends(Code, Base);
@ -1072,7 +1072,7 @@
code = this.body.expressions.length ? "\n" + (this.body.compileWithDeclarations(o)) + "\n" : '';
if (this.className) {
open = "(function() {\n" + comm + idt + "function " + this.className + "(";
close = "" + (code && idt) + "};\n" + idt + "return " + this.className + ";\n" + this.tab + "})()";
close = "" + (code && idt) + "}\n" + idt + "return " + this.className + ";\n" + this.tab + "})()";
} else {
open = "function(";
close = "" + (code && this.tab) + "}";
@ -1097,7 +1097,7 @@
Param.__super__.constructor.call(this);
this.value = new Literal(this.name = name);
return this;
};
}
return Param;
})();
__extends(Param, Base);
@ -1124,7 +1124,7 @@
Splat.__super__.constructor.call(this);
this.name = name.compile ? name : new Literal(name);
return this;
};
}
return Splat;
})();
__extends(Splat, Base);
@ -1198,7 +1198,7 @@
this.condition = (opts != null ? opts.invert : undefined) ? condition.invert() : condition;
this.guard = opts != null ? opts.guard : undefined;
return this;
};
}
return While;
})();
__extends(While, Base);
@ -1261,7 +1261,7 @@
this.second = second;
this.flip = !!flip;
return this;
};
}
return Op;
})();
__extends(Op, Base);
@ -1351,7 +1351,7 @@
this.object = _arg;
In.__super__.constructor.call(this);
return this;
};
}
return In;
})();
__extends(In, Base);
@ -1403,7 +1403,7 @@
this.attempt = _arg;
Try.__super__.constructor.call(this);
return this;
};
}
return Try;
})();
__extends(Try, Base);
@ -1433,7 +1433,7 @@
this.expression = _arg;
Throw.__super__.constructor.call(this);
return this;
};
}
return Throw;
})();
__extends(Throw, Base);
@ -1451,7 +1451,7 @@
this.expression = _arg;
Existence.__super__.constructor.call(this);
return this;
};
}
return Existence;
})();
__extends(Existence, Base);
@ -1470,7 +1470,7 @@
this.expression = _arg;
Parens.__super__.constructor.call(this);
return this;
};
}
return Parens;
})();
__extends(Parens, Base);
@ -1512,7 +1512,7 @@
this.pattern = this.name instanceof Value;
this.returns = false;
return this;
};
}
return For;
})();
__extends(For, Base);
@ -1631,7 +1631,7 @@
this.subject = _arg;
Switch.__super__.constructor.call(this);
return this;
};
}
return Switch;
})();
__extends(Switch, Base);
@ -1665,9 +1665,6 @@
code += idt1 + ("case " + (cond.compile(o, LEVEL_PAREN)) + ":\n");
}
code += block.compile(o, LEVEL_TOP) + '\n';
if (i === this.cases.length - 1 && !this.otherwise) {
break;
}
_ref5 = block.expressions;
for (_j = _ref5.length - 1; _j >= 0; _j--) {
expr = _ref5[_j];
@ -1696,7 +1693,7 @@
this.elseBody = null;
this.isChain = false;
return this;
};
}
return If;
})();
__extends(If, Base);
@ -1812,7 +1809,7 @@
UTILITIES = {
"extends": 'function(child, parent) {\n function ctor() { this.constructor = child; }\n ctor.prototype = parent.prototype;\n child.prototype = new ctor;\n if (typeof parent.extended === "function") parent.extended(child);\n child.__super__ = parent.prototype;\n}',
bind: 'function(func, context) {\n return function() { return func.apply(context, arguments); };\n}',
indexOf: 'Array.prototype.indexOf || function(item) {\n for (var i = 0, l = this.length; i < l; i++) if (this[i] === item) return i;\n return -1;\n}',
indexOf: 'Array.prototype.indexOf || function(item) {\n for (var i = 0, l = this.length; i < l; i++) {\n if (this[i] === item) return i;\n }\n return -1;\n}',
hasProp: 'Object.prototype.hasOwnProperty',
slice: 'Array.prototype.slice'
};

View file

@ -6,7 +6,7 @@
this.banner = banner;
this.rules = buildRules(rules);
return this;
};
}
return OptionParser;
})();
OptionParser.prototype.parse = function(args) {

View file

@ -1,13 +1,15 @@
(function() {
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, _i, _len, _ref, left, rite;
var __indexOf = Array.prototype.indexOf || function(item) {
for (var i = 0, l = this.length; i < l; i++) if (this[i] === item) return i;
for (var i = 0, l = this.length; i < l; i++) {
if (this[i] === item) return i;
}
return -1;
};
exports.Rewriter = (function() {
function Rewriter() {
return this;
};
}
return Rewriter;
})();
exports.Rewriter.prototype.rewrite = function(_arg) {

View file

@ -21,7 +21,7 @@
Scope.root = this;
}
return this;
};
}
return Scope;
})();
Scope.root = null;

View file

@ -107,7 +107,7 @@ compileScript = (file, input, base) ->
CoffeeScript.emit 'success', task
if o.print then console.log t.output.trim()
else if o.compile then writeJs t.file, t.output, base
else if o.lint then lint t.output
else if o.lint then lint t.file, t.output
catch err
CoffeeScript.emit 'failure', err, task
return if CoffeeScript.listeners('failure').length
@ -154,8 +154,8 @@ writeJs = (source, js, base) ->
# Pipe compiled JS through JSLint (requires a working `jsl` command), printing
# any errors or warnings that arise.
lint = (js) ->
printIt = (buffer) -> console.log buffer.toString().trim()
lint = (file, js) ->
printIt = (buffer) -> console.log file + ':\t' + buffer.toString().trim()
conf = __dirname + '/../extras/jsl.conf'
jsl = spawn 'jsl', ['-nologo', '-stdin', '-conf', conf]
jsl.stdout.on 'data', printIt

View file

@ -884,7 +884,7 @@ exports.Code = class Code extends Base
code = if @body.expressions.length then "\n#{ @body.compileWithDeclarations o }\n" else ''
if @className
open = "(function() {\n#{comm}#{idt}function #{@className}("
close = "#{ code and idt }};\n#{idt}return #{@className};\n#{@tab}})()"
close = "#{ code and idt }}\n#{idt}return #{@className};\n#{@tab}})()"
else
open = "function("
close = "#{ code and @tab }}"
@ -1367,7 +1367,6 @@ exports.Switch = class Switch extends Base
cond = cond.invert() unless @subject
code += idt1 + "case #{ cond.compile o, LEVEL_PAREN }:\n"
code += block.compile(o, LEVEL_TOP) + '\n'
break if i is @cases.length - 1 and not @otherwise
for expr in block.expressions by -1 when expr not instanceof Comment
code += idt2 + 'break;\n' unless expr instanceof Return
break
@ -1524,7 +1523,9 @@ UTILITIES =
# Discover if an item is in an array.
indexOf: '''
Array.prototype.indexOf || function(item) {
for (var i = 0, l = this.length; i < l; i++) if (this[i] === item) return i;
for (var i = 0, l = this.length; i < l; i++) {
if (this[i] === item) return i;
}
return -1;
}
'''