Documentation

ArxPy

ArxPy

ArxPy is the typed Python API for parsing, checking, compiling, and running Arx programs without invoking the CLI.

Current status

ArxPy now has a pre-stable end-to-end compiler facade.

Implemented:

Not yet stable or implemented:

Install

pip install arxpy

Usage

from pathlib import Path

from arxpy import ArtifactKind, Compiler

compiler = Compiler()
parsed = compiler.parse_file("program.x")
checked = compiler.check(parsed)
artifact = compiler.compile(
    checked,
    kind=ArtifactKind.EXECUTABLE,
    output=Path("build/program"),
)
result = compiler.run(artifact, timeout=10)
print(result.exit_code, result.stdout, result.stderr)

Expected failures expose structured diagnostics:

from arxpy import ArxError, Compiler

try:
    Compiler().check(Compiler().parse_file("program.x"))
except ArxError as error:
    for item in error.diagnostics:
        print(item.code, item.filename, item.line, item.column, item.message)

In-memory native compilation requires an explicit output path. File compilation defaults beside the source. No implicit persistent temporary directory is created. Compiler calls are safe to repeat and are serialized across instances because the current lexer reads a process-wide source buffer. Execution never uses a shell; a non-zero program exit is returned in ExecutionResult rather than raised. Command arguments must be supplied as a non-string sequence of strings; scalar str and bytes values are rejected.

Use the Arx CLI for compiler test discovery and other CLI-specific workflows. The roadmap tracks the remaining API stability work.

Search documentation

Type to search.