mcrl2::aterm::aterm_builder

Struct TermBuilder

Source
pub struct TermBuilder<I, C> { /* private fields */ }
Expand description

This can be used to construct a term from a given input of (inductive) type I, without using the system stack, i.e. recursion. See evaluate.

Implementations§

Source§

impl<I: Debug, C: Debug> TermBuilder<I, C>

Source

pub fn new() -> TermBuilder<I, C>

Source

pub fn evaluate<F, G>( &mut self, tp: &mut TermPool, input: I, transformer: F, construct: G, ) -> Result<ATerm, Box<dyn Error>>
where F: Fn(&mut TermPool, &mut ArgStack<'_, I, C>, I) -> Result<Yield<C>, Box<dyn Error>>, G: Fn(&mut TermPool, C, &[ATerm]) -> Result<ATerm, Box<dyn Error>>,

This can be used to construct a term from a given input of (inductive) type I, without using the system stack, i.e. recursion.

The transformer function is applied to every instance I, which can put more generate more inputs using a so-called argument stack and some instance C that is used to construct the result term. Alternatively, it yields a result term directly.

The construct function takes an instance C and the arguments pushed to stack where the transformer was applied for every input pushed onto the stack previously.

§Example

A simple example could be to transform a term into another term using a function f : ATerm -> Option<ATerm>. Then I will be ATerm since that is the input, and C will be the Symbol from which we can construct the recursive term.

transformer takes the input and applies f(input). Then either we return Yield(x) when f returns some term, or Construct(head(input)) with the arguments of the input term pushed to stack.

construct simply constructs the term from the symbol and the arguments on the stack.

However, it can also be that I is some syntax tree from which we want to construct a term.

Trait Implementations§

Source§

impl<I: Debug, C: Debug> Debug for TermBuilder<I, C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<I: Default, C: Default> Default for TermBuilder<I, C>

Source§

fn default() -> TermBuilder<I, C>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<I, C> Freeze for TermBuilder<I, C>

§

impl<I, C> RefUnwindSafe for TermBuilder<I, C>

§

impl<I, C> !Send for TermBuilder<I, C>

§

impl<I, C> Sync for TermBuilder<I, C>
where I: Sync, C: Sync,

§

impl<I, C> Unpin for TermBuilder<I, C>
where I: Unpin, C: Unpin,

§

impl<I, C> UnwindSafe for TermBuilder<I, C>
where I: UnwindSafe, C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V