From: Mikko Rasa Date: Wed, 3 Mar 2021 18:06:12 +0000 (+0200) Subject: Add a new associativity type for fully associative operators X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=2b74d276f67d07e37b56aeebc474a58ceeea3e68;p=libs%2Fgl.git Add a new associativity type for fully associative operators --- diff --git a/source/glsl/syntax.cpp b/source/glsl/syntax.cpp index c60b33bf..b74f482a 100644 --- a/source/glsl/syntax.cpp +++ b/source/glsl/syntax.cpp @@ -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 }, diff --git a/source/glsl/syntax.h b/source/glsl/syntax.h index 682a0f5a..0821ee5f 100644 --- a/source/glsl/syntax.h +++ b/source/glsl/syntax.h @@ -30,7 +30,8 @@ struct Operator enum Associativity { LEFT_TO_RIGHT, - RIGHT_TO_LEFT + RIGHT_TO_LEFT, + ASSOCIATIVE }; char token[4];