4 ms·
Let's write a compiler, part 4: Testing
- p4bl0 5y agoFor context, there was some discussion here on HN about parts 1 and 3 of this series: https://news.ycombinator.com/item?id=28183062 https://news.ycombinator.com/item?id=28183062 https://news.ycombinator.com/item?id=28197876 https://news.ycombinator.com/item?id=28197876
- rightbyte 5y agoLooking at the code it feels more like an assembler than a compiler since there is no mess and it outputs C code. But it is very clean and nice. I like the pattern.
- Joker_vD 5y ago> more like an assembler than a compiler since there is no mess and it outputs C code. Yes, translating between closely related languages is often like this: the mapping between their constructs is 1-to-1 and almost trivial. But try translating e.g. λ-calculus into C in one go, without separate lambda-lifting/closure-converting steps: it's absolutely doable but quite messy.
- chrisseaton 5y ago> feels more like an assembler than a compiler Yes it's a kind of transpiler, or template compiler, a typically 1-1 mapping.
- ModernMech 5y agoIt seems like we're going to have the same discussion on this topic every day until all parts are posted.
- monocasa 5y agoWhen absolute compiler perf isn't required, I love nanopass compilers for this. Each pass slowly massages a slightly different IR towards the final form and there isn't really a limit to how different the code source and end target can be, just needs more passes.