Retoor software development Projects Research SearchXNG
Register Sign In

16 lines
210 B
Plaintext
Raw Normal View History

feat: add break statement support with loop tracking and error handling Add TOKEN_BREAK keyword recognition and a loopBody field to the compiler to track the innermost loop's first instruction index. The break statement emits a jump to the end of the current loop, and compile-time errors are reported when break appears outside a loop body, inside a function defined within a loop, or inside a method defined within a loop. New test files verify correct behavior for break in while loops, nested loops, and error cases for invalid break usage.
2013-12-24 19:15:50 +01:00
var i = 0
while (true) {
i = i + 1
IO.write(i)
if (i > 2) {
// TODO: Should not require block for break.
break
}
IO.write(i)
}
// expect: 1
// expect: 1
// expect: 2
// expect: 2
// expect: 3
Reference in New Issue Copy Permalink
1a456738f6
wren/test/break/in_while_loop.wren
Response time: 26ms
Mail Licenses API