This is a compiler for a tiny programming language called "Gone", implemented using python, PLY, and llvmpy. "Gone" is a small subset of Go with support for basic imperative programming language features.
This compiler was developed under the supervision of David Beazley (@dabeaz) during a week-long course in July 2014.
make ; make linux
python3 goner.py tests/functions/mandel.g
goneast.py
: models of AST nodes representing pieces of a Gone programgoneblock.py
: models of blocks used during code generationgonecheck.py
: an AST visitor that performs type-checking on a Gone ASTgonecode.py
: an AST visitor that generates intermediate SSA code from a Gone ASTgoneinterp.py
: an interpreter for some Gone SSA instructions (partially implemented)gonelex.py
: a lexer for tokens in the Gone languagegonellvm.py
: generates llvm "bitcode" from Gone SSA instructionsgoneparse.py
: a parser generator for Gone, defining the grammargoner.py
: the main entry point to the compilergonert.c
: the C implementation of system-level calls for the Gone runtime (such as printing)gonetype.py
: definitions of the datatypes Gone supports
You can run most of these python files on any of the files in the tests
directory to view the intermediate stages of lexing, parsing, type checking,
code generation, and running.
This compiler is written in python3, so you'll need that. It also depends on ply, which you can get with
pip install -r requirements.txt
This compiler targets llvm and uses llvmpy, so you'll need to install both to use it. It's been tested with llvm 3.3. The easiest way to get llvmpy is to install it using Anaconda.
You can also use goneinterp.py
to run programs that don't include
conditionals, loops, or user-defined functions, as the interpreter does not
support these features.