Skip to main content

Table

Struct Table 

Source
pub struct Table {
    pub source: &'static str,
    pub nodes: &'static [Node],
    pub rules: &'static [Rule],
}
Expand description

A set of rules, as an automaton over their patterns.

Fields§

§source: &'static str

The rule file this was built from, so that anything said about a rule can name a file somebody can open.

§nodes: &'static [Node]

The trie. Node zero is the root.

§rules: &'static [Rule]

The rules, in the order the file writes them.

Implementations§

Source§

impl Table

Source

pub fn find<S: Subject>( &self, subject: &S, term: S::Node, ) -> Option<Match<S::Node>>

The rule that fires on this term, and what it bound.

The term is matched as a whole. Finding the terms in a function worth matching is the caller’s job and not this one’s.

Source

pub fn find_in<S: Subject>( &self, subject: &S, term: S::Node, left: &mut Vec<S::Node>, bindings: &mut Vec<S::Node>, ) -> Option<usize>

Table::find with the two stacks the walk needs handed in, for a caller that asks more than once and would rather not pay for them every time.

Both are emptied before the walk. What bindings holds afterwards is what the pattern bound when a rule fired, and nothing anybody reads when none did.

Source

pub fn rule<N>(&self, found: &Match<N>) -> &Rule

The rule a match found, which is the one thing every caller wants out of it.

Trait Implementations§

Source§

impl Debug for Table

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnsafeUnpin for Table

§

impl UnwindSafe for Table

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.