Skip to main content

Crate etdl_compiler

Crate etdl_compiler 

Source
Expand description

Compiler pipeline for the Event Tree Definition Language (ETDL).

Validates .etdl documents, resolves fault tree top-event probabilities (IEC 61025:2006), and generates service-local code. Reliability — event trees (IEC 62502), fault trees (IEC 61025), retry policies, SLAs — becomes a build-time, machine-checked artifact instead of scattered runtime guesses.

§Pipeline

  1. validate::validate_document — structural and semantic diagnostics (E-1xx, V-1xx..V-5xx, W-4xx)
  2. fault_tree::resolve_fault_trees — exact top-event probability evaluation (AND/OR/NOT/XOR/VOTING gates, exponential failure model)
  3. [typeck] — ECEL condition type-checking against AsyncAPI schemas
  4. codegen::CodeGenerator — backend trait; codegen::RustCodeGenerator emits async handlers with embedded probabilities, retry policies, and etdl-core instrumentation

§Example

use etdl_compiler::Compiler;
use etdl_parser::{parse_document_from_file, load_asyncapi_imports};
use std::path::Path;

let base = Path::new(".");
let doc = parse_document_from_file(&base.join("order-fulfillment.etdl"))?;
let registry = load_asyncapi_imports(&doc, base)?;
let result = Compiler::new().compile(&doc, &registry);
assert!(result.diagnostics.iter().all(|d| !d.is_error()));
assert!(result.rust_output.is_some());

Re-exports§

pub use codegen::CodeGenerator;
pub use codegen::GeneratedFile;
pub use codegen::RustCodeGenerator;
pub use extension::EtdlExtension;
pub use extension::ExtensionContext;
pub use extension::ExtensionRegistry;
pub use extension::SupplementDescriptor;
pub use validate::Diagnostic;

Modules§

codegen
diagnostics
Compiler integration for the ETDL Diagnostics Supplement (etdl.diagnostics).
extension
Generic semantic-extension mechanism for the ETDL compiler.
fault_tree
performance
Compiler integration for the ETDL Performance Supplement (etdl.performance).
reliability
Compiler integration for the ETDL Reliability Supplement (etdl.reliability).
safety
Compiler integration for the ETDL Safety Supplement (etdl.safety).
security
Compiler integration for the ETDL Security Supplement (etdl.security).
stdlib
ETDL Standard Library resolution and library expansion.
tree_event
Compiler integration for the ETDL Generic Tree Event Supplement (etdl.tree-event).
validate

Structs§

CompilationResult
A complete compilation result including optional reliability provenance.
Compiler
TargetCompilationResult
Result of compiling for one arbitrary target generator (Compiler::compile_target/Compiler::compile_target_with_base) — the target-neutral counterpart to CompilationResult, which stays Rust-specific (rust_output: Option<String>) for backward compatibility.