The Ragg tutorial uses Brainfuck as an example of how to use "compile a language by macros". The grammar of the input language is specified as BNF and the output is a syntax object representing Racket forms. Syntax objects are normally used in Racket to implement macros - and therefore there is an extremely rich support for manipulating syntax objects builtin. Using this machinery it is relatively simple to implement compilers using this representation of programs.
Since Brainfuck is an artifical language, I thought I'd show how to compile a "real" language using the same approach. My first idea was to look at Basic, but I decided it would be more fun to pick a language with types.
Having read Jensen's book on compiling Pascal years ago (a must read if you are interested in Pascal compilers) the choice fell on Pascal.
2 comments
[ 4.8 ms ] story [ 18.8 ms ] threadCan you elaborate why you chose a mini Pascal and the Readme mentions a Ragg tutorial, do you have a link?
Since Brainfuck is an artifical language, I thought I'd show how to compile a "real" language using the same approach. My first idea was to look at Basic, but I decided it would be more fun to pick a language with types.
Having read Jensen's book on compiling Pascal years ago (a must read if you are interested in Pascal compilers) the choice fell on Pascal.
The Ragg tutorial:
http://www.hashcollision.org/brainfudge/