Expand description
A syntax tree for WGSL and WESL files. The root of the tree is TranslationUnit
.
Following 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 syntactically 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.
§WESL Extensions
With the imports
, generics
, attributes
and condcomp
one can selectively allow
parsing WESL Extensions. Read more at https://github.com/wgsl-tooling-wg/wesl-spec.
§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.
Re-exports§
Structs§
- Assignment
Statement - Binary
Expression - Break
IfStatement - Break
Statement - Compound
Statement - Const
Assert - Continue
Statement - Continuing
Statement - Custom
Attribute - Declaration
- Decrement
Statement - Diagnostic
Attribute - Diagnostic
Directive - Discard
Statement - Else
Clause - Else
IfClause - Enable
Directive - ForStatement
- Formal
Parameter - Function
- Function
Call - Function
Call Statement - Ident
- Identifiers correspond to WGSL
ident
syntax node, except that they have several convenience features: - IfClause
- IfStatement
- Increment
Statement - Indexing
Expression - Interpolate
Attribute - Loop
Statement - Named
Component Expression - Parenthesized
Expression - Requires
Directive - Return
Statement - Struct
- Struct
Member - Switch
Clause - Switch
Statement - Template
Arg - Translation
Unit - Type
Alias - Type
Expression - Unary
Expression - While
Statement - Workgroup
Size Attribute
Enums§
- Access
Mode - Address
Space - Assignment
Operator - Attribute
- Binary
Operator - Builtin
Value - Case
Selector - Declaration
Kind - Diagnostic
Severity - Expression
- Global
Declaration - Global
Directive - Interpolation
Sampling - Interpolation
Type - Literal
Expression - Statement
- Unary
Operator