Enum Expr

Source
pub enum Expr<'arena> {
    RealNumber {
        val: f64,
    },
    ImaginaryNumber {
        val: f64,
    },
    ComplexNumber {
        val: Complex64,
    },
    Binding {
        name: &'arena mut str,
    },
    FunctionCall {
        ident: &'arena mut str,
        args: Vec<'arena, &'arena mut Expr<'arena>>,
    },
    Operator {
        op: Operator,
        rhs: &'arena mut Expr<'arena>,
        lhs: &'arena mut Expr<'arena>,
    },
}
Expand description

A token Tree representing a whole Expression It lives inside an Arena

Variants§

§

RealNumber

A real number

Fields

§val: f64

The value of the real number

§

ImaginaryNumber

An imaginary number

Fields

§val: f64

The value of the imaginary number, without the i unit

§

ComplexNumber

Complex number

Fields

§val: Complex64

The value of the complex number’s node

§

Binding

A variable

Fields

§name: &'arena mut str

The name of the variable

§

FunctionCall

A function call, with an variable amount of arguments

Fields

§ident: &'arena mut str

Name of the function

§args: Vec<'arena, &'arena mut Expr<'arena>>

List of argument in order they appeard

§

Operator

An operation

Fields

§op: Operator

The operator

§rhs: &'arena mut Expr<'arena>

Left side of the operation

§lhs: &'arena mut Expr<'arena>

Right side of the operation

Implementations§

Source§

impl<'arena> Expr<'arena>

Source

pub fn clone_in<'new_arena>( &self, arena: &'new_arena Bump, ) -> &'new_arena mut Expr<'new_arena>

Clone an AST with another backing arena

Source§

impl<'arena> Expr<'arena>

Source

pub fn parse<'input, 'words: 'input + 'word, 'word: 'input>( arena: &'arena Bump, input: &'input str, reserved_words: &'words [&'word str], ) -> Result<&'arena mut Expr<'arena>, BuildError<'input>>

Create an AST from an input str

§Errors

This will error on any wrong input

Trait Implementations§

Source§

impl<'arena> Debug for Expr<'arena>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'arena> Display for Expr<'arena>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'arena> PartialEq for Expr<'arena>

Source§

fn eq(&self, other: &Expr<'arena>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'arena> StructuralPartialEq for Expr<'arena>

Auto Trait Implementations§

§

impl<'arena> Freeze for Expr<'arena>

§

impl<'arena> !RefUnwindSafe for Expr<'arena>

§

impl<'arena> !Send for Expr<'arena>

§

impl<'arena> !Sync for Expr<'arena>

§

impl<'arena> Unpin for Expr<'arena>

§

impl<'arena> !UnwindSafe for Expr<'arena>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.