From e6251a23fe011ccb3136458144e4678be074ab7f Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Mon, 15 Feb 2021 22:54:25 -0500 Subject: [PATCH] [wgsl] fix boolean types and bang parsing --- src/front/wgsl/lexer.rs | 1 + src/front/wgsl/mod.rs | 4 ++++ src/front/wgsl/tests.rs | 1 + 3 files changed, 6 insertions(+) diff --git a/src/front/wgsl/lexer.rs b/src/front/wgsl/lexer.rs index a7eefe51db..8b13c1aee7 100644 --- a/src/front/wgsl/lexer.rs +++ b/src/front/wgsl/lexer.rs @@ -130,6 +130,7 @@ fn consume_token(mut input: &str) -> (Token<'_>, &str) { } '+' | '*' | '/' | '%' | '^' => (Token::Operation(cur), chars.as_str()), '!' => { + input = chars.as_str(); if chars.next() == Some('=') { (Token::LogicalOperation(cur), chars.as_str()) } else { diff --git a/src/front/wgsl/mod.rs b/src/front/wgsl/mod.rs index b096dc6ea1..4f3a56fae6 100644 --- a/src/front/wgsl/mod.rs +++ b/src/front/wgsl/mod.rs @@ -1258,6 +1258,10 @@ impl Parser { kind: crate::ScalarKind::Uint, width: 4, }, + "bool" => crate::TypeInner::Scalar { + kind: crate::ScalarKind::Bool, + width: 1, + }, "vec2" => { let (kind, width) = lexer.next_scalar_generic()?; crate::TypeInner::Vector { diff --git a/src/front/wgsl/tests.rs b/src/front/wgsl/tests.rs index 4fdfc1088b..2c0c928536 100644 --- a/src/front/wgsl/tests.rs +++ b/src/front/wgsl/tests.rs @@ -216,5 +216,6 @@ fn parse_expressions() { parse_str("fn foo() { const x: f32 = select(0.0, 1.0, true); const y: vec2 = select(vec2(1.0, 1.0), vec2(x, x), vec2(x < 0.5, x > 0.5)); + const z: bool = !(0.0 == 1.0); }").unwrap(); }