Commit Graph

1 Commits

Author SHA1 Message Date
Bob Nystrom
9bb2ca308e 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.
2013-10-22 19:16:39 +00:00