Skip to main content

StringAlgebra

Struct StringAlgebra 

Source
pub struct StringAlgebra { /* private fields */ }
Expand description

Binary string algebra over token symbols.

Values are token-symbol vectors. The reserved concat operation appends two vectors; every other nullary symbol evaluates to the one-token string containing that symbol.

Implementations§

Source§

impl StringAlgebra

Source

pub fn new() -> Self

Create a string algebra with the reserved concat symbol.

Source

pub fn with_signature(signature: Signature) -> Self

Create a string algebra from an existing operation signature.

Source

pub fn concat_symbol(&self) -> Symbol

Return the concat operation symbol.

Source

pub fn intern_word(&mut self, word: impl Into<String>) -> Symbol

Intern a token symbol.

Source

pub fn parse_string(&mut self, input: &str) -> Vec<Symbol>

Parse a whitespace-separated string into token symbols.

Source

pub fn decompose(&self, sentence: Vec<Symbol>) -> StringDecompositionAutomaton

Build the optimized lazy decomposition automaton for sentence.

Trait Implementations§

Source§

impl Algebra for StringAlgebra

Source§

type InternalValue = Vec<Symbol>

Efficient internal value domain used by evaluate and decomposition.
Source§

type Value = Vec<String>

Standalone public value produced for output by evaluate_term.
Source§

type ParseError = Infallible

Error returned when parsing a textual object representation.
Source§

fn signature(&self) -> &Signature

Return the operation signature used by this algebra.
Source§

fn evaluate( &self, symbol: Symbol, children: &[Self::InternalValue], ) -> Option<Self::InternalValue>

Evaluate an operation over child internal values. Read more
Source§

fn parse_object( &mut self, input: &str, ) -> Result<Self::InternalValue, Self::ParseError>

Parse a textual representation into an internal value.
Source§

fn to_external(&self, value: &Self::InternalValue) -> Self::Value

Map an internal value to its standalone public form.
Source§

fn visualize(&self, value: &Self::Value) -> VisualRepresentation

Convert a public value into this algebra’s preferred GUI-neutral representation.
Source§

fn evaluate_term_internal( &self, arena: &TreeArena<Symbol>, root: Tree, ) -> Option<Self::InternalValue>

Evaluate a term tree bottom-up to an internal value, applying evaluate at every node (e.g. a homomorphic image produced from a derivation tree). Read more
Source§

fn evaluate_term( &self, arena: &TreeArena<Symbol>, root: Tree, ) -> Option<Self::Value>

Evaluate a term tree to its public value (bottom-up evaluate, then to_external).
Source§

fn is_valid_value(&self, _value: &Self::InternalValue) -> bool

Return whether value is a valid internal value.
Source§

fn decompose_default( &self, value: Self::InternalValue, ) -> EvaluatingDecompositionAutomaton<'_, Self>
where Self: Sized,

Build the default evaluating decomposition automaton for value.
Source§

impl Clone for StringAlgebra

Source§

fn clone(&self) -> StringAlgebra

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StringAlgebra

Source§

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

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

impl Default for StringAlgebra

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.