pub enum StmtKind {
Show 15 variants
Let {
name: String,
value: Expr,
is_const: bool,
},
Assign {
target: AssignTarget,
op: AssignOp,
value: Expr,
},
If {
condition: Expr,
body: Vec<Stmt>,
else_ifs: Vec<(Expr, Vec<Stmt>)>,
else_body: Option<Vec<Stmt>>,
},
While {
condition: Expr,
body: Vec<Stmt>,
},
Repeat {
count: Expr,
body: Vec<Stmt>,
},
ForIn {
var: String,
iterable: Expr,
body: Vec<Stmt>,
},
FnDecl {
name: String,
params: Vec<String>,
body: Vec<Stmt>,
},
MethodDecl {
type_name: String,
method_name: String,
params: Vec<String>,
body: Vec<Stmt>,
},
Return {
value: Option<Expr>,
},
Break,
Continue,
Use {
path: String,
items: Option<Vec<String>>,
alias: Option<String>,
},
StructDecl {
name: String,
fields: Vec<String>,
},
EnumDecl {
name: String,
variants: Vec<VariantDecl>,
},
ExprStmt(Expr),
}Variants§
Let
let NAME = expr (value binding, mutable) and const NAME = expr (constant binding, immutable). The is_const flag
flips enforcement at use/assign sites: reassigning a
constant is a compile-time error (the parser refuses any
assignment whose LHS is an all-uppercase identifier — see
[parse_assign]).
Assign
If
Fields
While
Repeat
ForIn
FnDecl
MethodDecl
fn Type.method(self, ...) { body } — declares a method
on a user-defined struct or enum. At call time
(obj.method(...)) the receiver is passed as the first
parameter (conventionally named self), followed by the
rest.
Return
Break
Continue
Use
use foo.bar.baz — resolves the module named by the
dot-joined path through BopHost::resolve_module,
evaluates its top-level statements in a fresh scope, and
injects its exports into the importer’s scope. The shape
of the injection depends on the optional items / alias:
use foo— glob: all non-private top-level names land unqualified.use foo.{a, b}— selective: onlyaandbland unqualified._-prefixed names can be explicitly listed.use foo as m— aliased: all exports (including_-prefixed) hang off a newmnamespace value. Access viam.a,m.Entity, etc.use foo.{a, b} as m— selective + aliased:mnamespace contains onlyaandb.
Glob imports skip _-prefixed top-level names (privacy
convention). Aliased and selective imports pass them
through when the user asks for them explicitly.
Fields
StructDecl
struct Point { x, y } — registers a user-defined struct
type with the listed field names. Field values get their
types from the construction site (Point { x: 1, y: 2 }).
EnumDecl
enum Shape { Circle(radius), Rectangle { w, h }, Empty }
— registers a user-defined sum type with named variants.