[wgsl] fix boolean types and bang parsing

This commit is contained in:
Dzmitry Malyshau
2021-02-15 22:54:25 -05:00
committed by Dzmitry Malyshau
parent 91a1f581e0
commit e6251a23fe
3 changed files with 6 additions and 0 deletions

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -216,5 +216,6 @@ fn parse_expressions() {
parse_str("fn foo() {
const x: f32 = select(0.0, 1.0, true);
const y: vec2<f32> = select(vec2<f32>(1.0, 1.0), vec2<f32>(x, x), vec2<bool>(x < 0.5, x > 0.5));
const z: bool = !(0.0 == 1.0);
}").unwrap();
}