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.0.2.tar.gz (111.3 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.0.2-py3-none-win_amd64.whl (571.3 kB view details)

Uploaded Python 3Windows x86-64

generic_lang-2.0.2-py3-none-win32.whl (560.9 kB view details)

Uploaded Python 3Windows x86

generic_lang-2.0.2-py3-none-musllinux_1_2_x86_64.whl (751.0 kB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

generic_lang-2.0.2-py3-none-musllinux_1_2_i686.whl (757.3 kB view details)

Uploaded Python 3musllinux: musl 1.2+ i686

generic_lang-2.0.2-py3-none-musllinux_1_2_armv7l.whl (734.1 kB view details)

Uploaded Python 3musllinux: musl 1.2+ ARMv7l

generic_lang-2.0.2-py3-none-musllinux_1_2_aarch64.whl (710.7 kB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

generic_lang-2.0.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (703.3 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

generic_lang-2.0.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (821.1 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ s390x

generic_lang-2.0.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (780.3 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ppc64le

generic_lang-2.0.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (727.8 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

generic_lang-2.0.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (708.5 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

generic_lang-2.0.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (667.1 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

generic_lang-2.0.2-py3-none-macosx_11_0_arm64.whl (621.2 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for generic_lang-2.0.2.tar.gz
Algorithm Hash digest
SHA256 f40557f98aa8994f5d13087f05d1587ddc1ad6f45c4ee2e8b31da3b2633713f3
MD5 d91982a4a7c0f5e26205f94e88f94f8d
BLAKE2b-256 ebf62fa18767416385da9543cf222dd1bce065ac2e68984580c011f76066234e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for generic_lang-2.0.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 8d9db03ece4125d98e9cba711a93054bc09353a3570cef332f0e5b95ecae941b
MD5 20df224a7594f1e8c6577559012d7da3
BLAKE2b-256 78b21c75135fdf124331a4f79b35143e041b2527958e49b25b9b2df4304bc66f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for generic_lang-2.0.2-py3-none-win32.whl
Algorithm Hash digest
SHA256 5aae2d68b78fd189e19acfcc4ca58aacb9093e0242376b31d6aa472a7f3b664c
MD5 995f7ef141b7e8d4acbfe13fe322968f
BLAKE2b-256 0fd4d789ad92ec90b8d2000d6c2d17a16e9bdf12d5eb70ef8c70debacb4f41a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for generic_lang-2.0.2-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e692bd66c5dec6b17a1c2ba02e8ff48d08f5eeac94d80fcf7ae15fd36e7af858
MD5 c62c4347e9703d25dd8afeb4fcd05790
BLAKE2b-256 565bc355e5cd38636df2a7ce426977ad40a3a84c3639cee1b6c46cf96fc3bdfd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for generic_lang-2.0.2-py3-none-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 d111124fe5b5d6d8b4901232a2386b2570a27c0f5e647ad56e73174dac36510d
MD5 e1c17c26c2c6f68bc2280939b9caf6d0
BLAKE2b-256 1317a683cbe48ae0ae47c153626ad8a2c5f46e14ec2569f2880597cfc1f95dea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for generic_lang-2.0.2-py3-none-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 e90f2810549d17dd9099beba990868ede754b868553c844792223ff742c8d27e
MD5 2348a8615cf1c4672d1311429f5153bd
BLAKE2b-256 31a073d5a0af1c024aaa2f16d815e4715294ea80d66264435f7c07d7687d43e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for generic_lang-2.0.2-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 4dcc7a6b2660c15a862629c5b87557a2659fa05e02364347e86e8e88d7c83ac4
MD5 04d543fa97416b2cb149bfc940c1fad0
BLAKE2b-256 d519b4bc36ffa54db9a7b2bb925b691b9582e1257508dcc022ace688b8031039

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for generic_lang-2.0.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 007e706ad45b20b1952dd87fd59d232cddf14d00d1b94871b6bee697c592e907
MD5 2b167aaec4a1e9b528d1985b3f1206db
BLAKE2b-256 1b65de9290da8ba0bbb6a0dd7a338f24cbdc41dd4ce700aa16c217348ca0697b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for generic_lang-2.0.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 2533c073d480256afc85ec92d6d78a0021c4f4d3aab7bcb0facc481c24f7b0ab
MD5 1d2e6d2cad3f076b3a3f95281b8be6db
BLAKE2b-256 6b5fc3a5606add78e38df9aee5e2ce3a64a8c59a57db4a5a76643a9c3b7c57ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for generic_lang-2.0.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 4de3151bb8a24f8dc929491493f51122e21706e0693ae178f1042476f22adcc0
MD5 854284c2acb650e84fbe5c1edfd56480
BLAKE2b-256 e73a9ba7e7f1c5697f1ca8d328c57114b1c1be9114908be3c10eda788656fc33

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for generic_lang-2.0.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 ec7871c02f4f0d710f20108c3f2c9bb58e697b1338c7c6190bcc40c3a7d68928
MD5 48f55b8f1eb4f006a2f2eb0ff730d9d8
BLAKE2b-256 baca98e088cc7fd2cd46713f9de96d174e444446923c7a07b1f199d6d9379561

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for generic_lang-2.0.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 f41edf77cd7f7de4dbf2f38d362d66731c0c3ff0bb83ec8868309999accee0d0
MD5 3685fde5d21ca49f4ab959ddda2c9b2e
BLAKE2b-256 d7f5535e819a620aaaa9afde6c63706b2fec50826823a99c394eeaa21ce7143d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for generic_lang-2.0.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 debfab90b7ad4e75e4556675ac4e795045958918ce32ba21a12eeafc0f9b19f2
MD5 936a112e774f35ff1a29e5f76b5627cd
BLAKE2b-256 b7e7721072b9ebe687794cb731d06e17eb91eae1ca422734e8e26a6510720b1b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for generic_lang-2.0.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1dd97b21ab0ca58fb1afd43caf78f890016b2db220320872918fe64949379659
MD5 1093d625a1e5752d29ceda64c73e2ef7
BLAKE2b-256 5533ff67d25ac445c55538ffa93fb1a67db1e8fa2ea5f4b1a700d7d7aa0bb2c4

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