This is a quick and rough implementation of Jellonator's Nandlang as a racket #lang using the racket-peg library!
It's done in 3 parts:
- The parser processes the nand language input files, producing a lispy abstract syntax tree.
- The transformer translates the abstract syntax tree into regular racket code, implementing the semantics of the language by embedding it in another language.
- The runtime provides functions for the translated output to make use of during execution.
The same approach could be used to implement any other language.
Make sure you have the latest version of racket-peg installed.
raco pkg remove nand-lang
raco pkg install -u -t dir nand-lang