sigil-parser 1.0.1

Parser and native compiler for the Sigil programming language - a language that tracks data trust at the type level
Documentation
# Sigil Programming Language

A systems programming language with **evidentiality types** that track data trust at the type level. Compiles to native binaries via LLVM or runs interpreted/JIT.

[![Crates.io](https://img.shields.io/crates/v/sigil-parser.svg)](https://crates.io/crates/sigil-parser)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Features

- **Evidentiality Types** - Track data provenance (`!` known, `?` uncertain, `~` reported)
- **Morpheme Operators** - Pipeline transformations (`|tau`, `|phi`, `|sigma`, `|rho`)
- **Multiple Backends** - Interpreter, Cranelift JIT, LLVM AOT
- **Rich Type System** - Generics, traits, enums, pattern matching
- **Comprehensive Stdlib** - Vec, Option, Result, String, HashMap, Rc, Cell, RefCell

## Quick Start

```bash
# Build the compiler
cargo build --release

# Run a program (interpreter)
./target/release/sigil run program.sg

# JIT compile and run (Cranelift)
./target/release/sigil jit program.sg

# Compile to native binary (LLVM - requires --features llvm)
./target/release/sigil compile program.sg -o program
```

## Hello World

```sigil
fn main() {
    println("Hello, Sigil!");
}
```

## Evidentiality Types

Track where your data comes from:

```sigil
let verified! = 1 + 1           // Known: computed, verified
let maybe? = map.get("key")     // Uncertain: may be absent
let external~ = api.fetch(url)  // Reported: from external source
```

The type system enforces explicit handling of trust boundaries.

## Morpheme Operators

Transform data with pipeline syntax:

```sigil
let result = data
    |tau{_ * 2}       // Map: transform each element
    |phi{_ > 10}      // Filter: keep matching elements
    |sigma            // Sort ascending
    |rho+             // Reduce: sum all
```

## Core Language Features

```sigil
// Structs and methods
struct Point { x: i32, y: i32 }

impl Point {
    fn new(x: i32, y: i32) -> Point {
        Point { x, y }
    }

    fn distance(&self, other: &Point) -> f64 {
        let dx = (self.x - other.x) as f64;
        let dy = (self.y - other.y) as f64;
        (dx * dx + dy * dy).sqrt()
    }
}

// Enums and pattern matching
enum Option<T> {
    Some(T),
    None,
}

fn unwrap_or<T>(opt: Option<T>, default: T) -> T {
    match opt {
        Some(v) => v,
        None => default,
    }
}

// Closures
let doubled = vec![1, 2, 3].map(|x| x * 2);

// Traits
trait Display {
    fn display(&self) -> String;
}
```

## Execution Backends

| Command | Backend | Use Case |
|---------|---------|----------|
| `sigil run file.sg` | Interpreter | Development, debugging |
| `sigil jit file.sg` | Cranelift JIT | Fast iteration |
| `sigil compile file.sg -o out` | LLVM AOT | Production deployment |

## Building with LLVM

For native binary compilation:

```bash
# Install LLVM 18
apt install llvm-18-dev libpolly-18-dev libzstd-dev clang-18

# Build with LLVM support
CC=clang-18 cargo build --release --features llvm

# Compile to native binary
./target/release/sigil compile program.sg -o program
./program
```

## Test Suite

```bash
# Run compiler unit tests
cargo test

# Run language test suite (472 tests, 88% pass rate)
cd ../jormungandr/tests
./run_tests_rust.sh
```

### Test Categories

- **Core Language** - Types, functions, control flow, structs, enums
- **Standard Library** - Vec, Option, Result, String, iterators
- **Advanced Features** - Generics, traits, closures, pattern matching
- **Type Checker** - 30 negative tests for error detection

## Project Structure

```
parser/
├── src/
│   ├── main.rs          # CLI entry point
│   ├── lexer.rs         # Tokenizer
│   ├── parser.rs        # Parser (337KB)
│   ├── typeck.rs        # Type checker (125KB)
│   ├── interpreter.rs   # Tree-walking interpreter (452KB)
│   ├── codegen.rs       # Cranelift JIT backend
│   ├── llvm_codegen.rs  # LLVM AOT backend
│   └── stdlib.rs        # Standard library (1.2MB)
├── runtime/             # C runtime for AOT binaries
└── tests/               # Unit tests
```

## Requirements

**Basic (Interpreter + JIT):**
- Rust 1.75+

**LLVM Backend:**
- LLVM 18
- Clang 18
- libzstd-dev

## License

MIT License - Copyright (c) 2025-2026 Daemoniorum, Inc.

---

Part of the [Daemoniorum](https://github.com/Daemoniorum-LLC) ecosystem.