From bbcd5f8fceaac9327a5ec2a17cbf8b55bfcc4945 Mon Sep 17 00:00:00 2001 From: Mischa Date: Fri, 9 Jan 2026 22:12:36 -0800 Subject: [PATCH] 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 --- vendor/hlslparser/src/HLSLParser.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vendor/hlslparser/src/HLSLParser.cpp b/vendor/hlslparser/src/HLSLParser.cpp index aaf73007c..6b798d561 100644 --- a/vendor/hlslparser/src/HLSLParser.cpp +++ b/vendor/hlslparser/src/HLSLParser.cpp @@ -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; }