Skip to main content

Expression

Enum Expression 

Source
pub enum Expression {
Show 19 variants Binary(Box<BinaryExpression>), Call(Box<FunctionCall>), False(Option<Token>), Field(Box<FieldExpression>), Function(Box<FunctionExpression>), Identifier(Identifier), If(Box<IfExpression>), Index(Box<IndexExpression>), Nil(Option<Token>), Number(NumberExpression), Parenthese(Box<ParentheseExpression>), String(StringExpression), InterpolatedString(InterpolatedStringExpression), Table(TableExpression), True(Option<Token>), Unary(Box<UnaryExpression>), VariableArguments(Option<Token>), TypeCast(TypeCastExpression), TypeInstantiation(Box<TypeInstantiationExpression>),
}
Expand description

Represents all possible expressions.

Variants§

§

Binary(Box<BinaryExpression>)

A binary operation (e.g., a + b, x == y)

§

Call(Box<FunctionCall>)

A function call (e.g., print("Hello"))

§

False(Option<Token>)

The false keyword

§

Field(Box<FieldExpression>)

A field access (e.g., object.field)

§

Function(Box<FunctionExpression>)

A function definition (e.g., function(...) ... end)

§

Identifier(Identifier)

An identifier (e.g., variable name)

§

If(Box<IfExpression>)

An if expression (e.g., if a then b else c)

§

Index(Box<IndexExpression>)

A table index access (e.g., table[key])

§

Nil(Option<Token>)

The nil keyword

§

Number(NumberExpression)

A numeric literal (e.g., 42, 3.14)

§

Parenthese(Box<ParentheseExpression>)

An expression in parentheses (e.g., (1 + 2))

§

String(StringExpression)

A string literal (e.g., "hello")

§

InterpolatedString(InterpolatedStringExpression)

An interpolated string (e.g., `Hello ${name}`)

§

Table(TableExpression)

A table constructor (e.g., {key = value, [expr] = value})

§

True(Option<Token>)

The true keyword

§

Unary(Box<UnaryExpression>)

A unary operation (e.g., -x, not condition)

§

VariableArguments(Option<Token>)

The variable arguments symbol (...)

§

TypeCast(TypeCastExpression)

A type cast expression (e.g., value :: Type)

§

TypeInstantiation(Box<TypeInstantiationExpression>)

A type instantiation expression (e.g., var<<Type1, Type2>>)

Implementations§

Source§

impl Expression

Source

pub fn nil() -> Self

Creates a new nil expression.

Source

pub fn variable_arguments() -> Self

Creates a new variable arguments expression.

Source

pub fn identifier<S: Into<Identifier>>(identifier: S) -> Self

Creates a new identifier expression.

Source

pub fn in_parentheses(self) -> Self

Wraps this expression in parentheses.

Source

pub fn mutate_last_token(&mut self) -> &mut Token

Returns a mutable reference to the last token for this expression, creating it if missing.

Trait Implementations§

Source§

impl Clone for Expression

Source§

fn clone(&self) -> Expression

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Expression

Source§

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

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

impl Eq for Expression

Source§

impl From<&f32> for Expression

Source§

fn from(value: &f32) -> Self

Converts to this type from the input type.
Source§

impl From<&f64> for Expression

Source§

fn from(value: &f64) -> Self

Converts to this type from the input type.
Source§

impl From<&i8> for Expression

Source§

fn from(value: &i8) -> Self

Converts to this type from the input type.
Source§

impl From<&i16> for Expression

Source§

fn from(value: &i16) -> Self

Converts to this type from the input type.
Source§

impl From<&i32> for Expression

Source§

fn from(value: &i32) -> Self

Converts to this type from the input type.
Source§

impl From<&i64> for Expression

Source§

fn from(value: &i64) -> Self

Converts to this type from the input type.
Source§

impl From<&u8> for Expression

Source§

fn from(value: &u8) -> Self

Converts to this type from the input type.
Source§

impl From<&u16> for Expression

Source§

fn from(value: &u16) -> Self

Converts to this type from the input type.
Source§

impl From<&u32> for Expression

Source§

fn from(value: &u32) -> Self

