Trait teleparse::Lexicon

source ·
pub trait Lexicon: Debug + Clone + Copy + PartialEq + Eq + Hash + 'static {
    type Bit: Unsigned + Integer + BitAnd<Output = Self::Bit> + BitOr<Output = Self::Bit> + Not<Output = Self::Bit> + Copy;
    type Lexer<'s>: Lexer<'s, L = Self>;
    type Map<T: Default + Clone>: Default + Clone + Borrow<[T]> + BorrowMut<[T]>;

    // Required methods
    fn id(&self) -> usize;
    fn from_id(id: usize) -> Self;
    fn to_bit(&self) -> Self::Bit;
    fn first() -> Self;
    fn next(&self) -> Option<Self>;
    fn should_extract(&self) -> bool;
    fn lexer<'s>(source: &'s str) -> Result<Self::Lexer<'s>, GrammarError>;
}
Expand description

Trait for defining the token types of a grammar

See module level documentation for more information

Required Associated Types§

source

type Bit: Unsigned + Integer + BitAnd<Output = Self::Bit> + BitOr<Output = Self::Bit> + Not<Output = Self::Bit> + Copy

Bit flag representation of the token types

When derived, One of u8, u16, u32, u64, or u128 is chosen based on the number of variants in the enum

source

type Lexer<'s>: Lexer<'s, L = Self>

Lexer associated with this TokenType

source

type Map<T: Default + Clone>: Default + Clone + Borrow<[T]> + BorrowMut<[T]>

Map type used for storing token type mappings in tables for syntax analysis

Required Methods§

source

fn id(&self) -> usize

Get the id of this token type (ordinal)

source

fn from_id(id: usize) -> Self

source

fn to_bit(&self) -> Self::Bit

Convert to numeric representation for use in bit set

source

fn first() -> Self

Get the first type. Used to iterate over all types

source

fn next(&self) -> Option<Self>

Get the next type. Used to iterate over all types

source

fn should_extract(&self) -> bool

Whether this token should be excluded from AST, but still has value.

One example is comments

source

fn lexer<'s>(source: &'s str) -> Result<Self::Lexer<'s>, GrammarError>

Create a lexer for parsing this token type

Object Safety§

This trait is not object safe.

Implementors§