Browse files

Switching parenthesized side in comprehensions.

  • Loading branch information...
1 parent b32a758 commit 6347849cd085ef961767e67569d045a74c9dca68 @jashkenas committed Oct 24, 2010
View
2 Cakefile
@@ -42,7 +42,7 @@ task 'install', 'install CoffeeScript into /usr/local (or --prefix)', (options)
task 'build', 'build the CoffeeScript language from source', ->
files = fs.readdirSync 'src'
- files = 'src/' + file for file in files when file.match(/\.coffee$/)
+ files = ('src/' + file for file in files when file.match(/\.coffee$/))
run ['-c', '-o', 'lib'].concat(files)
View
2 examples/underscore.coffee
@@ -438,7 +438,7 @@
# Extend a given object with all of the properties in a source object.
_.extend = (obj) ->
for source in _.rest(arguments)
- (obj[key] = val) for key, val of source
+ obj[key] = val for key, val of source
obj
View
2 lib/command.js
@@ -120,7 +120,7 @@
if (o.watch) {
return console.log(err.message);
}
- error(err.stack);
+ console.error(err.stack);
return process.exit(1);
}
};
View
2 lib/grammar.js
@@ -596,7 +596,7 @@
})
]
};
- operators = [["left", 'CALL_START', 'CALL_END'], ["nonassoc", '++', '--'], ["left", '?'], ["right", 'UNARY'], ["left", 'MATH'], ["left", '+', '-'], ["left", 'SHIFT'], ["left", 'RELATION'], ["left", 'COMPARE'], ["left", 'LOGIC'], ["left", '.'], ["nonassoc", 'INDENT', 'OUTDENT'], ["right", '=', ':', 'COMPOUND_ASSIGN', 'RETURN'], ["right", 'WHEN', 'LEADING_WHEN', 'FORIN', 'FOROF', 'FROM', 'TO', 'BY', 'THROW'], ["right", 'IF', 'UNLESS', 'POST_IF', 'POST_UNLESS', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS', 'EXTENDS']];
+ operators = [["left", 'CALL_START', 'CALL_END'], ["nonassoc", '++', '--'], ["left", '?'], ["right", 'UNARY'], ["left", 'MATH'], ["left", '+', '-'], ["left", 'SHIFT'], ["left", 'RELATION'], ["left", 'COMPARE'], ["left", 'LOGIC'], ["left", '.'], ["nonassoc", 'INDENT', 'OUTDENT'], ["right", '=', ':', 'COMPOUND_ASSIGN', 'RETURN'], ["right", 'WHEN', 'LEADING_WHEN', 'FORIN', 'FOROF', 'FROM', 'TO', 'BY', 'THROW', 'IF', 'UNLESS', 'POST_IF', 'POST_UNLESS', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS', 'EXTENDS']];
tokens = [];
for (name in grammar) {
alternatives = grammar[name];
View
4 lib/nodes.js
@@ -664,7 +664,7 @@
}
}
o.indent = this.idt(1);
- nonComments = (function() {
+ nonComments = ((function() {
_ref3 = this.properties;
_result = [];
for (_i = 0, _len2 = _ref3.length; _i < _len2; _i++) {
@@ -674,7 +674,7 @@
}
}
return _result;
- }).call(this);
+ }).call(this));
lastNoncom = last(nonComments);
props = (function() {
_ref3 = this.properties;
View
2 lib/repl.js
@@ -21,7 +21,7 @@
console.log(inspect(val));
}
} catch (err) {
- console.log(err.stack || err.toString());
+ console.error(err.stack || err.toString());
}
return repl.prompt();
};
View
4 lib/rewriter.js
@@ -300,7 +300,7 @@
}
return 1;
});
- unclosed = (function() {
+ unclosed = ((function() {
_result = [];
for (key in levels) {
value = levels[key];
@@ -309,7 +309,7 @@
}
}
return _result;
- })();
+ })());
if (unclosed.length) {
throw Error("unclosed " + (open = unclosed[0]) + " on line " + (openLine[open] + 1));
}
View
4 src/command.coffee
@@ -109,12 +109,10 @@ compileScript = (file, input, base) ->
else if o.compile then writeJs t.file, t.output, base
else if o.lint then lint t.output
catch err
- # Avoid using 'error' as it is a special event -- if there is no handler,
- # node will print a stack trace and exit the program.
CoffeeScript.emit 'failure', err, task
return if CoffeeScript.listeners('failure').length
return console.log err.message if o.watch
- error err.stack
+ console.error err.stack
process.exit 1
# Attach the appropriate listeners to compile scripts incoming over **stdin**,
View
2 src/index.coffee
@@ -1,2 +1,2 @@
# Loader for CoffeeScript as a Node.js library.
-(exports[key] = val) for key, val of require './coffee-script'
+exports[key] = val for key, val of require './coffee-script'
View
4 src/nodes.coffee
@@ -169,7 +169,7 @@ exports.Expressions = class Expressions extends Base
push: (node) ->
@expressions.push node
this
-
+
# Remove and return the last expression of this expression list.
pop: ->
@expressions.pop()
@@ -578,7 +578,7 @@ exports.Obj = class Obj extends Base
for prop, i in @properties when (prop.variable or prop).base instanceof Parens
return @compileDynamic o, i
o.indent = @idt 1
- nonComments = prop for prop in @properties when prop not instanceof Comment
+ nonComments = (prop for prop in @properties when prop not instanceof Comment)
lastNoncom = last nonComments
props = for prop, i in @properties
join = if i is @properties.length - 1
View
2 src/repl.coffee
@@ -23,7 +23,7 @@ run = (buffer) ->
val = CoffeeScript.eval buffer.toString(), bare: on, globals: on, fileName: 'repl'
console.log inspect val if val isnt undefined
catch err
- console.log err.stack or err.toString()
+ console.error err.stack or err.toString()
repl.prompt()
# Create the REPL by listening to **stdin**.
View
4 src/rewriter.coffee
@@ -241,7 +241,7 @@ class exports.Rewriter
levels[open] -= 1
throw Error "too many #{token[1]} on line #{token[2] + 1}" if levels[open] < 0
1
- unclosed = key for all key, value of levels when value > 0
+ unclosed = (key for all key, value of levels when value > 0)
if unclosed.length
throw Error "unclosed #{ open = unclosed[0] } on line #{openLine[open] + 1}"
@@ -264,7 +264,7 @@ class exports.Rewriter
rewriteClosingParens: ->
stack = []
debt = {}
- (debt[key] = 0) for all key of INVERSES
+ debt[key] = 0 for all key of INVERSES
@scanTokens (token, i, tokens) ->
if (tag = token[0]) in EXPRESSION_START
stack.push token
View
2 src/scope.coffee
@@ -112,7 +112,7 @@ exports.Scope = class Scope
# Return the list of assignments that are supposed to be made at the top
# of this scope.
assignedVariables: ->
- "#{v.name} = #{v.type.value}" for v in @variables when v.type.assigned
+ ("#{v.name} = #{v.type.value}" for v in @variables when v.type.assigned)
# Compile the JavaScript for all of the variable declarations in this scope.
compiledDeclarations: ->
View
2 test/test_arguments.coffee
@@ -19,7 +19,7 @@ ok(area(
sumOfArgs = ->
sum = 0
- (sum += val) for val in arguments
+ sum += val for val in arguments
sum
ok sumOfArgs(1, 2, 3, 4, 5) is 15
View
2 test/test_functions.coffee
@@ -112,7 +112,7 @@ ok del() is 5
# Ensure that functions can have a trailing comma in their argument list
mult = (x, mids..., y) ->
- (x *= n) for n in mids
+ x *= n for n in mids
x *= y
ok mult(1, 2,) is 2

0 comments on commit 6347849

Please sign in to comment.