Module lexer

Source
Expand description

Definition of a lexer for the WebAssembly text format.

This module provides a Lexer type which is an iterate over the raw tokens of a WebAssembly text file. A Lexer accounts for every single byte in a WebAssembly text field, returning tokens even for comments and whitespace. Typically you’ll ignore comments and whitespace, however.

If you’d like to iterate over the tokens in a file you can do so via:

use wast::lexer::Lexer;

let wat = "(module (func $foo))";
for token in Lexer::new(wat).iter(0) {
    println!("{:?}", token?);
}

Note that you’ll typically not use this module but will rather use ParseBuffer instead.

Structs§

Integer
A fully parsed integer from a source string with a payload ready to parse into an integral type.
IntegerKind
Description of the parsed integer from the source.
Lexer
A structure used to lex the s-expression syntax of WAT files.
Token
A single token parsed from a Lexer.

Enums§

Float
Possible parsed float values
FloatKind
Description of a parsed float from the source.
LexError
Errors that can be generated while lexing.
SignToken
A sign token for an integer.
TokenKind
Classification of what was parsed from the input stream.