frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Ask HN: Testing AST or assembly output for a compiler

2•backslash_16•1d ago
Hi Hacker News,

I'm working on a c compiler from scratch and am in a bit of a deadzone figuring out how I can test the generated AST and assembly output. I'm specifically having a hard time finding something that is viable for a one person project and which is also useful.

I did some research on Clang and saw they use a custom Filecheck library. This looks incredible for a production grade compiler but for mine I'm not sure if I want to put in all of the effort (especially because my host language F# doesn't have a Filecheck lib and I would have to re-create it).

Same with the AST - the best I can think of is creating the nodes in my host code language. This is verbose.

What have you done to test and check your compiler output, any good recommendations for me? I'm happy to research or read anything. Please keep in mind I'm going for a good effort to reward ratio.

Comments

nicohayes•23h ago
Honestly, I think the biggest win is just having a solid test harness that can compare AST snapshots across versions. It’s not glamorous, but it catches regressions early and gives you confidence when you refactor the optimizer. Maybe throw in some fuzzing on the AST nodes and see what breaks – it’s surprisingly fun.
Jtsummers•15h ago
You can try creating an interpreter for the AST and other IR forms you use. This can also free you from testing for specific generated ASTs and IR, so long as they're equivalent (when executed will produce the same results). This will be more helpful once you start with things like adding in optimization passes.

Ask HN: Our AWS account got compromised after their outage

295•kinj28•16h ago•67 comments

Ask HN: Are you / should we be preparing for "cyberattack"

4•lifeisstillgood•1h ago•2 comments

Did people in the 90s worry about the efficiency of the internet

9•burgiee•8h ago•8 comments

Ask HN: What are people doing to get off of VMware?

188•jwithington•2d ago•162 comments

Ask HN: How to stop an AWS bot sending 2B requests/month?

282•lgats•5d ago•181 comments

HTTP error codes illustrated with stills from Columbo

8•ColinWright•17h ago•5 comments

Walrus: A High Performance Storage Engine built from first principles

8•nubskr•20h ago•0 comments

Claude output matching copyrighted StackOverflow code

4•randsp•22h ago•4 comments

Ask HN: How does one build large front end apps without a framework like React?

106•thepianodan•4d ago•186 comments

Ask HN: Why is Bowker's monopoly on ISBNs in the USA legal?

17•blindprogrammer•1d ago•12 comments

Programming language agnosticism is the only way to move forward in life

29•amano-kenji•3d ago•20 comments

Ask HN: What are you working on? (October 2025)

346•david927•1w ago•1049 comments

Warning: Gmail client Show Original can omit lines of the original

18•chrisjj•2d ago•2 comments

Ask HN: Abandoned/dead projects you think died before their time and why?

362•ofalkaed•1w ago•890 comments

Ask HN: Best way to make a documentation website for an open-source project?

5•mudge•2d ago•5 comments

Ask HN: Why isn't Amazon.com impacted by AWS outages?

5•trevoragilbert•1d ago•11 comments

Ask HN: DOS Based "Multitaskers"

5•alexshendi•3d ago•2 comments

Ask HN: Web app freezes, but not when Chrome is recording. How to debug?

6•febed•5d ago•2 comments

Ask HN: SQL using relational theory books?

6•shivajikobardan•3d ago•3 comments

Ask HN: Testing AST or assembly output for a compiler

2•backslash_16•1d ago•2 comments

Ask HN: Those who applied to the OpenAI Grove program, did you ever hear back?

23•heywoods•2d ago•8 comments

Ask HN: What level of news do you need and not need?

10•bwb•1d ago•12 comments

Ask HN: Is there an open source HN?

10•shafkathullah•2d ago•9 comments

Ask HN: New YouTube player not working in Firefox

3•gethly•1d ago•11 comments

Ask HN: I have a CS degree but taught for 5 years– how can I get back into tech?

4•padzochambers•1d ago•17 comments

Ask HN: Estimation of copyright material used by LLM

5•megamix•3d ago•8 comments

You've reached the end!