Trait ExprBuilder

Source
pub trait ExprBuilder: Clone {
    type Expr: Clone + Display;
    type Data: Default;

Show 45 methods // Required methods fn with_data(data: Self::Data) -> Self; fn with_maybe_source_loc(self, l: Option<&Loc>) -> Self; fn loc(&self) -> Option<&Loc>; fn data(&self) -> &Self::Data; fn val(self, v: impl Into<Literal>) -> Self::Expr; fn var(self, v: Var) -> Self::Expr; fn unknown(self, u: Unknown) -> Self::Expr; fn slot(self, s: SlotId) -> Self::Expr; fn ite( self, test_expr: Self::Expr, then_expr: Self::Expr, else_expr: Self::Expr, ) -> Self::Expr; fn not(self, e: Self::Expr) -> Self::Expr; fn is_eq(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr; fn and(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr; fn or(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr; fn less(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr; fn lesseq(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr; fn add(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr; fn sub(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr; fn mul(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr; fn neg(self, e: Self::Expr) -> Self::Expr; fn is_in(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr; fn contains(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr; fn contains_all(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr; fn contains_any(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr; fn is_empty(self, expr: Self::Expr) -> Self::Expr; fn get_tag(self, expr: Self::Expr, tag: Self::Expr) -> Self::Expr; fn has_tag(self, expr: Self::Expr, tag: Self::Expr) -> Self::Expr; fn set(self, exprs: impl IntoIterator<Item = Self::Expr>) -> Self::Expr; fn record( self, pairs: impl IntoIterator<Item = (SmolStr, Self::Expr)>, ) -> Result<Self::Expr, ExpressionConstructionError>; fn call_extension_fn( self, fn_name: Name, args: impl IntoIterator<Item = Self::Expr>, ) -> Self::Expr; fn get_attr(self, expr: Self::Expr, attr: SmolStr) -> Self::Expr; fn has_attr(self, expr: Self::Expr, attr: SmolStr) -> Self::Expr; fn like(self, expr: Self::Expr, pattern: Pattern) -> Self::Expr; fn is_entity_type( self, expr: Self::Expr, entity_type: EntityType, ) -> Self::Expr; // Provided methods fn new() -> Self where Self: Sized { ... } fn with_source_loc(self, l: &Loc) -> Self where Self: Sized { ... } fn is_in_entity_type( self, e1: Self::Expr, entity_type: EntityType, e2: Self::Expr, ) -> Self::Expr where Self: Sized { ... } fn unary_app(self, op: impl Into<UnaryOp>, arg: Self::Expr) -> Self::Expr where Self: Sized { ... } fn binary_app( self, op: impl Into<BinaryOp>, arg1: Self::Expr, arg2: Self::Expr, ) -> Self::Expr where Self: Sized { ... } fn noteq(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr where Self: Sized { ... } fn greater(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr where Self: Sized { ... } fn greatereq(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr where Self: Sized { ... } fn and_nary( self, first: Self::Expr, others: impl IntoIterator<Item = Self::Expr>, ) -> Self::Expr where Self: Sized { ... } fn or_nary( self, first: Self::Expr, others: impl IntoIterator<Item = Self::Expr>, ) -> Self::Expr where Self: Sized { ... } fn add_nary( self, first: Self::Expr, other: impl IntoIterator<Item = (AddOp, Self::Expr)>, ) -> Self::Expr where Self: Sized { ... } fn mul_nary( self, first: Self::Expr, other: impl IntoIterator<Item = Self::Expr>, ) -> Self::Expr where Self: Sized { ... }
}
Expand description

Defines a generic interface for building different expression data structures.

Required Associated Types§

Source

type Expr: Clone + Display

The type of expression constructed by this instance of ExprBuilder.

Source

type Data: Default

Type for extra information stored on nodes of the expression AST. This can be () if no data is stored.

Required Methods§

Source

fn with_data(data: Self::Data) -> Self

Build an expression storing this information

Source

fn with_maybe_source_loc(self, l: Option<&Loc>) -> Self

Build an expression located at l, if l is Some. An implementation may ignore this if it cannot store source information.

Source

fn loc(&self) -> Option<&Loc>

Extract the location for this builder, if set. Used internally to provide utilities that construct multiple nodes which should all be reported as having the same source location.

Source

fn data(&self) -> &Self::Data

Extract the data that will be stored on the constructed expression. Used internally to provide utilities that construct multiple nodes which will all have the same data.

Source

fn val(self, v: impl Into<Literal>) -> Self::Expr

Create an expression that’s just a single Literal.

Note that you can pass this a Literal, an Integer, a String, etc.

Source

fn var(self, v: Var) -> Self::Expr

Create an Expr that’s just this literal Var

Source

fn unknown(self, u: Unknown) -> Self::Expr

Create an Unknown Expr

Source

fn slot(self, s: SlotId) -> Self::Expr

Create an Expr that’s just this SlotId

Source

fn ite( self, test_expr: Self::Expr, then_expr: Self::Expr, else_expr: Self::Expr, ) -> Self::Expr

Create a ternary (if-then-else) Expr.

Source

fn not(self, e: Self::Expr) -> Self::Expr

Create a ‘not’ expression.

Source

