adding body-less while expressions
This commit is contained in:
parent
4c3f00cf77
commit
ae58e2ec6c
|
@ -14,9 +14,9 @@
|
||||||
# end
|
# end
|
||||||
|
|
||||||
LotteryTicket: {
|
LotteryTicket: {
|
||||||
get_picks: => this.picks
|
get_picks: => this.picks
|
||||||
set_picks: nums => this.picks: nums
|
set_picks: nums => this.picks: nums
|
||||||
get_purchase: => this.purchase
|
get_purchase: => this.purchase
|
||||||
set_purchase: amount => this.purchase: amount
|
set_purchase: amount => this.purchase: amount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -340,6 +340,7 @@ rule
|
||||||
# The while loop. (there is no do..while).
|
# The while loop. (there is no do..while).
|
||||||
While:
|
While:
|
||||||
WHILE Expression Block { result = WhileNode.new(val[1], val[2]) }
|
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.
|
# Array comprehensions, including guard and current index.
|
||||||
|
|
|
@ -609,6 +609,7 @@ module CoffeeScript
|
||||||
o[:top] = true
|
o[:top] = true
|
||||||
cond = @condition.compile(o)
|
cond = @condition.compile(o)
|
||||||
post = returns ? "\n#{idt}return null;" : ''
|
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}")
|
write("#{idt}while (#{cond}) {\n#{@body.compile(o)}\n#{idt}}#{post}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue