pub enum Expression {
Show 14 variants
ERROR,
Nil(Token),
Boolean(Token),
Number(Token),
String(Token),
Closure(Closure),
FunctionCall(FunctionCall),
ExpressionWrap(ExpressionWrap),
Var(Var),
Table(Table),
UnaryExpression {
operator: Token,
expression: Pointer<Expression>,
},
BinaryExpression {
left: Pointer<Expression>,
operator: Token,
right: Pointer<Expression>,
},
TypeCast {
expression: Pointer<Expression>,
operator: Token,
cast_to: Pointer<TypeValue>,
},
IfExpression(IfExpression),
}Expand description
An enum representing all possible values for an expression.
Variants§
ERROR
This Expression had a syntax error.
Nil(Token)
The nil value.
Boolean(Token)
A true or false value.
Number(Token)
Any number, be it a float, an unsigned integer, an integer or a hex digit.
String(Token)
A string, be it double quotes, single quotes, interpolated string, or multi-line.
Closure(Closure)
An anonymous function.
local foo = function(arg1: number): boolean
endFunctionCall(FunctionCall)
A function call.
local foo = bar()ExpressionWrap(ExpressionWrap)
An expression wrapped in parenthesis.
local _ = (foo)Var(Var)
A reference to another variable.
local _ = fooTable(Table)
A Table.
local _ = { foo = "bar" }UnaryExpression
A unary expression, these are expressions that have an operator before the actual expression:
local foo = not 1
local bar = -1
local qux = #tFields
expression: Pointer<Expression>The actual expression this operator is affecting.
BinaryExpression
A binary expression, this represents any 2 expressions with an operator between them.
local foo = 1 + 1
local bar = 1 == 1
local qux = bar // 2Fields
left: Pointer<Expression>The left expression.
right: Pointer<Expression>The right expression.
TypeCast
A typecast.
local foo = "hi" :: string
local bar = foo :: number
local qux = {} :: { number }Fields
expression: Pointer<Expression>The actual expression.
IfExpression(IfExpression)
An if expression.
Implementations§
Source§impl Expression
impl Expression
Sourcepub fn parse_from_literal(token: Token) -> Option<Self>
pub fn parse_from_literal(token: Token) -> Option<Self>
Parses an Expression from a literal TokenType::Literal
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 Default for Expression
impl Default for Expression
Source§fn default() -> Expression
fn default() -> Expression
Source§impl GetRange for Expression
impl GetRange for Expression
Source§fn get_range(&self) -> Result<Range, GetRangeError>
fn get_range(&self) -> Result<Range, GetRangeError>
Cst.status is
AstStatus::HasErrors.