pub enum Stmt {
Show 17 variants
Decl {
names: Vec<String>,
rest: Option<String>,
expr: Expr,
span: Span,
},
ConstDecl {
name: String,
expr: Expr,
span: Span,
},
Import {
module: String,
path: Option<String>,
span: Span,
},
Assign {
targets: Vec<Expr>,
rest: Option<Expr>,
expr: Expr,
op: Option<BinOp>,
flavored: bool,
span: Span,
},
Bark {
expr: Expr,
span: Span,
},
If {
branches: Vec<(Expr, Vec<Stmt>)>,
else_body: Option<Vec<Stmt>>,
span: Span,
},
For {
vars: Vec<String>,
rest: Option<String>,
iter: Expr,
body: Vec<Stmt>,
span: Span,
},
While {
cond: Expr,
body: Vec<Stmt>,
span: Span,
},
FuncDef {
name: String,
params: Params,
body: Vec<Stmt>,
span: Span,
},
ObjDef {
name: String,
parent: Option<String>,
methods: Vec<Stmt>,
span: Span,
},
Try {
body: Vec<Stmt>,
err_name: String,
handler: Vec<Stmt>,
span: Span,
},
Return {
expr: Option<Expr>,
span: Span,
},
Bonk {
expr: Expr,
span: Span,
},
Amaze {
cond: Expr,
message: Option<Expr>,
span: Span,
},
Bork {
span: Span,
},
Continue {
span: Span,
},
ExprStmt {
expr: Expr,
},
}Expand description
One statement. Variants mirror the docs/GRAMMAR.md grammar.
Variants§
Decl
such x = e, or a destructuring such a, b = e / such a, many rest = e.
names are the leading targets in order; rest, when present, is a
trailing many collector that gathers the surplus into a List. A plain
single declaration has one name and no rest.
ConstDecl
so X = e
Import
so math, or the string-path form so "lib/utils.doge". module is the
binding name (the stem for a path import); path is the raw string of a
path import, None for a bare-name import.
Assign
[very] target = e, or a destructuring [very] a, b = e /
[very] a, many rest = e — flavored is true when written with very.
targets are the leading assignable targets in order; rest, when
present, is a trailing many collector target that gathers the surplus
into a List. op is Some for an augmented assignment (target op= e),
which reads the target, applies the binary operator, and stores the result
back — augmented assignment is single-target only (one targets entry, no
rest).
Bark
bark e
If
if / elif / else. Each branch is (condition, body); else_body is the
optional trailing else block.
For
for v in iter:, or a destructuring for k, v in iter: /
for first, many rest in iter:. vars are the leading loop variables in
order; rest, when present, is a trailing many collector that gathers
each element’s surplus into a List. A plain loop has one var and no rest.
While
while cond:
FuncDef
such name much params: … wow
ObjDef
many Name [much Parent]: … wow — a body of function definitions
(methods). parent names the class it inherits from, when one is given.
Try
pls … oh no err! …
Return
return [e]
Bonk
bonk e — raise a catchable error whose message is e’s display form.
Amaze
amaze cond [, message] — assert: a no-op when cond is truthy, else a
catchable AssertError whose message is message’s display form (or a
default when omitted). The message is evaluated only on failure.
Bork
bork
Continue
continue
ExprStmt
A bare expression used as a statement, e.g. a call greet(x).