I’d like to explore the power of Clojure for compiler development, but I cannot find example to start with.
I am a total newbie (coming from Ruby), but I’m convinced that Clojure should be ideal for this purpose.
Let’s precise what I’m looking for :
- start from a simple AST defined in clojure (for let say a simple sequential language : if, while, func, assign, expression)
- simple visitor for this AST (pretty printer for example)
- I am not really interested by lexing/parsing (as I consider s-expression as sufficient for my DSL syntax)
What are the right idioms for this in Clojure ?
Here’s the simplest trivial example I can think of, using an AST tree built from s-expressions with keyword operators:
Hopefully that’s enough to give you some ideas / get you started. Obvious extensions to consider would be:
defrecordmight be suitable as an AST node representation