diff --git a/lib/coffee_script/command_line.js b/lib/coffee_script/command_line.js index a0f45979..d4e287c2 100644 --- a/lib/coffee_script/command_line.js +++ b/lib/coffee_script/command_line.js @@ -27,8 +27,7 @@ exports.compile = function compile(script, source) { var options; source = source || 'error'; - options = { - }; + options = {}; if (this.options.no_wrap) { options.no_wrap = true; } @@ -94,8 +93,7 @@ // Use OptionParser for all the options. exports.parse_options = function parse_options() { var oparser, opts, paths; - opts = (this.options = { - }); + opts = (this.options = {}); oparser = (this.option_parser = new optparse.OptionParser(SWITCHES)); oparser.add = oparser['on']; oparser.add('interactive', function() { diff --git a/lib/coffee_script/grammar.js b/lib/coffee_script/grammar.js index 4537c04e..0a8ea5a8 100644 --- a/lib/coffee_script/grammar.js +++ b/lib/coffee_script/grammar.js @@ -519,8 +519,7 @@ }; // Helpers ============================================================== // Make the Jison parser. - bnf = { - }; + bnf = {}; tokens = []; __a = grammar; for (name in __a) { diff --git a/lib/coffee_script/nodes.js b/lib/coffee_script/nodes.js index c5434727..86413f41 100644 --- a/lib/coffee_script/nodes.js +++ b/lib/coffee_script/nodes.js @@ -5,7 +5,7 @@ // Some helper functions // Tabs are two spaces for pretty printing. TAB = ' '; - TRAILING_WHITESPACE = /\s+$/g; + TRAILING_WHITESPACE = /\s+$/gm; // Keep the identifier regex in sync with the Lexer. IDENTIFIER = /^[a-zA-Z$_](\w|\$)*$/; // Flatten nested arrays recursively. @@ -46,8 +46,7 @@ } return __a; } else { - output = { - }; + output = {}; __d = input; for (key in __d) { val = __d[key]; @@ -61,8 +60,7 @@ // Merge objects. merge = function merge(src, dest) { var __a, __b, fresh, key, val; - fresh = { - }; + fresh = {}; __a = src; for (key in __a) { val = __a[key]; @@ -144,8 +142,7 @@ // already been asked to return the result. Node.prototype.compile = function compile(o) { var closure, top; - this.options = dup(o || { - }); + this.options = dup(o || {}); this.indent = o.indent; top = this.top_sensitive() ? this.options.top : del(this.options, 'top'); closure = this.is_statement() && !this.is_statement_only() && !top && !this.options.returns && !(this instanceof CommentNode) && !this.contains(function(node) { @@ -245,8 +242,7 @@ return node === this.expressions[l - last_index]; }, compile: function compile(o) { - o = o || { - }; + o = o || {}; return o.scope ? Node.prototype.compile.call(this, o) : this.compile_root(o); }, // Compile each expression in the Expressions body. @@ -525,11 +521,11 @@ }, // Hooking one constructor into another's prototype chain. compile_node: function compile_node(o) { - var child, constructor, parent; - constructor = o.scope.free_variable(); + var child, construct, parent; + construct = o.scope.free_variable(); child = this.child.compile(o); parent = this.parent.compile(o); - return this.idt() + constructor + ' = function(){};\n' + this.idt() + constructor + '.prototype = ' + parent + ".prototype;\n" + this.idt() + child + '.__superClass__ = ' + parent + ".prototype;\n" + this.idt() + child + '.prototype = new ' + constructor + "();\n" + this.idt() + child + '.prototype.constructor = ' + child + ';'; + return this.idt() + construct + ' = function(){};\n' + this.idt() + construct + '.prototype = ' + parent + ".prototype;\n" + this.idt() + child + '.__superClass__ = ' + parent + ".prototype;\n" + this.idt() + child + '.prototype = new ' + construct + "();\n" + this.idt() + child + '.prototype.constructor = ' + child + ';'; } })); statement(ExtendsNode); @@ -1215,8 +1211,7 @@ this.body = body && body.unwrap(); this.else_body = else_body && else_body.unwrap(); this.children = compact([this.condition, this.body, this.else_body]); - this.tags = tags || { - }; + this.tags = tags || {}; if (this.condition instanceof Array) { this.multiple = true; } diff --git a/lib/coffee_script/rewriter.js b/lib/coffee_script/rewriter.js index 0dc0dc4f..945884a7 100644 --- a/lib/coffee_script/rewriter.js +++ b/lib/coffee_script/rewriter.js @@ -32,8 +32,7 @@ IMPLICIT_END = ['IF', 'UNLESS', 'FOR', 'WHILE', 'TERMINATOR', 'OUTDENT']; IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'TRY', 'DELETE', 'TYPEOF', 'SWITCH', 'TRUE', 'FALSE', 'YES', 'NO', 'ON', 'OFF', '!', '!!', 'NOT', '@', '->', '=>', '[', '(', '{']; // The inverse mappings of token pairs we're trying to fix up. - INVERSES = { - }; + INVERSES = {}; __g = BALANCED_PAIRS; for (__h = 0; __h < __g.length; __h++) { pair = __g[__h]; @@ -266,8 +265,7 @@ // the course of the token stream. re.prototype.ensure_balance = function ensure_balance(pairs) { var __i, __j, key, levels, unclosed, value; - levels = { - }; + levels = {}; this.scan_tokens((function(__this) { var __func = function(prev, token, post, i) { var __i, __j, __k, close, open; @@ -322,11 +320,11 @@ // it with the inverse of what we've just popped. // 3. Keep track of "debt" for tokens that we fake, to make sure we end // up balanced in the end. + // re.prototype.rewrite_closing_parens = function rewrite_closing_parens() { var __i, debt, key, stack, val; stack = []; - debt = { - }; + debt = {}; __i = INVERSES; for (key in __i) { val = __i[key]; diff --git a/lib/coffee_script/scope.js b/lib/coffee_script/scope.js index c4415986..b322a218 100644 --- a/lib/coffee_script/scope.js +++ b/lib/coffee_script/scope.js @@ -12,8 +12,7 @@ this.parent = parent; this.expressions = expressions; this.method = method; - this.variables = { - }; + this.variables = {}; this.temp_variable = this.parent ? this.parent.temp_variable : '__a'; return this; }); diff --git a/src/nodes.coffee b/src/nodes.coffee index 7c7e132c..9cf85c38 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -4,7 +4,7 @@ process.mixin require './scope' # Tabs are two spaces for pretty printing. TAB: ' ' -TRAILING_WHITESPACE: /\s+$/g +TRAILING_WHITESPACE: /\s+$/gm # Keep the identifier regex in sync with the Lexer. IDENTIFIER: /^[a-zA-Z$_](\w|\$)*$/ @@ -382,13 +382,13 @@ ExtendsNode: exports.ExtendsNode: inherit Node, { # Hooking one constructor into another's prototype chain. compile_node: (o) -> - constructor: o.scope.free_variable() - child: @child.compile(o) - parent: @parent.compile(o) - @idt() + constructor + ' = function(){};\n' + @idt() + - constructor + '.prototype = ' + parent + ".prototype;\n" + @idt() + + construct: o.scope.free_variable() + child: @child.compile(o) + parent: @parent.compile(o) + @idt() + construct + ' = function(){};\n' + @idt() + + construct + '.prototype = ' + parent + ".prototype;\n" + @idt() + child + '.__superClass__ = ' + parent + ".prototype;\n" + @idt() + - child + '.prototype = new ' + constructor + "();\n" + @idt() + + child + '.prototype = new ' + construct + "();\n" + @idt() + child + '.prototype.constructor = ' + child + ';' }