Skip to content

Commit bbcd5f8

Browse files
committed
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
1 parent 014fb59 commit bbcd5f8

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

vendor/hlslparser/src/HLSLParser.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,6 +2283,20 @@ bool HLSLParser::ParseBinaryExpression(int priority, HLSLExpression*& expression
22832283
}
22842284
else
22852285
{
2286+
// Before breaking, consume end char if needed and check for more operators
2287+
if( needsExpressionEndChar != 0 )
2288+
{
2289+
if( !Expect(needsExpressionEndChar) )
2290+
return false;
2291+
needsExpressionEndChar = 0;
2292+
2293+
// After consuming end char, check if there's a binary operator to continue
2294+
if (AcceptBinaryOperator(priority, binaryOp))
2295+
{
2296+
acceptBinaryOp = true;
2297+
continue;
2298+
}
2299+
}
22862300
break;
22872301
}
22882302

0 commit comments

Comments
 (0)