Converts to this type from the input type.
Source§

impl From<&u64> for Expression

Source§

fn from(value: &u64) -> Self

Converts to this type from the input type.
Source§

impl From<&usize> for Expression

Source§

fn from(value: &usize) -> Self

Converts to this type from the input type.
Source§

impl From<BinaryExpression> for Expression

Source§

fn from(binary: BinaryExpression) -> Expression

Converts to this type from the input type.
Source§

impl From<BinaryNumber> for Expression

Source§

fn from(number: BinaryNumber) -> Self

Converts to this type from the input type.
Source§

impl From<DecimalNumber> for Expression

Source§

fn from(number: DecimalNumber) -> Self

Converts to this type from the input type.
Source§

impl From<Expression> for Prefix

Source§

fn from(expression: Expression) -> Self

Converts to this type from the input type.
Source§

impl From<FieldExpression> for Expression

Source§

fn from(field: FieldExpression) -> Expression

Converts to this type from the input type.
Source§

impl From<FunctionCall> for Expression

Source§

fn from(call: FunctionCall) -> Expression

Converts to this type from the input type.
Source§

impl From<FunctionExpression> for Expression

Source§

fn from(function: FunctionExpression) -> Self

Converts to this type from the input type.
Source§

impl From<HexNumber> for Expression

Source§

fn from(number: HexNumber) -> Self

Converts to this type from the input type.
Source§

impl From<Identifier> for Expression

Source§

fn from(identifier: Identifier) -> Self

Converts to this type from the input type.
Source§

impl From<IfExpression> for Expression

Source§

fn from(if_expression: IfExpression) -> Expression

Converts to this type from the input type.
Source§

impl From<IndexExpression> for Expression

Source§

fn from(index: IndexExpression) -> Self

Converts to this type from the input type.
Source§

impl From<InterpolatedStringExpression> for Expression

Source§

fn from(interpolated_string: InterpolatedStringExpression) -> Self

Converts to this type from the input type.
Source§

impl From<LiteralExpression> for Expression

Source§

fn from(literal: LiteralExpression) -> Self

Converts to this type from the input type.
Source§

impl From<NumberExpression> for Expression

Source§

fn from(number: NumberExpression) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<Expression>> From<Option<T>> for Expression

Source§

fn from(value: Option<T>) -> Self

Converts to this type from the input type.
Source§

impl From<ParentheseExpression> for Expression

Source§

fn from(expression: ParentheseExpression) -> Self

Converts to this type from the input type.
Source§

impl From<Prefix> for Expression

Source§

fn from(prefix: Prefix) -> Self

Converts to this type from the input type.
Source§

impl From<StringExpression> for Expression

Source§

fn from(string: StringExpression) -> Self

Converts to this type from the input type.
Source§

impl From<TableExpression> for Expression

Source§

fn from(table: TableExpression) -> Self

Converts to this type from the input type.
Source§

impl From<TypeCastExpression> for Expression

Source§

fn from(type_cast: TypeCastExpression) -> Self

Converts to this type from the input type.
Source§

impl From<TypeInstantiationExpression> for Expression

Source§

fn from(type_instantiation: TypeInstantiationExpression) -> Self

Converts to this type from the input type.
Source§

impl From<UnaryExpression> for Expression

Source§

fn from(unary: UnaryExpression) -> Self

Converts to this type from the input type.
Source§

impl From<Variable> for Expression

Source§

fn from(variable: Variable) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Expression

Source§

fn from(boolean: bool) -> Expression

Converts to this type from the input type.
Source§

impl From<f32> for Expression

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Expression

Source§

fn from(value: f64) -> Expression

Converts to this type from the input type.
Source§

impl From<i8> for Expression

Source§

fn from(value: i8) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Expression

Source§

fn from(value: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Expression

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Expression

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Expression

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Expression

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Expression

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Expression

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for Expression

Source§

fn from(value: usize) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<Expression> for TupleArguments

Source§

fn from_iter<T: IntoIterator<Item = Expression>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl PartialEq for Expression

Source§

fn eq(&self, other: &Expression) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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 StructuralPartialEq for Expression

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.