Skip to content

Latest commit

 

History

History
30 lines (19 loc) · 1.04 KB

README.md

File metadata and controls

30 lines (19 loc) · 1.04 KB

Build Status Coverage Status

another-super-tiny-compiler

Python version of the super tiny compiler project.

Why

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:)

Implementation

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

Demo

> compiler("(add 2 (subtract 4 2))")
add(2, subtract(4, 2));

Licence

MIT Licence