pub struct Pattern {
pub pattern: String,
pub terminal_type: TerminalID,
pub priority: usize,
pub lookahead: Lookahead,
}Expand description
A pattern is a data structure that is used during the construction of the NFA.
Fields§
§pattern: StringThe pattern string that is used to match input tokens.
terminal_type: TerminalIDThe terminal type associated with the pattern.
priority: usizeThe priority of the pattern, used to resolve conflicts between patterns. Patterns with priority lower value are preferred over those with higher priority value.
lookahead: LookaheadThe lookahead constraint for the pattern, which can be positive, negative, or none.
Implementations§
Source§impl Pattern
impl Pattern
Sourcepub fn new(pattern: String, terminal_type: TerminalID) -> Self
pub fn new(pattern: String, terminal_type: TerminalID) -> Self
Creates a new pattern with the given pattern string, terminal type, and optional lookahead.
§Arguments
pattern- The pattern string.terminal_type- The terminal type associated with the pattern.
Sourcepub fn with_lookahead(self, lookahead: Lookahead) -> Self
pub fn with_lookahead(self, lookahead: Lookahead) -> Self
Sets the lookahead constraint for the pattern while consuming the current pattern.
§Arguments
lookahead- The lookahead constraint to set.
Sourcepub fn with_priority(self, priority: usize) -> Self
pub fn with_priority(self, priority: usize) -> Self
Trait Implementations§
impl Eq for Pattern
Source§impl Parse for Pattern
This is used to create a pattern from a part of a macro input.
The macro input looks like this:
impl Parse for Pattern
This is used to create a pattern from a part of a macro input. The macro input looks like this:
token r"World" followed by r"!" => 11;where the lookahead part can be either
followed by r"!";
```text
or
```text
not followed by r"!";
```text
or it can be omitted completely.
The lookahead part should be parsed with the help of the `Lookahead` struct's `parse` method.
Note that the `token` keyword is not part of the pattern, but it is used to identify the
pattern.fn parse(input: ParseStream<'_>) -> Result<Self>
impl StructuralPartialEq for Pattern
Auto Trait Implementations§
impl Freeze for Pattern
impl RefUnwindSafe for Pattern
impl Send for Pattern
impl Sync for Pattern
impl Unpin for Pattern
impl UnsafeUnpin for Pattern
impl UnwindSafe for Pattern
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more