[][src]Enum endbasic_core::ast::Expr

pub enum Expr {
    Boolean(bool),
    Double(f64),
    Integer(i32),
    Symbol(VarRef),
    Text(String),
    Add(Box<Expr>, Box<Expr>),
    Subtract(Box<Expr>, Box<Expr>),
    Multiply(Box<Expr>, Box<Expr>),
    Divide(Box<Expr>, Box<Expr>),
    Modulo(Box<Expr>, Box<Expr>),
    Negate(Box<Expr>),
    Equal(Box<Expr>, Box<Expr>),
    NotEqual(Box<Expr>, Box<Expr>),
    Less(Box<Expr>, Box<Expr>),
    LessEqual(Box<Expr>, Box<Expr>),
    Greater(Box<Expr>, Box<Expr>),
    GreaterEqual(Box<Expr>, Box<Expr>),
    And(Box<Expr>, Box<Expr>),
    Not(Box<Expr>),
    Or(Box<Expr>, Box<Expr>),
    Xor(Box<Expr>, Box<Expr>),
    Call(VarRefVec<Expr>),
}

Represents an expression and provides mechanisms to evaluate it.

Variants

Boolean(bool)

A literal boolean value.

Double(f64)

A literal double-precision floating point value.

Integer(i32)

A literal integer value.

Symbol(VarRef)

A reference to a variable.

Text(String)

A literal string value.

Add(Box<Expr>, Box<Expr>)

Arithmetic addition of two expressions.

Subtract(Box<Expr>, Box<Expr>)

Arithmetic subtraction of two expressions.

Multiply(Box<Expr>, Box<Expr>)

Arithmetic multiplication of two expressions.

Divide(Box<Expr>, Box<Expr>)

Arithmetic division of two expressions.

Modulo(Box<Expr>, Box<Expr>)

Arithmetic modulo operation of two expressions.

Negate(Box<Expr>)

Arithmetic sign flip of an expression.

Equal(Box<Expr>, Box<Expr>)

Relational equality comparison of two expressions.

NotEqual(Box<Expr>, Box<Expr>)

Relational inequality comparison of two expressions.

Less(Box<Expr>, Box<Expr>)

Relational less-than comparison of two expressions.

LessEqual(Box<Expr>, Box<Expr>)

Relational less-than or equal-to comparison of two expressions.

Greater(Box<Expr>, Box<Expr>)

Relational greater-than comparison of two expressions.

GreaterEqual(Box<Expr>, Box<Expr>)

Relational greater-than or equal-to comparison of two expressions.

And(Box<Expr>, Box<Expr>)

Logical and of two expressions.

Not(Box<Expr>)

Logical not of an expression.

Or(Box<Expr>, Box<Expr>)

Logical or of two expressions.

Xor(Box<Expr>, Box<Expr>)

Logical xor of two expressions.

Call(VarRefVec<Expr>)

A function call.

Implementations

impl Expr[src]

pub fn eval(
    &self,
    vars: &Vars,
    fs: &HashMap<&'static str, Rc<dyn BuiltinFunction>>
) -> Result<Value>
[src]

Evaluates the expression to a value.

Variable references are resolved by querying vars. Function calls are resolved by querying fs. Errors in the computation are returned via the special Value::Bad type.

Trait Implementations

impl Clone for Expr[src]

impl Debug for Expr[src]

impl PartialEq<Expr> for Expr[src]

impl StructuralPartialEq for Expr[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.