fn is_eq(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr

Create a ‘==’ expression

Source

fn and(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr

Create an ‘and’ expression.

Source

fn or(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr

Create an ‘or’ expression.

Source

fn less(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr

Create a ‘<’ expression.

Source

fn lesseq(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr

Create a ‘<=’ expression.

Source

fn add(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr

Create an ‘add’ expression.

Source

fn sub(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr

Create a ‘sub’ expression.

Source

fn mul(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr

Create a ‘mul’ expression.

Source

fn neg(self, e: Self::Expr) -> Self::Expr

Create a ‘neg’ expression.

Source

fn is_in(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr

Create an ‘in’ expression. First argument must evaluate to Entity type.

Source

fn contains(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr

Create a ‘contains’ expression.

Source

fn contains_all(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr

Create a ‘contains_all’ expression. Arguments must evaluate to Set type

Source

fn contains_any(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr

Create an ‘contains_any’ expression. Arguments must evaluate to Set type

Source

fn is_empty(self, expr: Self::Expr) -> Self::Expr

Create an ‘is_empty’ expression. Argument must evaluate to Set type

Source

fn get_tag(self, expr: Self::Expr, tag: Self::Expr) -> Self::Expr

Create a ‘getTag’ expression.

Source

fn has_tag(self, expr: Self::Expr, tag: Self::Expr) -> Self::Expr

Create a ‘hasTag’ expression.

Source

fn set(self, exprs: impl IntoIterator<Item = Self::Expr>) -> Self::Expr

Create an Expr which evaluates to a Set of the given Exprs

Source

fn record( self, pairs: impl IntoIterator<Item = (SmolStr, Self::Expr)>, ) -> Result<Self::Expr, ExpressionConstructionError>

Create an Expr which evaluates to a Record with the given (key, value) pairs.

Source

fn call_extension_fn( self, fn_name: Name, args: impl IntoIterator<Item = Self::Expr>, ) -> Self::Expr

Create an Expr which calls the extension function with the given Name on args

Source

fn get_attr(self, expr: Self::Expr, attr: SmolStr) -> Self::Expr

Create an Expr which gets a given attribute of a given Entity or record.

Source

fn has_attr(self, expr: Self::Expr, attr: SmolStr) -> Self::Expr

Create an Expr which tests for the existence of a given attribute on a given Entity or record.

Source

fn like(self, expr: Self::Expr, pattern: Pattern) -> Self::Expr

Create a ‘like’ expression.

Source

fn is_entity_type(self, expr: Self::Expr, entity_type: EntityType) -> Self::Expr

Create an ‘is’ expression.

Provided Methods§

Source

fn new() -> Self
where Self: Sized,

Construct a new expression builder for an expression that will not carry any data.

Source

fn with_source_loc(self, l: &Loc) -> Self
where Self: Sized,

Build an expression located at l. An implementation may ignore this if it cannot store source information.

Source

fn is_in_entity_type( self, e1: Self::Expr, entity_type: EntityType, e2: Self::Expr, ) -> Self::Expr
where Self: Sized,

Create an _ is _ in _ expression

Source

fn unary_app(self, op: impl Into<UnaryOp>, arg: Self::Expr) -> Self::Expr
where Self: Sized,

Create an application Expr which applies the given built-in unary operator to the given arg

Source

fn binary_app( self, op: impl Into<BinaryOp>, arg1: Self::Expr, arg2: Self::Expr, ) -> Self::Expr
where Self: Sized,

Create an application Expr which applies the given built-in binary operator to arg1 and arg2

Source

fn noteq(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr
where Self: Sized,

Create a ‘!=’ expression.

Source

fn greater(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr
where Self: Sized,

Create a ‘>’ expression.

Source

fn greatereq(self, e1: Self::Expr, e2: Self::Expr) -> Self::Expr
where Self: Sized,

Create a ‘>=’ expression.

Source

fn and_nary( self, first: Self::Expr, others: impl IntoIterator<Item = Self::Expr>, ) -> Self::Expr
where Self: Sized,

Create an and expression that may have more than two subexpressions (A && B && C) or may have only one subexpression, in which case no && is performed at all. Arguments must evaluate to Bool type.

This may create multiple AST && nodes. If it does, all the nodes will have the same source location and the same T data (taken from this builder) unless overridden, e.g., with another call to with_source_loc().

Source

fn or_nary( self, first: Self::Expr, others: impl IntoIterator<Item = Self::Expr>, ) -> Self::Expr
where Self: Sized,

Create an or expression that may have more than two subexpressions (A || B || C) or may have only one subexpression, in which case no || is performed at all. Arguments must evaluate to Bool type.

This may create multiple AST || nodes. If it does, all the nodes will have the same source location and the same T data (taken from this builder) unless overridden, e.g., with another call to with_source_loc().

Source

fn add_nary( self, first: Self::Expr, other: impl IntoIterator<Item = (AddOp, Self::Expr)>, ) -> Self::Expr
where Self: Sized,

Create expression containing addition and subtraction that may have more than two subexpressions (A + B - C) or may have only one subexpression, in which case no operations are performed at all.

Source

fn mul_nary( self, first: Self::Expr, other: impl IntoIterator<Item = Self::Expr>, ) -> Self::Expr
where Self: Sized,

Create expression containing multiplication that may have more than two subexpressions (A * B * C) or may have only one subexpression, in which case no operations are performed at all.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§