A small experimental programming language implemented in Python.
Project description
NEX
NEX is a small experimental programming language implemented in Python.
The project currently includes:
- a lexer
- a recursive-descent parser
- a tree-walking interpreter
- a small CLI runner
- an
mdBookdocumentation site underdocs/
Example
int x = 0;
while(x < 10) {
print(x);
x = x + 1;
}
Installation
Install the package in editable mode:
python -m pip install -e .
Once published, the package can be installed from PyPI with:
python -m pip install nex-lang
Install development dependencies as well:
python -m pip install -e ".[dev]"
Enable the local pre-commit hook to block commits when formatting, linting, or ASCII-only checks fail:
pre-commit install
Running Programs
The package exposes a nexlang command:
nexlang examples/hello.nex
You can check the installed CLI version with:
nexlang --version
You can also run the CLI module directly:
python -m nex.cli examples/hello.nex
The CLI also supports a few inspection and reporting options:
nexlang tokens examples/hello.nex
nexlang ast examples/hello.nex
nexlang --times examples/hello.nex
nexlang run --times --color examples/hello.nex
tokensprints the token stream and stops after lexing.astprints the parsed syntax tree and stops after parsing.--timesshows a formatted timing summary for the lexer, parser, interpreter, and total runtime after the program finishes.--color(or-c) colorizes the timing summary. It is intended to be used together with--times.
Documentation
The language reference lives in the mdBook project under docs/.
Build it locally with:
python scripts/generate_grammar_diagrams.py
~/.cargo/bin/mdbook build docs
The grammar page diagrams are generated from the fenced grammar block in
docs/src/reference/grammar.md, so rerun the generator whenever that grammar
changes.
Once GitHub Pages is enabled for this repository, the published book will be available at:
https://ifilot.github.io/nex-lang/
VS Code Syntax Highlighting
A lightweight VS Code syntax-highlighting extension for .nex files lives at:
editors/vscode/nex-syntax
If you are using VS Code through WSL, you can expose that extension to the WSL server with:
cd editors/vscode/nex-syntax
mkdir -p ~/.vscode-server/extensions && ln -s "$(pwd)" ~/.vscode-server/extensions/local.nex-syntax
After that, reload the VS Code window.
Releases
PyPI releases are published from Git tags that start with v. The published
package name is nex-lang. The installed CLI command remains nexlang.
Before publishing, the release workflow checks that the tag matches
nex.__version__ exactly, for example v0.3.0, and that the package version
does not already exist on PyPI.
For local releases, create the tag through the guarded helper:
python scripts/create_release_tag.py
The helper creates v<nex.__version__> only after checking that the local Git
tag does not already exist and that the package version is still available on
PyPI.
Testing
Run the test suite with:
python -m pytest -q tests
Using python -m pytest is the most reliable form across environments and editors.
Linting
Check linting, formatting, and ASCII-only text files with:
python -m ruff check .
python -m ruff format --check .
python scripts/check_ascii.py
Project Structure
nex/
lexer/ Tokenization
parser/ Recursive-descent parser
interpreter/ AST nodes, environment, and interpreter
cli.py Command-line entry point
tests/ Unit tests
examples/ Example programs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nex_lang-0.3.0.tar.gz.
File metadata
- Download URL: nex_lang-0.3.0.tar.gz
- Upload date:
- Size: 77.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
402453b7ff3c6d679d41996da517f1243cf767af73519d262653b0c7249dd106
|
|
| MD5 |
251da8002ae37da04eab1ffecd0fe455
|
|
| BLAKE2b-256 |
a90459a580102ff5536213dfdfe6766dbf126a96110f6cfd6c48b8def92d87c1
|
Provenance
The following attestation bundles were made for nex_lang-0.3.0.tar.gz:
Publisher:
pypi-release.yml on ifilot/nex-lang
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nex_lang-0.3.0.tar.gz -
Subject digest:
402453b7ff3c6d679d41996da517f1243cf767af73519d262653b0c7249dd106 - Sigstore transparency entry: 1367505500
- Sigstore integration time:
-
Permalink:
ifilot/nex-lang@0dec048e1a67afdac914279901e21779d0d69239 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/ifilot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@0dec048e1a67afdac914279901e21779d0d69239 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nex_lang-0.3.0-py3-none-any.whl.
File metadata
- Download URL: nex_lang-0.3.0-py3-none-any.whl
- Upload date:
- Size: 54.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cb7e0c8d27ceaec91f45636a8757a5db0277b61f50d9d73ae766c23215a0759
|
|
| MD5 |
15fec1e6aeac28de2697547d220c92d7
|
|
| BLAKE2b-256 |
085cb66481e133cc887ccf277496fd7d026fd9d0fe3f0fde391cee0708825774
|
Provenance
The following attestation bundles were made for nex_lang-0.3.0-py3-none-any.whl:
Publisher:
pypi-release.yml on ifilot/nex-lang
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nex_lang-0.3.0-py3-none-any.whl -
Subject digest:
4cb7e0c8d27ceaec91f45636a8757a5db0277b61f50d9d73ae766c23215a0759 - Sigstore transparency entry: 1367505511
- Sigstore integration time:
-
Permalink:
ifilot/nex-lang@0dec048e1a67afdac914279901e21779d0d69239 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/ifilot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@0dec048e1a67afdac914279901e21779d0d69239 -
Trigger Event:
push
-
Statement type: