Module syntax

Source
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§

pub use crate::span::Span;
pub use crate::span::Spanned;

Structs§

AssignmentStatement
BinaryExpression
BreakIfStatement
BreakStatement
CompoundStatement
ConstAssert
ContinueStatement
ContinuingStatement
CustomAttribute
Declaration
DecrementStatement
DiagnosticAttribute
DiagnosticDirective
DiscardStatement
ElseClause
ElseIfClause
EnableDirective
ForStatement
FormalParameter
Function
FunctionCall
FunctionCallStatement
Ident
Identifiers correspond to WGSL ident syntax node, except that they have several convenience features:
IfClause
IfStatement
IncrementStatement
IndexingExpression
InterpolateAttribute
LoopStatement
NamedComponentExpression
ParenthesizedExpression
RequiresDirective
ReturnStatement
Struct
StructMember
SwitchClause
SwitchStatement
TemplateArg
TranslationUnit
TypeAlias
TypeExpression
UnaryExpression
WhileStatement
WorkgroupSizeAttribute

Enums§

AccessMode
AddressSpace
AssignmentOperator
Attribute
BinaryOperator
BuiltinValue
CaseSelector
DeclarationKind
DiagnosticSeverity
Expression
GlobalDeclaration
GlobalDirective
InterpolationSampling
InterpolationType
LiteralExpression
Statement
UnaryOperator

Type Aliases§

AttributeNode
Attributes
ConstAssertStatement
DeclarationStatement
ExpressionNode
FunctionCallExpression
GlobalDeclarationNode
StatementNode
StructMemberNode
TemplateArgs