toylisp: Development Log
If statements and function are the tricky thing to me, now I have to add label support, a label is also a statement that has the form of:
Ideally, the instruction list will be able to keep track of the label position, so it can jump to a label at any time….
Not much for today, just adding some unit tests and implement a symbol table during the compilation process. The way it works is pretty much like the Constant Table that was mentioned yesterday.
If we have a let statement like in the following example, after the compilation process, the
STORE_NAME opcode will be generated with the address of the
Started working on compiling logic, at this point, the compiler is capable of generating the opcode for the
let statement and some arithmetic operators.
For this project, I’ll just use a generator to create parser code, as I want to focus on the bytecode virtual machine.
PeggyJS is the best generator I could find for now, it even supports TypeScript, this mean, we can control the return type for each non-terminals….