feat: add ObjBlock type, block compilation, and newline skipping in parser

Introduce a new ObjBlock object type with OBJ_BLOCK tag, replacing the placeholder OBJ_NUM in makeBlock(). Refactor the compiler to separate Parser and Compiler structs, adding skipNewlines and hasError fields to Parser and a parent pointer to Compiler for nested block support. Implement compileBlock() function that compiles a block up to a specified end token, and update callBlock() in the VM to push empty slots for local variables. Adjust token reading functions to accept Parser instead of Compiler, and remove the MAX_TOKEN enum entry.
This commit is contained in:
Bob Nystrom
2013-10-24 19:39:01 +00:00
parent 816264c21e
commit 281c917a50
3 changed files with 283 additions and 144 deletions
+3 -1
View File
@@ -1,4 +1,6 @@
class Foo {}
{
123
}
var a = 123
var b = 345
a