GithubHelp home page GithubHelp logo

maxmalysh / tiny-py-interpreter Goto Github PK

View Code? Open in Web Editor NEW
18.0 2.0 4.0 252 KB

Python interpreter written in Python. Uses ANTLR4. ๐Ÿ

License: MIT License

Python 91.67% ANTLR 8.33%
antlr interpreter compiler parsing python

tiny-py-interpreter's Introduction

Unix Build Status Windows Build status Coverage Status

TinyPy Interpreter

About

TinyPy is an interpreter of a small Python subset I have written as a coursework.

Installation

This project uses ANTLR4 as a parser generator. To run the interpreter, you will need to install ANTLR4 Python3 runtime and ANTLR itself.

Please note, that 4.5.2 runtime has a bug which results in a dramatic performance dropdown. At the moment this text was written, pypi had an older version, so it's recommended to install ANTLR4 runtime manually.

Step-by-step instruction:

  1. Install ANTLR4

  2. Install ANTLR4 Python3 runtime:

    1. git clone https://github.com/antlr/antlr4
    2. cd antlr4/runtime/Python3
    3. python3 setup.py install

    It's also possible to use pip, package name is antlr4-python3-runtime. Be aware of the bug described above.

  3. Generate parser

    1. cd tiny-py-interpreter/tinypy
    2. antlr4 -visitor parser/TinyPy.g4
  4. Install tinypy: pip3 install .

  5. Try to launch some tests: python3 setup.py test

tiny-py-interpreter's People

Contributors

maxmalysh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tiny-py-interpreter's Issues

Fix break / continue statement parsing

Add exceptions (to the parser) for break / continue outside of loops and return outside of function definition. Grammar allows it, so we should check this manually. See how Python3 does this.

Fix unicode / Cyrillic support

File input currently doesn't allow to use unicode. Manually reading from the stdin in the shell mode breaks unicode support too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.