Fix HLSLParser failing on parenthesized expressions in declarations

The parser rejected valid HLSL like `float2 var = (float2(x,y)) * scalar`
with "expected ';'" errors. When parsing a parenthesized expression, the
loop would break before consuming the closing paren, so subsequent binary
operators were never seen.

Moves end-char consumption into the else block and checks for operators
after consuming the paren, continuing the loop if one is found.

Fixes #940
This commit is contained in:
Mischa
2026-01-09 22:12:36 -08:00
parent 014fb59dd5
commit bbcd5f8fce

View File

@ -2283,6 +2283,20 @@ bool HLSLParser::ParseBinaryExpression(int priority, HLSLExpression*& expression
}
else
{
// Before breaking, consume end char if needed and check for more operators
if( needsExpressionEndChar != 0 )
{
if( !Expect(needsExpressionEndChar) )
return false;
needsExpressionEndChar = 0;
// After consuming end char, check if there's a binary operator to continue
if (AcceptBinaryOperator(priority, binaryOp))
{
acceptBinaryOp = true;
continue;
}
}
break;
}