HACKER Q&A
📣 kesava

Beginner non-trivial transpiler projects to learn from?


I have some compilers background and would like to study beginner non-trivial transpiler source code. Any recommendations?


  👤 HackedBunny Accepted Answer ✓
These might be too far off the beaten track for you, being non-standard languages with full game library systems, but Mark Sibly's Monkey2 (discontinued for lack of support) is a complex transpiler project written in a very read-friendly language:

https://github.com/blitz-research/monkey2/tree/develop/src/m...

... and one of his previous languages, BlitzMax, is continued by others today as BlitzMaxNG, and it uses a frequently-updated transpiler based off the former/similar Monkey language:

https://github.com/bmx-ng/bcc

Again, easy to read, and the principles are the same for almost any language.

Downloadable distros:

https://blitzresearch.itch.io/monkey2 https://blitzmax.org/

Targets include Windows x86/64, Mac, Linux, Android and HTML5... among others!


👤 Const-me
Take a look there: https://github.com/Const-me/vis_avs_dx/tree/master/avs_dx/Dx... Couple test cases: https://github.com/Const-me/vis_avs_dx/blob/master/avs_dx/Co...

The transpiler is in C++/17. The source language is something called NSEEL, implemented in Winamp couple decades ago. The original runtime was a JIT into old-school x87 code. The target language is Microsoft HLSL, specifically it’s for shader model 5 for Direct3D 11.0.

I have little to no background with compiler development, but IMO my transpiler ain’t too bad, and it’s very efficient.


👤 quickthrower2
I knocked something up. It might be a bit too trivial but I’ll let you judge: https://github.com/mcapodici/badlanguage

👤 max_
You may want to have a look at an "MVP" compiler one of such projects is The Super Tiny Compiler[0]

[0]https://github.com/jamiebuilds/the-super-tiny-compiler