[][src]Trait antlr_rust::token_factory::TokenFactory

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;
    pub fn create<T: ?Sized>(
        &'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>
;
pub fn create_invalid() -> Self::Tok;
pub fn get_data(from: Self::From) -> Cow<'a, Self::Data>; }

Trait for creating tokens.

Associated Types

type Inner: Token<Data = Self::Data> + ?Sized + 'a[src]

Type of tokens emitted by this factory.

type Tok: Borrow<Self::Inner> + Clone + 'a + Debug[src]

Ownership of the emitted tokens

type Data: InputData + ?Sized[src]

Type of the underlying storage

type From[src]

Type of the CharStream that factory can produce tokens from

Loading content...

Required methods

pub fn create<T: ?Sized>(
    &'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>, 
[src]

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

pub fn create_invalid() -> Self::Tok[src]

Creates invalid token Invalid tokens must have TOKEN_INVALID_TYPE token type.

pub fn get_data(from: Self::From) -> Cow<'a, Self::Data>[src]

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

Loading content...

Implementors

impl<'a> TokenFactory<'a> for CommonTokenFactory[src]

type Inner = CommonToken<'a>

type Tok = Box<Self::Inner>

type Data = str

type From = Cow<'a, str>

impl<'a> TokenFactory<'a> for OwningTokenFactory[src]

type Inner = OwningToken

type Tok = Box<Self::Inner>

type Data = str

type From = String

impl<'input, TF, Tok> TokenFactory<'input> for ArenaFactory<'input, TF, Tok> where
    TF: TokenFactory<'input, Tok = Box<Tok>, Inner = Tok>,
    Tok: Token<Data = TF::Data> + Clone + TidAble<'input>,
    &'a Tok: Default
[src]

type Inner = Tok

type Tok = &'input Tok

type Data = TF::Data

type From = TF::From

Loading content...