pub struct TermLexerDriver<I> {
pub buffer2: Vec<u8>,
pub span2: Span,
/* private fields */
}Expand description
Stateful driver that handles rule matches from the generated DFA.
TermLexerDriver receives callbacks when a rule matches. It can:
- emit tokens (e.g., identifiers, numbers, operators),
- adjust internal bookkeeping (e.g., nested comment depth),
- switch modes (e.g., on comment boundaries).
The driver is parameterized by an input type I that yields bytes and
supports contextual access to Arena.
§Internal State
comment_level: current nesting depth of block comments; positive values mean we’re inside a comment._marker: binds the genericIwithout storage.
§Associated Types (via LexerDriver)
LexerData = LexDataToken = TermTokenLexer = Lexer<I, Self, Arena>Error = TermErrorContext = Arena
§Errors
TermError::ParseIntfor invalid numeric literals,TermError::FromUtf8for invalid UTF-8 when decoding identifiers,
Fields§
§buffer2: Vec<u8>Secondary buffer.
span2: SpanSecondary span.
Trait Implementations§
Source§impl<I> LexerDriver for TermLexerDriver<I>
impl<I> LexerDriver for TermLexerDriver<I>
Source§type Lexer = Lexer<I, TermLexerDriver<I>, <TermLexerDriver<I> as LexerDriver>::Context>
type Lexer = Lexer<I, TermLexerDriver<I>, <TermLexerDriver<I> as LexerDriver>::Context>
Concrete lexer type parameterized by input, driver and context.
Source§fn action(
&mut self,
lexer: &mut Self::Lexer,
arena: &mut Self::Context,
rule: <Self::LexerData as LexerData>::LexerRule,
) -> Result<(), ParlexError>
fn action( &mut self, lexer: &mut Self::Lexer, arena: &mut Self::Context, rule: <Self::LexerData as LexerData>::LexerRule, ) -> Result<(), ParlexError>
Handles a single lexer rule match.
Called by the lexer when a DFA rule in Lexer fires. The implementation
typically inspects rule, reads the matched span from lexer, and either:
- emits a
TermToken(e.g., numbers, operators), - updates internal state (e.g.,
comment_nest_count), - or returns an error if the match is invalid.
Implementations may also use context (an Arena) to intern identifiers
and store terms in Value::Term.
§Errors
Propagates any lexical, parsing, UTF-8 decoding, or arena errors as
[TermError].
Auto Trait Implementations§
impl<I> Freeze for TermLexerDriver<I>
impl<I> RefUnwindSafe for TermLexerDriver<I>where
I: RefUnwindSafe,
impl<I> Send for TermLexerDriver<I>where
I: Send,
impl<I> Sync for TermLexerDriver<I>where
I: Sync,
impl<I> Unpin for TermLexerDriver<I>where
I: Unpin,
impl<I> UnwindSafe for TermLexerDriver<I>where
I: UnwindSafe,
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