Skip to main content

Lex

Struct Lex 

Source
pub struct Lex { /* private fields */ }
Expand description

The lexer, plus the token buffer the rule machine peeks into.

Tokens are lexed lazily: Lex::peek produces only as many as the alt being tried needs, under the rule that is trying it. A token already in the buffer is NOT re-lexed when a later rule looks at it — that caching is what makes a comment right after { a node (read under declbody) while a comment between a property and its : is not (read under decl).

Implementations§

Source§

impl Lex

Source

pub fn new(src: &str, lowercase_properties: bool) -> Lex

A lexer over src.

Source

pub fn peek(&mut self, n: usize, rule: &str) -> Result<&[Token], Error>

Ensure the buffer holds n tokens, lexing any shortfall under rule, and return them.

Source

pub fn consume(&mut self, n: usize)

Drop the first n buffered tokens. Anything left stays cached.

Source

pub fn point(&self) -> Point

The current scan position, for error reporting.

Auto Trait Implementations§

§

impl Freeze for Lex

§

impl RefUnwindSafe for Lex

§

impl Send for Lex

§

impl Sync for Lex

§

impl Unpin for Lex

§

impl UnsafeUnpin for Lex

§

impl UnwindSafe for Lex

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.