X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fsyntax.cpp;h=c60b33bf5bad26b86d2b0abc53b7ba442b451ce2;hb=19a24f859cd7fcf581442319499ae24b3e7385a4;hp=90e26c39a37c24d663dc8846bb172f65007ec694;hpb=4df8fcb07f21b450d3885eaec39dc4bcf3f07f81;p=libs%2Fgl.git diff --git a/source/glsl/syntax.cpp b/source/glsl/syntax.cpp index 90e26c39..c60b33bf 100644 --- a/source/glsl/syntax.cpp +++ b/source/glsl/syntax.cpp @@ -1,3 +1,4 @@ +#include #include "syntax.h" #include "visitor.h" @@ -10,7 +11,7 @@ namespace SL { const Operator Operator::operators[] = { { "[", 2, BINARY, LEFT_TO_RIGHT }, - { "(", 2, BINARY, LEFT_TO_RIGHT }, + { "(", 2, POSTFIX, LEFT_TO_RIGHT }, { ".", 2, BINARY, LEFT_TO_RIGHT }, { "++", 2, POSTFIX, LEFT_TO_RIGHT }, { "--", 2, POSTFIX, LEFT_TO_RIGHT }, @@ -56,6 +57,14 @@ const Operator Operator::operators[] = { { 0 }, 18, NO_OPERATOR, LEFT_TO_RIGHT } }; +const Operator &Operator::get_operator(const string &token, Type type) +{ + for(const Operator *i=operators; i->type; ++i) + if(i->type==type && i->token==token) + return *i; + throw key_error(token); +} + template NodeContainer::NodeContainer(const NodeContainer &c): @@ -90,6 +99,11 @@ void Block::visit(NodeVisitor &visitor) } +Expression::Expression(): + oper(0) +{ } + + void Literal::visit(NodeVisitor &visitor) { visitor.visit(*this); @@ -151,10 +165,6 @@ void MemberAccess::visit(NodeVisitor &visitor) } -UnaryExpression::UnaryExpression(): - prefix(true) -{ } - void UnaryExpression::visit(NodeVisitor &visitor) { visitor.visit(*this);