pub enum Expression {
Show 18 variants
LiteralInteger(i64),
LiteralReal(String),
LiteralString(String),
LiteralBoolean(bool),
FeatureRef(String),
MemberAccess(Box<Node<Expression>>, String),
Index {
base: Box<Node<Expression>>,
index: Box<Node<Expression>>,
},
Bracket(Box<Node<Expression>>),
LiteralWithUnit {
value: Box<Node<Expression>>,
unit: Box<Node<Expression>>,
},
BinaryOp {
op: BinaryOperator,
left: Box<Node<Expression>>,
right: Box<Node<Expression>>,
},
UnaryOp {
op: UnaryOperator,
operand: Box<Node<Expression>>,
},
Invocation {
callee: Box<Node<Expression>>,
args: Vec<Node<Expression>>,
},
Tuple(Vec<Node<Expression>>),
Classification {
metaclass: String,
},
TypeCheck {
kind: TypeCheckKind,
operand: Option<Box<Node<Expression>>>,
type_name: String,
},
Select {
base: Box<Node<Expression>>,
selector: String,
},
Collect {
base: Box<Node<Expression>>,
selector: String,
},
Null,
}Expand description
Expression: literals, feature refs, member access, index, bracket/unit, etc.
Variants§
LiteralInteger(i64)
LiteralReal(String)
LiteralString(String)
LiteralBoolean(bool)
FeatureRef(String)
Single name or qualified name.
MemberAccess(Box<Node<Expression>>, String)
base.member (e.g. engine.fuelCmdPort).
Index
base#(index) e.g. frontWheel#(1).
Bracket(Box<Node<Expression>>)
unit e.g. [kg].
LiteralWithUnit
value unit e.g. 1750 [kg].
BinaryOp
Binary infix operation e.g. a >= b * c, x / y.
UnaryOp
Unary prefix: + - ~ not
Invocation
Function-like invocation, e.g. ComputeMargin(a, b).
Tuple(Vec<Node<Expression>>)
Comma-separated sequence in parentheses, e.g. (engine1, engine2) for ordered composition values.
Classification
Metadata classification: @Metaclass (e.g. @SysML::PartUsage).
TypeCheck
Type test: expr istype Type, expr hastype Type, or expr as Type.
Select
Select expression: base.?selector.
Collect
Collect expression: base.**selector.
Null
KerML null or empty sequence ().
Implementations§
Source§impl Expression
impl Expression
Sourcepub fn is_boolean_literal(&self) -> bool
pub fn is_boolean_literal(&self) -> bool
Whether this expression node is a literal Boolean.
Sourcepub fn is_classification(&self) -> bool
pub fn is_classification(&self) -> bool
Whether this expression is a metadata @Metaclass classification.
Sourcepub fn is_type_check(&self) -> bool
pub fn is_type_check(&self) -> bool
Whether this expression is a KerML type test (istype / hastype / as).
Sourcepub fn binary_op_is_comparison(op: &BinaryOperator) -> bool
pub fn binary_op_is_comparison(op: &BinaryOperator) -> bool
Whether a binary operator is a comparison.
Sourcepub fn binary_op_is_logical(op: &BinaryOperator) -> bool
pub fn binary_op_is_logical(op: &BinaryOperator) -> bool
Whether a binary operator is logical (and / or / xor / implies).
Trait Implementations§
Source§impl Clone for Expression
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
1.0.0 (const: unstable) · 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
impl Eq for Expression
Source§impl PartialEq for Expression
impl PartialEq for Expression
Source§fn eq(&self, other: &Expression) -> bool
fn eq(&self, other: &Expression) -> bool
self and other values to be equal, and is used by ==.