]> git.tdb.fi Git - libs/gl.git/commitdiff
Add a new associativity type for fully associative operators
authorMikko Rasa <tdb@tdb.fi>
Wed, 3 Mar 2021 18:06:12 +0000 (20:06 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 4 Mar 2021 00:26:15 +0000 (02:26 +0200)
source/glsl/syntax.cpp
source/glsl/syntax.h

index c60b33bf5bad26b86d2b0abc53b7ba442b451ce2..b74f482aa8df5a21dfffebc23c2f2b6fb8a8dd21 100644 (file)
@@ -21,10 +21,10 @@ const Operator Operator::operators[] =
        { "-", 3, PREFIX, RIGHT_TO_LEFT },
        { "~", 3, PREFIX, RIGHT_TO_LEFT },
        { "!", 3, PREFIX, RIGHT_TO_LEFT },
-       { "*", 4, BINARY, LEFT_TO_RIGHT },
+       { "*", 4, BINARY, ASSOCIATIVE },
        { "/", 4, BINARY, LEFT_TO_RIGHT },
        { "%", 4, BINARY, LEFT_TO_RIGHT },
-       { "+", 5, BINARY, LEFT_TO_RIGHT },
+       { "+", 5, BINARY, ASSOCIATIVE },
        { "-", 5, BINARY, LEFT_TO_RIGHT },
        { "<<", 6, BINARY, LEFT_TO_RIGHT },
        { ">>", 6, BINARY, LEFT_TO_RIGHT },
@@ -34,12 +34,12 @@ const Operator Operator::operators[] =
        { ">=", 7, BINARY, LEFT_TO_RIGHT },
        { "==", 8, BINARY, LEFT_TO_RIGHT },
        { "!=", 8, BINARY, LEFT_TO_RIGHT },
-       { "&", 9, BINARY, LEFT_TO_RIGHT },
-       { "^", 10, BINARY, LEFT_TO_RIGHT },
-       { "|", 11, BINARY, LEFT_TO_RIGHT },
-       { "&&", 12, BINARY, LEFT_TO_RIGHT },
-       { "^^", 13, BINARY, LEFT_TO_RIGHT },
-       { "||", 14, BINARY, LEFT_TO_RIGHT },
+       { "&", 9, BINARY, ASSOCIATIVE },
+       { "^", 10, BINARY, ASSOCIATIVE },
+       { "|", 11, BINARY, ASSOCIATIVE },
+       { "&&", 12, BINARY, ASSOCIATIVE },
+       { "^^", 13, BINARY, ASSOCIATIVE },
+       { "||", 14, BINARY, ASSOCIATIVE },
        { "?", 15, BINARY, RIGHT_TO_LEFT },
        { ":", 15, BINARY, RIGHT_TO_LEFT },
        { "=", 16, BINARY, RIGHT_TO_LEFT },
index 682a0f5aeeaa2246b01226df25536a23a91d9c7a..0821ee5fe97c8780f836b0ce75f562c939de8d10 100644 (file)
@@ -30,7 +30,8 @@ struct Operator
        enum Associativity
        {
                LEFT_TO_RIGHT,
-               RIGHT_TO_LEFT
+               RIGHT_TO_LEFT,
+               ASSOCIATIVE
        };
 
        char token[4];