Struct naga::front::wgsl::parse::lexer::Lexer

source ·
pub(in front::wgsl) struct Lexer<'a> {
    input: &'a str,
    pub(in front::wgsl) source: &'a str,
    last_end_offset: usize,
    pub(in front::wgsl) enable_extensions: EnableExtensions,
}

Fields§

§input: &'a str§source: &'a str§last_end_offset: usize§enable_extensions: EnableExtensions

Implementations§

source§

impl<'a> Lexer<'a>

source

pub(in front::wgsl) const fn new( input: &'a str, ) -> Self

source

pub fn capture_span<T, E>( &mut self, inner: impl FnOnce(&mut Self) -> Result<T, E>, ) -> Result<(T, Span), E>

Calls the function with a lexer and returns the result of the function as well as the span for everything the function parsed

§Examples
let lexer = Lexer::new("5");
let (value, span) = lexer.capture_span(Lexer::next_uint_literal);
assert_eq!(value, 5);
source

pub(in front::wgsl) fn start_byte_offset( &mut self, ) -> usize

source

fn peek_token_and_rest(&mut self) -> ((Token<'a>, Span), &'a str)

source

const fn current_byte_offset(&self) -> usize

source

pub(in front::wgsl) fn span_from( &self, offset: usize, ) -> Span

source

pub(in front::wgsl) fn next( &mut self, ) -> (Token<'a>, Span)

Return the next non-whitespace token from self.

Assume we are a parse state where bit shift operators may occur, but not angle brackets.

source

pub(in front::wgsl) fn next_generic( &mut self, ) -> (Token<'a>, Span)

Return the next non-whitespace token from self.

Assume we are in a parse state where angle brackets may occur, but not bit shift operators.

source

fn next_impl(&mut self, generic: bool) -> (Token<'a>, Span)

Return the next non-whitespace token from self, with a span.

See consume_token for the meaning of generic.

source

pub(in front::wgsl) fn peek( &mut self, ) -> (Token<'a>, Span)

source

pub(in front::wgsl) fn expect_span( &mut self, expected: Token<'a>, ) -> Result<Span, Error<'a>>

source

pub(in front::wgsl) fn expect( &mut self, expected: Token<'a>, ) -> Result<(), Error<'a>>

source

pub(in front::wgsl) fn expect_generic_paren( &mut self, expected: char, ) -> Result<(), Error<'a>>

source

pub(in front::wgsl) fn skip( &mut self, what: Token<'_>, ) -> bool

If the next token matches it is skipped and true is returned

source

pub(in front::wgsl) fn next_ident_with_span( &mut self, ) -> Result<(&'a str, Span), Error<'a>>

source

pub(in front::wgsl) fn peek_ident_with_span( &mut self, ) -> Result<(&'a str, Span), Error<'a>>

source

fn word_as_ident_with_span( word: &'a str, span: Span, ) -> Result<(&'a str, Span), Error<'a>>

source

pub(in front::wgsl) fn next_ident( &mut self, ) -> Result<Ident<'a>, Error<'a>>

source

fn word_as_ident( word: &'a str, span: Span, ) -> Result<(&'a str, Span), Error<'a>>

source

pub(in front::wgsl) fn next_scalar_generic( &mut self, ) -> Result<Scalar, Error<'a>>

Parses a generic scalar type, for example <f32>.

source

pub(in front::wgsl) fn next_scalar_generic_with_span( &mut self, ) -> Result<(Scalar, Span), Error<'a>>

Parses a generic scalar type, for example <f32>.

Returns the span covering the inner type, excluding the brackets.

source

pub(in front::wgsl) fn next_storage_access( &mut self, ) -> Result<StorageAccess, Error<'a>>

source

pub(in front::wgsl) fn next_format_generic( &mut self, ) -> Result<(StorageFormat, StorageAccess), Error<'a>>

source

pub(in front::wgsl) fn open_arguments( &mut self, ) -> Result<(), Error<'a>>

source

pub(in front::wgsl) fn close_arguments( &mut self, ) -> Result<(), Error<'a>>

source

pub(in front::wgsl) fn next_argument( &mut self, ) -> Result<bool, Error<'a>>

Trait Implementations§

source§

impl<'a> Clone for Lexer<'a>

source§

fn clone(&self) -> Lexer<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Lexer<'a>

§

impl<'a> RefUnwindSafe for Lexer<'a>

§

impl<'a> Send for Lexer<'a>

§

impl<'a> Sync for Lexer<'a>

§

impl<'a> Unpin for Lexer<'a>

§

impl<'a> UnwindSafe for Lexer<'a>

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.