Crate wast[−][src]
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. |
custom_reserved | A macro for defining custom reserved symbols. |
Structs
Alias | An |
ArrayType | An array type with fields. |
BlockType | Extra information associated with block-related instructions. |
BrOnCast | Payload of the |
BrOnExn | Payload of the |
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. |
Event | A WebAssembly event directive, part of the exception handling proposal. |
Export | A entry in a WebAssembly module's export section. |
ExportType | The type of an exported item from a module or instance. |
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. |
FuncBindType | Extra information associated with the func.bind instruction. |
FunctionType | A function type with parameters and results. |
FunctionTypeNoNames | A function type with parameters and results. |
Global | A WebAssembly global in a module |
GlobalType | Type for a |
I8x16Shuffle | Lanes being shuffled in the |
Id | An identifier in a WebAssembly module, prefixed by |
Import | An |
IndexOrRef | Convenience structure to parse |
InlineExport | A listing of inline |
InlineImport | A listing of a inline |
Instance | A nested WebAssembly instance to be created as part of a module. |
InstanceArg | Arguments to the |
InstanceType | A type for a nested instance |
ItemSig | |
LParen | A convenience type to use with |
LaneArg | Payload for lane-related instructions. Unsigned with no + prefix. |
LetType | Extra information associated with the let instruction. |
Limits | Min/max limits used for tables/memories. |
Limits64 | Min/max limits used for 64-bit memories |
LoadOrStoreLane | Extra data associated with the |
Local | A local for a |
MemArg | Payload for memory-related instructions indicating offset/alignment of memory accesses. |
Memory | A defined WebAssembly memory instance inside of a module. |
MemoryArg | Extra data associated with unary memory instructions. |
MemoryCopy | Extra data associated with the |
MemoryInit | Extra data associated with the |
Module | A parsed WebAssembly module. |
ModuleType | A type for a nested module |
NameAnnotation | An |
Names | Representation of the results of name resolution for a module. |
NestedModule | A nested WebAssembly nested module to be created as part of a module. |
RTTSub | Payload of the |
RefTest | Payload of the |
RefType | A reference type in a wasm module. |
SelectTypes | Payload of the |
Span | A position in the original source stream, used to render errors. |
StructAccess | Extra data associated with the |
StructField | A field of a struct type. |
StructNarrow | Extra data associated with the |
StructType | A struct type with fields. |
Table | A WebAssembly |
TableArg | Extra data associated with unary table instructions. |
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. |
Wast | A parsed representation of a |
WastInvoke | |
Wat | A |
Enums
AliasKind | |
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. |
DataVal | Differnet ways the value of a data segment can be defined. |
ElemKind | Different ways to define an element segment in an mdoule. |
ElemPayload | Different ways to define the element segment payload in a module. |
EventType | Listing of various types of events that can be defined in a wasm 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. |
HeapType | A heap type for a reference type |
Index | A reference to another item in a wasm module. |
InstanceKind | Possible ways to define a instance in the text format. |
Instruction | A listing of all WebAssembly instructions that can be in a module that this crate currently parses. |
ItemKind | |
ItemRef | Parses |
MemoryKind | Different syntactical ways a memory can be defined in a module. |
MemoryType | Configuration for a memory of a wasm 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 ( |
NestedModuleKind | Possible ways to define a nested module in the text format. |
QuoteModule | |
StorageType | The types of values that may be used in a struct or array. |
TableKind | Different ways to textually define a table. |
TypeDef | A definition of a type. |
V128Const | Different ways to specify a |
V128Pattern | A version of |
ValType | The value types for a wasm module. |
WastDirective | The different kinds of directives found in a |
WastExecute |