pub struct Cursor<'a> { /* private fields */ }
Expand description

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.

Implementations

Returns the span of the next Token token.

Does not take into account whitespace or comments.

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

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 comments, whitespace, or unknown annotations.

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 comments, whitespace, or unknown annotations.

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 comments, whitespace, or unknown annotations.

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 comments, whitespace, or unknown annotations.

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 comments, whitespace, or unknown annotations.

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 comments, whitespace, or unknown annotations.

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 comments, whitespace, or unknown annotations.

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 comments, whitespace, or unknown annotations.

Attempts to advance this cursor if the current token is a Token::Reserved and looks like the start of an annotation.

Annotations are a WebAssembly proposal for the text format which allows placing structured text inside of a text file, for example to specify the name section or other custom sections.

This function will attempt to see if the current token is the @foo part of the annotation. This requires the previous token to be ( and the current token is Reserved which starts with @ and has a nonzero length for the following name.

Note that this will skip unknown annoations. Only pre-registered annotations will be returned here.

This function will automatically skip over any comments, whitespace, or unknown annotations.

Attempts to advance this cursor if the current token is a Token::LineComment or a Token::BlockComment

This function will only skip whitespace, no other tokens.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.