pub struct Logic<'a> { /* private fields */ }
Expand description
A logic expression.
This struct represents a logic expression as an Abstract Syntax Tree (AST). It holds a reference to the root token of the expression and the arena in which the tokens are allocated.
Implementations§
Source§impl<'a> Logic<'a>
impl<'a> Logic<'a>
Sourcepub fn from_token(token: Token<'a>, arena: &'a DataArena) -> Self
pub fn from_token(token: Token<'a>, arena: &'a DataArena) -> Self
Creates a new logic expression from a token.
Sourcepub fn literal(value: DataValue<'a>, arena: &'a DataArena) -> Self
pub fn literal(value: DataValue<'a>, arena: &'a DataArena) -> Self
Creates a new literal logic expression.
Sourcepub fn variable(
path: &str,
default: Option<Logic<'a>>,
arena: &'a DataArena,
) -> Self
pub fn variable( path: &str, default: Option<Logic<'a>>, arena: &'a DataArena, ) -> Self
Creates a new variable logic expression.
Sourcepub fn operator(
op_type: OperatorType,
args: Vec<Logic<'a>>,
arena: &'a DataArena,
) -> Self
pub fn operator( op_type: OperatorType, args: Vec<Logic<'a>>, arena: &'a DataArena, ) -> Self
Creates an operator logic expression.
Sourcepub fn custom_operator(
name: &str,
args: Vec<Logic<'a>>,
arena: &'a DataArena,
) -> Self
pub fn custom_operator( name: &str, args: Vec<Logic<'a>>, arena: &'a DataArena, ) -> Self
Creates a custom operator logic expression.
Sourcepub fn is_literal(&self) -> bool
pub fn is_literal(&self) -> bool
Returns true if this logic expression is a literal.
Sourcepub fn is_variable(&self) -> bool
pub fn is_variable(&self) -> bool
Returns true if this logic expression is a variable.
Sourcepub fn is_operator(&self) -> bool
pub fn is_operator(&self) -> bool
Returns true if this logic expression is an operator.
Sourcepub fn is_custom_operator(&self) -> bool
pub fn is_custom_operator(&self) -> bool
Returns true if this logic expression is a custom operator.
Sourcepub fn as_literal(&self) -> Option<&DataValue<'a>>
pub fn as_literal(&self) -> Option<&DataValue<'a>>
Returns the literal value if this logic expression is a literal.
Sourcepub fn as_variable(&self) -> Option<(&'a str, Option<&'a Token<'a>>)>
pub fn as_variable(&self) -> Option<(&'a str, Option<&'a Token<'a>>)>
Returns the variable path if this logic expression is a variable.
Sourcepub fn as_operator(&self) -> Option<(OperatorType, &'a Token<'a>)>
pub fn as_operator(&self) -> Option<(OperatorType, &'a Token<'a>)>
Returns the operator type and arguments if this logic expression is an operator.
Sourcepub fn as_custom_operator(&self) -> Option<(&'a str, &'a Token<'a>)>
pub fn as_custom_operator(&self) -> Option<(&'a str, &'a Token<'a>)>
Returns the custom operator name and arguments if this logic expression is a custom operator.