From 4deabf5e01405d39ce9e91b413e1184d66c8b49e Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Fri, 12 Feb 2010 16:26:28 -0500 Subject: [PATCH] passing the funky comment test --- lib/coffee_script/grammar.js | 3 ++- lib/coffee_script/parser.js | 5 ++++- src/grammar.coffee | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/coffee_script/grammar.js b/lib/coffee_script/grammar.js index b5b8ef90..57f592a2 100644 --- a/lib/coffee_script/grammar.js +++ b/lib/coffee_script/grammar.js @@ -474,7 +474,8 @@ statement: true }); }), o("Comment TERMINATOR When", function() { - return $3.comment = $1; + $3.comment = $1; + return $3; }) ], // The most basic form of "if". diff --git a/lib/coffee_script/parser.js b/lib/coffee_script/parser.js index f3881b88..42ee2a7c 100755 --- a/lib/coffee_script/parser.js +++ b/lib/coffee_script/parser.js @@ -370,7 +370,10 @@ case 173:this.$ = new IfNode($$[$0-4+2-1], $$[$0-4+3-1], null, { statement: true }); break; -case 174:this.$ = $$[$0-3+3-1].comment = $$[$0-3+1-1]; +case 174:this.$ = (function () { + $$[$0-3+3-1].comment = $$[$0-3+1-1]; + return $$[$0-3+3-1]; + }()); break; case 175:this.$ = new IfNode($$[$0-3+2-1], $$[$0-3+3-1]); break; diff --git a/src/grammar.coffee b/src/grammar.coffee index 671d91a7..65e61a46 100644 --- a/src/grammar.coffee +++ b/src/grammar.coffee @@ -406,7 +406,8 @@ grammar: { When: [ o "LEADING_WHEN SimpleArgs Block", -> new IfNode($2, $3, null, {statement: true}) o "LEADING_WHEN SimpleArgs Block TERMINATOR", -> new IfNode($2, $3, null, {statement: true}) - o "Comment TERMINATOR When", -> $3.comment: $1 + o "Comment TERMINATOR When", -> + $3.comment: $1; $3 ] # The most basic form of "if".