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:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user