# 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](https://twitter.com/intent/user?screen_name=munificentbob) for his excellent book [Crafting Interpreters](https://craftinginterpreters.com).
This implementation is written in [Rust](https://github.com/rust-lang/rust) and *very* closely based on [clox-rs](https://github.com/abesto/clox-rs/). The walkthrough of the book alongside clox-rs can be found in the previous [repo](https://github.com/JanEricNitschke/CraftingInterpreters).
## Syntax highlighting
A rudimentary vscode extension exists in the form of [generic-lang-vscode](https://github.com/JanEricNitschke/generic-lang-vscode).
## Building
The interpreter can be build like this:
```bash
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:
```bash
generic --test your_file.gen
```
This will discover and run all test functions in isolation, providing detailed reporting. See [TESTING.md](TESTING.md) for complete documentation.
### Integration Testing
A comprehensive integration test suite and driver can be found in [test](test) and [tool](tool) respectively.
The driver is written in [Dart](https://dart.dev/) and taken directly from the [book repo](https://github.com/munificent/craftinginterpreters) 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:
```bash
make test
```
## Benchmark
Benchmarking **Generic** against the official [c](https://github.com/munificent/craftinginterpreters/tree/master/c) and [java](https://github.com/munificent/craftinginterpreters/tree/master/java/com/craftinginterpreters) lox implementations as well as, to a limited degree, [python](https://www.python.org/) and [ruby](https://www.ruby-lang.org/) is also possible. The reference programs for that can be found in [benchmark](benchmark).
The benchmarking setup is driven by [hyperfine](https://github.com/sharkdp/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](https://github.com/munificent/craftinginterpreters)
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:
```bat
@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:
```bash
make benchmark
```
## Installation
I recommend installing Generic by building from the source code as follows:
```bash
# Download the source code
git clone https://github.com/JanEricNitschke/generic-lang
cd generic-lang
# Install 'generic'
cargo install --path .
```
Or more simply:
```bash
cargo install generic-lang
```
Or install with uv (recommended), pip, or pipx:
```bash
# 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:
```bash
generic
```
Raw data
{
"_id": null,
"home_page": null,
"name": "generic-lang",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "programming-language, generic",
"author": "Jan-Eric <janericnitschke@gmail.com",
"author_email": "Jan-Eric <janericnitschke@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ac/7a/b3873186a9ed4859b1d5af7c05918dd64ac5ecf9b3d18470f22f9b9c7b98/generic_lang-2.1.0.tar.gz",
"platform": null,
"description": "# The Generic Programming Language\n\nThis is the main source code repository for **Generic**. It contains the interpreter and will at some point contain the\nstandard library, and documentation.\n\n## Influence\n\n**Generic** is based on the Lox programming language created by [Bob Nystrom](https://twitter.com/intent/user?screen_name=munificentbob) for his excellent book [Crafting Interpreters](https://craftinginterpreters.com).\n\nThis implementation is written in [Rust](https://github.com/rust-lang/rust) and *very* closely based on [clox-rs](https://github.com/abesto/clox-rs/). The walkthrough of the book alongside clox-rs can be found in the previous [repo](https://github.com/JanEricNitschke/CraftingInterpreters).\n\n## Syntax highlighting\n\nA rudimentary vscode extension exists in the form of [generic-lang-vscode](https://github.com/JanEricNitschke/generic-lang-vscode).\n\n## Building\n\nThe interpreter can be build like this:\n```bash\ncargo build --release\n```\n\n## Testing\n\n**Generic** supports two types of testing:\n\n### Unit Testing (Built-in)\n\nThe language includes built-in unit testing support. Write test functions (starting with `test_`) and run them with:\n\n```bash\ngeneric --test your_file.gen\n```\n\nThis will discover and run all test functions in isolation, providing detailed reporting. See [TESTING.md](TESTING.md) for complete documentation.\n\n### Integration Testing\n\nA comprehensive integration test suite and driver can be found in [test](test) and [tool](tool) respectively.\nThe driver is written in [Dart](https://dart.dev/) and taken directly from the [book repo](https://github.com/munificent/craftinginterpreters) of Crafting Interpreters.\nThe suite is an extension of the one that can be found in the same repository.\n\nTo run the full integration test suite:\n```bash\nmake test\n```\n\n## Benchmark\n\nBenchmarking **Generic** against the official [c](https://github.com/munificent/craftinginterpreters/tree/master/c) and [java](https://github.com/munificent/craftinginterpreters/tree/master/java/com/craftinginterpreters) lox implementations as well as, to a limited degree, [python](https://www.python.org/) and [ruby](https://www.ruby-lang.org/) is also possible. The reference programs for that can be found in [benchmark](benchmark).\n\nThe benchmarking setup is driven by [hyperfine](https://github.com/sharkdp/hyperfine) which has to be installed and added to the path separately.\nThis also holds for ruby and python.\n\nHowever, 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](https://github.com/munificent/craftinginterpreters)\nand placed into the (relative) path\n\n`{generic-lang}/reference/craftinginterpreters`.\n\nRunning the benchmark on linux is done via:\n```\nmake benchmark-ci\n```\n\nTo run the benchmarking on windows a `jlox.bat` with the following content:\n```bat\n@echo off\n\nset \"script_dir=%~dp0\"\njava -cp \"%script_dir%\\build\\java\" com.craftinginterpreters.lox.Lox %*\n```\n\nfirst has to be placed in the `craftinginterpreters` directory.\n\nThe benchmarking is then run via:\n```bash\nmake benchmark\n```\n\n## Installation\n\nI recommend installing Generic by building from the source code as follows:\n\n```bash\n# Download the source code\ngit clone https://github.com/JanEricNitschke/generic-lang\ncd generic-lang\n\n# Install 'generic'\ncargo install --path .\n```\n\nOr more simply:\n\n```bash\ncargo install generic-lang\n```\n\nOr install with uv (recommended), pip, or pipx:\n\n```bash\n# With uv.\nuv tool install generic-lang # Install generic globally\n\n# With pip.\npip install generic-lang\n\n# With pipx.\npipx install generic-lang\n```\n\nNow to use generic, in your terminal, run:\n```bash\ngeneric\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Lox based programming language",
"version": "2.1.0",
"project_urls": {
"Source Code": "https://github.com/JanEricNitschke/generic-lang"
},
"split_keywords": [
"programming-language",
" generic"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "89003a873d072fcdb4218869089ca8d11d8ad45eb874b7e0cf2872931d8984fd",
"md5": "06cc9417ce8b8b5a225e3c0f08b0de87",
"sha256": "d317c606c3aeb253fab5daa5a169ad426ef53a7240d3f44b9c3eaa9652c965cb"
},
"downloads": -1,
"filename": "generic_lang-2.1.0-py3-none-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "06cc9417ce8b8b5a225e3c0f08b0de87",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 642057,
"upload_time": "2025-09-06T12:48:02",
"upload_time_iso_8601": "2025-09-06T12:48:02.658153Z",
"url": "https://files.pythonhosted.org/packages/89/00/3a873d072fcdb4218869089ca8d11d8ad45eb874b7e0cf2872931d8984fd/generic_lang-2.1.0-py3-none-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ad6c7f7011c0096a875959b149242c6ba2182c3b84d14bd74f790ead0ddc2574",
"md5": "5310e95a8551ad8eeeda0a425512a0e4",
"sha256": "1796ca8de53526c736e0b5f84921c456f0bc4070c25b625b29cc91a71b2d89cf"
},
"downloads": -1,
"filename": "generic_lang-2.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"has_sig": false,
"md5_digest": "5310e95a8551ad8eeeda0a425512a0e4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 687009,
"upload_time": "2025-09-06T12:47:53",
"upload_time_iso_8601": "2025-09-06T12:47:53.877323Z",
"url": "https://files.pythonhosted.org/packages/ad/6c/7f7011c0096a875959b149242c6ba2182c3b84d14bd74f790ead0ddc2574/generic_lang-2.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "381454861ccefff02d49712c74b42c489f0a805a99302baafe9790e1d817374d",
"md5": "8b18e83d4665b354843519c954cfa695",
"sha256": "afa165338aef7e12ebe8e8fc50cae43b408734746a4e63c00ac777acf07535c8"
},
"downloads": -1,
"filename": "generic_lang-2.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl",
"has_sig": false,
"md5_digest": "8b18e83d4665b354843519c954cfa695",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 732481,
"upload_time": "2025-09-06T12:47:55",
"upload_time_iso_8601": "2025-09-06T12:47:55.347600Z",
"url": "https://files.pythonhosted.org/packages/38/14/54861ccefff02d49712c74b42c489f0a805a99302baafe9790e1d817374d/generic_lang-2.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "9e5fdbe29d1255dcc27a8c5c0ee81498c71350a2534e3efc3f5765d62423df65",
"md5": "f33da0cf79fe007fa11fa37dd218c6ac",
"sha256": "7e7bc675168d0782255c747cbfc38554cc8edd365bde067c4162a1a272532834"
},
"downloads": -1,
"filename": "generic_lang-2.1.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl",
"has_sig": false,
"md5_digest": "f33da0cf79fe007fa11fa37dd218c6ac",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 749827,
"upload_time": "2025-09-06T12:47:59",
"upload_time_iso_8601": "2025-09-06T12:47:59.803951Z",
"url": "https://files.pythonhosted.org/packages/9e/5f/dbe29d1255dcc27a8c5c0ee81498c71350a2534e3efc3f5765d62423df65/generic_lang-2.1.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a6d5e905269285c59d26a297aedf268f03b81d927829d23ed0f2c464fecfa0e7",
"md5": "45b24214bff7f494173853b658d18a7b",
"sha256": "c2768dc20f07614413eee48c2f1e8deeca8d2600d69ed87c4bd631579cf3cf3a"
},
"downloads": -1,
"filename": "generic_lang-2.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl",
"has_sig": false,
"md5_digest": "45b24214bff7f494173853b658d18a7b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 802443,
"upload_time": "2025-09-06T12:47:56",
"upload_time_iso_8601": "2025-09-06T12:47:56.804110Z",
"url": "https://files.pythonhosted.org/packages/a6/d5/e905269285c59d26a297aedf268f03b81d927829d23ed0f2c464fecfa0e7/generic_lang-2.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "95cef3598f3125b77f2070a5841a40606f4d97ac01b19abbbb6fe908c1089d61",
"md5": "03b8b4740ad0b7c0aa2d9b7ac3c3de2e",
"sha256": "b6a91e77455bc92109a2889a31b5616875a5b981c46a94d1161cf310e6aaa1fd"
},
"downloads": -1,
"filename": "generic_lang-2.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl",
"has_sig": false,
"md5_digest": "03b8b4740ad0b7c0aa2d9b7ac3c3de2e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 849135,
"upload_time": "2025-09-06T12:47:58",
"upload_time_iso_8601": "2025-09-06T12:47:58.247079Z",
"url": "https://files.pythonhosted.org/packages/95/ce/f3598f3125b77f2070a5841a40606f4d97ac01b19abbbb6fe908c1089d61/generic_lang-2.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "674faad842c5115e004befd42f3dd26875905b9644e898d3c1df9ca81796bbcf",
"md5": "61ee4f5ebde24d94b6a383bf3a615948",
"sha256": "872621dcc14bcaa5f6696bc6c8db82185ef981914094485e7919d2803898b16b"
},
"downloads": -1,
"filename": "generic_lang-2.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "61ee4f5ebde24d94b6a383bf3a615948",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 727366,
"upload_time": "2025-09-06T12:48:01",
"upload_time_iso_8601": "2025-09-06T12:48:01.482098Z",
"url": "https://files.pythonhosted.org/packages/67/4f/aad842c5115e004befd42f3dd26875905b9644e898d3c1df9ca81796bbcf/generic_lang-2.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "97ad922b3ea55a48a5b72b88961dd3b75bc0c923fd3c96e25032fb87126da5cf",
"md5": "6f17f67178a60881f32cb0183af1aa65",
"sha256": "b4d9b854d7906408a52bb8f8c0fd3d384cdd2d2fcff1870ba75d27997d2dd14a"
},
"downloads": -1,
"filename": "generic_lang-2.1.0-py3-none-musllinux_1_2_aarch64.whl",
"has_sig": false,
"md5_digest": "6f17f67178a60881f32cb0183af1aa65",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 730739,
"upload_time": "2025-09-06T12:48:03",
"upload_time_iso_8601": "2025-09-06T12:48:03.862407Z",
"url": "https://files.pythonhosted.org/packages/97/ad/922b3ea55a48a5b72b88961dd3b75bc0c923fd3c96e25032fb87126da5cf/generic_lang-2.1.0-py3-none-musllinux_1_2_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "2fedeef806220e72fb95a5d1a973aa33bf3751be4c5d8d8213cd5b848bcae24b",
"md5": "18dd59f6c9663b237889b6d843aaf72d",
"sha256": "d0941da09b3e79bc253402591a0c5e4077d32a052b71e7f533a3710703dd9a9f"
},
"downloads": -1,
"filename": "generic_lang-2.1.0-py3-none-musllinux_1_2_armv7l.whl",
"has_sig": false,
"md5_digest": "18dd59f6c9663b237889b6d843aaf72d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 761044,
"upload_time": "2025-09-06T12:48:05",
"upload_time_iso_8601": "2025-09-06T12:48:05.317904Z",
"url": "https://files.pythonhosted.org/packages/2f/ed/eef806220e72fb95a5d1a973aa33bf3751be4c5d8d8213cd5b848bcae24b/generic_lang-2.1.0-py3-none-musllinux_1_2_armv7l.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "0aee19c28047bf6a4dffd2d8c94ff67aee2c4142fd14808bead101c8e4a92df5",
"md5": "44c06984d43ec4665c815217261b8ccb",
"sha256": "c1093699514de30fb88bee6eb1022d4564f28d751657eff17c33cc6da1b99538"
},
"downloads": -1,
"filename": "generic_lang-2.1.0-py3-none-musllinux_1_2_i686.whl",
"has_sig": false,
"md5_digest": "44c06984d43ec4665c815217261b8ccb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 778751,
"upload_time": "2025-09-06T12:48:07",
"upload_time_iso_8601": "2025-09-06T12:48:07.008219Z",
"url": "https://files.pythonhosted.org/packages/0a/ee/19c28047bf6a4dffd2d8c94ff67aee2c4142fd14808bead101c8e4a92df5/generic_lang-2.1.0-py3-none-musllinux_1_2_i686.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "6424c06d8006c422fca749eedd2a8d5cd33441bd729784617c03253815fb7e1d",
"md5": "2bbe0e6f49c0c462cb9f5bf8789db68a",
"sha256": "5c252c8c4a1cbd3027d362ac2f63f5160c92b37554b240ddb0f4a6c6c056caa7"
},
"downloads": -1,
"filename": "generic_lang-2.1.0-py3-none-musllinux_1_2_x86_64.whl",
"has_sig": false,
"md5_digest": "2bbe0e6f49c0c462cb9f5bf8789db68a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 776075,
"upload_time": "2025-09-06T12:48:08",
"upload_time_iso_8601": "2025-09-06T12:48:08.113611Z",
"url": "https://files.pythonhosted.org/packages/64/24/c06d8006c422fca749eedd2a8d5cd33441bd729784617c03253815fb7e1d/generic_lang-2.1.0-py3-none-musllinux_1_2_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "118b9b844e854292b8e4e647f5e9ab003e38d5bc48d35221a8967fa545c877c5",
"md5": "2ef5f1ea314039cc27bce8ad41156071",
"sha256": "2c141b01f12b98823faa31c0e776ed034af8b8022927c1e67c595b27bba9a74f"
},
"downloads": -1,
"filename": "generic_lang-2.1.0-py3-none-win32.whl",
"has_sig": false,
"md5_digest": "2ef5f1ea314039cc27bce8ad41156071",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 582541,
"upload_time": "2025-09-06T12:48:12",
"upload_time_iso_8601": "2025-09-06T12:48:12.241103Z",
"url": "https://files.pythonhosted.org/packages/11/8b/9b844e854292b8e4e647f5e9ab003e38d5bc48d35221a8967fa545c877c5/generic_lang-2.1.0-py3-none-win32.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "23227a7ca5c9837875ba973bae7f1e7026117ef2bc960ef349a63c984fac2e2e",
"md5": "41e2038bc859dc9ffc275a294cf85c6c",
"sha256": "2fa2f30e5f0aaa6199d381661650a79e79d637b83709ec870961e525ddd2b7f2"
},
"downloads": -1,
"filename": "generic_lang-2.1.0-py3-none-win_amd64.whl",
"has_sig": false,
"md5_digest": "41e2038bc859dc9ffc275a294cf85c6c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 593284,
"upload_time": "2025-09-06T12:48:10",
"upload_time_iso_8601": "2025-09-06T12:48:10.514849Z",
"url": "https://files.pythonhosted.org/packages/23/22/7a7ca5c9837875ba973bae7f1e7026117ef2bc960ef349a63c984fac2e2e/generic_lang-2.1.0-py3-none-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ac7ab3873186a9ed4859b1d5af7c05918dd64ac5ecf9b3d18470f22f9b9c7b98",
"md5": "f5ecd22344c5e77c7a7e28d16d8c7bec",
"sha256": "7074da9cb58f3dc03347a8591d12b9c113f71810c95919c68ce63c1ba69d8f35"
},
"downloads": -1,
"filename": "generic_lang-2.1.0.tar.gz",
"has_sig": false,
"md5_digest": "f5ecd22344c5e77c7a7e28d16d8c7bec",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 116903,
"upload_time": "2025-09-06T12:48:09",
"upload_time_iso_8601": "2025-09-06T12:48:09.673358Z",
"url": "https://files.pythonhosted.org/packages/ac/7a/b3873186a9ed4859b1d5af7c05918dd64ac5ecf9b3d18470f22f9b9c7b98/generic_lang-2.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-06 12:48:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "JanEricNitschke",
"github_project": "generic-lang",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "generic-lang"
}