wgsl-parse 0.0.1

Parse a wgsl source file to a syntax tree
Documentation

A parser for WGSL files, written directly from the specification with lalrpop.

Parsing

let source = "@fragment fn frag_main() -> @location(0) vec4f { return vec4(1); }";
let module = parser::parse(source);
println!("{module:?}");

Syntax tree

The syntax tree was designed with [Spans][span::Span] a bit everywhere. These spans allow referring to the source &str without a lifetime bind. In the future, different variants of the [Span][span::Span] will allow modifying the Source code while preserving correct syntax tree spans. (TODO)

Parsing variants

recognize

Parsing exists in two flavors: recognize and spanned. The recognize version simply ensures that the input file has no syntax errors. The spanned version returns a full syntax tree.

Stringify

To be documented (TODO)