I am actually thinking these days about building a BASIC compiler for another Z80 retro machine (Galaksija). But I am a little bit afraid about the machine code generation part. How hard was it to target Z80?
Automatic generation of code for Z80 is kind of hard because some operations are forced to use a few registers.
For example, ADD only works with A or HL (and IX or IY), and the code generator requires register shuffling or using the stack for saving temporary values.
My current approach is building a node tree for expressions, generating code by detecting common patterns, and if there isn't a pattern it goes the complicated but simple way. For example, for add:
right expr. / push hl / left expr. / pop de / add hl,de