feat: replace AST-based parser with single-pass bytecode compiler and VM
Replace the recursive-descent parser that built an AST (Node* tree) with a single-pass compiler that emits bytecode directly into a Block structure. Remove the parser.c/parser.h files and their AST node types (NodeLiteral, NodeCall, NodeBinaryOp, etc.), add new compiler.c/compiler.h with a Compiler struct and Pratt-style precedence parsing that outputs CODE_CONSTANT and CODE_END instructions, and introduce vm.c/vm.h containing a Fiber-based interpreter with a stack, interpret() loop, and printValue() for OBJ_INT. Update main.c to call compile() then interpret() instead of parse(), remove TOKEN_INDENT/TOKEN_OUTDENT from token.h and dumpTokens(), and adjust the Xcode project to include the new source files while excluding the old parser.
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
123(1, true, "a string".whatevs)
|
||||
2
|
||||
|
||||
Reference in New Issue
Block a user