[opengtl-commits] [426] also pare typed coumpound expression from a binary expression

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 426
Author:   cyrille
Date:     2008-10-06 14:17:44 +0200 (Mon, 06 Oct 2008)

Log Message:
-----------
also pare typed coumpound expression from a binary expression

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h


Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-10-06 12:03:38 UTC (rev 425)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-10-06 12:17:44 UTC (rev 426)
@@ -368,6 +368,32 @@
   }
 }
 
+AST::Expression* ParserBase::parseTypeCoumpoundExpression(bool _constantExpression )
+{
+  const Type* type = parseType();
+  if( isOfType( d->currentToken, Token::STARTBRACKET ) )
+  {
+    AST::Expression* expression = 0;
+    if( type->dataType() == Type::VECTOR or type->dataType() == Type::ARRAY or type->dataType() == Type::STRUCTURE )
+    {
+      expression = parseCoumpoundExpression( type, _constantExpression);
+    } else {
+      getNextToken();
+      expression = parseExpression(_constantExpression, type);
+      isOfType( currentToken(), Token::ENDBRACKET );
+      getNextToken();
+    }
+    if( expression )
+    {
+      return d->compiler->convertCenter()->createConvertExpression( expression, type );
+    }
+  } else {
+    GTL_DEBUG("unexpected");
+    reportUnexpected( d->currentToken );
+  }
+  return 0;
+}
+
 AST::Expression* ParserBase::parseExpression(bool _constantExpression, const GTLCore::Type* _type)
 {
   // The first token of an expression is either a primary, or an unary expression or a parenthesis
@@ -425,28 +451,7 @@
       return new AST::GlobalDataExpression( coumpoundExpression );
     }
   } else if( isType(currentToken()) ) {
-    const Type* type = parseType();
-    if( isOfType( d->currentToken, Token::STARTBRACKET ) )
-    {
-      AST::Expression* expression = 0;
-      if( type->dataType() == Type::VECTOR or type->dataType() == Type::ARRAY or type->dataType() == Type::STRUCTURE )
-      {
-        expression = parseCoumpoundExpression( type, _constantExpression);
-      } else {
-        getNextToken();
-        expression = parseExpression(_constantExpression, type);
-        isOfType( currentToken(), Token::ENDBRACKET );
-        getNextToken();
-      }
-      if( expression )
-      {
-        return d->compiler->convertCenter()->createConvertExpression( expression, type );
-      }
-    } else {
-      GTL_DEBUG("unexpected");
-      reportUnexpected( d->currentToken );
-    }
-    return 0;
+    return parseTypeCoumpoundExpression( _constantExpression );
   } else {
     GTL_DEBUG("unexpected");
     reportUnexpected( d->currentToken );
@@ -504,8 +509,10 @@
         AST::Expression* coumpoundExpression = parseCoumpoundExpression( _lhs->type() , true );
         if( coumpoundExpression )
         {
-          return new AST::GlobalDataExpression( coumpoundExpression );
+          expr = new AST::GlobalDataExpression( coumpoundExpression );
         }
+      } else if( isType(currentToken()) ) {
+        expr = parseTypeCoumpoundExpression(_constantExpression);      
       } else {
         GTL_DEBUG("unexpected");
         reportUnexpected( d->currentToken );

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h	2008-10-06 12:03:38 UTC (rev 425)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h	2008-10-06 12:17:44 UTC (rev 426)
@@ -122,6 +122,10 @@
       std::list< AST::Expression* > parseArraySize(bool _constantExpression);
       AST::AccessorExpression* parseMemberArrayExpression(AST::AccessorExpression* _expression, bool _constantExpression);
       /**
+       * Parse coumpound expression ( float3( 1, 2, 6 ) )
+       */
+      AST::Expression* parseTypeCoumpoundExpression(bool _constantExpression );
+      /**
        * Parse coumpound expression ( { 1, 2, { 4, 5, 6 } } )
        */
       AST::Expression* parseCoumpoundExpression( const Type* _type, bool _constantExpression );


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/