adding body-less while expressions
This commit is contained in:
parent
4c3f00cf77
commit
ae58e2ec6c
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue