[glsl-in] Avoid infinite loop when parsing invalid statements (#1280)

This commit is contained in:
fsh
2021-08-24 21:46:54 +02:00
committed by GitHub
parent a35de06f33
commit f11afd4fcf

View File

@@ -493,25 +493,16 @@ impl<'source> ParsingContext<'source> {
meta
}
TokenValue::Plus
| TokenValue::Dash
| TokenValue::Bang
| TokenValue::Tilde
| TokenValue::LeftParen
| TokenValue::Increment
| TokenValue::Decrement
| TokenValue::Identifier(_)
| TokenValue::TypeName(_)
| TokenValue::IntConstant(_)
| TokenValue::BoolConstant(_)
| TokenValue::FloatConstant(_) => {
TokenValue::Semicolon => self.bump(parser)?.meta,
_ => {
// Attempt to force expression parsing for remainder of the
// tokens. Unknown or invalid tokens will be caught there and
// turned into an error.
let mut stmt = ctx.stmt_ctx();
let expr = self.parse_expression(parser, ctx, &mut stmt, body)?;
ctx.lower(stmt, parser, expr, ExprPos::Rhs, body)?;
self.expect(parser, TokenValue::Semicolon)?.meta
}
TokenValue::Semicolon => self.bump(parser)?.meta,
_ => meta,
};
Ok(Some(meta.union(&meta_rest)))