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.
This commit is contained in:
Bob Nystrom
2013-12-24 18:15:50 +00:00
parent b081f2622d
commit 1a456738f6
6 changed files with 177 additions and 20 deletions
+1
View File
@@ -0,0 +1 @@
break // expect error