Enum aftermath::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

Fields

§val: f64

The value of the real number

A real number

§

ImaginaryNumber

Fields

§val: f64

The value of the imaginary number, without the i unit

An imaginary number

§

ComplexNumber

Fields

§val: Complex64

The value of the complex number’s node

Complex number

§

Binding

Fields

§name: &'arena mut str

The name of the variable

A variable

§

FunctionCall

Fields

§ident: &'arena mut str

Name of the function

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

List of argument in order they appeard

A function call, with an variable amount of arguments

§

Operator

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

An 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<Expr<'arena>> for Expr<'arena>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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> !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 Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere
    T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.