1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//! Bundled Bop standard library modules, resolved by name.
//!
//! Each `.bop` file under `src/modules/` is baked into the binary
//! as an `&'static str` via `include_str!`. When a Bop script
//! does `use std.math`, the engine asks its `BopHost` to
//! resolve the module — embedders route that call to
//! [`resolve`], which returns the bundled source text.
//!
//! Gated behind the `bop-std` feature (on by default). Disable
//! with `default-features = false` when you want a truly minimal
//! core with no bundled modules:
//!
//! ```toml
//! bop-lang = { version = "0.3", default-features = false }
//! ```
//!
//! Available modules:
//!
//! - `std.math` — numeric constants (`PI`, `E`, `TAU`) and
//! helpers that don't fit on a numeric receiver (`clamp`,
//! `factorial`, `gcd`, …)
//! - `std.iter` — functional helpers on arrays (`map`, `filter`,
//! `reduce`, `sum`, `find`, …)
//! - `std.string` — string helpers that didn't fit the
//! method-on-string pattern (`pad_left`, `pad_right`,
//! `chars`, …)
//! - `std.test` — `assert`, `assert_eq`, `assert_near` plus a
//! tiny test-runner
//! - `std.collections` — `Set`, `Queue`, `Stack` as struct
//! types with value-semantic methods (`s = s.push(v)` etc.)
//! - `std.json` — `parse(text)` / `stringify(value)`. Pure
//! Bop implementation; adequate for scripting workloads.
//!
//! `Result` combinators (`is_ok`, `unwrap`, `map`, `and_then`,
//! …) used to live in `std.result` but are now methods on the
//! built-in `Result` type — always available without a `use`.
//! See `methods::result_method`.
const MATH: &str = include_str!;
const ITER: &str = include_str!;
const STRING_MOD: &str = include_str!;
const TEST_MOD: &str = include_str!;
const COLLECTIONS: &str = include_str!;
const JSON_MOD: &str = include_str!;
/// Map a `std.*` module name to its bundled Bop source.
///
/// Returns `None` for any path outside the stdlib — chain this
/// with your own [`crate::BopHost::resolve_module`] so user
/// modules still resolve:
///
/// ```ignore
/// use bop::{BopError, BopHost};
///
/// impl BopHost for MyHost {
/// fn resolve_module(&mut self, name: &str) -> Option<Result<String, BopError>> {
/// if let Some(src) = bop::stdlib::resolve(name) {
/// return Some(Ok(src.to_string()));
/// }
/// // fall back to your own resolver (filesystem,
/// // embedded modules, etc.)
/// self.my_own_resolver(name)
/// }
/// # fn call(&mut self, _: &str, _: &[bop::Value], _: u32)
/// # -> Option<Result<bop::Value, BopError>> { None }
/// }
/// # struct MyHost;
/// # impl MyHost {
/// # fn my_own_resolver(&mut self, _: &str) -> Option<Result<String, BopError>> { None }
/// # }
/// ```
/// Every module name this crate can resolve. Useful for docs,
/// diagnostics, or a "did you mean…" suggestion in error paths.
pub const MODULES: & = &;