MVP: AILang-Sprache mit JSON-AST, Typchecker, LLVM-IR-Backend

Erste lauffähige Iteration. examples/sum.ail.json wird zu nativem Binary
kompiliert und druckt 55 (Summe 1..10) als End-to-End-Test.

Architektur:
- ailang-core: hashbares JSON-AST + canonical-form + pretty-printer
- ailang-check: monomorpher HM-Subset + Effekt-Set-Tracking
- ailang-codegen: LLVM-IR-Text-Emitter (kein libllvm-link)
- ail: CLI mit check/manifest/render/describe/emit-ir/build/builtins

Designentscheidungen sind in docs/DESIGN.md dokumentiert; der Verlauf
in docs/JOURNAL.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-07 10:18:32 +02:00
commit 2fbcdba0b1
21 changed files with 2633 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
//! AILang Kerndatenmodell.
//!
//! Quelle einer AILang-Übersetzungseinheit ist ein `Module` als JSON. Dieses
//! Crate definiert das Schema, Serialisierung und content-addressed Hashing.
pub mod ast;
pub mod canonical;
pub mod hash;
pub mod pretty;
pub use ast::{ConstDef, Def, FnDef, Import, Literal, Module, Term, Type};
pub use hash::def_hash;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("schema mismatch: expected {expected:?}, got {got:?}")]
SchemaMismatch { expected: String, got: String },
#[error("json: {0}")]
Json(#[from] serde_json::Error),
#[error("io: {0}")]
Io(#[from] std::io::Error),
}
pub type Result<T> = std::result::Result<T, Error>;
pub const SCHEMA: &str = "ailang/v0";
pub fn load_module(path: &std::path::Path) -> Result<Module> {
let bytes = std::fs::read(path)?;
let module: Module = serde_json::from_slice(&bytes)?;
if module.schema != SCHEMA {
return Err(Error::SchemaMismatch {
expected: SCHEMA.to_string(),
got: module.schema,
});
}
Ok(module)
}