[HN Gopher] Let's write a compiler, part 4: Testing
___________________________________________________________________
Let's write a compiler, part 4: Testing
Author : ingve
Score : 86 points
Date : 2021-08-17 13:29 UTC (9 hours ago)
(HTM) web link (briancallahan.net)
(TXT) w3m dump (briancallahan.net)
| rightbyte wrote:
| Looking 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 wrote:
| > 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. l-calculus into C in
| one go, without separate lambda-lifting/closure-converting
| steps: it's absolutely doable but quite messy.
| chrisseaton wrote:
| > feels more like an assembler than a compiler
|
| Yes it's a kind of transpiler, or template compiler, a
| typically 1-1 mapping.
| ModernMech wrote:
| It seems like we're going to have the same discussion on this
| topic every day until all parts are posted.
| monocasa wrote:
| When 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.
| p4bl0 wrote:
| For 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=28197876
___________________________________________________________________
(page generated 2021-08-17 23:01 UTC)