Skip to main content

Crate bop

Crate bop 

Source

Re-exports§

pub use error::BopError;
pub use error::BopWarning;
pub use parser::Stmt;
pub use parser::count_instructions;
pub use value::Value;

Modules§

builtins
Language-level builtins (range, str, int, type, len, …) and the shared argument-validation helpers used across the runtime.
check
Static checks that run after parse, before execution.
error
Error type for the Bop interpreter.
error_messages
Shared error-message format helpers.
host
Ready-made BopHost building blocks for embedders.
lexer
math
Tiny f64 math facade that works on both the default (std) build and the no_std opt-in. core::f64 doesn’t expose sqrt / sin / cos / etc. — those methods live in std::f64’s platform-dependent math library — so the no_std build has to forward to the pure-Rust libm crate instead. The std build stays dep-free and calls the native f64 methods directly.
memory
Memory tracking for Bop script execution.
methods
naming
Identifier classification: the shared rules every engine and the parser consult to sort a name into naming buckets.
ops
Operator primitives shared across execution engines.
parser
precheck
stdlib
Bundled Bop standard library (use std.math, std.json, std.collections, std.iter, std.string, std.result, std.test). Feature-gated behind bop-std (on by default).
suggest
“Did you mean?” suggestions — used by error paths to turn Variable lenght not found into a hint that points at length (or len) when those exist in the surrounding scope.
value
Value type for the Bop interpreter.

Structs§

BopLimits
Resource limits enforced during execution.
ReplSession
Persistent state for an interactive REPL session. Unlike the one-shot run / [Evaluator::run] pair, a ReplSession carries its scopes, fns, user types, method tables, and import cache across calls, so session.eval("let x = 5") followed by session.eval("print(x)") sees the same x. Persistent state for an interactive REPL session. Build once with Self::new, then call Self::eval for each fresh line / block the user types. State carried across calls: every let / const / fn / struct / enum / method declaration, every use’d module’s bindings and aliases, the global rng seed, and the import cache.

Traits§

BopHost
Extension point for embedders to add custom built-in functions.

Functions§

parse
Parse Bop source into an AST (useful for instruction counting).
parse_with_warnings
Parse Bop source and run the static check pass, returning both the AST and any non-fatal warnings (currently: match-exhaustiveness). Prefer this over parse in tools that surface diagnostics to users — the CLI uses it to print warnings before running the program.
parse_with_warnings_and_resolver
Like parse_with_warnings but follows every top-level use statement via the supplied resolver so the exhaustiveness check can see imported enums. resolver has the same shape as BopHost::resolve_module.
pattern_matches
The core pattern matcher. Re-exported so engines beyond the tree-walker (the bytecode VM, the AOT runtime) can apply the same structural rules without re-implementing them. Attempt to match pattern against value. On success, appends any captured (name, Value) bindings to bindings and returns true; on failure, returns false and leaves bindings in an undefined state — it’s the caller’s responsibility to discard it.
resolve_type_in
Shared scope walker for resolving source-level type references to the declaring module. Re-exported because VM and AOT both need to build per-frame type resolvers when calling pattern_matches — the identity comparison lives on the matcher side, but the scope lookup is identical across engines. Walk a pair of scope stacks to resolve a source-level type reference — the same logic as [Evaluator::resolve_type_ref], but free-standing so the pattern matcher can be called with a borrow of the evaluator’s tables without needing the evaluator itself. Returns None if the name isn’t in scope.
run
Run a Bop program with the given host and limits.

Type Aliases§

TypeResolveFn
Type alias for the resolver closure pattern_matches expects. Resolver that turns a source-level type reference — optional namespace plus bare name (m.Color vs plain Color) — into the declaring module’s path. Pattern matching threads this through so a pattern like Color::Red only matches values whose module identity agrees with the current scope’s binding of Color.