| Crates.io | generic-lang |
| lib.rs | generic-lang |
| version | 2.1.0 |
| created_at | 2024-05-03 07:01:22.885801+00 |
| updated_at | 2025-09-06 12:46:10.459106+00 |
| description | A Lox based programming language |
| homepage | |
| repository | https://github.com/JanEricNitschke/generic-lang |
| max_upload_size | |
| id | 1228430 |
| size | 577,560 |
This is the main source code repository for Generic. It contains the interpreter and will at some point contain the standard library, and documentation.
Generic is based on the Lox programming language created by Bob Nystrom for his excellent book Crafting Interpreters.
This implementation is written in Rust and very closely based on clox-rs. The walkthrough of the book alongside clox-rs can be found in the previous repo.
A rudimentary vscode extension exists in the form of generic-lang-vscode.
The interpreter can be build like this:
cargo build --release
Generic supports two types of testing:
The language includes built-in unit testing support. Write test functions (starting with test_) and run them with:
generic --test your_file.gen
This will discover and run all test functions in isolation, providing detailed reporting. See TESTING.md for complete documentation.
A comprehensive integration test suite and driver can be found in test and tool respectively. The driver is written in Dart and taken directly from the book repo of Crafting Interpreters. The suite is an extension of the one that can be found in the same repository.
To run the full integration test suite:
make test
Benchmarking Generic against the official c and java lox implementations as well as, to a limited degree, python and ruby is also possible. The reference programs for that can be found in benchmark.
The benchmarking setup is driven by hyperfine which has to be installed and added to the path separately. This also holds for ruby and python.
However, the main benchmarking is against the lox implementations. For those runs to be possible the two versions have to be install from the book repo and placed into the (relative) path
{generic-lang}/reference/craftinginterpreters.
Running the benchmark on linux is done via:
make benchmark-ci
To run the benchmarking on windows a jlox.bat with the following content:
@echo off
set "script_dir=%~dp0"
java -cp "%script_dir%\build\java" com.craftinginterpreters.lox.Lox %*
first has to be placed in the craftinginterpreters directory.
The benchmarking is then run via:
make benchmark
I recommend installing Generic by building from the source code as follows:
# Download the source code
git clone https://github.com/JanEricNitschke/generic-lang
cd generic-lang
# Install 'generic'
cargo install --path .
Or more simply:
cargo install generic-lang
Or install with uv (recommended), pip, or pipx:
# With uv.
uv tool install generic-lang # Install generic globally
# With pip.
pip install generic-lang
# With pipx.
pipx install generic-lang
Now to use generic, in your terminal, run:
generic