Skip to content

edcrypt/kermit

Repository files navigation

Kermit - An example interpreter

Build Status Coverage Quality

This is an example interpreter written using PyPy. A preferred way to walk through it is to follow the history of commits. Interesting tags are

For a full list of interesting tags/releases see: Latest Releases

Note

This is a fork of PyPy's example interpreter Kermit. You may still follow the commit history as a learning guide, however; this fork is a divergent from PyPy's version of Kermit and is not compatible.

Prerequisites

It is recommended that you do all development using a Python Virtual Environment using virtualenv and/or using the nice virtualenvwrapper.

$ mkvirtualenv kermit

Installation

Grab the source from https://github.com/prologic/kermit and either run python setup.py develop or pip install -e .

$ git clone https://github.com/prologic/kermit.git
$ cd kermit
$ pip install -e .

Building

To build the interpreter simply run kermit/main.py against the RPython Compiler. There is a Makefile that has a default target for building and translating the interpreter.

$ make

You can also use Docker to build the interpreter:

$ docker build -t kermit .

Usage

You can either run the interpreter using Python itself or by running the compiled interpreter kermit in ./bin/kermit.

$ ./bin/kermit examples/hello.ker

Untranslated running on top of Python (CPython):

$ kermit examples/hello.ker

Grammar

The grammar of kermit is currently as follows:

main: statement* [EOF];

statement: expr ";"
           | VARIABLE "=" expr ";"
           | "while" "(" expr ")" "{" statement* "}"
           | "if" "(" expr ")" "{" statement* "}"
           | "print" expr ";";

expr: atom ADD_SYMBOL expr | atom;

atom: DECIMAL | FLOAT | STRING | VARIABLE;

About

pypy example interpreter fork.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published