Skip to main content

A small experimental programming language implemented in Python.

Project description

NEX

PyPI Version Python Version Unit Tests Docs License: GPLv3

NEX is a small experimental programming language implemented in Python.

Nex logo

The project currently includes:

  • a lexer
  • a recursive-descent parser
  • a tree-walking interpreter
  • a small CLI runner
  • an mdBook documentation site under docs/

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
  • tokens prints the token stream and stops after lexing.
  • ast prints the parsed syntax tree and stops after parsing.
  • --times shows 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


Download files

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

Source Distribution

nex_lang-0.3.0.tar.gz (77.1 kB view details)

Uploaded Source

Built Distribution

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

nex_lang-0.3.0-py3-none-any.whl (54.9 kB view details)

Uploaded Python 3

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

Hashes for nex_lang-0.3.0.tar.gz
Algorithm Hash digest
SHA256 402453b7ff3c6d679d41996da517f1243cf767af73519d262653b0c7249dd106
MD5 251da8002ae37da04eab1ffecd0fe455
BLAKE2b-256 a90459a580102ff5536213dfdfe6766dbf126a96110f6cfd6c48b8def92d87c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for nex_lang-0.3.0.tar.gz:

Publisher: pypi-release.yml on ifilot/nex-lang

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for nex_lang-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4cb7e0c8d27ceaec91f45636a8757a5db0277b61f50d9d73ae766c23215a0759
MD5 15fec1e6aeac28de2697547d220c92d7
BLAKE2b-256 085cb66481e133cc887ccf277496fd7d026fd9d0fe3f0fde391cee0708825774

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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