Lever
Lever is a small, esoteric programming language inspired by Minecraft Redstone. Programs move byte values through Redstone-inspired components such as chests, hoppers, dust, repeaters, observers, comparators, pistons, and lamps.
The interpreter is written in Python and includes a lexer, recursive-descent parser, abstract syntax tree, runtime, stack-based storage, examples, and unit tests.
[!IMPORTANT]
Disclaimer
Lever is an independent programming language inspired by Minecraft's Redstone mechanics and terminology. It is not affiliated with, endorsed by, sponsored by, or associated with Mojang Studios or Microsoft. Minecraft is a trademark of Microsoft/Mojang.
Requirements
- Python 3.12 or newer
- A terminal capable of reading standard input
- No third-party Python packages
Check your installed Python version with:
python --version
On Windows, the Python Launcher can be used to select a specific version:
py -3.12 --version
Setup
Clone or download the project, then open a terminal in the project directory.
Windows PowerShell
py -3.12 -m venv .venv
.\.venv\Scripts\Activate.ps1
python --version
If the py launcher is not available, use the Python executable directly:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
PowerShell may require permission to run activation scripts. If activation is blocked for your user account, run PowerShell once with the following command and then activate the environment again:
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
macOS and Linux
python3.12 -m venv .venv
source .venv/bin/activate
python --version
The project has no runtime dependencies to install. When finished, leave the virtual environment with:
deactivate
Run a program
Run the interpreter as a Python module from the project root:
python -m src.main examples/hello.lever
Programs must use the .lever extension. The interpreter reports syntax and runtime errors in the terminal and returns a non-zero exit status when execution fails.
Examples
Hello world bytes
examples/hello.lever demonstrates storing ASCII bytes in a Chest, transferring them in valid Hopper batches, and printing them with Slime_Piston:
RedstoneBlock hello.lever
Chest 33,100,108,114,111,87,32,111