Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework WGSL grammar to make it nicer for recursive descent #3299

Merged
merged 2 commits into from Aug 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 27 additions & 16 deletions wgsl/index.bs
Expand Up @@ -2028,7 +2028,7 @@ Some consequences of the restrictions structure member and array element types a
<div class='syntax' noexport='true'>
<dfn for=syntax>struct_body_decl</dfn> :

| [=syntax/brace_left=] ( [=syntax/struct_member=] [=syntax/comma=] ) * [=syntax/struct_member=] [=syntax/comma=] ? [=syntax/brace_right=]
| [=syntax/brace_left=] ( [=syntax/struct_member=] ( [=syntax/comma=] [=syntax/struct_member=] ) * [=syntax/comma=] ? ) ? [=syntax/brace_right=]
dneto0 marked this conversation as resolved.
Show resolved Hide resolved
</div>
<div class='syntax' noexport='true'>
<dfn for=syntax>struct_member</dfn> :
Expand Down Expand Up @@ -4302,19 +4302,19 @@ such that the redundant loads are eliminated.

| [=syntax/variable_decl=] [=syntax/equal=] [=syntax/expression=]

| [=syntax/let=] ( [=syntax/ident=] | [=syntax/variable_ident_decl=] ) [=syntax/equal=] [=syntax/expression=]
| [=syntax/let=] [=syntax/optionally_typed_ident=] [=syntax/equal=] [=syntax/expression=]

| [=syntax/const=] ( [=syntax/ident=] | [=syntax/variable_ident_decl=] ) [=syntax/equal=] [=syntax/expression=]
| [=syntax/const=] [=syntax/optionally_typed_ident=] [=syntax/equal=] [=syntax/expression=]
</div>
<div class='syntax' noexport='true'>
<dfn for=syntax>variable_decl</dfn> :

| [=syntax/var=] [=syntax/variable_qualifier=] ? ( [=syntax/ident=] | [=syntax/variable_ident_decl=] )
| [=syntax/var=] [=syntax/variable_qualifier=] ? [=syntax/optionally_typed_ident=]
</div>
<div class='syntax' noexport='true'>
<dfn for=syntax>variable_ident_decl</dfn> :
<dfn for=syntax>optionally_typed_ident</dfn> :

| [=syntax/ident=] [=syntax/colon=] [=syntax/type_decl=]
| [=syntax/ident=] ( [=syntax/colon=] [=syntax/type_decl=] ) ?
</div>
<div class='syntax' noexport='true'>
<dfn for=syntax>variable_qualifier</dfn> :
Expand All @@ -4331,9 +4331,9 @@ such that the redundant loads are eliminated.
<div class='syntax' noexport='true'>
<dfn for=syntax>global_constant_decl</dfn> :

| [=syntax/const=] ( [=syntax/ident=] | [=syntax/variable_ident_decl=] ) [=syntax/equal=] [=syntax/expression=]
| [=syntax/const=] [=syntax/optionally_typed_ident=] [=syntax/equal=] [=syntax/expression=]

| [=syntax/attribute=] * [=syntax/override=] ( [=syntax/ident=] | [=syntax/variable_ident_decl=] ) ( [=syntax/equal=] [=syntax/expression=] ) ?
| [=syntax/attribute=] * [=syntax/override=] [=syntax/optionally_typed_ident=] ( [=syntax/equal=] [=syntax/expression=] ) ?
</div>

# Expressions # {#expressions}
Expand Down Expand Up @@ -6095,7 +6095,7 @@ When an identifier is used as a [=syntax/callable=] item, it is one of:
<div class='syntax' noexport='true'>
<dfn for=syntax>argument_expression_list</dfn> :

| [=syntax/paren_left=] ( ( [=syntax/expression=] [=syntax/comma=] ) * [=syntax/expression=] [=syntax/comma=] ? ) ? [=syntax/paren_right=]
| [=syntax/paren_left=] ( [=syntax/expression=] ( [=syntax/comma=] [=syntax/expression=] ) * [=syntax/comma=] ? ) ? [=syntax/paren_right=]
</div>
<div class='syntax' noexport='true'>
<dfn for=syntax>postfix_expression</dfn> :
Expand Down Expand Up @@ -6143,20 +6143,31 @@ When an identifier is used as a [=syntax/callable=] item, it is one of:

| [=syntax/unary_expression=]

| [=syntax/multiplicative_expression=] [=syntax/star=] [=syntax/unary_expression=]
| [=syntax/multiplicative_expression=] [=syntax/multiplicative_operator=] [=syntax/unary_expression=]

| [=syntax/multiplicative_expression=] [=syntax/forward_slash=] [=syntax/unary_expression=]
</div>
<div class='syntax' noexport='true'>
<dfn for=syntax>multiplicative_operator</dfn> :

| [=syntax/star=]

| [=syntax/forward_slash=]

| [=syntax/multiplicative_expression=] [=syntax/modulo=] [=syntax/unary_expression=]
| [=syntax/modulo=]
</div>
<div class='syntax' noexport='true'>
<dfn for=syntax>additive_expression</dfn> :

| [=syntax/multiplicative_expression=]

| [=syntax/additive_expression=] [=syntax/plus=] [=syntax/multiplicative_expression=]
| [=syntax/additive_expression=] [=syntax/additive_operator=] [=syntax/multiplicative_expression=]
</div>
<div class='syntax' noexport='true'>
<dfn for=syntax>additive_operator</dfn> :

| [=syntax/plus=]

| [=syntax/additive_expression=] [=syntax/minus=] [=syntax/multiplicative_expression=]
| [=syntax/minus=]
</div>
<div class='syntax' noexport='true'>
<dfn for=syntax>shift_expression</dfn> :
Expand Down Expand Up @@ -7659,12 +7670,12 @@ The [=return type=], if specified, [=shader-creation error|must=] be [=construct
<div class='syntax' noexport='true'>
<dfn for=syntax>param_list</dfn> :

| ( [=syntax/param=] [=syntax/comma=] ) * [=syntax/param=] [=syntax/comma=] ?
| [=syntax/param=] ( [=syntax/comma=] [=syntax/param=] ) * [=syntax/comma=] ?
</div>
<div class='syntax' noexport='true'>
<dfn for=syntax>param</dfn> :

| [=syntax/attribute=] * [=syntax/variable_ident_decl=]
| [=syntax/attribute=] * [=syntax/ident=] [=syntax/colon=] [=syntax/type_decl=]
</div>

WGSL defines the following attributes that can be applied to function declarations:
Expand Down