pub enum Expression {
Show 18 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),
}
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
)
Implementations§
Source§impl Expression
impl Expression
Sourcepub fn variable_arguments() -> Self
pub fn variable_arguments() -> Self
Creates a new variable arguments expression.
Sourcepub fn identifier<S: Into<Identifier>>(identifier: S) -> Self
pub fn identifier<S: Into<Identifier>>(identifier: S) -> Self
Creates a new identifier expression.
Sourcepub fn in_parentheses(self) -> Self
pub fn in_parentheses(self) -> Self
Wraps this expression in parentheses.
Sourcepub fn mutate_last_token(&mut self) -> &mut Token
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
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for Expression
impl Debug for Expression
Source§impl From<BinaryExpression> for Expression
impl From<BinaryExpression> for Expression
Source§fn from(binary: BinaryExpression) -> Expression
fn from(binary: BinaryExpression) -> Expression
Source§impl From<BinaryNumber> for Expression
impl From<BinaryNumber> for Expression
Source§fn from(number: BinaryNumber) -> Self
fn from(number: BinaryNumber) -> Self
Source§impl From<DecimalNumber> for Expression
impl From<DecimalNumber> for Expression
Source§fn from(number: DecimalNumber) -> Self
fn from(number: DecimalNumber) -> Self
Source§impl From<Expression> for Prefix
impl From<Expression> for Prefix
Source§fn from(expression: Expression) -> Self
fn from(expression: Expression) -> Self
Source§impl From<FieldExpression> for Expression
impl From<FieldExpression> for Expression
Source§fn from(field: FieldExpression) -> Expression
fn from(field: FieldExpression) -> Expression
Source§impl From<FunctionCall> for Expression
impl From<FunctionCall> for Expression
Source§fn from(call: FunctionCall) -> Expression
fn from(call: FunctionCall) -> Expression
Source§impl From<FunctionExpression> for Expression
impl From<FunctionExpression> for Expression
Source§fn from(function: FunctionExpression) -> Self
fn from(function: FunctionExpression) -> Self
Source§impl From<HexNumber> for Expression
impl From<HexNumber> for Expression
Source§impl From<Identifier> for Expression
impl From<Identifier> for Expression
Source§fn from(identifier: Identifier) -> Self
fn from(identifier: Identifier) -> Self
Source§impl From<IfExpression> for Expression
impl From<IfExpression> for Expression
Source§fn from(if_expression: IfExpression) -> Expression
fn from(if_expression: IfExpression) -> Expression
Source§impl From<IndexExpression> for Expression
impl From<IndexExpression> for Expression
Source§fn from(index: IndexExpression) -> Self
fn from(index: IndexExpression) -> Self
Source§impl From<InterpolatedStringExpression> for Expression
impl From<InterpolatedStringExpression> for Expression
Source§fn from(interpolated_string: InterpolatedStringExpression) -> Self
fn from(interpolated_string: InterpolatedStringExpression) -> Self
Source§impl From<NumberExpression> for Expression
impl From<NumberExpression> for Expression
Source§fn from(number: NumberExpression) -> Self
fn from(number: NumberExpression) -> Self
Source§impl<T: Into<Expression>> From<Option<T>> for Expression
impl<T: Into<Expression>> From<Option<T>> for Expression
Source§impl From<ParentheseExpression> for Expression
impl From<ParentheseExpression> for Expression
Source§fn from(expression: ParentheseExpression) -> Self
fn from(expression: ParentheseExpression) -> Self
Source§impl From<Prefix> for Expression
impl From<Prefix> for Expression
Source§impl From<StringExpression> for Expression
impl From<StringExpression> for Expression
Source§fn from(string: StringExpression) -> Self
fn from(string: StringExpression) -> Self
Source§impl From<TableExpression> for Expression
impl From<TableExpression> for Expression
Source§fn from(table: TableExpression) -> Self
fn from(table: TableExpression) -> Self
Source§impl From<TypeCastExpression> for Expression
impl From<TypeCastExpression> for Expression
Source§fn from(type_cast: TypeCastExpression) -> Self
fn from(type_cast: TypeCastExpression) -> Self
Source§impl From<UnaryExpression> for Expression
impl From<UnaryExpression> for Expression
Source§fn from(unary: UnaryExpression) -> Self
fn from(unary: UnaryExpression) -> Self
Source§impl From<Variable> for Expression
impl From<Variable> for Expression
Source§impl From<bool> for Expression
impl From<bool> for Expression
Source§fn from(boolean: bool) -> Expression
fn from(boolean: bool) -> Expression
Source§impl From<f32> for Expression
impl From<f32> for Expression
Source§impl From<f64> for Expression
impl From<f64> for Expression
Source§fn from(value: f64) -> Expression
fn from(value: f64) -> Expression
Source§impl From<i16> for Expression
impl From<i16> for Expression
Source§impl From<i32> for Expression
impl From<i32> for Expression
Source§impl From<i64> for Expression
impl From<i64> for Expression
Source§impl From<i8> for Expression
impl From<i8> for Expression
Source§impl From<u16> for Expression
impl From<u16> for Expression
Source§impl From<u32> for Expression
impl From<u32> for Expression
Source§impl From<u64> for Expression
impl From<u64> for Expression
Source§impl From<u8> for Expression
impl From<u8> for Expression
Source§impl From<usize> for Expression
impl From<usize> for Expression
Source§impl FromIterator<Expression> for TupleArguments
impl FromIterator<Expression> for TupleArguments
Source§fn from_iter<T: IntoIterator<Item = Expression>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = Expression>>(iter: T) -> Self
Source§impl PartialEq for Expression
impl PartialEq for Expression
impl Eq for Expression
impl StructuralPartialEq for Expression
Auto Trait Implementations§
impl Freeze for Expression
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin for Expression
impl UnwindSafe for Expression
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
Source§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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