pub enum Expression {
Show 15 variants
Invalid,
Literal(Literal),
FormatString(FormatString),
ArrayExpression(ArrayExpression),
TupleExpression(TupleExpression),
Body(Body),
Call(Call),
QualifiedName(QualifiedName),
Marker(Marker),
BinaryOp {
lhs: Box<Expression>,
op: String,
rhs: Box<Expression>,
src_ref: SrcRef,
},
UnaryOp {
op: String,
rhs: Box<Expression>,
src_ref: SrcRef,
},
ArrayElementAccess(Box<Expression>, Box<Expression>, SrcRef),
PropertyAccess(Box<Expression>, Identifier, SrcRef),
AttributeAccess(Box<Expression>, Identifier, SrcRef),
MethodCall(Box<Expression>, MethodCall, SrcRef),
}Expand description
Any expression.
Variants§
Invalid
Something went wrong (and an error will be reported)
Literal(Literal)
An integer, float, color or bool literal: 1, 1.0, #00FF00, false
FormatString(FormatString)
A string that contains format expressions: “value = {a}”
ArrayExpression(ArrayExpression)
A list: [a, b, c]
TupleExpression(TupleExpression)
A tuple: (a, b, c)
Body(Body)
A body: {}.
Call(Call)
A call: ops::subtract().
QualifiedName(QualifiedName)
A qualified name: foo::bar.
Marker(Marker)
A marker expression: @input.
BinaryOp
A binary operation: a + b
UnaryOp
A unary operation: !a
Fields
rhs: Box<Expression>Right -hand side
ArrayElementAccess(Box<Expression>, Box<Expression>, SrcRef)
Access an element of a list (a[0]) or a tuple (a.0 or a.b)
PropertyAccess(Box<Expression>, Identifier, SrcRef)
Access an element of a tuple: a.b.
AttributeAccess(Box<Expression>, Identifier, SrcRef)
Access an attribute of a model: a#b.
MethodCall(Box<Expression>, MethodCall, SrcRef)
Call to a method: [2,3].len()
First expression must evaluate to a value
Implementations§
Source§impl Expression
impl Expression
Sourcepub fn eval_with_attribute_list(
&self,
attribute_list: &AttributeList,
context: &mut EvalContext,
) -> EvalResult<Value>
pub fn eval_with_attribute_list( &self, attribute_list: &AttributeList, context: &mut EvalContext, ) -> EvalResult<Value>
Evaluate an expression together with an attribute list.
The attribute list will be also evaluated and the resulting attributes will be assigned to the resulting value.
Source§impl Expression
impl Expression
Sourcepub fn literal_from_str(s: &str) -> ParseResult<Self>
pub fn literal_from_str(s: &str) -> ParseResult<Self>
Generate literal from string
Source§impl Expression
impl Expression
Sourcepub fn single_identifier(&self) -> Option<&Identifier>
pub fn single_identifier(&self) -> Option<&Identifier>
If the expression consists of a single identifier, e.g. a
Trait Implementations§
Source§impl AsRef<Expression> for Expression
impl AsRef<Expression> for Expression
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 Display for Expression
impl Display for Expression
Source§impl Eval<Option<Model>> for Expression
impl Eval<Option<Model>> for Expression
Source§fn eval(&self, context: &mut EvalContext) -> EvalResult<Option<Model>>
fn eval(&self, context: &mut EvalContext) -> EvalResult<Option<Model>>
T.Source§impl Eval for Expression
impl Eval for Expression
Source§fn eval(&self, context: &mut EvalContext) -> EvalResult<Value>
fn eval(&self, context: &mut EvalContext) -> EvalResult<Value>
T.Source§impl Parse for Expression
impl Parse for Expression
fn parse(pair: Pair<'_>) -> ParseResult<Self>
Source§impl PartialEq for Expression
impl PartialEq for Expression
Source§impl SrcReferrer for Expression
impl SrcReferrer for Expression
Source§impl TreeDisplay for Expression
impl TreeDisplay for Expression
Source§fn tree_print(&self, f: &mut Formatter<'_>, depth: TreeState) -> Result
fn tree_print(&self, f: &mut Formatter<'_>, depth: TreeState) -> Result
f and use {:depth$} syntax in front of your single line
output to get proper indention.Source§fn display_tree(&self, f: &mut Formatter<'_>) -> Result
fn display_tree(&self, f: &mut Formatter<'_>) -> Result
0.Source§fn debug_tree(&self, f: &mut Formatter<'_>) -> Result
fn debug_tree(&self, f: &mut Formatter<'_>) -> Result
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<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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more