pub enum Expr {
}Expand description
A formula’s syntax tree.
A flat operator chain such as =A1+A2+… nests one Expr::Binary per operator on its
left, so a formula as long as Excel allows (8,192 characters) is about 4,000 levels deep.
Clone, PartialEq, Expr::walk and Expr::map therefore follow that left spine in a
loop and recurse only into right-hand operands and real nesting, which the parser bounds.
Variants§
Number(f64)
Text(Arc<str>)
Bool(bool)
Error(CellError)
Array(Vec<Vec<Expr>>)
Array constant {1,2;3,4} (rows of literal expressions).
Ref(Reference)
Name(String)
Defined name, table name or LET/LAMBDA parameter.
Struct(StructRef)
Unary(UnOp, Box<Expr>)
Binary(BinOp, Box<Expr>, Box<Expr>)
Call(String, Vec<Expr>)
Function call; the name is upper-case without _xlfn..
Invoke(Box<Expr>, Vec<Expr>)
Calling the result of an expression, e.g. LAMBDA(x,x+1)(2).
Missing
An omitted argument F(1,,3).
Paren(Box<Expr>)
Implementations§
Source§impl Expr
impl Expr
Sourcepub fn walk<'a>(&'a self, f: &mut dyn FnMut(&'a Expr))
pub fn walk<'a>(&'a self, f: &mut dyn FnMut(&'a Expr))
Visits every node depth-first, parents before children, left to right.
Sourcepub fn map(self, f: &mut dyn FnMut(Expr) -> Expr) -> Expr
pub fn map(self, f: &mut dyn FnMut(Expr) -> Expr) -> Expr
Rewrites every node bottom-up, children left to right before their parent.
Sourcepub fn references(&self) -> Vec<&Reference>
pub fn references(&self) -> Vec<&Reference>
All references in the formula.