TermLexerDriver

Struct TermLexerDriver 

Source
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 generic I without storage.

§Associated Types (via LexerDriver)

  • LexerData = LexData
  • Token = TermToken
  • Lexer = Lexer<I, Self, Arena>
  • Error = TermError
  • Context = Arena

§Errors

  • TermError::ParseInt for invalid numeric literals,
  • TermError::FromUtf8 for invalid UTF-8 when decoding identifiers,

Fields§

§buffer2: Vec<u8>

Secondary buffer.

§span2: Span

Secondary span.

Trait Implementations§

Source§

impl<I> LexerDriver for TermLexerDriver<I>
where I: TryNextWithContext<Arena, Item = u8, Error: Display + 'static>,

Source§

type LexerData = LexData

Rule identifiers and metadata produced by the lexer generator.

Source§

type Token = TermToken

Concrete token type emitted by the driver.

Source§

type Lexer = Lexer<I, TermLexerDriver<I>, <TermLexerDriver<I> as LexerDriver>::Context>

Concrete lexer type parameterized by input, driver and context.

Source§

type Context = Arena

Externally supplied context available to actions (symbol table).

Source§

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> 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 = 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V