Skip to main content

Resnik HAL/S Compiler 🚀

An open-source compiler for the HAL/S aerospace programming language, translating legacy NASA HAL/S source code to safe, modern Rust.

License: GPL-3.0-or-later Python 3.9+ Emits Rust Version 1.0.1

Version: 1.0.1 (Modern Edition)
Status: Lexer ✓ | Parser ✓ | Backend ✓ | Cross-compilation (ARM Cortex-M stub, ESP32-C3) ✓ | Separate compilation (TEMPLIB) ✓

Hello, World

A complete HAL/S program is three lines (docs/HAL-S-Source-Code-Examples/hello_word/hello_world.hal):

HELLO: PROGRAM;
  WRITE(6) 'HELLO, WORLD [HAL/S LIVES!]';
CLOSE HELLO;

From a clone with the venv active (see Installation):

resnik compile docs/HAL-S-Source-Code-Examples/hello_word/hello_world.hal --emit-exe
./docs/HAL-S-Source-Code-Examples/hello_word/hello_world
# HELLO, WORLD [HAL/S LIVES!]

resnik compile alone writes hello_world.rs; --emit-exe also runs rustc to produce the binary. Prefer a window? ./start_ide.sh opens the same file in the desktop IDE. The same source flashes to an ESP32-C3 with --target esp32-c3 --emit-cargo — see Embedded targets.

Status

  • Front end: lexer and parser (with HAL/S semantic checks) for a working subset of USA003088 Appendix B, plus a few Resnik conveniences (GOTO, DOWNTO, infix XOR/MOD, parameterized MACRO, TEMPLATE, RESUME).
  • Back end: Rust code generation for hosted (std) programs and no_std firmware (ARM Cortex-M stub, ESP32-C3); ON ERROR lowers onto Result.
  • Separate compilation: TEMPLIB-style templates (--gen-tpl / --templib) with cross-unit type checking; EXTERNAL FFI to C/assembly.
  • Not yet: UPDATE blocks, SCHEDULE … AFTER/AT/ON/UNTIL/WHILE, LOCK/LATCHED, READALL/FILE, WRITE format controls, SUBBIT, and others — the full keyword-by-keyword table is in docs/LANGUAGE_SUPPORT.md. On no_std targets, VECTOR/MATRIX, the math built-ins (via libm), COMPOOL (via critical-section) and SCHEDULE/TASK (via a generated cyclic executive) work; WAIT, READ and CHARACTER variables still need std and emit a compile_error!.

Installation

Requirement Notes
OS Linux — the supported, tested deployment. Native Windows/macOS are untested; on Windows use WSL (unverified on this project).
Python 3.9 or newer, with venv and pip
Git To clone the repository
Rust toolchain (optional) Only for --emit-exe, --emit-cargo, embedded targets, or the regression suite. Install from rustup.rs: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh then . "$HOME/.cargo/env". The HW_INTERFACE example also needs cc (sudo apt install build-essential).
Tk (IDE only) sudo apt install python3-tk on Debian/Ubuntu; bundled with python.org builds

You do not need Rust to run Resnik or to emit .rs files. Python dependencies (rply, click, rich) are installed by pip install -e .:

# Clone the repository
git clone https://github.com/bitWarrior/resnik
cd resnik

# Create and activate the python venv
python3 -m venv resnik-venv
. resnik-venv/bin/activate

# Install with development dependencies
pip install -e ".[dev]"

# Or just runtime dependencies
pip install -e .

Install the Rust toolchain (see the table above) if you will use --emit-exe, ./tests/regression/run_regression.sh, --emit-cargo, or an embedded --target. Skip it if you only need Resnik to write .rs files.

Usage

Command line

# Tokenize a HAL/S file  
resnik lex tests/fixtures/valid/sample_hals_code.hal

# Parse to AST
resnik parse tests/fixtures/valid/simple_parser_test.hal

# Complete compilation pipeline
resnik compile tests/fixtures/valid/sample_hals_code.hal

# Get help
resnik --help

# End-to-end HAL/S example regression (needs rustc; see Requirements)
./tests/regression/run_regression.sh

IDE

Resnik ships a minimal desktop IDE (Tk) for editing a HAL/S file, running a Semantic Check (lexer + parser) or a full Compile, and watching the result in a log pane. It lives in ide/ and is installed together with the compiler by pip install -e ..

# From the repository root, no need to activate the venv:
./start_ide.sh                                   # empty editor
./start_ide.sh docs/HAL-S-Source-Code-Examples/hello_word/hello_world.hal

# Equivalent, with the venv active:
resnik-ide [file.hal]
python -m resnik_ide [file.hal]

