Copied

DEXA language overview

Early draft. Examples and playground target the 0.1.0 reference compiler. Start with the Tour then return here.

DEXA runs on dxa.dev, uses .dxa source files, and compiles via the dxc reference compiler.

GitHub
  1. git clone https://github.com/dxiv/dxa-dev
  2. cd compiler
  3. cargo run -- ../examples/hello.dxa
fn add(a: int, b: int) -> int {
    return a + b;
}
fn main() { let three: int = add(1, 2); return; }
Run in Playground →

Functions with fn; statements: let, return, if/else, loops. Types: int, float, bool, string, unit, address. Explicit address("...") — no implicit coercions.

int, float, bool, string, unit, address, Record<Name>. No implicit coercions; address("...") builtin.

model / contract. Record literals; update syntax Type { ..base; field: expr }. Base must match type.

model Wallet {
    owner: address;
    balance: int;
}
Run in Playground →

fn with typed params; return optional. let / let mut; if/else, while, loop, break, continue.

print(expr), address(string), require(cond, msg?). Math: abs(x), min(a,b), max(a,b), sqrt(x) (float). len(s) → int. On false → ProgramResult::RequireFail.

fn main() -> int {
    require(abs(-7) == 7, "abs");
    require(min(1, 2) == 1 && max(1, 2) == 2, "min/max");
    require(sqrt(4.0) == 2.0, "sqrt");
    require(len("hello") == 5, "len");
    return 0;
}
Run in Playground →

Source → tokens → AST → typecheck → lower → DX-IR → IR validation → interpret. ProgramResult::Ok { value, prints, trace, gas } or RequireFail.

Running main yields value, prints, trace, gas. require(cond, msg?) → RequireFail on false.

DEXA aims for deterministic execution: the same source, inputs, and gas limit always produce the same result, trace, and gas usage. No hidden IO, syscalls, or ambient state.

The interpreter tracks a logical gasSteps counter: each evaluated expression, branch, and loop iteration consumes gas. When gas is exhausted, evaluation halts safely instead of diverging.

The execution trace records the high-level steps the program took (calls, requires, branches). Together, trace + gas make runs auditable and bound in cost, even before specialised backends exist.

Now: Lexer, parser, functions, blocks, if/else, loops, let/let mut, typechecker, DX-IR, interpreter, IR validation.

Next: Diagnostics, arrays/slices, CLI JSON, minimal stdlib.

Later: Tensor types & GPU, contract subset & DX-VM.