[−][src]Crate wast
A crate for low-level parsing of the WebAssembly text formats: WAT and WAST.
This crate is intended to be a low-level detail of the wat
crate,
providing a low-level parsing API for parsing WebAssembly text format
structures. The API provided by this crate is very similar to
syn
and provides the ability to write customized
parsers which may be an extension to the core WebAssembly text format. For
more documentation see the parser
module.
High-level Overview
This crate provides a few major pieces of functionality
-
lexer
- this is a raw lexer for the wasm text format. This is not customizable, but if you'd like to iterate over raw tokens this is the module for you. You likely won't use this much. -
parser
- this is the workhorse of this crate. Theparser
module provides theParse
trait primarily and utilities around working with aParser
to parse streams of tokens. -
Module
- this contains an Abstract Syntax Tree (AST) of the WebAssembly Text format (WAT) as well as the unofficial WAST format. This also has aModule::encode
method to emit a module in its binary form.
Stability and WebAssembly Features
This crate provides support for many in-progress WebAssembly features such
as reference types, multi-value, etc. Be sure to check out the documentation
of the wast
crate for policy information on crate
stability vs WebAssembly Features. The tl;dr; version is that this crate
will issue semver-non-breaking releases which will break the parsing of the
text format. This crate, unlike wast
, is expected to have numerous Rust
public API changes, all of which will be accompanied with a semver-breaking
release.
Compile-time Cargo features
This crate has a wasm-module
feature which is turned on by default which
includes all necessary support to parse full WebAssembly modules. If you
don't need this (for example you're parsing your own s-expression format)
then this feature can be disabled.
Modules
annotation | Common annotations used to parse WebAssembly text files. |
kw | Common keyword used to parse WebAssembly text files. |
lexer | Definition of a lexer for the WebAssembly text format. |
parser | Traits for parsing the WebAssembly Text format |
Macros
annotation | A macro, like |
custom_keyword | A macro to create a custom keyword parser. |
Structs
BlockType | Extra information associated with block-related instructions. |
BrTableIndices | Extra information associated with the |
CallIndirect | Extra data associated with the |
Custom | A wasm custom section within a module. |
Data | A |
Elem | An |
Error | A convenience error type to tie together all the detailed errors produced by this crate. |
Export | A entry in a WebAssembly module's export section. |
Expression | An expression, or a list of instructions, in the WebAssembly text format. |
Float32 | A parsed floating-point type |
Float64 | A parsed floating-point type |
Func | A WebAssembly function to be inserted into a module. |
FunctionType | A function type with parameters and results. |
Global | A WebAssembly global in a module |
GlobalType | Type for a |
Id | An identifier in a WebAssembly module, prefixed by |
Import | An |
InlineExport | A listing of inline |
LParen | A convenience type to use with |
Limits | Min/max limits used for tables/memories. |
MemArg | Payload for memory-related instructions indicating offset/alignment of memory accesses. |
Memory | A defined WebAssembly memory instance inside of a module. |
MemoryInit | Extra data associated with the |
MemoryType | Configuration for a memory of a wasm module |
Module | A parsed WebAssembly module. |
NameAnnotation | An |
Names | Representation of the results of name resolution for a module. |
SelectTypes | Payload of the |
Span | A position in the original source stream, used to render errors. |
Table | A WebAssembly |
TableCopy | Extra data associated with the |
TableInit | Extra data associated with the |
TableType | Configuration for a table of a wasm mdoule |
Type | A type declaration in a module |
TypeUse | A reference to a type defined in this module. |
V8x16Shuffle | Lanes being shuffled in the |
Wast | A parsed representation of a |
WastInvoke | |
Wat | A |
Enums
AssertExpression | An expression that is valid inside an |
CustomPlace | Possible locations to place a custom section within a module. |
CustomPlaceAnchor | Known sections that custom sections can be placed relative to. |
DataKind | Different kinds of data segments, either passive or active. |
ElemKind | Different ways to define an element segment in an mdoule. |
ElemPayload | Different ways to define the element segment payload in a module. |
ExportKind | Different kinds of elements that can be exported from a WebAssembly module,
contained in an |
FuncKind | Possible ways to define a function in the text format. |
GlobalKind | Different kinds of globals that can be defined in a module. |
ImportKind | All possible types of items that can be imported into a wasm module. |
Index | A reference to another item in a wasm module. |
Instruction | A listing of all WebAssembly instructions that can be in a module that this crate currently parses. |
MemoryKind | Different syntactical ways a memory can be defined in a module. |
ModuleField | A listing of all possible fields that can make up a WebAssembly module. |
ModuleKind | The different kinds of ways to define a module. |
NanPattern | Either a NaN pattern ( |
QuoteModule | |
TableElemType | List of different kinds of table types we can have. |
TableKind | Different ways to textually define a table. |
V128Pattern | A version of |
V128Const | Different ways to specify a |
ValType | The value types for a wasm module. |
WastDirective | The different kinds of directives found in a |
WastExecute |