start_ide.sh uses resnik-venv/bin/python when present (else python3 on PATH) and tells you what to install if Tk (python3-tk on Debian/Ubuntu) or the resnik_ide package is missing. Keyboard: F7 Semantic Check, F5 Compile, F9 Build and Run (compile with --emit-exe, then run the program with its output in the log), Ctrl+, Compiler Options, Ctrl+O/S/N open/save/new. Click a diagnostic in the log to jump to its line. Options… exposes every resnik compile flag with a live equivalent-command line; settings persist in ~/.config/resnik/ide.json. The Target panel checks the Rust toolchain for the selected profile (rustup target add, rust-src, espflash / probe-rs — one-click Install), lists serial ports, and runs Build / Flash & Run / Monitor / Run on host / Stop through a streamed, cancellable process runner. The editor highlights HAL/S syntax using the compiler's own lexer and remembers recent files, font size and window layout. See ide/README.md and the "Desktop IDE" chapter of the Users Guide (docs/Resnik Users Guide/) for details.

Embedded targets

Resnik can emit either hosted Rust or bare-metal firmware, selected with the --target flag on resnik compile:

Profile Description
host (default) Hosted std Rust — runs on your local computer.
cortex-m no_std stub for ARM Cortex-M (semihosting WRITE; not a finished MCU port).
esp32-c3 no_std firmware for ESP32-C3 (RISC-V) via esp-hal. USB-serial WRITE.

Once per machine (ESP32-C3; needs stable Rust ≥ 1.88 — stock rustc, not espup):

rustup target add riscv32imc-unknown-none-elf   # RISC-V code generation
rustup component add rust-src                   # esp-hal builds core from source
cargo install espflash --locked                 # flasher + serial monitor (compiles for a few
                                                # minutes; installs to ~/.cargo/bin — put that on
                                                # PATH: . "$HOME/.cargo/env")
sudo usermod -aG dialout $USER                  # serial-port permission (log out/in once)

The ESP32 libraries themselves (esp-hal, esp-println, esp-backtrace, esp-bootloader-esp-idf) are not installed by hand: the scaffold's Cargo.toml pins them, and the first cargo build downloads and compiles them (~130 crates, network required, a minute or two; instant afterwards).

Then, per program:

resnik compile hello_world.hal --target esp32-c3 --emit-cargo ./firmware
cd firmware && cargo run --release      # builds, flashes, opens the serial monitor

--emit-cargo scaffolds a buildable crate (Cargo.toml, .cargo/config.toml with the flash runner, memory.x for Cortex-M). The full walkthrough — Cortex-M stub layout, the ESP32-C3 hello world step by step, what works on no_std — is in docs/EMBEDDED_TARGETS.md.

Common trip-ups (details and fixes in docs/EMBEDDED_TARGETS.md → Troubleshooting):

Symptom Cause
unresolved import esp_hal (E0432) and friends from rustc --emit-exe was combined with an embedded --target. --emit-exe builds a single file with plain rustc, which cannot supply the embedded runtime crates — use --emit-cargo and build/flash with cargo.
espflash: command not found right after cargo install espflash cargo install puts binaries in ~/.cargo/bin, which is not on PATH when rustup/cargo come from the distro. Add it to PATH (. "$HOME/.cargo/env"). The IDE finds it there automatically.
espflash fails with Failed to initialize input reader after flashing Its interactive serial monitor needs a real terminal on stdin. From a script or IDE, pass --non-interactive (espflash ≥ 3); the Resnik IDE does this for you.

Templates & separate compilation

HAL/S supports separate compilation through templates — signature-only prototypes, analogous to C headers. Resnik mirrors the original compiler's template library (TEMPLIB) workflow: --gen-tpl writes a .tpl prototype for each PROCEDURE/FUNCTION/COMPOOL on a successful compile, and a D INCLUDE TEMPLATE <name> directive pulls one in (searched via --templib). CALL sites are type-checked against the template — arity and dimensions — before any code is generated.

resnik compile nav_update.hal --gen-tpl ./TEMPLIB     # writes ./TEMPLIB/NAV_UPDATE.tpl
resnik compile guidance.hal   --templib ./TEMPLIB     # guidance.hal: D INCLUDE TEMPLATE NAV_UPDATE

Foreign code: EXTERNAL

EXTERNAL declares a symbol whose definition is genuinely foreign — hand-written assembly, a C routine, a BSP entry point — and lowers directly to extern "C" (every use is unsafe; nothing is type-checked across the boundary). Link the objects in with --link-search / --link-lib / --link-obj:

cc -c i2c.c -o i2c.o
resnik compile hw_interface.hal --emit-exe --link-obj i2c.o

Both features, with the generated Rust and the linkage rules, are documented in docs/SEPARATE_COMPILATION_AND_FFI.md.

Programmatic usage

from resnik import Lexer, Parser

# Tokenize
lexer = Lexer()
tokens = lexer.tokenize_file("program.hal")

