uni_core/
lib.rs

1//! # Uni Core
2//!
3//! Core interpreter for the Uni programming language - a homoiconic stack-based language
4//! that unifies code and data through cons cells and immediate execution.
5//!
6//! This library provides the core language implementation without platform-specific I/O,
7//! making it suitable for embedding in other applications or for use on embedded systems.
8//!
9//! ## Features
10//!
11//! - **no_std compatible**: Works on embedded systems without the Rust standard library
12//! - **Homoiconic**: Code and data have identical representation
13//! - **Stack-based**: All operations work with a central computation stack
14//! - **Tail-call optimized**: Continuation-based evaluator enables infinite recursion
15//! - **Multiple numeric types**: Integers, rationals, floats, and complex numbers
16//!
17//! ## Example
18//!
19//! ```
20//! use uni_core::{Interpreter, execute_string};
21//!
22//! let mut interp = Interpreter::new();
23//!
24//! // Execute some Uni code
25//! execute_string("5 3 +", &mut interp).unwrap();
26//!
27//! // Check the result
28//! assert_eq!(interp.stack.len(), 1);
29//! ```
30//!
31//! ## Optional Features
32//!
33//! - `std` - Enables standard library support (required for desktop platforms)
34//! - `advanced_math` - Trigonometric functions, exp/log, rounding operations
35//! - `complex_numbers` - Complex number and Gaussian integer support
36
37#![cfg_attr(target_os = "none", no_std)]
38
39#[cfg(target_os = "none")]
40extern crate alloc;
41
42// Hardware platform support
43#[cfg(feature = "hardware-microbit")]
44extern crate microbit;
45#[cfg(any(feature = "hardware-microbit", feature = "hardware-pico"))]
46extern crate embedded_hal;
47#[cfg(any(feature = "hardware-microbit", feature = "hardware-pico"))]
48extern crate cortex_m;
49#[cfg(any(feature = "hardware-microbit", feature = "hardware-pico"))]
50extern crate cortex_m_rt;
51
52// Public modules
53pub mod output;
54pub mod time_source;
55pub mod value;
56pub mod interpreter;
57pub mod evaluator;
58pub mod parser;
59pub mod tokenizer;
60pub mod builtins;
61pub mod prelude;
62pub mod primitives;
63pub mod hardware;
64
65// Internal module
66mod compat;
67
68// Re-exports for convenience
69pub use interpreter::{Interpreter, DictEntry};
70pub use value::{Value, RuntimeError};
71pub use output::Output;
72pub use time_source::{TimeSource, DateComponents};
73pub use evaluator::execute_string;