1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

ForBody is really the ForSource

This commit is contained in:
Jeremy Ashkenas 2009-12-25 13:40:57 -08:00
parent 763e04fec9
commit f55b4cd8b6

View file

@ -318,15 +318,17 @@ rule
# Array comprehensions, including guard and current index.
For:
Expression FOR
ForVariables ForBody { result = ForNode.new(val[0], val[3][0], val[2][0], val[3][1], val[2][1]) }
ForVariables ForSource { result = ForNode.new(val[0], val[3][0], val[2][0], val[3][1], val[2][1]) }
;
# An array comprehension has variables for the current element and index.
ForVariables:
IDENTIFIER { result = val }
| IDENTIFIER "," IDENTIFIER { result = [val[0], val[2]] }
;
ForBody:
# The source of the array comprehension can optionally be filtered.
ForSource:
IN PureExpression "." { result = [val[1]] }
| IN PureExpression
IF Expression "." { result = [val[1], val[3]] }