pub enum Expr<'a> {
Show 19 variants
Literal(Literal),
Identifier(Symbol),
BinaryOp {
op: BinaryOpKind,
left: &'a Expr<'a>,
right: &'a Expr<'a>,
},
Call {
function: Symbol,
args: Vec<&'a Expr<'a>>,
},
Index {
collection: &'a Expr<'a>,
index: &'a Expr<'a>,
},
Slice {
collection: &'a Expr<'a>,
start: &'a Expr<'a>,
end: &'a Expr<'a>,
},
Copy {
expr: &'a Expr<'a>,
},
Length {
collection: &'a Expr<'a>,
},
Contains {
collection: &'a Expr<'a>,
value: &'a Expr<'a>,
},
Union {
left: &'a Expr<'a>,
right: &'a Expr<'a>,
},
Intersection {
left: &'a Expr<'a>,
right: &'a Expr<'a>,
},
ManifestOf {
zone: &'a Expr<'a>,
},
ChunkAt {
index: &'a Expr<'a>,
zone: &'a Expr<'a>,
},
List(Vec<&'a Expr<'a>>),
Tuple(Vec<&'a Expr<'a>>),
Range {
start: &'a Expr<'a>,
end: &'a Expr<'a>,
},
FieldAccess {
object: &'a Expr<'a>,
field: Symbol,
},
New {
type_name: Symbol,
type_args: Vec<Symbol>,
init_fields: Vec<(Symbol, &'a Expr<'a>)>,
},
NewVariant {
enum_name: Symbol,
variant: Symbol,
fields: Vec<(Symbol, &'a Expr<'a>)>,
},
}Expand description
Shared expression type for pure computations (LOGOS §15.0.0).
Expr is used by both LogicExpr (as terms) and Stmt (as values). These are pure computations without side effects.
Variants§
Literal(Literal)
Literal value: 42, “hello”, true, nothing
Identifier(Symbol)
Variable reference: x
BinaryOp
Binary operation: x plus y
Call
Function call as expression: f(x, y)
Index
Dynamic index access: items at i (1-indexed).
Slice
Dynamic slice access: items 1 through mid (1-indexed, inclusive).
Copy
Copy expression: copy of slice → slice.to_vec().
Length
Length expression: length of items → items.len().
Contains
Set contains: set contains x or x in set
Union
Set union: a union b
Intersection
Set intersection: a intersection b
ManifestOf
Get manifest of a zone.
the manifest of Zone → FileSipper::from_zone(&zone).manifest()
ChunkAt
Get chunk at index from a zone.
the chunk at N in Zone → FileSipper::from_zone(&zone).get_chunk(N)
List(Vec<&'a Expr<'a>>)
List literal: [1, 2, 3]
Tuple(Vec<&'a Expr<'a>>)
Tuple literal: (1, “hello”, true)
Range
Range: 1 to 10 (inclusive)
FieldAccess
Field access: p's x or the x of p.
New
Constructor: a new Point or a new Point with x 10 and y 20.
Supports generics: a new Box of Int
NewVariant
Enum variant constructor: a new Circle with radius 10.