This PR updates switch statement parsing to match the latest version of the WGSL spec.
A slight hack has been implemented to support the "combined default" syntax, e.g.:
switch x {
// ...
case 2, default {
// ...
}
}
Case selectors are now represented in the syntax tree as Exprs, so to accommodate this, the default keyword in a case like the one above will be parsed as an Expr::Ident(IdentExpr::Leaf "default" (Keyword (...)).
That's a little gross and makes the tree a little more awkward to traverse, but would only be exceptionally inconvenient if you were trying to do a full semantic validation — e.g., checking for the presence of exactly one default case would now be a more onerous task. That type of validation is currently beyond the scope of this project, so I'm not overly concerned about it.
This PR updates
switch
statement parsing to match the latest version of the WGSL spec.A slight hack has been implemented to support the "combined default" syntax, e.g.:
Case selectors are now represented in the syntax tree as
Expr
s, so to accommodate this, thedefault
keyword in a case like the one above will be parsed as anExpr::Ident(IdentExpr::Leaf "default" (Keyword (...))
.That's a little gross and makes the tree a little more awkward to traverse, but would only be exceptionally inconvenient if you were trying to do a full semantic validation — e.g., checking for the presence of exactly one
default
case would now be a more onerous task. That type of validation is currently beyond the scope of this project, so I'm not overly concerned about it.