A interpreter written in Python for the language, Monkey
Project description
Monkey
Peelpreter is a interpreter for the language Monkey specified in the book Writing an Interpreter in Go
.
It is not not designed to be the fastest implementation but instead a (mostly) readable one.
I, personally don't find encapsulating every little function of a program in classes to be particularly readable.
Hence, I have kept things bare-bone functions where I thought it made sense and used classes to encapsulate data like C-Structs
and sometimes to store methods.
Monkey Features
Peelpreter supports all features of the canon implementation as well as some more. They are:-
- Variables
- If expressions
- First-Class Functions
- Closures
- Array
- Hash Map (Dictionary)
- Builtin Functions
- Array and Hash mutability
- Improved
puts
function
Features Planned to be added
Some features which I wish for in a programming language are not present yet in this.
Suppport for them will be slowly added as soon as type annotations are improved for the existing code base.
They are:-
1. Input function
2. Type conversion
3. Constants
4. Loops
5. Structs
6. Chaining variable assignments. E.g, let x = y = 7
7. Import System
8. Extension modules using Python
I might also added a Type Checker later on, but thats upto the future.
Installation
For installation of the package run,
pip install peelpreter
Or if you would prefer to build and install yourself for a more up-to-date version, clone the repository and cd into it,
git clone https://github.com/GogiBoy102/Peelpreter.git
cd Peelpreter
then run,
python3 -m build
If build
is not already installed onto the system then install it with,
pip install --upgrade build
After the build process ends, cd into dist
and install the tar with,
cd dist
pip install peelpreter-<version>.tar.gz
And, voila! Peelpreter has been installed! For usage, follow the next section.
Usage
Peelpreter comes with a script called monkey
which is the entry point for the interpreter and also the reccomended way for it to be used.
Files in monkey usually have the extension ".mon".
monkey
, when executed with no command line arguments starts the REPL for Monkey. However, it can also execute files if the path to those files are supplied as a command line argument.
The examples directory can be looked at for example programs writen in Monkey.
monkey (for starting a repl)
monkey /path/to/file (for running a file)
License
Peelpreter is license under the GNU General Public License version 3 or above with it also being copyrighted by Jeebak Samajdwar
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for Peelpreter-1.6.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9484c59ecaa280466a15bed760515b8e6f9245b80f0fd60ef8b5e898d8007e19 |
|
MD5 | 5be03259a5bf2fb534de0b7ceb6a7b6d |
|
BLAKE2b-256 | f4dab8a4eb71b16c8fae2d7bee48b63c2b0c87456d75fdfaa15f8564346ddc32 |