The #Kittyscript compiler (as per it's current concept) has three phases: parser...
Luna Dragofelis ΘΔ🏳️⚧️🐱& @LunaDragofelis@void.lgbt
The #Kittyscript compiler (as per it's current concept) has three phases: parser, midend and backend.
The parser and the backend can be switched out to use different source languages and targets.
The input to the midend is a Lisp-like tree of lists, symbols and literals. The midend applies compiler plugins and macros that can access and modify the environment of their surrounding expression, and calls itself recursively.
I'm currently thinking hard about what the midend's output structure looks like. It doesn't need to be immediately serializable, just like how the input expressions don't need to be serializable either, because the compiler stages run inside the same Kittyscript process. (The in-Kittyscript part of a backend stage can also choose to just dump it into a byte stream to feed into a separate compiler system like LLVM)
My idea for the midend output is still vague, but it might be a Pascal-like semantic structure where the variables are explicit and not declared by the statements (the midend already collected all the variables declared in the block) and closures are explicitly getting passed their enclosed variables (the midend has already tracked which variables get used in the closure).
The parser and the backend can be switched out to use different source languages and targets.
The input to the midend is a Lisp-like tree of lists, symbols and literals. The midend applies compiler plugins and macros that can access and modify the environment of their surrounding expression, and calls itself recursively.
I'm currently thinking hard about what the midend's output structure looks like. It doesn't need to be immediately serializable, just like how the input expressions don't need to be serializable either, because the compiler stages run inside the same Kittyscript process. (The in-Kittyscript part of a backend stage can also choose to just dump it into a byte stream to feed into a separate compiler system like LLVM)
My idea for the midend output is still vague, but it might be a Pascal-like semantic structure where the variables are explicit and not declared by the statements (the midend already collected all the variables declared in the block) and closures are explicitly getting passed their enclosed variables (the midend has already tracked which variables get used in the closure).