diff --git a/lib/coffee-script.js b/lib/coffee-script.js index 6d613841..e05eb1b6 100644 --- a/lib/coffee-script.js +++ b/lib/coffee-script.js @@ -1,6 +1,6 @@ (function() { var Lexer, compile, helpers, lexer, parser, path, processScripts; - if (typeof process !== "undefined" && process !== null) { + if ((typeof process !== "undefined" && process !== null)) { path = require('path'); Lexer = require('./lexer').Lexer; parser = require('./parser').parser; diff --git a/lib/helpers.js b/lib/helpers.js index af94f522..1a80b5ef 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -1,6 +1,6 @@ (function() { var compact, count, del, ends, extend, flatten, helpers, include, indexOf, merge, starts; - if (!(typeof process !== "undefined" && process !== null)) { + if (!((typeof process !== "undefined" && process !== null))) { this.exports = this; } helpers = (exports.helpers = {}); @@ -70,7 +70,7 @@ _a = []; _b = properties; for (key in _b) { val = _b[key]; - _a.push(object[key] = val); + _a.push((object[key] = val)); } return _a; }); diff --git a/lib/lexer.js b/lib/lexer.js index acc6a9e4..8cf3c9bf 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -1,7 +1,7 @@ (function() { var ASSIGNED, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_KEYWORDS, COMMENT, CONVERSIONS, HEREDOC, HEREDOC_INDENT, IDENTIFIER, JS_CLEANER, JS_FORBIDDEN, JS_KEYWORDS, LAST_DENT, LAST_DENTS, LINE_BREAK, Lexer, MULTILINER, MULTI_DENT, NEXT_CHARACTER, NOT_REGEX, NO_NEWLINE, NUMBER, OPERATOR, REGEX_END, REGEX_ESCAPE, REGEX_INTERPOLATION, REGEX_START, RESERVED, Rewriter, STRING_NEWLINES, WHITESPACE, _a, _b, _c, compact, count, helpers, include, starts; var __slice = Array.prototype.slice; - if (typeof process !== "undefined" && process !== null) { + if ((typeof process !== "undefined" && process !== null)) { _a = require('./rewriter'); Rewriter = _a.Rewriter; _b = require('./helpers'); @@ -537,7 +537,7 @@ if (!(tok = this.prev(index))) { return null; } - if (typeof newTag !== "undefined" && newTag !== null) { + if ((typeof newTag !== "undefined" && newTag !== null)) { return (tok[0] = newTag); } return tok[0]; @@ -547,7 +547,7 @@ if (!(tok = this.prev(index))) { return null; } - if (typeof val !== "undefined" && val !== null) { + if ((typeof val !== "undefined" && val !== null)) { return (tok[1] = val); } return tok[1]; diff --git a/lib/nodes.js b/lib/nodes.js index f64ef318..10cbe8c1 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -1,5 +1,5 @@ (function() { - var AccessorNode, ArrayNode, AssignNode, BaseNode, CallNode, ClassNode, ClosureNode, CodeNode, CommentNode, DOUBLE_PARENS, ExistenceNode, Expressions, ExtendsNode, ForNode, IDENTIFIER, IS_STRING, IfNode, InNode, IndexNode, LiteralNode, NUMBER, ObjectNode, OpNode, ParamNode, ParentheticalNode, PushNode, RangeNode, ReturnNode, SIMPLENUM, Scope, SliceNode, SplatNode, TAB, TRAILING_WHITESPACE, ThrowNode, TryNode, UTILITIES, ValueNode, WhileNode, _a, compact, del, ends, flatten, helpers, include, indexOf, literal, merge, starts, utility; + var AccessorNode, ArrayNode, AssignNode, BaseNode, CallNode, ClassNode, ClosureNode, CodeNode, CommentNode, ExistenceNode, Expressions, ExtendsNode, ForNode, IDENTIFIER, IS_STRING, IfNode, InNode, IndexNode, LiteralNode, NUMBER, ObjectNode, OpNode, ParamNode, ParentheticalNode, PushNode, RangeNode, ReturnNode, SIMPLENUM, Scope, SliceNode, SplatNode, TAB, TRAILING_WHITESPACE, ThrowNode, TryNode, UTILITIES, ValueNode, WhileNode, _a, compact, del, ends, flatten, helpers, include, indexOf, literal, merge, starts, utility; var __extends = function(child, parent) { var ctor = function(){}; ctor.prototype = parent.prototype; @@ -8,7 +8,7 @@ if (typeof parent.extended === "function") parent.extended(child); child.__superClass__ = parent.prototype; }; - if (typeof process !== "undefined" && process !== null) { + if ((typeof process !== "undefined" && process !== null)) { Scope = require('./scope').Scope; helpers = require('./helpers').helpers; } else { @@ -227,7 +227,6 @@ o.scope = new Scope(null, this, null); code = this.compileWithDeclarations(o); code = code.replace(TRAILING_WHITESPACE, ''); - code = code.replace(DOUBLE_PARENS, '($1)'); return o.noWrap ? code : ("(function() {\n" + (code) + "\n})();\n"); }; Expressions.prototype.compileWithDeclarations = function(o) { @@ -1776,7 +1775,6 @@ }; TAB = ' '; TRAILING_WHITESPACE = /[ \t]+$/gm; - DOUBLE_PARENS = /\(\(([^\(\)\n]*)\)\)/g; IDENTIFIER = /^[a-zA-Z\$_](\w|\$)*$/; NUMBER = /^(((\b0(x|X)[0-9a-fA-F]+)|((\b[0-9]+(\.[0-9]+)?|\.[0-9]+)(e[+\-]?[0-9]+)?)))\b$/i; SIMPLENUM = /^-?\d+/; diff --git a/lib/rewriter.js b/lib/rewriter.js index 025ded1b..4b3853d2 100644 --- a/lib/rewriter.js +++ b/lib/rewriter.js @@ -3,7 +3,7 @@ var __bind = function(func, context) { return function(){ return func.apply(context, arguments); }; }, __hasProp = Object.prototype.hasOwnProperty; - if (typeof process !== "undefined" && process !== null) { + if ((typeof process !== "undefined" && process !== null)) { _a = require('./helpers'); helpers = _a.helpers; } else { diff --git a/lib/scope.js b/lib/scope.js index 7c66cd6a..01eadef7 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -1,7 +1,7 @@ (function() { var Scope; var __hasProp = Object.prototype.hasOwnProperty; - if (!(typeof process !== "undefined" && process !== null)) { + if (!((typeof process !== "undefined" && process !== null))) { this.exports = this; } exports.Scope = (function() { diff --git a/src/nodes.coffee b/src/nodes.coffee index d6e94512..2784aa3d 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -205,7 +205,6 @@ exports.Expressions = class Expressions extends BaseNode o.scope = new Scope(null, this, null) code = @compileWithDeclarations(o) code = code.replace(TRAILING_WHITESPACE, '') - code = code.replace(DOUBLE_PARENS, '($1)') if o.noWrap then code else "(function() {\n#{code}\n})();\n" # Compile the expressions body for the contents of a function, with @@ -1539,9 +1538,6 @@ TAB = ' ' # with Git. TRAILING_WHITESPACE = /[ \t]+$/gm -# Obvious redundant parentheses should be removed. -DOUBLE_PARENS = /\(\(([^\(\)\n]*)\)\)/g - # Keep these identifier regexes in sync with the Lexer. IDENTIFIER = /^[a-zA-Z\$_](\w|\$)*$/ NUMBER = /^(((\b0(x|X)[0-9a-fA-F]+)|((\b[0-9]+(\.[0-9]+)?|\.[0-9]+)(e[+\-]?[0-9]+)?)))\b$/i diff --git a/test/test_literals.coffee b/test/test_literals.coffee index 095de6f5..7c7f6e43 100644 --- a/test/test_literals.coffee +++ b/test/test_literals.coffee @@ -54,9 +54,9 @@ trailingComma = {k1: "v1", k2: 4, k3: (-> true),} ok trailingComma.k3() and (trailingComma.k2 is 4) and (trailingComma.k1 is "v1") -money$ = 'dollars' +money$ = '(((dollars)))' -ok money$ is 'dollars' +ok money$ is '\(\(\(dollars\)\)\)' multiline = "one