logoalt Hacker News

ape4today at 11:45 AM1 replyview on HN

Would a practical approach be parsing the source into clang's AST format. Then let it make the actual executable.


Replies

ethan_smithtoday at 5:58 PM

You'd more likely want to emit LLVM IR rather than try to match clang's internal AST. That's essentially what most new language projects do now (Rust, Swift, Zig all use LLVM as their backend). You get optimization passes and codegen for multiple architectures for free, and the IR is well-documented. The tradeoff is you skip learning about the backend, which is arguably the most interesting part.