9 unstable releases (3 breaking)
Uses new Rust 2024
| 0.3.2 | Dec 27, 2025 |
|---|---|
| 0.3.1 | Dec 9, 2025 |
| 0.2.0 | Jul 28, 2025 |
| 0.1.2 | Mar 16, 2025 |
| 0.0.2 | Aug 29, 2024 |
#200 in Data formats
15,363 downloads per month
Used in 14 crates
(3 directly)
570KB
13K
SLoC
wgsl-parse
A parser and syntax tree for WGSL files, written directly from the specification with lalrpop.
It supports WESL language extensions guarded by feature flags.
WESL Features
| name | description | WESL Specification |
|---|---|---|
wesl |
enable all WESL extensions below | |
imports |
import statements and inline qualified paths |
complete |
attributes |
extra attributes locations on statements | complete |
condcomp |
@if attributes |
complete |
generics |
@type attributes |
experimental |
Other Features
| name | description |
|---|---|
naga-ext |
enable all Naga/WGPU extensions (experimental) |
serde |
derive Serialize and Deserialize for syntax tree nodes |
tokrepr |
derive TokRepr for syntax tree nodes |
Parsing and Stringification
TranslationUnit implements FromStr.
Other syntax nodes also implement FromStr: GlobalDirective, GlobalDeclaration, Statement, Expression and ImportStatement.
The syntax tree elements implement Display.
The display is always pretty-printed.
# use wgsl_parse::syntax::TranslationUnit;
# use std::str::FromStr;
let source = "@fragment fn frag_main() -> @location(0) vec4f { return vec4(1); }";
let mut module = TranslationUnit::from_str(source).unwrap();
// modify the module as needed...
println!("{module}");
Dependencies
~6–8.5MB
~136K SLoC