Skip to main content

A Lox based programming language

Project description

The Generic Programming Language

This is the main source code repository for Generic. It contains the interpreter and will at some point contain the standard library, and documentation.

Influence

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.

Syntax highlighting

A rudimentary vscode extension exists in the form of generic-lang-vscode.

Building

The interpreter can be build like this:

cargo build --release

Testing

Generic supports two types of testing:

Unit Testing (Built-in)

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.

Integration Testing

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

Benchmark

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

Installation

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

generic_lang-2.1.0.tar.gz (116.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

generic_lang-2.1.0-py3-none-win_amd64.whl (593.3 kB view details)

Uploaded Python 3Windows x86-64

generic_lang-2.1.0-py3-none-win32.whl (582.5 kB view details)

Uploaded Python 3Windows x86

generic_lang-2.1.0-py3-none-musllinux_1_2_x86_64.whl (776.1 kB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

generic_lang-2.1.0-py3-none-musllinux_1_2_i686.whl (778.8 kB view details)

Uploaded Python 3musllinux: musl 1.2+ i686

generic_lang-2.1.0-py3-none-musllinux_1_2_armv7l.whl (761.0 kB view details)

Uploaded Python 3musllinux: musl 1.2+ ARMv7l

generic_lang-2.1.0-py3-none-musllinux_1_2_aarch64.whl (730.7 kB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

generic_lang-2.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (727.4 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

generic_lang-2.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (849.1 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ s390x

generic_lang-2.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (802.4 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ppc64le

generic_lang-2.1.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (749.8 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

generic_lang-2.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (732.5 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

generic_lang-2.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (687.0 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

generic_lang-2.1.0-py3-none-macosx_11_0_arm64.whl (642.1 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file generic_lang-2.1.0.tar.gz.

File metadata

  • Download URL: generic_lang-2.1.0.tar.gz
  • Upload date:
  • Size: 116.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.4

File hashes

Hashes for generic_lang-2.1.0.tar.gz
Algorithm Hash digest
SHA256 7074da9cb58f3dc03347a8591d12b9c113f71810c95919c68ce63c1ba69d8f35
MD5 f5ecd22344c5e77c7a7e28d16d8c7bec
BLAKE2b-256 ac7ab3873186a9ed4859b1d5af7c05918dd64ac5ecf9b3d18470f22f9b9c7b98

See more details on using hashes here.

File details

Details for the file generic_lang-2.1.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for generic_lang-2.1.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 2fa2f30e5f0aaa6199d381661650a79e79d637b83709ec870961e525ddd2b7f2
MD5 41e2038bc859dc9ffc275a294cf85c6c
BLAKE2b-256 23227a7ca5c9837875ba973bae7f1e7026117ef2bc960ef349a63c984fac2e2e

See more details on using hashes here.

File details

Details for the file generic_lang-2.1.0-py3-none-win32.whl.

File metadata

  • Download URL: generic_lang-2.1.0-py3-none-win32.whl
  • Upload date:
  • Size: 582.5 kB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.4

File hashes

Hashes for generic_lang-2.1.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 2c141b01f12b98823faa31c0e776ed034af8b8022927c1e67c595b27bba9a74f
MD5 2ef5f1ea314039cc27bce8ad41156071
BLAKE2b-256 118b9b844e854292b8e4e647f5e9ab003e38d5bc48d35221a8967fa545c877c5

See more details on using hashes here.

File details

Details for the file generic_lang-2.1.0-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for generic_lang-2.1.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5c252c8c4a1cbd3027d362ac2f63f5160c92b37554b240ddb0f4a6c6c056caa7
MD5 2bbe0e6f49c0c462cb9f5bf8789db68a
BLAKE2b-256 6424c06d8006c422fca749eedd2a8d5cd33441bd729784617c03253815fb7e1d

See more details on using hashes here.

File details

Details for the file generic_lang-2.1.0-py3-none-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for generic_lang-2.1.0-py3-none-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 c1093699514de30fb88bee6eb1022d4564f28d751657eff17c33cc6da1b99538
MD5 44c06984d43ec4665c815217261b8ccb
BLAKE2b-256 0aee19c28047bf6a4dffd2d8c94ff67aee2c4142fd14808bead101c8e4a92df5

See more details on using hashes here.

File details

Details for the file generic_lang-2.1.0-py3-none-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for generic_lang-2.1.0-py3-none-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 d0941da09b3e79bc253402591a0c5e4077d32a052b71e7f533a3710703dd9a9f
MD5 18dd59f6c9663b237889b6d843aaf72d
BLAKE2b-256 2fedeef806220e72fb95a5d1a973aa33bf3751be4c5d8d8213cd5b848bcae24b

See more details on using hashes here.

File details

Details for the file generic_lang-2.1.0-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for generic_lang-2.1.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 b4d9b854d7906408a52bb8f8c0fd3d384cdd2d2fcff1870ba75d27997d2dd14a
MD5 6f17f67178a60881f32cb0183af1aa65
BLAKE2b-256 97ad922b3ea55a48a5b72b88961dd3b75bc0c923fd3c96e25032fb87126da5cf

See more details on using hashes here.

File details

Details for the file generic_lang-2.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for generic_lang-2.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 872621dcc14bcaa5f6696bc6c8db82185ef981914094485e7919d2803898b16b
MD5 61ee4f5ebde24d94b6a383bf3a615948
BLAKE2b-256 674faad842c5115e004befd42f3dd26875905b9644e898d3c1df9ca81796bbcf

See more details on using hashes here.

File details

Details for the file generic_lang-2.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for generic_lang-2.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 b6a91e77455bc92109a2889a31b5616875a5b981c46a94d1161cf310e6aaa1fd
MD5 03b8b4740ad0b7c0aa2d9b7ac3c3de2e
BLAKE2b-256 95cef3598f3125b77f2070a5841a40606f4d97ac01b19abbbb6fe908c1089d61

See more details on using hashes here.

File details

Details for the file generic_lang-2.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for generic_lang-2.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 c2768dc20f07614413eee48c2f1e8deeca8d2600d69ed87c4bd631579cf3cf3a
MD5 45b24214bff7f494173853b658d18a7b
BLAKE2b-256 a6d5e905269285c59d26a297aedf268f03b81d927829d23ed0f2c464fecfa0e7

See more details on using hashes here.

File details

Details for the file generic_lang-2.1.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for generic_lang-2.1.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 7e7bc675168d0782255c747cbfc38554cc8edd365bde067c4162a1a272532834
MD5 f33da0cf79fe007fa11fa37dd218c6ac
BLAKE2b-256 9e5fdbe29d1255dcc27a8c5c0ee81498c71350a2534e3efc3f5765d62423df65

See more details on using hashes here.

File details

Details for the file generic_lang-2.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for generic_lang-2.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 afa165338aef7e12ebe8e8fc50cae43b408734746a4e63c00ac777acf07535c8
MD5 8b18e83d4665b354843519c954cfa695
BLAKE2b-256 381454861ccefff02d49712c74b42c489f0a805a99302baafe9790e1d817374d

See more details on using hashes here.

File details

Details for the file generic_lang-2.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for generic_lang-2.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1796ca8de53526c736e0b5f84921c456f0bc4070c25b625b29cc91a71b2d89cf
MD5 5310e95a8551ad8eeeda0a425512a0e4
BLAKE2b-256 ad6c7f7011c0096a875959b149242c6ba2182c3b84d14bd74f790ead0ddc2574

See more details on using hashes here.

File details

Details for the file generic_lang-2.1.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for generic_lang-2.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d317c606c3aeb253fab5daa5a169ad426ef53a7240d3f44b9c3eaa9652c965cb
MD5 06cc9417ce8b8b5a225e3c0f08b0de87
BLAKE2b-256 89003a873d072fcdb4218869089ca8d11d8ad45eb874b7e0cf2872931d8984fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page