Skip to content

Compiler API Reference

API documentation for the USL compiler.

Command Line Interface

Compile

usl compile [OPTIONS] <FILE>

Options: - --verify=[none|basic|full] - Verification level (default: full) - --incremental - Enable incremental compilation - --jobs=N - Parallel compilation threads - --verbose - Verbose output - --output=DIR - Output directory

Example:

usl compile --verify=full --incremental my-app.usl

Generate

usl generate --target=<TARGET> [OPTIONS] <FILE>

Targets: - typescript - TypeScript/Node.js - rust - Rust - python - Python - openapi - OpenAPI specification

Options: - --output=DIR - Output directory - --optimize - Enable optimizations - --tree-shake - Remove unused code

Example:

usl generate --target=typescript --output=./backend my-app.usl

Test

usl test [OPTIONS] <FILE>

Options: - --filter=PATTERN - Run matching tests - --verbose - Show test details

Verify

usl verify [OPTIONS] <FILE>

Runs formal verification without code generation.

Programmatic API

Rust

use usl_compiler::{Compiler, CompilerOptions};

let options = CompilerOptions {
    verify: VerificationLevel::Full,
    incremental: true,
    ..Default::default()
};

let compiler = Compiler::new(options);
let result = compiler.compile_file("my-app.usl")?;

TypeScript

import { Compiler, CompilerOptions } from '@usl-lang/compiler';

const options: CompilerOptions = {
  verify: 'full',
  incremental: true,
};

const compiler = new Compiler(options);
const result = await compiler.compileFile('my-app.usl');

Configuration File

usl.toml:

[package]
name = "my-app"
version = "0.1.0"

[compiler]
verification = "full"
experimental = false

[generate.typescript]
output = "./backend"
framework = "express"

Back to Index