pub trait TokenFactory<'a>: TidAble<'a> + Sized {
    type Inner: Token<Data = Self::Data> + ?Sized + 'a;
    type Tok: Borrow<Self::Inner> + Clone + 'a + Debug;
    type Data: InputData + ?Sized;
    type From;

    fn create<T>(
        &'a self,
        source: Option<&mut T>,
        ttype: isize,
        text: Option<<Self::Data as ToOwned>::Owned>,
        channel: isize,
        start: isize,
        stop: isize,
        line: isize,
        column: isize
    ) -> Self::Tok
    where
        T: CharStream<Self::From> + ?Sized
; fn create_invalid() -> Self::Tok; fn get_data(from: Self::From) -> Cow<'a, Self::Data>; }
Expand description

Trait for creating tokens.

Required Associated Types

Type of tokens emitted by this factory.

Ownership of the emitted tokens

Type of the underlying storage

Type of the CharStream that factory can produce tokens from

Required Methods

Creates token either from sourse or from pure data in text Either source or text are not None

Creates invalid token Invalid tokens must have TOKEN_INVALID_TYPE token type.

Creates Self::Data representation for from for lexer to work with when it does not need to create full token

Implementors