13 releases (breaking)

Uses new Rust 2024

new 0.10.1 Mar 9, 2026
0.9.0 Feb 7, 2026
0.8.0 Dec 27, 2025
0.7.0 Nov 15, 2025
0.1.0 Nov 30, 2024

#896 in Parser implementations


Used in 3 crates (2 directly)

MIT license

245KB
7.5K SLoC

The parser for WebAssembly Text Format.

This parser is error-tolerant, which means it can parse even even if the input contains syntax errors.

This parser will produce concrete syntax tree (CST), but you can build AST from it with a bunch of helpers from wat_syntax::ast module.

Usage

Use the main parse function:

use wat_syntax::SyntaxKind;

let input = "(module)";
let (tree, errors) = wat_parser::parse(input);
assert_eq!(tree.kind(), SyntaxKind::ROOT.into());

Any syntax errors won't prevent the parser from parsing the rest of the input, so the parse function returns a tuple which contains the CST and syntax errors. You can access syntax errors like this:

use wat_syntax::{SyntaxKind, TextSize};

let input = "(module";
let (tree, errors) = wat_parser::parse(input);
assert_eq!(errors[0].range.start(), TextSize::from(7));
assert!(errors[0].message.to_string().contains("expected `)`"));

Dependencies

~270–570KB
~11K SLoC