3 ms·
I have seen a custom DSL used to do code generation once, but... it's not very nice. Here's the VM definition file for the Emerald virtual machine: https://gith
by mort96 4y ago
I have seen a custom DSL used to do code generation once, but... it's not very nice. Here's the VM definition file for the Emerald virtual machine: https://github.com/emerald/old-emerald/blob/master/vm/vm.d https://github.com/emerald/old-emerald/blob/master/vm/vm.d
I'm sure there are nicer examples out there.
- mncharity 4y agoHmm. So that vm.d is a source file for a nearby compiler[1] ... written in C. With a .l and .y, and implementations of assorted collection datatypes, and ... basically printf'ing code. Sigh. Better instead say a vm_d.py direct emitter, and skip the vmc? [1] https://github.com/emerald/old-emerald/tree/master/vmc https://github.com/emerald/old-emerald/tree/master/vmc
- mort96 4y agoI'm 100% in agreement. I don't think the idea of one source file with a DSL for sections is a terrible idea, but it could be done as a 10-line python script rather than a giant lex+yacc C project.