Expand description
A syntax tree for WGSL files. The root of the tree is a TranslationUnit.
Follwing the spec at this date: 2024-07-31. The syntax tree closely mirrors wgsl structure while allowing language extensions.
§Strictness
This syntax tree is rather strict, meaning it cannot represent most syntaxically incorrect programs. But it is only syntactic, meaning it doesn’t perform many contextual checks: for example, certain attributes can only appear in certain places, or declarations have different constraints depending on where they appear. stricter checking is TODO and will be optional.
§Extensions
TODO, the syntax tree can be mutated to allow well-defined language extensions with feature flags (wgsl-tooling-imports, wgsl-tooling-generics, …).
§Design considerations
The parsing is not designed to be primarily efficient, but flexible and correct. It is made with the ultimate goal to implement spec-compliant language extensions. This is why this parser doesn’t borrow strings.
Structs§
- Assignment
Statement - Attribute
- Binary
Expression - Compound
Statement - Const
Assert - Continuing
Statement - Declaration
- Diagnostic
Directive - Enable
Directive - ForStatement
- Formal
Parameter - Function
- Function
Call Expression - IfStatement
- Indexing
Expression - Loop
Statement - Named
Component Expression - Requires
Directive - Struct
- Struct
Member - Switch
Clause - Switch
Statement - Translation
Unit - Type
Alias - Type
Expression - Unary
Expression - While
Statement
Enums§
- Assignment
Operator - Binary
Operator - Case
Selector - Declaration
Kind - Diagnostic
Severity - Expression
- Global
Declaration - Global
Directive - Literal
Expression - Statement
- Unary
Operator