From cb6d3fa8156ac4ecad80224c517c875e9b0791e8 Mon Sep 17 00:00:00 2001 From: Igor Shaposhnik Date: Wed, 24 Nov 2021 17:59:36 +0300 Subject: [PATCH] [wgsl] Move backend keyword list into its own module --- src/back/wgsl/mod.rs | 1 - src/back/wgsl/writer.rs | 2 +- src/keywords/mod.rs | 2 + .../wgsl/keywords.rs => keywords/wgsl.rs} | 268 +++++++++--------- src/lib.rs | 1 + 5 files changed, 138 insertions(+), 136 deletions(-) create mode 100644 src/keywords/mod.rs rename src/{back/wgsl/keywords.rs => keywords/wgsl.rs} (94%) diff --git a/src/back/wgsl/mod.rs b/src/back/wgsl/mod.rs index 2d8392c62..2f35311e6 100644 --- a/src/back/wgsl/mod.rs +++ b/src/back/wgsl/mod.rs @@ -1,4 +1,3 @@ -mod keywords; mod writer; use thiserror::Error; diff --git a/src/back/wgsl/writer.rs b/src/back/wgsl/writer.rs index 641c61e0a..6d5b2016a 100644 --- a/src/back/wgsl/writer.rs +++ b/src/back/wgsl/writer.rs @@ -73,7 +73,7 @@ impl Writer { fn reset(&mut self, module: &Module) { self.names.clear(); self.namer - .reset(module, super::keywords::RESERVED, &[], &mut self.names); + .reset(module, crate::keywords::wgsl::RESERVED, &[], &mut self.names); self.named_expressions.clear(); self.ep_results.clear(); } diff --git a/src/keywords/mod.rs b/src/keywords/mod.rs new file mode 100644 index 000000000..67101a1c1 --- /dev/null +++ b/src/keywords/mod.rs @@ -0,0 +1,2 @@ +#[cfg(any(feature = "wgsl-in", feature = "wgsl-out"))] +pub mod wgsl; \ No newline at end of file diff --git a/src/back/wgsl/keywords.rs b/src/keywords/wgsl.rs similarity index 94% rename from src/back/wgsl/keywords.rs rename to src/keywords/wgsl.rs index f40ecd0ce..16e11ea3d 100644 --- a/src/back/wgsl/keywords.rs +++ b/src/keywords/wgsl.rs @@ -1,134 +1,134 @@ -// https://gpuweb.github.io/gpuweb/wgsl/#keyword-summary -pub const RESERVED: &[&str] = &[ - // type-defining keywords - "array", - "atomic", - "bool", - "float32", - "int32", - "mat2x2", - "mat2x3", - "mat2x4", - "mat3x2", - "mat3x3", - "mat3x4", - "mat4x2", - "mat4x3", - "mat4x4", - "pointer", - "sampler", - "sampler_comparison", - "struct", - "texture_1d", - "texture_2d", - "texture_2d_array", - "texture_3d", - "texture_cube", - "texture_cube_array", - "texture_multisampled_2d", - "texture_storage_1d", - "texture_storage_2d", - "texture_storage_2d_array", - "texture_storage_3d", - "texture_depth_2d", - "texture_depth_2d_array", - "texture_depth_cube", - "texture_depth_cube_array", - "texture_depth_multisampled_2d", - "uint32", - "vec2", - "vec3", - "vec4", - // other keywords - "bitcast", - "block", - "break", - "case", - "continue", - "continuing", - "default", - "discard", - "else", - "else_if", - "enable", - "fallthrough", - "false", - "fn", - "for", - "function", - "if", - "let", - "loop", - "private", - "read", - "read_write", - "return", - "storage", - "switch", - "true", - "type", - "uniform", - "var", - "workgroup", - "write", - // image format keywords - "r8unorm", - "r8snorm", - "r8uint", - "r8sint", - "r16uint", - "r16sint", - "r16float", - "rg8unorm", - "rg8snorm", - "rg8uint", - "rg8sint", - "r32uint", - "r32sint", - "r32float", - "rg16uint", - "rg16sint", - "rg16float", - "rgba8unorm", - "rgba8unorm_srgb", - "rgba8snorm", - "rgba8uint", - "rgba8sint", - "bgra8unorm", - "bgra8unorm_srgb", - "rgb10a2unorm", - "rg11b10float", - "rg32uint", - "rg32sint", - "rg32float", - "rgba16uint", - "rgba16sint", - "rgba16float", - "rgba32uint", - "rgba32sint", - "rgba32float", - // reserved keywords - "asm", - "bf16", - "const", - "do", - "enum", - "f16", - "f64", - "handle", - "i8", - "i16", - "i64", - "mat", - "premerge", - "regardless", - "typedef", - "u8", - "u16", - "u64", - "unless", - "using", - "vec", - "void", - "while", -]; +// https://gpuweb.github.io/gpuweb/wgsl/#keyword-summary +pub const RESERVED: &[&str] = &[ + // type-defining keywords + "array", + "atomic", + "bool", + "float32", + "int32", + "mat2x2", + "mat2x3", + "mat2x4", + "mat3x2", + "mat3x3", + "mat3x4", + "mat4x2", + "mat4x3", + "mat4x4", + "pointer", + "sampler", + "sampler_comparison", + "struct", + "texture_1d", + "texture_2d", + "texture_2d_array", + "texture_3d", + "texture_cube", + "texture_cube_array", + "texture_multisampled_2d", + "texture_storage_1d", + "texture_storage_2d", + "texture_storage_2d_array", + "texture_storage_3d", + "texture_depth_2d", + "texture_depth_2d_array", + "texture_depth_cube", + "texture_depth_cube_array", + "texture_depth_multisampled_2d", + "uint32", + "vec2", + "vec3", + "vec4", + // other keywords + "bitcast", + "block", + "break", + "case", + "continue", + "continuing", + "default", + "discard", + "else", + "else_if", + "enable", + "fallthrough", + "false", + "fn", + "for", + "function", + "if", + "let", + "loop", + "private", + "read", + "read_write", + "return", + "storage", + "switch", + "true", + "type", + "uniform", + "var", + "workgroup", + "write", + // image format keywords + "r8unorm", + "r8snorm", + "r8uint", + "r8sint", + "r16uint", + "r16sint", + "r16float", + "rg8unorm", + "rg8snorm", + "rg8uint", + "rg8sint", + "r32uint", + "r32sint", + "r32float", + "rg16uint", + "rg16sint", + "rg16float", + "rgba8unorm", + "rgba8unorm_srgb", + "rgba8snorm", + "rgba8uint", + "rgba8sint", + "bgra8unorm", + "bgra8unorm_srgb", + "rgb10a2unorm", + "rg11b10float", + "rg32uint", + "rg32sint", + "rg32float", + "rgba16uint", + "rgba16sint", + "rgba16float", + "rgba32uint", + "rgba32sint", + "rgba32float", + // reserved keywords + "asm", + "bf16", + "const", + "do", + "enum", + "f16", + "f64", + "handle", + "i8", + "i16", + "i64", + "mat", + "premerge", + "regardless", + "typedef", + "u8", + "u16", + "u64", + "unless", + "using", + "vec", + "void", + "while", +]; diff --git a/src/lib.rs b/src/lib.rs index 05506190e..d1a0e0ef2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -212,6 +212,7 @@ pub mod front; pub mod proc; mod span; pub mod valid; +pub(crate) mod keywords; pub use crate::arena::{Arena, Handle, Range, UniqueArena};