[][src]Struct wast::parser::Cursor

pub struct Cursor<'a> { /* fields omitted */ }

An immutable cursor into a list of tokens.

This cursor cannot be mutated but can be used to parse more tokens in a list of tokens. Cursors are created from the Parser::step method. This is a very low-level parsing structure and you likely won't use it much.

Methods

impl<'a> Cursor<'a>[src]

pub fn cur_span(&self) -> Span[src]

Returns the span of the next Token token.

Does not take into account whitespace or comments.

pub fn error(&self, msg: impl Display) -> Error[src]

Same as Parser::error, but works with the current token in this Cursor instead.

pub fn lparen(self) -> Option<Self>[src]

Attempts to advance this cursor if the current token is a (.

If the current token is (, returns a new Cursor pointing at the rest of the tokens in the stream. Otherwise returns None.

This function will automatically skip over any comment or whitespace tokens.

pub fn rparen(self) -> Option<Self>[src]

Attempts to advance this cursor if the current token is a ).

If the current token is ), returns a new Cursor pointing at the rest of the tokens in the stream. Otherwise returns None.

This function will automatically skip over any comment or whitespace tokens.

pub fn id(self) -> Option<(&'a str, Self)>[src]

Attempts to advance this cursor if the current token is a Token::Id

If the current token is Id, returns the identifier minus the leading $ character as well as a new Cursor pointing at the rest of the tokens in the stream. Otherwise returns None.

This function will automatically skip over any comment or whitespace tokens.

pub fn keyword(self) -> Option<(&'a str, Self)>[src]

Attempts to advance this cursor if the current token is a Token::Keyword

If the current token is Keyword, returns the keyword as well as a new Cursor pointing at the rest of the tokens in the stream. Otherwise returns None.

This function will automatically skip over any comment or whitespace tokens.

pub fn reserved(self) -> Option<(&'a str, Self)>[src]

Attempts to advance this cursor if the current token is a Token::Reserved

If the current token is Reserved, returns the reserved token as well as a new Cursor pointing at the rest of the tokens in the stream. Otherwise returns None.

This function will automatically skip over any comment or whitespace tokens.

pub fn integer(self) -> Option<(&'a Integer<'a>, Self)>[src]

Attempts to advance this cursor if the current token is a Token::Integer

If the current token is Integer, returns the integer as well as a new Cursor pointing at the rest of the tokens in the stream. Otherwise returns None.

This function will automatically skip over any comment or whitespace tokens.

pub fn float(self) -> Option<(&'a Float<'a>, Self)>[src]

Attempts to advance this cursor if the current token is a Token::Float

If the current token is Float, returns the float as well as a new Cursor pointing at the rest of the tokens in the stream. Otherwise returns None.

This function will automatically skip over any comment or whitespace tokens.

pub fn string(self) -> Option<(&'a [u8], Self)>[src]

Attempts to advance this cursor if the current token is a Token::String

If the current token is String, returns the byte value of the string as well as a new Cursor pointing at the rest of the tokens in the stream. Otherwise returns None.

This function will automatically skip over any comment or whitespace tokens.

pub fn comment(self) -> Option<(&'a Comment<'a>, Self)>[src]

Attempts to advance this cursor if the current token is a Source::Comment

This function will skip any whitespace tokens, but it will not skip any other tokens.

Trait Implementations

impl<'a> Clone for Cursor<'a>[src]

impl<'a> Copy for Cursor<'a>[src]

Auto Trait Implementations

impl<'a> !Send for Cursor<'a>

impl<'a> !Sync for Cursor<'a>

impl<'a> Unpin for Cursor<'a>

impl<'a> !UnwindSafe for Cursor<'a>

impl<'a> !RefUnwindSafe for Cursor<'a>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]