Hacker News new | ask | show | jobs
by bjoli 16 days ago
i have made a language that xompiles to c#. I wrote a lexer. then a parser. then a type checker (hindley milner, function local so that top level functions must have type signatures) a match compiler.

the hardest part was what came next: the code generation. despite producing c# instead of MSIL. The features I use are: static and dynamic traits, pattern matching, and a concurrentML.

It is actually quite simple when you don't have to do closure conversion yourself.

1 comments

I've done that for transpilation from SAOL (an MPEG 4 historically curious language) to C++. It does make it incredibly easy to write the compiler.

The big drawback that I never managed to sort out is how to integrate with visual debuggers. How to generate GDB source mappings (or .PDB source mappings) that reference the original LanguageX source files.

So you end up with a toy language that is un-debuggable. Which is not nearly as much fun as it should be.

if you compile to c# you can use #line directives to get integration with debuggers. it is really simple. for debug builds you can do an ANF pass and generate debugging locations for every different expression.