Table of Contents
[Self](https://selflanguage.org/) is an object-oriented programming language designed around the use of prototypes, objects that are reused to derive behavior for other objects. It comes with its own environment, virtual machine, and GUI to execute in, the latter of which is defined in Self code. To learn more about how Self works, checkout out the [Self Handbook](https://handbook.selflanguage.org/2017.1/index.html).
As of the time of writing, the Self virtual machine is incapable of running directly on most modern operating systems such as Windows. To get working on an OS such as Windows, it requires users to set up a virtual machine that instead emulates older, 32-bit versions of Linux. For those who are interested in Self or adjacent languages like Smalltalk, this can be an unfortunate barrier of entry. This system, designed to parse and interpret Self inputs in a similar manner to the Self environment and virtual machine, is meant to address this problem. The project is built in Python, which is compatible with most modern platforms (e.g. Windows, Linux, macOS).
The Self Interpreter project is an interpreter for the Self language, built as a senior design project at the Rose-Hulman Institute of Technology. Its main purpose is to serve as an educational tool to inform computer science students of alternative programming paradigms but can also be used for most of your Self needs. The system is capable of reading in Self files from the existing Self implementation which is how most key objects (e.g. numbers, booleans, vectors, sets, dictionaries, etc) are built up.
If you are looking for a brief introduction to the project that does not require installing anything, then check out our video demos down below - Video Demos.
- Professor Kim Tracy - Advisor
- Dr. Michael Hewner - Client
We have implemented support for the following features:
- Full-fledged parser
- Capable of parsing valid Self input using Python LEX and YACC
- Robust Interpreter
- Interprets core language features
- Interprets classical algorithms such as the binary search algorithm
- Interprets multi-line files written in Self (allows for code to be imported into the system)
- The following original Self modules supported as a result of this feature include: block, boolean, collection, defaultBehavior, float, indexable, integer, list, nil, number, rootTraits, setAndDictionary, smallInt, string, vector
- Can be run in parsing mode (to examine how a given input is parsed by the system) or interpreting mode (regular system without GUI)
- REPL
- Read-eval-print loop for interfacing with the application through the console
- GUI
- Built in the Self language, making it extensible by users
- Powered by Kivy
- Compatibility with modern platforms
This project is a work in progress. As a result, you may experience some issues when working with the following:
- Error handling functions
- Methods defined outside of objects (i.e. only using parentheses to define a method)
The following must be installed with the given minimum versions.
- python 3.7+
- ply
pip install ply==3.11
- kivy
pip install kivy==2.1.0
- pytest [optional: for tests only]
pip install pytest==6.2.5
- Clone the repo:
- SSH:
git clone git@github.com:pinneyja/self-interpreter.git
- HTTP:
git clone https://github.com/pinneyja/self-interpreter.git
- Run the interpreter in CLI or GUI mode:
- CLI: Run the interpreter command-line interface
python src/REPL.py
- GUI: Run the interpreter graphical user interface
python src/GUI.py
- To use the interpreter, boot up using the instructions above.
- While using the CLI, type commands into the console of your choice which will print the output.
- While using the GUI, navigate using the on screen menus and evaluators.
- To mass import Self code, add files to the
self_files/
directory. Then, use the_RunScript
primitive to import your custom code! - Have fun and play around!
- Binary Search:
lobby _AddSlots: (| binarySearch: startVector Value: searchValue = (| binarySearchHelper: vector Value: value FirstIndex: firstIndex LastIndex: lastIndex = (| middleIndex. element | middleIndex: firstIndex + ((lastIndex - firstIndex) / 2). (firstIndex > lastIndex) ifTrue: [^ -1] False: [ ]. element: (vector at: middleIndex IfAbsent: [error]). (value == element) ifTrue: [^ middleIndex] False: [ ((value) < element) ifTrue: [binarySearchHelper: vector Value: value FirstIndex: firstIndex LastIndex: (middleIndex - 1)] False: [binarySearchHelper: vector Value: value FirstIndex: (middleIndex + 1) LastIndex: lastIndex]]) | binarySearchHelper: startVector Value: searchValue FirstIndex: 0 LastIndex: (startVector size) - 1) |)
Distributed under the MIT License. See LICENSE.txt
for more information.