I wish more resource were available on the part most of these leave out. Emitting the AST into machine code or IL, or instead integrating with llvm. Seems these articles all assume people would only be interested in parsers and interpreted non-compiled languages.
Turning an expression tree into basic machine code is typically relatively straightforward if the target is stack-based. Basically you do a post-order traversal. For leaf nodes, just push the value. For other nodes, obtain the arguments from the stack, perform the operation and push the result.
let me teach you 4 years of physics and now you can build a rocket that goes to the moon. compiler books feel exactly like this, parsing something seems obvious but most compiler books devote 90% of their content to parsing, but how do you convert something from a class to binary code or how do you represent loops and modules, you don't even know where to begin. I figured out parsing pretty quickly and was able to build a working parser in a week, it took me a good few months to grasp converting that to x86 instructions.
Yes! Thank you! This is 100% what I mean. Especially higher level constructs like structs or classes as well. Emitting is for some reason even more of a dark art than parsing. How crazy is that?