feat: add block scope support with push/pop macros and scope tracking in compiler

Introduce Scope struct and PUSH_SCOPE/POP_SCOPE macros to manage nested variable scopes during compilation. Update declareVariable to distinguish global declarations from local ones based on scope presence rather than parent compiler. Add truncateSymbolTable helper to clean up local symbols when exiting a scope. Include new test files verifying scoped variable isolation in if, while, and block constructs.
This commit is contained in:
Bob Nystrom
2013-11-18 17:19:03 +00:00
parent dc2f053d76
commit ed9f4ec9f3
8 changed files with 127 additions and 14 deletions
@@ -0,0 +1,9 @@
{
var a = "first"
io.write(a) // expect: first
}
{
var a = "second"
io.write(a) // expect: second
}