Expand description
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. Theparsermodule provides theParsetrait primarily and utilities around working with aParserto 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::encodemethod 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
Macros
custom_keyword, to create a type which can be used to
parse/peek annotation directives.Structs
*.wast file.Enums
*.wast file.*.wat file parser, or a parser for one parenthesized module.