Skip to content

hanks/another-super-tiny-compiler

Repository files navigation

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

About

Python version of the super tiny compiler project

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages