lemma/
lib.rs

1//! # Lemma Engine
2//!
3//! **Rules for man and machine**
4//!
5//! Lemma is a declarative programming language for expressing rules, facts, and business logic
6//! in a way that is both human-readable and machine-executable.
7//!
8//! ## Quick Start
9//!
10//! ```rust,no_run
11//! use lemma::{Engine, LemmaResult};
12//!
13//! fn main() -> LemmaResult<()> {
14//!     let mut engine = Engine::new();
15//!
16//!     // Load Lemma code
17//!     engine.add_lemma_code(r#"
18//!         doc example
19//!         fact price = 100 USD
20//!         fact quantity = 5
21//!         rule total = price * quantity
22//!     "#, "example.lemma")?;
23//!
24//!     // Evaluate the document
25//!     let response = engine.evaluate("example", None, None)?;
26//!
27//!     Ok(())
28//! }
29//! ```
30//!
31//! ## Core Concepts
32//!
33//! ### Documents
34//! A document is a collection of facts and rules. Documents can reference
35//! other documents to build composable logic.
36//!
37//! ### Facts
38//! Facts are named values: numbers, text, dates, booleans, or typed units
39//! like `50 kilograms` or `100 USD`.
40//!
41//! ### Rules
42//! Rules compute values based on facts and other rules. They support
43//! conditional logic through "unless" clauses.
44//!
45//! ### Types
46//! Lemma has a rich type system including units (mass, length, time, money)
47//! with automatic conversions.
48
49pub mod analysis;
50pub mod ast;
51pub mod engine;
52pub mod error;
53pub mod evaluator;
54pub mod operation_result;
55pub mod parser;
56pub mod response;
57pub mod semantic;
58pub mod serializers;
59pub mod validator;
60
61#[cfg(target_arch = "wasm32")]
62pub mod wasm;
63
64pub use ast::{ExpressionId, ExpressionIdGenerator, Span};
65pub use engine::Engine;
66pub use error::LemmaError;
67pub use operation_result::OperationResult;
68pub use parser::{parse, parse_facts};
69pub use response::{OperationRecord, Response, RuleResult};
70pub use semantic::*;
71pub use validator::{ValidatedDocuments, Validator};
72
73/// Result type for Lemma operations
74pub type LemmaResult<T> = Result<T, LemmaError>;
75
76#[cfg(test)]
77mod tests;