[−][src]Struct wast::parser::Cursor
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 comments, whitespace, or unknown annotations.
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 comments, whitespace, or unknown annotations.
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 comments, whitespace, or unknown annotations.
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 comments, whitespace, or unknown annotations.
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 comments, whitespace, or unknown annotations.
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 comments, whitespace, or unknown annotations.
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 comments, whitespace, or unknown annotations.
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 comments, whitespace, or unknown annotations.
pub fn annotation(self) -> Option<(&'a str, Self)>
[src]
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.
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 only skip whitespace, no other tokens.
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Cursor<'a>
impl<'a> !Send for Cursor<'a>
impl<'a> !Sync for Cursor<'a>
impl<'a> Unpin for Cursor<'a>
impl<'a> !UnwindSafe for Cursor<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,