Cosmo/examples/break.cosmo
CPunch a408353c25 added "break" and "continue" statements
a LoopState was added to the CCompilerState struct which keeps track of breaks, start chunk index, and the start scope of the active loop.
Also, break.cosmo was added to the examples directory, 'continue' and 'break' work as expected.
2020-12-24 00:41:00 -06:00

26 lines
515 B
Plaintext

// just testing continues and breaks
for (var x = 0; x < 700; x++) do
for (var i = 0; true; i++) do
var str = i .. "." .. x
if (i == 998) then
print(i .. " reached")
break
end
print("for cont- " .. str)
continue
end
var i = 0
while true do
var str = i .. "." .. x
if (i++ == 1034) then
print("done")
break
end
print("while cont- " .. str)
continue
end
end