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//! - `repl` - Enables REPL (Read-Eval-Print Loop) functionality with line editing
37
38#![cfg_attr(target_os = "none", no_std)]
39
40#[cfg(target_os = "none")]
41extern crate alloc;
42
43// Hardware platform support
44#[cfg(feature = "hardware-microbit")]
45extern crate microbit;
46#[cfg(any(feature = "hardware-microbit", feature = "hardware-pico2"))]
47extern crate embedded_hal;
48#[cfg(any(feature = "hardware-microbit", feature = "hardware-pico2"))]
49extern crate cortex_m;
50#[cfg(any(feature = "hardware-microbit", feature = "hardware-pico2"))]
51extern crate cortex_m_rt;
52
53// Public modules
54pub mod output;
55pub mod time_source;
56pub mod value;
57pub mod interpreter;
58pub mod evaluator;
59pub mod parser;
60pub mod tokenizer;
61pub mod builtins;
62pub mod prelude;
63pub mod primitives;
64pub mod hardware;
65
66// Optional REPL module (only with "repl" feature)
67#[cfg(feature = "repl")]
68pub mod repl;
69
70// Internal module
71mod compat;
72
73// Re-exports for convenience
74pub use interpreter::{Interpreter, DictEntry};
75pub use value::{Value, RuntimeError};
76pub use output::Output;
77pub use time_source::{TimeSource, DateComponents};
78pub use evaluator::execute_string;