mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[glsl-in] Add support for declaration statements
This commit is contained in:
committed by
Dzmitry Malyshau
parent
168a55396c
commit
fec67ced8e
@@ -1130,20 +1130,30 @@ impl<'source, 'program, 'options> Parser<'source, 'program, 'options> {
|
||||
ctx.remove_current_scope();
|
||||
body.push(Statement::Block(block));
|
||||
}
|
||||
// TODO: We should also add TypeName here because this is valid
|
||||
// ```glsl
|
||||
// vec4(1.0);
|
||||
// ```
|
||||
// But this would require us to add lookahead to also support
|
||||
// declarations and since this statement is very unlikely and most
|
||||
// likely an error, for now we don't support it
|
||||
TokenValue::Plus
|
||||
| TokenValue::Dash
|
||||
| TokenValue::Bang
|
||||
| TokenValue::Tilde
|
||||
| TokenValue::LeftParen
|
||||
| TokenValue::Identifier(_)
|
||||
| TokenValue::TypeName(_)
|
||||
| TokenValue::IntConstant(_)
|
||||
| TokenValue::BoolConstant(_)
|
||||
| TokenValue::FloatConstant(_) => {
|
||||
self.parse_expression(ctx)?;
|
||||
self.expect(TokenValue::Semicolon)?;
|
||||
}
|
||||
_ => {}
|
||||
_ => {
|
||||
if self.peek_type_name() || self.peek_type_qualifier() {
|
||||
self.parse_declaration(ctx, body, false)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -116,10 +116,9 @@ fn control_flow() {
|
||||
let _program = parse_program(
|
||||
r#"
|
||||
# version 450
|
||||
int x;
|
||||
int y;
|
||||
|
||||
void main() {
|
||||
int x;
|
||||
int y = 3;
|
||||
switch (5) {
|
||||
case 2:
|
||||
x = 2;
|
||||
@@ -138,9 +137,8 @@ fn control_flow() {
|
||||
let _program = parse_program(
|
||||
r#"
|
||||
# version 450
|
||||
int x;
|
||||
|
||||
void main() {
|
||||
int x = 0;
|
||||
while(x < 5) {
|
||||
x = x + 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user