The 'compilation state' was wrapped up in a State monad which held a list of emitted instruction blocks, free registers, and so on. I didn't go as far as to wrap each of the instructions in their own functions to get an assembly-like DSL, but you can imagine defining functions like `add = emit $ ADD` for each instruction to get the same effect.
* Expression evaluation: https://github.com/michaelmelanson/cminus-compiler/blob/mast...
* Statement compilation: https://github.com/michaelmelanson/cminus-compiler/blob/mast...
* Definition of the monad: https://github.com/michaelmelanson/cminus-compiler/blob/mast...
The 'compilation state' was wrapped up in a State monad which held a list of emitted instruction blocks, free registers, and so on. I didn't go as far as to wrap each of the instructions in their own functions to get an assembly-like DSL, but you can imagine defining functions like `add = emit $ ADD` for each instruction to get the same effect.