pub enum Stmt {
Sample {
var: String,
addr: Addr,
dist: DistCall,
},
Let {
var: String,
value: Expr,
},
Assign {
var: String,
value: Expr,
},
Observe {
addr: Addr,
dist: DistCall,
value: Expr,
},
Factor {
logw: Expr,
},
For {
var: String,
start: Expr,
end: Expr,
body: Vec<Stmt>,
},
If {
cond: Expr,
then_branch: Vec<Stmt>,
else_branch: Vec<Stmt>,
},
Break {},
}Expand description
A statement. The JSON form is an object tagged by "stmt".
Variants§
Sample
let var <- sample(addr, dist); — draw from dist at addr and bind
the draw (with the site’s natural type) to var.
Fields
Let
let var = value; — bind a new variable (shadowing any outer one
until the end of the enclosing block).
Assign
var = value; — reassign a variable bound by an enclosing let
(or by the data). The new value is visible for the rest of that
variable’s scope, including later iterations of an enclosing loop.
Observe
observe(addr, dist, value); — condition on value under dist.
Fields
Factor
factor(logw); — add logw to the execution’s log-weight.
For
for var in start..end { body } — run body with var bound to each
integer of the half-open range, evaluated once on entry.
Fields
If
if cond { then } else { else } (else optional; else if chains
nest an If as the only statement of the else branch).
Fields
Break
break; — leave the innermost for loop.