Python version of the super tiny compiler project.
Just for study, and I am interested in compiler implementation, so I follow this tiny project to study the basic ideas to implement a small compiler:)
In this project, the object is to transform Lisp-style
code to C-style
code. And there are four phases implemented:
- tokenizer, similar to
lexer
to generate token from source code - parser, conduct tokens to AST(abstract syntax tree)
- transformer, change AST v1 to AST v2
- code generator, output target code from AST v2
> compiler("(add 2 (subtract 4 2))")
add(2, subtract(4, 2));
MIT Licence