pub mod core; pub mod datetime; pub mod intrinsics; pub mod math; pub mod series; pub mod streams; pub mod type_registry; use crate::ast::environment::Environment; pub fn register(env: &Environment) { core::register(env); datetime::register(env); math::register(env); series::register(env); streams::register(env); } /// Registers a native RTL function and optionally attaches documentation. /// /// Required: `doc:` — a short one-line description. /// Optional: `description:` — a longer explanation. /// Optional: `examples:` — a `&'static [&'static str]` of Myc code snippets. /// /// # Example /// ```ignore /// rtl_fn!(env, "+", /// doc: "Adds two values.", /// add_ty, Pure, |args| { ... } /// ); /// /// rtl_fn!(env, "push", /// doc: "Pushes a new record into a series.", /// description: "The record must match the series layout.", /// examples: &["(push my_ticks {:price 10.5})"], /// push_ty, Impure, |args| { ... } /// ); /// ``` #[macro_export] macro_rules! rtl_fn { // With description and examples ($env:expr, $name:expr, doc: $doc:expr, description: $desc:expr, examples: $ex:expr, $ty:expr, $purity:expr, $impl:expr $(,)?) => { $env.register_native_fn($name, $ty, $purity, $impl) .doc($doc) .description($desc) .examples($ex); }; // With description only ($env:expr, $name:expr, doc: $doc:expr, description: $desc:expr, $ty:expr, $purity:expr, $impl:expr $(,)?) => { $env.register_native_fn($name, $ty, $purity, $impl) .doc($doc) .description($desc); }; // With examples only ($env:expr, $name:expr, doc: $doc:expr, examples: $ex:expr, $ty:expr, $purity:expr, $impl:expr $(,)?) => { $env.register_native_fn($name, $ty, $purity, $impl) .doc($doc) .examples($ex); }; // doc only ($env:expr, $name:expr, doc: $doc:expr, $ty:expr, $purity:expr, $impl:expr $(,)?) => { $env.register_native_fn($name, $ty, $purity, $impl) .doc($doc); }; } /// Registers a native RTL constant and optionally attaches documentation. /// Same optional fields as `rtl_fn!`. #[macro_export] macro_rules! rtl_const { // With description and examples ($env:expr, $name:expr, doc: $doc:expr, description: $desc:expr, examples: $ex:expr, $ty:expr, $val:expr $(,)?) => { $env.register_constant($name, $ty, $val) .doc($doc) .description($desc) .examples($ex); }; // With description only ($env:expr, $name:expr, doc: $doc:expr, description: $desc:expr, $ty:expr, $val:expr $(,)?) => { $env.register_constant($name, $ty, $val) .doc($doc) .description($desc); }; // doc only ($env:expr, $name:expr, doc: $doc:expr, $ty:expr, $val:expr $(,)?) => { $env.register_constant($name, $ty, $val) .doc($doc); }; }