Crates.io | wat |
lib.rs | wat |
version | |
source | src |
created_at | 2016-09-23 00:08:16.33392 |
updated_at | 2024-12-02 22:48:30.008805 |
description | Rust parser for the WebAssembly Text format, WAT |
homepage | https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wat |
repository | https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wat |
max_upload_size | |
id | 6594 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Add wat
to your Cargo.toml
$ cargo add wat
And then you can parse WAT to binary WebAssembly via:
// Parse from a file ...
let binary = wat::parse_file("./foo.wat")?;
// ... or a string
let wat = r#"
(module
(func $foo)
(func (export "bar")
call $foo
)
)
"#;
let binary = wat::parse_str(wat)?;
The wat
crate does not expose an AST as its goal is to provide a
forever-stable interface against the wast
crate. Using wat
is suitable when
all you want to do is translate from text-to-binary, for example parsing the
input of a CLI program into the WebAssembly binary format.
If instead you're interested in working with the AST of a text file or otherwise
adding your own parsing to the text format you'll want to take a look at the
wast
crate.
Consult the crate documentation for more information, but the general idea is this crate will not issue a semver-breaking change for breaking changes in the WAT format, either for MVP features or post-MVP features. No opt-in is required to use WebAssembly features, so using them may break if the upstream spec changes.
This project is licensed under the Apache 2.0 license with the LLVM exception. See LICENSE for more details.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.