adding body-less while expressions

This commit is contained in:
Jeremy Ashkenas 2010-01-09 11:51:32 -05:00
parent 4c3f00cf77
commit ae58e2ec6c
3 changed files with 5 additions and 3 deletions

View File

@ -14,9 +14,9 @@
# end
LotteryTicket: {
get_picks: => this.picks
set_picks: nums => this.picks: nums
get_purchase: => this.purchase
get_picks: => this.picks
set_picks: nums => this.picks: nums
get_purchase: => this.purchase
set_purchase: amount => this.purchase: amount
}

View File

@ -340,6 +340,7 @@ rule
# The while loop. (there is no do..while).
While:
WHILE Expression Block { result = WhileNode.new(val[1], val[2]) }
| WHILE Expression { result = WhileNode.new(val[1], nil) }
;
# Array comprehensions, including guard and current index.

View File

@ -609,6 +609,7 @@ module CoffeeScript
o[:top] = true
cond = @condition.compile(o)
post = returns ? "\n#{idt}return null;" : ''
return write("#{idt}while (#{cond});#{post}") if @body.nil?
write("#{idt}while (#{cond}) {\n#{@body.compile(o)}\n#{idt}}#{post}")
end
end