pub enum ExprKind {
Show 21 variants
Int(i64),
Number(f64),
Str(String),
StringInterp(Vec<StringPart>),
Bool(bool),
None,
Ident(String),
BinaryOp {
left: Box<Expr>,
op: BinOp,
right: Box<Expr>,
},
UnaryOp {
op: UnaryOp,
expr: Box<Expr>,
},
Call {
callee: Box<Expr>,
args: Vec<Expr>,
},
MethodCall {
object: Box<Expr>,
method: String,
args: Vec<Expr>,
},
FieldAccess {
object: Box<Expr>,
field: String,
},
StructConstruct {
namespace: Option<String>,
type_name: String,
fields: Vec<(String, Expr)>,
},
EnumConstruct {
namespace: Option<String>,
type_name: String,
variant: String,
payload: VariantPayload,
},
Index {
object: Box<Expr>,
index: Box<Expr>,
},
Array(Vec<Expr>),
Dict(Vec<(String, Expr)>),
IfExpr {
condition: Box<Expr>,
then_expr: Box<Expr>,
else_expr: Box<Expr>,
},
Lambda {
params: Vec<String>,
body: Vec<Stmt>,
},
Match {
scrutinee: Box<Expr>,
arms: Vec<MatchArm>,
},
Try(Box<Expr>),
}Variants§
Int(i64)
Integer literal (phase 6). Produced by integer tokens
like 42; distinct from Number so each engine can
emit a Value::Int(i64) directly.
Number(f64)
Str(String)
StringInterp(Vec<StringPart>)
Bool(bool)
None
Ident(String)
BinaryOp
UnaryOp
Call
MethodCall
FieldAccess
Bare field read: obj.field (no parens after the field
name). Distinct from MethodCall, which always has (…).
StructConstruct
Struct literal: Point { x: 1, y: 2 }. Only parsed in
contexts where struct literals are allowed — control-flow
conditions and for-in iterables disallow them so that
if foo { body } stays unambiguous.
Fields
EnumConstruct
Enum variant construction: Shape::Circle(5),
Shape::Rectangle { w: 4, h: 3 }, Shape::Empty. The
payload shape is determined at parse time from the syntax
at the construction site.
Fields
namespace: Option<String>Some("r") for r.Result::Ok(v) — a namespaced
variant constructor through a module alias. None
for unqualified Result::Ok(v).
payload: VariantPayloadIndex
Array(Vec<Expr>)
Dict(Vec<(String, Expr)>)
IfExpr
Lambda
Anonymous function expression: fn(params) { body }.
Captures the referenced free variables from the enclosing
scope when evaluated; see the evaluator for capture rules.
Match
match scrutinee { pat => body, ... } — checks each arm
top-to-bottom, evaluates the first matching arm’s body,
and returns its value. Raises a runtime error if no arm
matches (exhaustiveness isn’t checked statically in v1).
Try(Box<Expr>)
try <expr> — inspect a Result-shaped enum variant.
If <expr> evaluates to an Ok(value)-shaped variant,
unwrap to value. If it evaluates to an Err(...)-shaped
variant, short-circuit the enclosing function’s return
with that value (same mechanism as a return statement).
At top-level scope (no enclosing fn) or on a non-Result
scrutinee, try raises a runtime error.
Desugars roughly to the match:
match <expr> {
Ok(v) => v,
Err(_) => return <expr>,
}but is its own AST node so each engine can compile it directly without paying the pattern-construction cost.