From 78835073db81fef9484824259138356472b48491 Mon Sep 17 00:00:00 2001 From: satyr Date: Thu, 21 Oct 2010 06:00:52 +0900 Subject: [PATCH] removed extra parens from array/index compilations --- lib/grammar.js | 2 +- lib/nodes.js | 8 ++++---- lib/optparse.js | 2 +- lib/rewriter.js | 2 +- src/nodes.coffee | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/grammar.js b/lib/grammar.js index cad68f95..f3424c83 100644 --- a/lib/grammar.js +++ b/lib/grammar.js @@ -12,7 +12,7 @@ action = (match = unwrap.exec(action)) ? match[1] : "(" + action + "())"; action = action.replace(/\bnew /g, '$&yy.'); action = action.replace(/\bExpressions\.wrap\b/g, 'yy.$&'); - return [patternString, ("$$ = " + action + ";"), options]; + return [patternString, "$$ = " + action + ";", options]; }; grammar = { Root: [ diff --git a/lib/nodes.js b/lib/nodes.js index a56df961..93931108 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -188,9 +188,9 @@ }; Expressions.prototype.makeReturn = function() { var end, idx; - end = this.expressions[(idx = this.expressions.length - 1)]; + end = this.expressions[idx = this.expressions.length - 1]; if (end instanceof Comment) { - end = this.expressions[(idx -= 1)]; + end = this.expressions[idx -= 1]; } if (end && !(end instanceof Return)) { this.expressions[idx] = end.makeReturn(); @@ -646,7 +646,7 @@ __extends(Index, Base); Index.prototype.children = ['index']; Index.prototype.compileNode = function(o) { - return "" + (this.proto ? '.prototype' : '') + "[" + (this.index.compile(o)) + "]"; + return (this.proto ? '.prototype' : '') + ("[" + (this.index.compileBare(o)) + "]"); }; Index.prototype.isComplex = function() { return this.index.isComplex(); @@ -849,7 +849,7 @@ objects = []; for (i = 0, _len2 = (_ref3 = this.objects).length; i < _len2; i++) { obj = _ref3[i]; - code = obj.compile(o); + code = obj.compileBare(o); objects.push(obj instanceof Comment ? "\n" + code + "\n" + (o.indent) : i === this.objects.length - 1 ? code : code + ', '); } objects = objects.join(''); diff --git a/lib/optparse.js b/lib/optparse.js index cd4e534e..4a9ae283 100755 --- a/lib/optparse.js +++ b/lib/optparse.js @@ -22,7 +22,7 @@ for (_i = 0, _len2 = (_ref = this.rules).length; _i < _len2; _i++) { rule = _ref[_i]; if (rule.shortFlag === arg || rule.longFlag === arg) { - value = rule.hasArgument ? args[(i += 1)] : true; + value = rule.hasArgument ? args[i += 1] : true; options[rule.name] = rule.isList ? (options[rule.name] || []).concat(value) : value; matchedRule = true; break; diff --git a/lib/rewriter.js b/lib/rewriter.js index a96067ef..eb4fe250 100644 --- a/lib/rewriter.js +++ b/lib/rewriter.js @@ -333,7 +333,7 @@ if (!(__indexOf.call(EXPRESSION_END, tag) >= 0)) { return 1; } - if (debt[(inv = INVERSES[tag])] > 0) { + if (debt[inv = INVERSES[tag]] > 0) { debt[inv] -= 1; tokens.splice(i, 1); return 0; diff --git a/src/nodes.coffee b/src/nodes.coffee index 0805638b..3a9e20c0 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -581,7 +581,7 @@ exports.Index = class Index extends Base super() compileNode: (o) -> - "#{ if @proto then '.prototype' else '' }[#{ @index.compile o }]" + (if @proto then '.prototype' else '') + "[#{ @index.compileBare o }]" isComplex: -> @index.isComplex() @@ -732,7 +732,7 @@ exports.ArrayLiteral = class ArrayLiteral extends Base return @compileSplatLiteral o objects = [] for obj, i in @objects - code = obj.compile o + code = obj.compileBare o objects.push (if obj instanceof Comment "\n#{code}\n#{o.indent}" else if i is @objects.length - 1