]> git.tdb.fi Git - libs/gl.git/commitdiff
Ignore precedence for prefix operators
authorMikko Rasa <tdb@tdb.fi>
Fri, 5 Mar 2021 22:33:44 +0000 (00:33 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 5 Mar 2021 23:00:31 +0000 (01:00 +0200)
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

index c924606f09c018c33388b020ec23100aa5a291f4..d2261126a652d109deba3c4193713568dc317616 100644 (file)
@@ -447,7 +447,8 @@ RefPtr<Expression> 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;