Skip to main content

RegexTerminal

Struct RegexTerminal 

Source
pub struct RegexTerminal<'a> {
    pub automaton: DFA<&'a [u32]>,
    /* private fields */
}
Expand description

A special type of Terminal which is a regex recognizer.

Implements label so that regex machines can be used. The string representation/uuid of the machine is its regex pattern.

Fields§

§automaton: DFA<&'a [u32]>

The regex automaton this terminal represents.

Implementations§

Source§

impl<'a> RegexTerminal<'a>

Source

pub const fn new(pattern: &'a str, automaton: DFA<&'a [u32]>) -> Self

Construct a new RegexTerminal.

Trait Implementations§

Source§

impl<'a> Debug for RegexTerminal<'a>

Source§

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

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

impl<'a> Label<'a> for RegexTerminal<'a>

Source§

fn _first( &self, state: &mut GLLState<'a>, _: &mut HashSet<Rc<str>>, ) -> GLLResult<'a, bool>

A regex is sort of between a non-terminal and a terminal. They way first is used, we want it to return true if some terminal is parsable from this point. In the case of a regex, this means the pattern is accepting.

Source§

fn first_set( &self, _: &GLLState<'a>, ) -> ImplementationResult<'a, Vec<(Vec<GLLBlockLabel<'a>>, Option<Terminal<'a>>)>>

Returns the first-follow set of the label. Read more
Source§

fn code(&self, _: &mut GLLState<'a>) -> GLLResult<'a, ()>

Any code to run when encountering this label. Read more
Source§

fn _weight( &self, _: &GLLState<'a>, ) -> Option<ImplementationResult<'a, Value<'a>>>

Optionally return the weight of this label. Read more
Source§

fn to_string(&self) -> &str

A string representation of the chunk (likely a GLL block) that this label represents.
Source§

fn str_parts(&self) -> Vec<&str>

The chunk represented by Label::to_string, but split by symbol into a vector.
Source§

fn uuid(&self) -> &str

A unique identifier for this label.
Source§

fn attr_rep_map(&self) -> (Vec<&str>, Vec<&str>)

A tuple of string representations for any associated attributes. Read more
Source§

fn is_eps(&self) -> bool

Is this Label epsilon? Read more
Source§

fn is_terminal(&self) -> bool

Is this label a terminal? Read more
Source§

fn _is_nullable( &self, _: &GLLState<'a>, _: &mut HashSet<Rc<str>>, ) -> ImplementationResult<'a, bool>

Internal method for Label::is_nullable to do the recursive step. Read more
Source§

fn first(&self, state: &mut GLLState<'a>) -> GLLResult<'a, bool>

Check if the next token in the current state is accepted by this label’s first-follow set. Read more
Source§

fn is_nullable(&self, state: &GLLState<'a>) -> ImplementationResult<'a, bool>

Could this label resolve to epsilon? Read more
Source§

fn weight(&self, state: &GLLState<'a>) -> ImplementationResult<'a, Value<'a>>

Returns either the weight of this label as calculated by _weight, or 1. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for RegexTerminal<'a>

§

impl<'a> RefUnwindSafe for RegexTerminal<'a>

§

impl<'a> Send for RegexTerminal<'a>

§

impl<'a> Sync for RegexTerminal<'a>

§

impl<'a> Unpin for RegexTerminal<'a>

§

impl<'a> UnsafeUnpin for RegexTerminal<'a>

§

impl<'a> UnwindSafe for RegexTerminal<'a>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.