From 33ac70aec349eb91151f5fe0a1a562120eabf456 Mon Sep 17 00:00:00 2001 From: Trevor Burnham Date: Tue, 19 Oct 2010 14:24:38 -0400 Subject: [PATCH] Whitespace fix for unstepPart (thanks, Tesco) --- lib/browser.js | 2 -- lib/cake.js | 4 ---- lib/command.js | 8 ------- lib/grammar.js | 6 ----- lib/helpers.js | 8 ------- lib/index.js | 2 -- lib/lexer.js | 8 ------- lib/nodes.js | 59 +++--------------------------------------------- lib/optparse.js | 12 ---------- lib/rewriter.js | 10 -------- lib/scope.js | 8 ------- src/nodes.coffee | 7 +++--- 12 files changed, 6 insertions(+), 128 deletions(-) diff --git a/lib/browser.js b/lib/browser.js index e958a538..c35d5feb 100644 --- a/lib/browser.js +++ b/lib/browser.js @@ -36,8 +36,6 @@ })(); script = _j; } - - return null; }; if (window.addEventListener) { diff --git a/lib/cake.js b/lib/cake.js index 4bddc356..770a648b 100755 --- a/lib/cake.js +++ b/lib/cake.js @@ -51,8 +51,6 @@ arg = _ref[_i]; _result.push(invoke(arg)); } - - return _result; }); }; @@ -66,8 +64,6 @@ desc = task.description ? ("# " + (task.description)) : ''; puts("cake " + name + spaces + " " + desc); } - - return switches.length ? puts(oparse.help()) : undefined; }; missingTask = function(task) { diff --git a/lib/command.js b/lib/command.js index d53c62b3..58a27745 100644 --- a/lib/command.js +++ b/lib/command.js @@ -70,8 +70,6 @@ file = files[_k]; _result2.push(compile(path.join(source, file))); } - - return _result2; }); } else if (topLevel || path.extname(source) === '.coffee') { @@ -88,8 +86,6 @@ })(); source = _j; } - - return _result; }; compileScript = function(file, input, base) { @@ -101,8 +97,6 @@ req = _ref2[_i]; require(helpers.starts(req, '.') ? fs.realpathSync(req) : req); } - - } try { t = (task = { @@ -203,8 +197,6 @@ return "[" + tag + " " + value + "]"; })()); } - - return _result; })(); return puts(strings.join(' ')); diff --git a/lib/grammar.js b/lib/grammar.js index 3cc01e98..e038a740 100644 --- a/lib/grammar.js +++ b/lib/grammar.js @@ -604,21 +604,15 @@ tokens.push(token); } } - - if (name === 'Root') { alt[1] = ("return " + (alt[1])); } return alt; })()); } - - return _result; })(); } - - exports.parser = new Parser({ tokens: tokens.join(' '), bnf: grammar, diff --git a/lib/helpers.js b/lib/helpers.js index 31eb8e3c..5983bf6d 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -10,8 +10,6 @@ return index; } } - - return -1; })); exports.include = function(list, value) { @@ -34,8 +32,6 @@ _result.push(item); } } - - return _result; }; exports.count = function(string, letter) { @@ -55,8 +51,6 @@ val = properties[key]; object[key] = val; } - - return object; }); exports.flatten = (flatten = function(array) { @@ -70,8 +64,6 @@ flattened.push(element); } } - - return flattened; }); exports.del = function(obj, key) { diff --git a/lib/index.js b/lib/index.js index ec88a8c0..dc5ab13c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -6,6 +6,4 @@ val = _ref[key]; (exports[key] = val); } - - }).call(this); diff --git a/lib/lexer.js b/lib/lexer.js index c8c5f0bb..ce25616b 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -226,8 +226,6 @@ } tokens.push(['+', '+']); } - - tokens.pop(); if ((((_ref4 = tokens[0]) != null) ? _ref4[0] : undefined) !== 'STRING') { this.tokens.push(['STRING', '""'], ['+', '+']); @@ -482,8 +480,6 @@ break; } } - - } if (!levels.length) { break; @@ -554,8 +550,6 @@ this.token('STRING', this.makeString(value, '"', heredoc)); } } - - if (interpolated) { this.token(')', ')'); } @@ -606,8 +600,6 @@ })) { COFFEE_KEYWORDS.push(op); } - - RESERVED = ['case', 'default', 'do', 'function', 'var', 'void', 'with', 'const', 'let', 'enum', 'export', 'import', 'native', '__hasProp', '__extends', '__slice']; JS_FORBIDDEN = JS_KEYWORDS.concat(RESERVED); IDENTIFIER = /^([$A-Za-z_][$\w]*)([^\n\S]*:(?!:))?/; diff --git a/lib/nodes.js b/lib/nodes.js index 7df413f1..4c8ba9dc 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -58,8 +58,6 @@ node = pair[i]; (pair[i] = node.compile(o)); } - - } return pair; }; @@ -108,8 +106,6 @@ child = _ref2[_i]; _result.push(child.toString(idt + TAB)); } - - return _result; }).call(this).join(''); klass = override || this.constructor.name + (this.soakNode ? '?' : ''); @@ -130,12 +126,8 @@ return; } } - - } } - - return _result; }; Base.prototype.collectChildren = function() { @@ -216,8 +208,6 @@ node = _ref2[_i]; _result.push(this.compileExpression(node, merge(o))); } - - return _result; }).call(this).join('\n'); }; @@ -421,8 +411,6 @@ prop = props[_i]; (code += prop.compile(o)); } - - return code; }; Value.prototype.unfoldSoak = function(o) { @@ -448,8 +436,6 @@ return ifn; } } - - return null; }; return Value; @@ -556,8 +542,6 @@ } ifn = If.unfoldSoak(o, call, 'variable'); } - - return ifn; }; Call.prototype.compileNode = function(o) { @@ -572,16 +556,12 @@ return this.compileSplat(o); } } - - args = (function() { _result = []; for (_j = 0, _len2 = (_ref4 = this.args).length; _j < _len2; _j++) { arg = _ref4[_j]; _result.push((arg.parenthetical = true) && arg.compile(o)); } - - return _result; }).call(this).join(', '); return this.isSuper ? this.compileSuper(args, o) : ("" + (this.prefix()) + (this.variable.compile(o)) + "(" + args + ")"); @@ -812,8 +792,6 @@ _result.push(prop); } } - - return _result; }).call(this); lastNoncom = last(nonComments); @@ -832,8 +810,6 @@ return indent + prop.compile(o) + join; }).call(this)); } - - return _result; }).call(this); props = props.join(''); @@ -848,8 +824,6 @@ return true; } } - - return false; }; return ObjectLiteral; @@ -878,16 +852,12 @@ return this.compileSplatLiteral(o); } } - - objects = []; for (i = 0, _len2 = (_ref3 = this.objects).length; i < _len2; i++) { obj = _ref3[i]; code = obj.compile(o); objects.push(obj instanceof Comment ? ("\n" + code + "\n" + (o.indent)) : (i === this.objects.length - 1 ? code : code + ', ')); } - - objects = objects.join(''); return 0 < objects.indexOf('\n') ? ("[\n" + (o.indent) + objects + "\n" + (this.tab) + "]") : ("[" + objects + "]"); }; @@ -899,8 +869,6 @@ return true; } } - - return false; }; return ArrayLiteral; @@ -989,8 +957,6 @@ } props.push(prop); } - - constructor.className = className.match(/[\w\d\$_]+$/); if (me) { constructor.body.unshift(new Literal("" + me + " = this")); @@ -1116,8 +1082,6 @@ } assigns.push(new Assign(obj, val).compile(otop)); } - - if (!top) { assigns.push(valVar); } @@ -1195,8 +1159,6 @@ } } } - - o.scope.startLevel(); params = (function() { _result = []; @@ -1204,8 +1166,6 @@ param = params[_i]; _result.push(param.compile(o)); } - - return _result; })(); if (!(empty || this.noReturn)) { @@ -1215,8 +1175,6 @@ param = params[_i]; (o.scope.parameter(param)); } - - comm = this.comment ? this.comment.compile(o) + '\n' : ''; if (this.className) { o.indent = this.idt(2); @@ -1304,8 +1262,6 @@ pos = this.trailings.length - idx; o.scope.assign(trailing.compile(o), "arguments[" + variadic + " ? " + len + " - " + pos + " : " + (this.index + idx) + "]"); } - - } return "" + name + " = " + (utility('slice')) + ".call(arguments, " + (this.index) + end + ")"; }; @@ -1335,8 +1291,6 @@ } args[++end] = i === 0 ? code : (".concat(" + code + ")"); } - - return args.join(''); }; return Splat; @@ -1538,8 +1492,6 @@ item = _ref2[i]; _result.push("" + (i ? this.obj2 : this.obj1) + " === " + (item.compile(o))); } - - return _result; }).call(this); return "(" + (tests.join(' || ')) + ")"; @@ -1806,7 +1758,8 @@ varPart = ("" + idt1 + namePart + ";\n"); } if (forPart && name === ivar) { - unstepPart = this.step ? ("\n" + name + " -= " + (this.step.compile(o)) + ";") : ("\n" + name + "--;"); + unstepPart = this.step ? ("" + name + " -= " + (this.step.compile(o)) + ";") : ("" + name + "--;"); + unstepPart = ("\n" + (this.tab)) + unstepPart; } } if (this.object) { @@ -1820,7 +1773,7 @@ top: true })); vars = range ? name : ("" + name + ", " + ivar); - return "" + resultPart + (this.tab) + "for (" + forPart + ") {" + guardPart + "\n" + varPart + body + "\n" + (this.tab) + "}\n" + unstepPart + "\n" + returnResult; + return "" + resultPart + (this.tab) + "for (" + forPart + ") {" + guardPart + "\n" + varPart + body + "\n" + (this.tab) + "}" + unstepPart + returnResult; }; return For; })(); @@ -1846,8 +1799,6 @@ pair = _ref2[_i]; pair[1].makeReturn(); } - - if (this.otherwise) { this.otherwise.makeReturn(); } @@ -1869,15 +1820,11 @@ } code += ("\n" + (this.idt(1)) + "case " + (condition.compile(o)) + ":"); } - - code += ("\n" + (block.compile(o))); if (!(last(exprs) instanceof Return)) { code += ("\n" + idt + "break;"); } } - - if (this.otherwise) { code += ("\n" + (this.idt(1)) + "default:\n" + (this.otherwise.compile(o))); } diff --git a/lib/optparse.js b/lib/optparse.js index 4bb7dc2e..4a9ae283 100755 --- a/lib/optparse.js +++ b/lib/optparse.js @@ -28,8 +28,6 @@ break; } } - - if (isOption && !matchedRule) { throw new Error("unrecognized option: " + arg); } @@ -38,8 +36,6 @@ break; } } - - return options; }; OptionParser.prototype.help = function() { @@ -55,8 +51,6 @@ letPart = rule.shortFlag ? rule.shortFlag + ', ' : ' '; lines.push(' ' + letPart + rule.longFlag + spaces + rule.description); } - - return "\n" + (lines.join('\n')) + "\n"; }; return OptionParser; @@ -77,8 +71,6 @@ return buildRule.apply(buildRule, tuple); })()); } - - return _result; }; buildRule = function(shortFlag, longFlag, description, options) { @@ -106,14 +98,10 @@ l = _ref[_j]; result.push('-' + l); } - - } else { result.push(arg); } } - - return result; }; }).call(this); diff --git a/lib/rewriter.js b/lib/rewriter.js index 424cd06a..6999fc88 100644 --- a/lib/rewriter.js +++ b/lib/rewriter.js @@ -90,8 +90,6 @@ break; } } - - return i ? this.tokens.splice(0, i) : undefined; }; exports.Rewriter.prototype.removeMidExpressionNewlines = function() { @@ -298,8 +296,6 @@ throw Error("too many " + (token[1]) + " on line " + (token[2] + 1)); } } - - return 1; }); unclosed = (function() { @@ -310,8 +306,6 @@ _result.push(key); } } - - return _result; })(); if (unclosed.length) { @@ -325,8 +319,6 @@ for (key in INVERSES) { (debt[key] = 0); } - - return this.scanTokens(function(token, i, tokens) { var inv, match, mtag, oppos, tag, val; if (include(EXPRESSION_START, tag = token[0])) { @@ -374,8 +366,6 @@ EXPRESSION_START.push(INVERSES[rite] = left); EXPRESSION_END.push(INVERSES[left] = rite); } - - EXPRESSION_CLOSE = ['CATCH', 'WHEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_END); IMPLICIT_FUNC = ['IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@', 'THIS']; IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'UNLESS', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'UNARY', '@', '->', '=>', '[', '(', '{', '--', '++']; diff --git a/lib/scope.js b/lib/scope.js index 90833293..b0f2a648 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -35,8 +35,6 @@ _result.push(vars[name] = 'reuse'); } } - - return _result; }; Scope.prototype.find = function(name, options) { @@ -55,8 +53,6 @@ return true; } } - - return false; }; Scope.prototype.parameter = function(name) { @@ -112,8 +108,6 @@ _result.push(key); } } - - return _result; }).call(this).sort(); }; @@ -127,8 +121,6 @@ _result.push("" + key + " = " + (val.value)); } } - - return _result; }; Scope.prototype.compiledDeclarations = function() { diff --git a/src/nodes.coffee b/src/nodes.coffee index 4fef55c4..c0157449 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1469,7 +1469,8 @@ exports.For = class For extends Base else varPart = "#{idt1}#{namePart};\n" if namePart if forPart and name is ivar - unstepPart = if @step then "\n#{name} -= #{ @step.compile(o) };" else "\n#{name}--;" + unstepPart = if @step then "#{name} -= #{ @step.compile(o) };" else "#{name}--;" + unstepPart = "\n#{@tab}" + unstepPart if @object forPart = "#{ivar} in #{sourcePart}" guardPart = "\n#{idt1}if (!#{utility('hasProp')}.call(#{svar}, #{ivar})) continue;" unless @raw @@ -1478,9 +1479,7 @@ exports.For = class For extends Base """ #{resultPart}#{@tab}for (#{forPart}) {#{guardPart} #{varPart}#{body} - #{@tab}} - #{unstepPart} - #{returnResult} + #{@tab}}#{unstepPart}#{returnResult} """ #### Switch