mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-02-04 16:15:46 +00:00
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:
14
vendor/hlslparser/src/HLSLParser.cpp
vendored
14
vendor/hlslparser/src/HLSLParser.cpp
vendored
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user