From f55b4cd8b68c5004f9027f73d25d85010ef74ff7 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Fri, 25 Dec 2009 13:40:57 -0800 Subject: [PATCH] ForBody is really the ForSource --- lib/coffee_script/grammar.y | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/coffee_script/grammar.y b/lib/coffee_script/grammar.y index 5dd42d3b..99034a2a 100644 --- a/lib/coffee_script/grammar.y +++ b/lib/coffee_script/grammar.y @@ -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]] }