|
908 | 908 | <a href="#907" id="907">907</a> |
909 | 909 | <a href="#908" id="908">908</a> |
910 | 910 | <a href="#909" id="909">909</a> |
911 | | -</pre></div><pre class="rust"><code><span class="kw">use </span><span class="kw">crate</span>::front::wgsl::parse::directive::{DirectiveKind, UnimplementedDirectiveKind}; |
| 911 | +<a href="#910" id="910">910</a> |
| 912 | +<a href="#911" id="911">911</a> |
| 913 | +<a href="#912" id="912">912</a> |
| 914 | +<a href="#913" id="913">913</a> |
| 915 | +<a href="#914" id="914">914</a> |
| 916 | +<a href="#915" id="915">915</a> |
| 917 | +<a href="#916" id="916">916</a> |
| 918 | +<a href="#917" id="917">917</a> |
| 919 | +<a href="#918" id="918">918</a> |
| 920 | +<a href="#919" id="919">919</a> |
| 921 | +<a href="#920" id="920">920</a> |
| 922 | +<a href="#921" id="921">921</a> |
| 923 | +<a href="#922" id="922">922</a> |
| 924 | +<a href="#923" id="923">923</a> |
| 925 | +<a href="#924" id="924">924</a> |
| 926 | +<a href="#925" id="925">925</a> |
| 927 | +<a href="#926" id="926">926</a> |
| 928 | +<a href="#927" id="927">927</a> |
| 929 | +<a href="#928" id="928">928</a> |
| 930 | +<a href="#929" id="929">929</a> |
| 931 | +<a href="#930" id="930">930</a> |
| 932 | +<a href="#931" id="931">931</a> |
| 933 | +<a href="#932" id="932">932</a> |
| 934 | +<a href="#933" id="933">933</a> |
| 935 | +<a href="#934" id="934">934</a> |
| 936 | +<a href="#935" id="935">935</a> |
| 937 | +<a href="#936" id="936">936</a> |
| 938 | +<a href="#937" id="937">937</a> |
| 939 | +<a href="#938" id="938">938</a> |
| 940 | +<a href="#939" id="939">939</a> |
| 941 | +<a href="#940" id="940">940</a> |
| 942 | +<a href="#941" id="941">941</a> |
| 943 | +<a href="#942" id="942">942</a> |
| 944 | +<a href="#943" id="943">943</a> |
| 945 | +<a href="#944" id="944">944</a> |
| 946 | +<a href="#945" id="945">945</a> |
| 947 | +<a href="#946" id="946">946</a> |
| 948 | +<a href="#947" id="947">947</a> |
| 949 | +<a href="#948" id="948">948</a> |
| 950 | +<a href="#949" id="949">949</a> |
| 951 | +<a href="#950" id="950">950</a> |
| 952 | +<a href="#951" id="951">951</a> |
| 953 | +<a href="#952" id="952">952</a> |
| 954 | +<a href="#953" id="953">953</a> |
| 955 | +<a href="#954" id="954">954</a> |
| 956 | +<a href="#955" id="955">955</a> |
| 957 | +<a href="#956" id="956">956</a> |
| 958 | +<a href="#957" id="957">957</a> |
| 959 | +<a href="#958" id="958">958</a> |
| 960 | +<a href="#959" id="959">959</a> |
| 961 | +<a href="#960" id="960">960</a> |
| 962 | +<a href="#961" id="961">961</a> |
| 963 | +<a href="#962" id="962">962</a> |
| 964 | +<a href="#963" id="963">963</a> |
| 965 | +<a href="#964" id="964">964</a> |
| 966 | +<a href="#965" id="965">965</a> |
| 967 | +<a href="#966" id="966">966</a> |
| 968 | +<a href="#967" id="967">967</a> |
| 969 | +<a href="#968" id="968">968</a> |
| 970 | +<a href="#969" id="969">969</a> |
| 971 | +<a href="#970" id="970">970</a> |
| 972 | +<a href="#971" id="971">971</a> |
| 973 | +<a href="#972" id="972">972</a> |
| 974 | +<a href="#973" id="973">973</a> |
| 975 | +<a href="#974" id="974">974</a> |
| 976 | +<a href="#975" id="975">975</a> |
| 977 | +<a href="#976" id="976">976</a> |
| 978 | +<a href="#977" id="977">977</a> |
| 979 | +<a href="#978" id="978">978</a> |
| 980 | +<a href="#979" id="979">979</a> |
| 981 | +<a href="#980" id="980">980</a> |
| 982 | +<a href="#981" id="981">981</a> |
| 983 | +<a href="#982" id="982">982</a> |
| 984 | +<a href="#983" id="983">983</a> |
| 985 | +<a href="#984" id="984">984</a> |
| 986 | +<a href="#985" id="985">985</a> |
| 987 | +<a href="#986" id="986">986</a> |
| 988 | +</pre></div><pre class="rust"><code><span class="kw">use </span><span class="kw">crate</span>::front::wgsl::parse::directive::enable_extension::{ |
| 989 | + EnableExtension, UnimplementedEnableExtension, |
| 990 | +}; |
| 991 | +<span class="kw">use </span><span class="kw">crate</span>::front::wgsl::parse::directive::{DirectiveKind, UnimplementedDirectiveKind}; |
912 | 992 | <span class="kw">use </span><span class="kw">crate</span>::front::wgsl::parse::lexer::Token; |
913 | 993 | <span class="kw">use </span><span class="kw">crate</span>::front::wgsl::Scalar; |
914 | 994 | <span class="kw">use </span><span class="kw">crate</span>::proc::{Alignment, ConstantEvaluatorError, ResolveError}; |
|
1022 | 1102 | </span><span class="kw">pub enum </span>ExpectedToken<<span class="lifetime">'a</span>> { |
1023 | 1103 | Token(Token<<span class="lifetime">'a</span>>), |
1024 | 1104 | Identifier, |
| 1105 | + AfterIdentListComma, |
| 1106 | + AfterIdentListArg, |
1025 | 1107 | <span class="doccomment">/// Expected: constant, parenthesized expression, identifier |
1026 | 1108 | </span>PrimaryExpression, |
1027 | 1109 | <span class="doccomment">/// Expected: assignment, increment/decrement expression |
|
1094 | 1176 | UnknownType(Span), |
1095 | 1177 | UnknownStorageFormat(Span), |
1096 | 1178 | UnknownConservativeDepth(Span), |
| 1179 | + UnknownEnableExtension(Span, <span class="kw-2">&</span><span class="lifetime">'a </span>str), |
1097 | 1180 | SizeAttributeTooLow(Span, u32), |
1098 | 1181 | AlignAttributeTooLow(Span, Alignment), |
1099 | 1182 | NonPowerOfTwoAlignAttribute(Span), |
|
1183 | 1266 | DirectiveAfterFirstGlobalDecl { |
1184 | 1267 | directive_span: Span, |
1185 | 1268 | }, |
| 1269 | + EnableExtensionNotYetImplemented { |
| 1270 | + kind: UnimplementedEnableExtension, |
| 1271 | + span: Span, |
| 1272 | + }, |
| 1273 | + EnableExtensionNotEnabled { |
| 1274 | + kind: EnableExtension, |
| 1275 | + span: Span, |
| 1276 | + }, |
1186 | 1277 | } |
1187 | 1278 |
|
1188 | 1279 | <span class="attr">#[derive(Clone, Debug)] |
|
1255 | 1346 | ExpectedToken::Type => <span class="string">"type"</span>.to_string(), |
1256 | 1347 | ExpectedToken::Variable => <span class="string">"variable access"</span>.to_string(), |
1257 | 1348 | ExpectedToken::Function => <span class="string">"function name"</span>.to_string(), |
| 1349 | + ExpectedToken::AfterIdentListArg => { |
| 1350 | + <span class="string">"next argument, trailing comma, or end of list (',' or ';')"</span>.to_string() |
| 1351 | + } |
| 1352 | + ExpectedToken::AfterIdentListComma => { |
| 1353 | + <span class="string">"next argument or end of list (';')"</span>.to_string() |
| 1354 | + } |
1258 | 1355 | }; |
1259 | 1356 | ParseError { |
1260 | 1357 | message: <span class="macro">format!</span>( |
|
1427 | 1524 | labels: <span class="macro">vec!</span>[(bad_span, <span class="string">"unknown type"</span>.into())], |
1428 | 1525 | notes: <span class="macro">vec!</span>[], |
1429 | 1526 | }, |
| 1527 | + Error::UnknownEnableExtension(span, word) => ParseError { |
| 1528 | + message: <span class="macro">format!</span>(<span class="string">"unknown enable-extension `{}`"</span>, word), |
| 1529 | + labels: <span class="macro">vec!</span>[(span, <span class="string">""</span>.into())], |
| 1530 | + notes: <span class="macro">vec!</span>[ |
| 1531 | + <span class="string">"See available extensions at <https://www.w3.org/TR/WGSL/#enable-extension>." |
| 1532 | + </span>.into(), |
| 1533 | + ], |
| 1534 | + }, |
1430 | 1535 | Error::SizeAttributeTooLow(bad_span, min_size) => ParseError { |
1431 | 1536 | message: <span class="macro">format!</span>(<span class="string">"struct member size must be at least {min_size}"</span>), |
1432 | 1537 | labels: <span class="macro">vec!</span>[(bad_span, <span class="macro">format!</span>(<span class="string">"must be at least {min_size}"</span>).into())], |
|
1809 | 1914 | </span>) |
1810 | 1915 | .into()], |
1811 | 1916 | }, |
| 1917 | + Error::EnableExtensionNotYetImplemented { kind, span } => ParseError { |
| 1918 | + message: <span class="macro">format!</span>( |
| 1919 | + <span class="string">"the `{}` extension is not yet supported"</span>, |
| 1920 | + EnableExtension::Unimplemented(kind).to_ident() |
| 1921 | + ), |
| 1922 | + labels: <span class="macro">vec!</span>[( |
| 1923 | + span, |
| 1924 | + <span class="macro">concat!</span>( |
| 1925 | + <span class="string">"this extension specifies standard functionality "</span>, |
| 1926 | + <span class="string">"which is not yet implemented in Naga" |
| 1927 | + </span>) |
| 1928 | + .into(), |
| 1929 | + )], |
| 1930 | + notes: <span class="macro">vec!</span>[<span class="macro">format!</span>( |
| 1931 | + <span class="macro">concat!</span>( |
| 1932 | + <span class="string">"Let Naga maintainers know that you ran into this at "</span>, |
| 1933 | + <span class="string">"<https://github.com/gfx-rs/wgpu/issues/{}>, "</span>, |
| 1934 | + <span class="string">"so they can prioritize it!" |
| 1935 | + </span>), |
| 1936 | + kind.tracking_issue_num() |
| 1937 | + )], |
| 1938 | + }, |
| 1939 | + Error::EnableExtensionNotEnabled { kind, span } => ParseError { |
| 1940 | + message: <span class="macro">format!</span>(<span class="string">"`{}` enable extension is not enabled"</span>, kind.to_ident()), |
| 1941 | + labels: <span class="macro">vec!</span>[( |
| 1942 | + span, |
| 1943 | + <span class="macro">format!</span>( |
| 1944 | + <span class="macro">concat!</span>( |
| 1945 | + <span class="string">"the `{}` enable extension is needed for this functionality, "</span>, |
| 1946 | + <span class="string">"but it is not currently enabled" |
| 1947 | + </span>), |
| 1948 | + kind.to_ident() |
| 1949 | + ) |
| 1950 | + .into(), |
| 1951 | + )], |
| 1952 | + notes: <span class="kw">if let </span>EnableExtension::Unimplemented(kind) = kind { |
| 1953 | + <span class="macro">vec!</span>[<span class="macro">format!</span>( |
| 1954 | + <span class="macro">concat!</span>( |
| 1955 | + <span class="string">"This extension is not yet implemented. "</span>, |
| 1956 | + <span class="string">"Let Naga maintainers know that you ran into this at "</span>, |
| 1957 | + <span class="string">"<https://github.com/gfx-rs/wgpu/issues/{}>, "</span>, |
| 1958 | + <span class="string">"so they can prioritize it!" |
| 1959 | + </span>), |
| 1960 | + kind.tracking_issue_num() |
| 1961 | + )] |
| 1962 | + } <span class="kw">else </span>{ |
| 1963 | + <span class="macro">vec!</span>[] |
| 1964 | + }, |
| 1965 | + }, |
1812 | 1966 | } |
1813 | 1967 | } |
1814 | 1968 | } |
|
0 commit comments