From cd68f02981142db269719fe5f5904621852ae0ec Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Wed, 30 Dec 2009 18:59:33 -0500 Subject: [PATCH] big milestone. examples/code.coffee now compiles correctly under the new whitespace regime --- examples/code.coffee | 2 +- lib/coffee_script/grammar.y | 2 +- lib/coffee_script/nodes.rb | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/code.coffee b/examples/code.coffee index 2986df37..7c327ad3 100644 --- a/examples/code.coffee +++ b/examples/code.coffee @@ -150,7 +150,7 @@ Snake.prototype.move: => alert('Slithering...') super(5) -Horse: name => this.name: name. +Horse: name => this.name: name Horse extends Animal Horse.prototype.move: => alert('Galloping...') diff --git a/lib/coffee_script/grammar.y b/lib/coffee_script/grammar.y index c30bed97..6e6b377a 100644 --- a/lib/coffee_script/grammar.y +++ b/lib/coffee_script/grammar.y @@ -353,7 +353,7 @@ rule # An elsif portion of an if-else block. ElsIf: - ELSE IfBlock { result = val[1] } + ELSE IfBlock { result = val[1].force_statement } ; # Multiple elsifs can be chained together. diff --git a/lib/coffee_script/nodes.rb b/lib/coffee_script/nodes.rb index 82077906..11d5f1f4 100644 --- a/lib/coffee_script/nodes.rb +++ b/lib/coffee_script/nodes.rb @@ -684,6 +684,11 @@ module CoffeeScript @else_body ? @else_body << eb : @else_body = eb self end + + def force_statement + @tags[:statement] = true + self + end # Rewrite a chain of IfNodes with their switch condition for equality. def rewrite_condition(expression)