Struct charlexer

Source
pub struct charlexer<'t> {
    pub modify: fn(char) -> String,
    /* private fields */
}
Expand description

This struct is deprecated by charscanner. It is compatible with Lexer and Lextoken, which are also deprecated. This struct requires the legacy-parser installation feature.

Fields§

§modify: fn(char) -> String

function to modify char returned by nextsym, can be changed. Both charlexer::make and charlexer::new sets this function initially to |x|{x.to_string()}. For example, some characters such as ‘{’ and ‘}’ cannot be used as terminal symbols of a grammar and must be translated into something like “LBRACE” and “RBRACE”

Implementations§

Source§

impl<'t> charlexer<'t>

Source

pub fn new<'u: 't>(input: &'u str) -> charlexer<'u>

creates a charlexer that emits only non-whitespace chars

Source

pub fn make<'u: 't>(input: &'u str, kws: bool) -> charlexer<'u>

creates a charlexer with the option of keeping whitespace chars if kws=true

Trait Implementations§

Source§

impl<'t, AT: Default> Lexer<AT> for charlexer<'t>

Source§

fn linenum(&self) -> usize

returns current line number starting from 1

Source§

fn column(&self) -> usize

returns the index of the current char, starting from 1

Source§

fn current_line(&self) -> &str

returns slice of underlying data using std::str::Chars::as_str

Source§

fn nextsym(&mut self) -> Option<Lextoken<AT>>

retrieves the next Lextoken, or None at end-of-stream.

Auto Trait Implementations§

§

impl<'t> Freeze for charlexer<'t>

§

impl<'t> RefUnwindSafe for charlexer<'t>

§

impl<'t> Send for charlexer<'t>

§

impl<'t> Sync for charlexer<'t>

§

impl<'t> Unpin for charlexer<'t>

§

impl<'t> UnwindSafe for charlexer<'t>

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.