# Parse
parser = Parser()
ast = parser.parse(tokens)

# Check for errors
if parser.errors:
    parser.report_errors()
else:
    print(f"✓ Successfully parsed: {ast.name}")

Documentation

Document What it covers
Users Guide Lexer, parser, backend, CLI, the desktop IDE, troubleshooting
Desktop IDE Editor, Semantic Check / Compile / Build and Run, Options, Target panel, settings
Language support Resnik-only words and the Appendix B keywords still to do
Embedded targets Cortex-M stub, ESP32-C3 hello world, no_std feature support
Separate compilation & FFI TEMPLATE / TEMPLIB and EXTERNAL in detail
Design notes Why Python for the front end and Rust for the back end
Background About HAL/S, Shuttle flight-software history, the compiler's namesake
Requirements · HAL/S specification · Programmer's Guide · Examples Reference material

Development

src/resnik/   lexer/ parser/ backend/ cli.py driver.py templib.py   # the compiler
ide/          resnik_ide/ tests/                                      # the desktop IDE
tests/        test_lexer/ test_parser/ test_backend/ test_driver/ regression/
docs/         specifications, guides, examples
python -m pytest                            # unit tests (no rustc needed)
./tests/regression/run_regression.sh        # compile + run the registered examples (needs rustc)
./tests/regression/run_embedded_build.sh    # cargo-build examples for esp32-c3 (no board)
./tests/regression/run_exec_semantics.sh    # cyclic-executive semantics (fake clock, needs rustc)

The full project layout, test-suite details, coverage and regression notes are in CONTRIBUTING.md.

Design notes

Resnik is implemented in Python and emits Rust — each language is used where it is strongest: Python for an exploratory, text-heavy compiler front end that runs at build time, Rust as a memory-safe, no_std-capable target that mirrors HAL/S's typed, real-time design and has a path to safety-critical qualification. The reasoning in full: docs/DESIGN.md.

Background

HAL/S (High-order Assembly Language / Shuttle) is a real-time aerospace programming language developed by Intermetrics for NASA in the early 1970s. It was the primary language for the Space Shuttle's flight software and is one of the most successful safety-critical languages ever fielded, flying human-rated avionics for roughly three decades. Designed decades before "memory safety" was a common term, it emphasized strong typing, explicit real-time semantics, and verifiability — the same properties that make Rust a fitting modern compilation target. Beyond the Shuttle, HAL/S flew on NASA's Galileo spacecraft, whose Attitude and Articulation Control Subsystem software was written in it: the Galileo spacecraft launched on October 18, 1989, while the first satellites for the European Galileo Navigation System lifted off on December 28, 2005.

The compiler is named after Judith Resnik (1949–1986), electrical engineer, pilot and NASA astronaut. More on the language, its Shuttle deployments, the PASS flight software and its history, and the namesake: docs/BACKGROUND.md and docs/Space_Shuttle_Flight_Software_History/.

Contributing and security

  • CONTRIBUTING.md — development setup, test layers, and how to submit changes.
  • CODE_OF_CONDUCT.md — expected behaviour in project spaces.
  • SECURITY.md — how to report a vulnerability privately, and what Resnik executes when it compiles and runs a program.
  • CHANGELOG.md — release history.

License

Copyright (C) 2025-2026 Steven Doran.

This project is licensed under the GNU General Public License v3.0 or later — see the LICENSE.md file for details. It comes with no warranty and is not qualified for flight or safety-critical use.

The two HAL/S reference PDFs under docs/ are third-party documents and are not covered by this license; see docs/THIRD_PARTY.md.

Metadata

Release files for resnik 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for resnik 1.0.1
File Size Uploaded Provenance Actions
resnik-1.0.1.tar.gz 811.0 kB With provenance Details for resnik-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for resnik 1.0.1
File Interpreter ABI Platform Actions
resnik-1.0.1-py3-none-any.whl Python 3 none any Details for resnik-1.0.1-py3-none-any.whl

Total release size: 1.0 MB

Release files / resnik-1.0.1.tar.gz

Download URL resnik-1.0.1.tar.gz
Size 811.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7dd6e933a0bd34386eda956eac92587881b68ca59c54b4acd492610c1cf7eca7
BLAKE2b-256 checksum
How to use checksums
0eb7266052eadc995e94abe4291c3e7ecc57ddd26b47fe906d32122445164bc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Release files / resnik-1.0.1-py3-none-any.whl

Download URL resnik-1.0.1-py3-none-any.whl
Size 196.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e16d473e0d9b14fb32c41038e72a6d31ba32a862e4933b2db024a2c350a192a3
BLAKE2b-256 checksum
How to use checksums
c2191ad39f1d8ea3994a326286739afb46663c2ec296291cf775cba6d6267794
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Security for resnik 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for resnik-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page