From e8542d921a07b7391d558cb3349a68f26675f797 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 6 Mar 2021 00:33:44 +0200 Subject: [PATCH] Ignore precedence for prefix operators Since the operator appears at the start of an expression or after another operator, there's no way for it to bind to anything but whatever follows. This fixes a bug where chained prefix operators were not recognized. --- source/glsl/parser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/glsl/parser.cpp b/source/glsl/parser.cpp index c924606f..d2261126 100644 --- a/source/glsl/parser.cpp +++ b/source/glsl/parser.cpp @@ -447,7 +447,8 @@ RefPtr Parser::parse_expression(unsigned precedence) if(token==i->token && (!left || i->type!=Operator::PREFIX) && (left || i->type!=Operator::POSTFIX)) oper = i; - if(token==";" || token==")" || token=="]" || token=="," || (oper && precedence && oper->precedence>=precedence)) + bool lower_precedence = (oper && oper->type!=Operator::PREFIX && precedence && oper->precedence>=precedence); + if(token==";" || token==")" || token=="]" || token=="," || lower_precedence) { if(left) return left; -- 2.45.2