pub enum Token<'a> {
    LineComment(&'a str),
    BlockComment(&'a str),
    Whitespace(&'a str),
    LParen(&'a str),
    RParen(&'a str),
    String(WasmString<'a>),
    Id(&'a str),
    Keyword(&'a str),
    Reserved(&'a str),
    Integer(Integer<'a>),
    Float(Float<'a>),
}
Expand description

A fragment of source lex’d from an input string.

This enumeration contains all kinds of fragments, including comments and whitespace. For most cases you’ll probably ignore these and simply look at tokens.

Variants

LineComment(&'a str)

A line comment, preceded with ;;

BlockComment(&'a str)

A block comment, surrounded by (; and ;). Note that these can be nested.

Whitespace(&'a str)

A fragment of source that represents whitespace.

LParen(&'a str)

A left-parenthesis, including the source text for where it comes from.

RParen(&'a str)

A right-parenthesis, including the source text for where it comes from.

String(WasmString<'a>)

A string literal, which is actually a list of bytes.

Id(&'a str)

An identifier (like $foo).

All identifiers start with $ and the payload here is the original source text.

Keyword(&'a str)

A keyword, or something that starts with an alphabetic character.

The payload here is the original source text.

Reserved(&'a str)

A reserved series of idchar symbols. Unknown what this is meant to be used for, you’ll probably generate an error about an unexpected token.

Integer(Integer<'a>)

An integer.

Float(Float<'a>)

A float.

Implementations

Returns the original source text for this token.

Trait Implementations

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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