Example functional compiler

In the not too distant past, I wanted to work on an example compiler in a similar vein as the “Real World” project for UI libraries. That is, a minimal, straightforward compiler that illustrates techniques that can be used for production-level results. For example, it’s easy to just error "Bad" and crash in a pedagogical compiler, but it’s harder if you want good source spans and pretty errors. I don’t think I’ve achieved everything I’ve wanted to, and it’s not as documented and bug-free as I’d like, but I hope you find the result useful anyway.


Here were some examples of error reporting:


Did you consider a language server? It seems like language servers are a major advantage that new development environments can utilize now.

1 Like

In parsing you stated “This means our original source is fully represented in this tree, and can be printed back out exactly.” How do you get this to print back to source? I see no implementation for that. Would you consider a biparsing solution similar to the one outlined in https://github.com/BebeSparkelSparkel/biparsing/blob/master/papers/1902.06950.pdf ?


Actually, I’m just adding these as issues so they can be better connected to the repo.

1 Like