como-lang-ng
como-lang-ng copied to clipboard
Compiler, Parser, Executor separation
Write now como_compiler.c is really sloppy and includes the ast construction stage, compiling stage, and execution stage. What needs to happen is that the como_compiler.c needs to only do compiling onto a new struct which is just an array of ComoByteCode blocks.
After that, the executor can be cleaner by implementing it as a series of function pointers.
The design of the executor, the executor will have an array of ComoOpCode structs embedded in the main ExecutionEnvironment structure. The ExecutionEnvrionment structure will contain the program counter, and the stack.
The ExecutionEnvironment structure will also contain the symbol tables for each frame. A frame is a ComoByteCode struct.
The ExecutionEnvrionment structure implements the Virtual Machine for this language.
Update: I am working on implementing this.