mirror of
https://github.com/CPunch/Cosmo.git
synced 2025-11-13 02:50:05 +00:00
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.
This commit is contained in:
26
examples/break.cosmo
Normal file
26
examples/break.cosmo
Normal file
@@ -0,0 +1,26 @@
|
||||
// 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
|
||||
Reference in New Issue
Block a user