[opengtl-commits] [223] * allow "empty" for statements for(;;)

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


Revision: 223
Author:   cyrille
Date:     2008-06-24 21:32:08 +0200 (Tue, 24 Jun 2008)

Log Message:
-----------
* allow "empty" for statements for(;;)
* fix the expression parsing messing with priority (aka x*x + y*y < a was seen as x*x+ (y*y < a) instead of (x*x+y*y)<a )

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


Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.cpp	2008-06-24 19:30:00 UTC (rev 222)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.cpp	2008-06-24 19:32:08 UTC (rev 223)
@@ -163,11 +163,21 @@
 
 llvm::BasicBlock* ForStatement::generateStatement( GenerationContext& _context, llvm::BasicBlock* _bb) const
 {
-  llvm::BasicBlock* initBlock = m_initStatement->generateStatement( _context, _bb);
+  // Generate the init block
+  llvm::BasicBlock* initBlock = _bb;
+  if( m_initStatement )
+  {
+    initBlock = m_initStatement->generateStatement( _context, _bb);
+  }
+  // Generate the test block
   llvm::BasicBlock* testBlock = createBlock( _context );
   llvm::Value* test = m_testExpression->generateValue( _context, testBlock ).value();
+  // Generate the update block
   llvm::BasicBlock* updateBlock = createBlock( _context );
-  m_updateExpression->generateStatement( _context, updateBlock );
+  if( m_updateExpression )
+  {
+    m_updateExpression->generateStatement( _context, updateBlock );
+  }
   llvm::BasicBlock* startAction = createBlock( _context );
   llvm::BasicBlock* endAction = m_forStatement->generateStatement( _context, startAction );
   llvm::BasicBlock* after = createBlock( _context );

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-06-24 19:30:00 UTC (rev 222)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-06-24 19:32:08 UTC (rev 223)
@@ -52,14 +52,14 @@
 
 struct ParserBase::Context
 {
-  std::map< GTLCore::ScopedName, GTLCore::VariableNG* > variables;
+  std::map< ScopedName, VariableNG* > variables;
 };
 
 struct ParserBase::Private {
-  GTLCore::Token currentToken;
+  Token currentToken;
   CompilerBase* compiler;
   LexerBase* lexer;
-  GTLCore::String nameSpace;
+  String nameSpace;
   std::list< Context > contextes;
 };
 
@@ -79,52 +79,52 @@
   d->currentToken = d->lexer->nextToken();
 }
 
-const GTLCore::Token& ParserBase::currentToken()
+const Token& ParserBase::currentToken()
 {
   return d->currentToken;
 }
 
 void ParserBase::parseStructDefinition()
 {
-  GTL_ASSERT( d->currentToken.type == GTLCore::Token::STRUCT );
+  GTL_ASSERT( d->currentToken.type == Token::STRUCT );
   getNextToken();
-  if( isOfType( d->currentToken, GTLCore::Token::IDENTIFIER ) )
+  if( isOfType( d->currentToken, Token::IDENTIFIER ) )
   {
-    GTLCore::String name = d->currentToken.string;
+    String name = d->currentToken.string;
     getNextToken();
     if( d->compiler->typeManager()->d->isKnownType( name ) )
     { // It has allready been declared
       reportError( name + " has allready been declared", d->currentToken);
     } else {
-      std::vector<GTLCore::Type::StructDataMember> members;
-      if( isOfType( d->currentToken, GTLCore::Token::STARTBRACE ) )
+      std::vector<Type::StructDataMember> members;
+      if( isOfType( d->currentToken, Token::STARTBRACE ) )
       {
         getNextToken(); // Positionate on the first struct member
         while( true )
         { // Parse struct member
           if( isType(d->currentToken) )
           {
-            const GTLCore::Type* smtype = parseType();
+            const Type* smtype = parseType();
             GTL_ASSERT( smtype );
-            if( isOfType( d->currentToken, GTLCore::Token::IDENTIFIER ) )
+            if( isOfType( d->currentToken, Token::IDENTIFIER ) )
             {
-              GTLCore::String smname = d->currentToken.string;
+              String smname = d->currentToken.string;
               getNextToken();
               // Check if it's an array
               std::list<int> memberArraySize = expressionsListToIntegersList( parseArraySize(true) );
               smtype = d->compiler->typeManager()->getArray( smtype, memberArraySize.size() );
               // Check if expression end by a SEMI and add the struct member
-              if( isOfType( d->currentToken, GTLCore::Token::SEMI ) )
+              if( isOfType( d->currentToken, Token::SEMI ) )
               {
                 getNextToken();
-                members.push_back( GTLCore::Type::StructDataMember( smname, smtype, memberArraySize ) );
+                members.push_back( Type::StructDataMember( smname, smtype, memberArraySize ) );
               } else {
                 return;
               }
             } else {
               return;
             }
-          } else if( d->currentToken.type == GTLCore::Token::ENDBRACE )
+          } else if( d->currentToken.type == Token::ENDBRACE )
           {
             getNextToken();
             break;
@@ -134,7 +134,7 @@
             return;
           }
         }
-        if( isOfType( d->currentToken, GTLCore::Token::SEMI ) )
+        if( isOfType( d->currentToken, Token::SEMI ) )
         {
           getNextToken();
           d->compiler->typeManager()->d->createStructure( name, members);
@@ -146,17 +146,17 @@
 
 AST::AccessorExpression* ParserBase::parseMemberArrayExpression(AST::AccessorExpression* _expression, bool _constantExpression)
 {
-  if( d->currentToken.type == GTLCore::Token::DOT )
+  if( d->currentToken.type == Token::DOT )
   {
     getNextToken();
-    if( d->currentToken.type == GTLCore::Token::SIZE )
+    if( d->currentToken.type == Token::SIZE )
     {
       getNextToken(); // eat size
       return new AST::ArraySizeAccessorExpression( _expression );
-    } else if( isOfType( d->currentToken, GTLCore::Token::IDENTIFIER ) ) {
-      GTLCore::String name = d->currentToken.string;
+    } else if( isOfType( d->currentToken, Token::IDENTIFIER ) ) {
+      String name = d->currentToken.string;
       getNextToken();
-      if( d->currentToken.type == GTLCore::Token::STARTBRACKET )
+      if( d->currentToken.type == Token::STARTBRACKET )
       {
         getNextToken(); // Eat the start bracket
         const Type::StructFunctionMember* sfm = _expression->type()->d->functionMember( name );
@@ -171,11 +171,11 @@
         return parseMemberArrayExpression( new AST::StructAccessorExpression( _expression , _expression->type()->d->memberToIndex( name )  ), _constantExpression);
       }
     }
-  } else if( d->currentToken.type == GTLCore::Token::STARTBOXBRACKET )
+  } else if( d->currentToken.type == Token::STARTBOXBRACKET )
   {
     getNextToken();
     AST::Expression* expr = parseExpression( _constantExpression );
-    if( isOfType( d->currentToken, GTLCore::Token::ENDBOXBRACKET ) )
+    if( isOfType( d->currentToken, Token::ENDBOXBRACKET ) )
     {
       getNextToken();
       return parseMemberArrayExpression( new AST::ArrayAccessorExpression( _expression , expr  ), _constantExpression);
@@ -189,16 +189,16 @@
 std::list< AST::Expression* > ParserBase::parseArraySize(bool _constantExpression)
 {
   std::list< AST::Expression* > list_;
-  while( d->currentToken.type == GTLCore::Token::STARTBOXBRACKET )
+  while( d->currentToken.type == Token::STARTBOXBRACKET )
   {
     getNextToken();
-    if( d->currentToken.type == GTLCore::Token::ENDBOXBRACKET )
+    if( d->currentToken.type == Token::ENDBOXBRACKET )
     {
       getNextToken();
       list_.push_back( 0 );
     } else {
       AST::Expression* expr = parseExpression( _constantExpression );
-      if( expr and d->currentToken.type == GTLCore::Token::ENDBOXBRACKET )
+      if( expr and d->currentToken.type == Token::ENDBOXBRACKET )
       {
         getNextToken();
         list_.push_back( expr );
@@ -211,19 +211,19 @@
   return list_;
 }
 
-GTLCore::AST::CoumpoundExpression* ParserBase::parseCoumpoundExpression( const GTLCore::Type* _type, bool _constantExpression )
+AST::CoumpoundExpression* ParserBase::parseCoumpoundExpression( const Type* _type, bool _constantExpression )
 {
   GTL_ASSERT( _type );
-  GTL_ASSERT( d->currentToken.type == GTLCore::Token::STARTBRACE );
+  GTL_ASSERT( d->currentToken.type == Token::STARTBRACE );
   getNextToken(); // Eat '{'
-  std::vector< GTLCore::AST::Expression* > expressions_;
+  std::vector< AST::Expression* > expressions_;
   int index = 0;
   while(true)
   {
-    GTLCore::AST::Expression* expression = 0;
-    if( d->currentToken.type == GTLCore::Token::STARTBRACE )
+    AST::Expression* expression = 0;
+    if( d->currentToken.type == Token::STARTBRACE )
     {
-      const GTLCore::Type* type = 0;
+      const Type* type = 0;
       if ( _type->dataType() == Type::ARRAY )
       {
         type = _type->embeddedType();
@@ -235,16 +235,17 @@
       if( type->dataType() != Type::STRUCTURE and type->dataType() != Type::ARRAY )
       {
         reportUnexpected( d->currentToken );
+        return 0;
       }
       expression = parseCoumpoundExpression( type, _constantExpression );
     } else {
       expression = parseExpression( _constantExpression );
     }
     expressions_.push_back( expression );
-    if( d->currentToken.type == GTLCore::Token::COMA )
+    if( d->currentToken.type == Token::COMA )
     {
       getNextToken();
-    } else if( d->currentToken.type == GTLCore::Token::ENDBRACE )
+    } else if( d->currentToken.type == Token::ENDBRACE )
     {
       getNextToken();
       return new AST::CoumpoundExpression(_type, expressions_);
@@ -256,16 +257,16 @@
 AST::Expression* ParserBase::parseExpression(bool _constantExpression)
 {
   // The first token of an expression is either a primary, or an unary expression or a parenthesis
-  if( d->currentToken.type == GTLCore::Token::STARTBRACKET )
+  if( d->currentToken.type == Token::STARTBRACKET )
   {
     getNextToken();
     AST::Expression* expr = parseExpression(_constantExpression);
-    if( isOfType( d->currentToken, GTLCore::Token::ENDBRACKET ) )
+    if( expr and isOfType( d->currentToken, Token::ENDBRACKET ) )
     {
       getNextToken();
-      if( d->currentToken.isBinaryOperator() )
+      if( expr and d->currentToken.isBinaryOperator() )
       {
-        expr = parseBinaryOperator( _constantExpression, expr );
+        expr = parseFlatBinaryOperator( _constantExpression, expr );
       }
     }
     return expr;
@@ -279,7 +280,7 @@
       {
         return exprConst;
       } else if( d->currentToken.isBinaryOperator() ) {
-        return parseBinaryOperator( _constantExpression, exprConst );
+        return parseFlatBinaryOperator( _constantExpression, exprConst );
       } else {
         GTL_DEBUG("unexpected");
         reportUnexpected( d->currentToken );
@@ -298,8 +299,8 @@
     if( d->currentToken.isExpressionTerminal())
     {
       return expr;
-    } else if( d->currentToken.isBinaryOperator() ) {
-      return parseBinaryOperator( _constantExpression, expr );
+    } else if( expr and d->currentToken.isBinaryOperator() ) {
+      return parseFlatBinaryOperator( _constantExpression, expr );
     }
   } else {
     GTL_DEBUG("unexpected");
@@ -309,18 +310,136 @@
   return 0;
 }
 
-AST::Expression* ParserBase::parseBinaryOperator( bool _constantExpression, AST::Expression* lhs )
+#if 1
+AST::Expression* ParserBase::parseFlatBinaryOperator( bool _constantExpression, AST::Expression* _lhs)
 {
+  GTL_ASSERT(_lhs);
+  AST::Expression* current = _lhs;
+  while( d->currentToken.isBinaryOperator() )
+  {
+    GTL_DEBUG( "Looping in parseFlatBinaryOperator");
+    current = parseBinaryOperator( _constantExpression, current );
+    if( not current ) // An error has occured
+    {
+      return 0;
+    }
+  }
+  return current;
+}
+
+AST::Expression* ParserBase::parseBinaryOperator( bool _constantExpression, AST::Expression* _lhs)
+{
+  GTL_ASSERT(_lhs);
+  Token binOp = d->currentToken;
+  GTL_DEBUG( "parseBinaryOperator: " << binOp )
+  getNextToken();
+  AST::Expression* expr = 0;
+  while(true)
+  {
+    GTL_DEBUG( binOp << " " << expr );
+    // What's next ? A primary expression or an unary operator or a parenthesis
+    if( expr == 0 )
+    {
+      if( d->currentToken.type == Token::STARTBRACKET )
+      {
+        getNextToken();
+        expr = parseExpression(_constantExpression);
+        if( not isOfType( d->currentToken, Token::ENDBRACKET ) )
+        {
+          delete expr;
+          return 0;
+        }
+        getNextToken();
+      } else if( d->currentToken.isPrimary() )
+      {
+        expr = parsePrimaryExpression(_constantExpression);
+      } else if( d->currentToken.isUnaryOperator() ) {
+        expr = parseUnaryOperator(_constantExpression);
+      } else {
+        GTL_DEBUG("unexpected");
+        reportUnexpected( d->currentToken );
+        return 0;
+      }
+    }
+    // What's next, either a semi or an other binary operator
+    if( d->currentToken.isExpressionTerminal() ) {
+      GTL_DEBUG( binOp << " terminal" );
+      return createBinaryOperator( binOp, _lhs, expr);
+    } else if( d->currentToken.isBinaryOperator() ) {
+      GTL_DEBUG( binOp << " vs " << d->currentToken.isBinaryOperator());
+      GTL_ASSERT( binOp.binaryOperationPriority() != -1 );
+      GTL_ASSERT( d->currentToken.binaryOperationPriority() != -1 );
+      
+      if( d->currentToken.binaryOperationPriority() == binOp.binaryOperationPriority() )
+      {
+        GTL_DEBUG( binOp << " collapse _lhs and expr and keep going" );
+        _lhs = createBinaryOperator( binOp, _lhs, expr );
+        binOp = d->currentToken;
+        getNextToken(); // eat the current operator
+        expr = 0;
+      } else if( d->currentToken.binaryOperationPriority() > binOp.binaryOperationPriority() )
+      {
+        GTL_DEBUG( binOp << " keep parsing to collapse expr with what is next" );
+        expr = parseBinaryOperator( _constantExpression, expr );
+        if( expr == 0 ) return 0;
+        if( d->currentToken.isExpressionTerminal() )
+        {
+          return createBinaryOperator( binOp, _lhs, expr);
+        }
+      } else {
+        GTL_DEBUG( binOp << " collapse _lhs and expr and return" );
+        return createBinaryOperator( binOp, _lhs, expr );
+      }
+    } else {
+      GTL_DEBUG("unexpected");
+      reportUnexpected( d->currentToken );
+      return 0;
+    }
+  }
+}
+
+#endif
+
+#if 0
+
+AST::Expression* ParserBase::parseFlatBinaryOperator( bool _constantExpression, AST::Expression* _lhs )
+{
+  AST::Expression* currentExpr = _lhs;
+  while( true )
+  {
+    Token binOp = d->currentToken;
+    AST::Expression* nextExpr = currentExpr;
+    bool lhsUsed = false;
+    do {
+      nextExpr = parseBinaryOperator( _constantExpression, nextExpr, lhsUsed );
+      if( not d->currentToken.isBinaryOperator() )
+      {
+        if( lhsUsed )
+        {
+          return nextExpr;
+        } else {
+          return createBinaryOperator( binOp, currentExpr, nextExpr );
+        }
+      }
+      GTL_ASSERT( binOp.binaryOperationPriority() != -1 );
+      GTL_ASSERT( d->currentToken.binaryOperationPriority() != -1 );
+    } while( binOp.binaryOperationPriority() < d->currentToken.binaryOperationPriority() );
+    currentExpr = createBinaryOperator( binOp, currentExpr, nextExpr );
+  }
+}
+
+AST::Expression* ParserBase::parseBinaryOperator( bool _constantExpression, AST::Expression* lhs, bool& lhsUsed )
+{
   GTL_ASSERT(lhs);
-  GTLCore::Token binOp = d->currentToken;
+  Token binOp = d->currentToken;
   getNextToken();
   AST::Expression* expr = 0;
   // What's next ? A primary expression or an unary operator or a parenthesis
-  if( d->currentToken.type == GTLCore::Token::STARTBRACKET )
+  if( d->currentToken.type == Token::STARTBRACKET )
   {
     getNextToken();
     expr = parseExpression(_constantExpression);
-    if( not isOfType( d->currentToken, GTLCore::Token::ENDBRACKET ) )
+    if( not isOfType( d->currentToken, Token::ENDBRACKET ) )
     {
       delete expr;
       return 0;
@@ -338,6 +457,7 @@
   }
   // What's next, either a semi or an other binary operator
   if( d->currentToken.isExpressionTerminal() ) {
+    lhsUsed = true;
     return createBinaryOperator( binOp, lhs, expr);
   } else if( d->currentToken.isBinaryOperator() ) {
     GTL_ASSERT( binOp.binaryOperationPriority() != -1 );
@@ -345,12 +465,16 @@
     // Check which operator has the priority over the other one
     if( binOp.binaryOperationPriority() < d->currentToken.binaryOperationPriority())
     { // This operator has lowest priority, which means the result of the second operator will be the right hand side for this operator
-      AST::Expression* rhs = parseBinaryOperator( _constantExpression, expr );
-      return createBinaryOperator( binOp, lhs, rhs );
+//       AST::Expression* rhs = parseBinaryOperator( _constantExpression, expr );
+//       return createBinaryOperator( binOp, lhs, rhs );
+      lhsUsed = false;
+      return expr;
     } else {
       // This operator has more priority, which means the result of this operator will be the left hand side for the second operator
+      lhsUsed = true;
+      bool v = false;
       AST::Expression* nlhs = createBinaryOperator( binOp, lhs, expr );
-      return parseBinaryOperator( _constantExpression, nlhs );
+      return parseBinaryOperator( _constantExpression, nlhs, v );
     }
   } else {
     GTL_DEBUG("unexpected");
@@ -359,16 +483,18 @@
   }
 }
 
+#endif
+
 AST::Expression* ParserBase::parseUnaryOperator( bool _constantExpression )
 {
-  GTLCore::Token unaryTok = d->currentToken;
+  Token unaryTok = d->currentToken;
   GTL_ASSERT(unaryTok.isUnaryOperator() );
   getNextToken();
   // What's next ? An unary operator is either followed by a parenthesis or an other unary operator or a primary
   AST::Expression* expr = 0;
-  if( d->currentToken.type == GTLCore::Token::STARTBRACKET ) {
+  if( d->currentToken.type == Token::STARTBRACKET ) {
     expr = parseExpression(_constantExpression);
-    if( not isOfType( d->currentToken, GTLCore::Token::ENDBRACKET ) )
+    if( not isOfType( d->currentToken, Token::ENDBRACKET ) )
     {
       delete expr;
       return 0;
@@ -386,14 +512,14 @@
   }
   switch( unaryTok.type )
   {
-    case GTLCore::Token::MINUS:
+    case Token::MINUS:
       return new AST::MinusUnaryExpression( expr );
-    case GTLCore::Token::MINUSMINUS:
+    case Token::MINUSMINUS:
     {
       AST::AccessorExpression* varexpr = dynamic_cast<AST::AccessorExpression*>( expr );
       if( varexpr  )
       {
-        if( expr->type() == GTLCore::Type::Integer32 )
+        if( expr->type() == Type::Integer32 )
         {
           return new AST::MinusMinusUnaryExpression( varexpr );
         } else {
@@ -403,12 +529,12 @@
         reportError( "'--' operator requires a variable", unaryTok );
       }
     }
-    case GTLCore::Token::PLUSPLUS:
+    case Token::PLUSPLUS:
     {
       AST::AccessorExpression* varexpr = dynamic_cast<AST::AccessorExpression*>( expr );
       if( varexpr  )
       {
-        if( expr->type() == GTLCore::Type::Integer32 )
+        if( expr->type() == Type::Integer32 )
         {
           return new AST::PlusPlusUnaryExpression( varexpr );
         } else {
@@ -418,13 +544,13 @@
         reportError( "'++' operator requires a variable", unaryTok );
       }
     }
-    case GTLCore::Token::NOT:
+    case Token::NOT:
     {
       return new AST::NotUnaryExpression( expr );
     }
-    case GTLCore::Token::TILDE:
+    case Token::TILDE:
     {
-      if( expr->type() != GTLCore::Type::Integer32 )
+      if( expr->type() != Type::Integer32 )
       {
         reportError( "'~' operator only work with integer" , unaryTok );
         return 0;
@@ -442,16 +568,16 @@
 void ParserBase::parseFunction()
 {
   GTL_ASSERT( d->currentToken.isFunctionType() );
-  const GTLCore::Type* returnType = parseFunctionType();
+  const Type* returnType = parseFunctionType();
   GTL_ASSERT( returnType );
   // Next is the name of the function
-  if( isOfType( d->currentToken, GTLCore::Token::IDENTIFIER ) )
+  if( isOfType( d->currentToken, Token::IDENTIFIER ) )
   {
-    GTLCore::Token nameToken = d->currentToken;
-    GTLCore::ScopedName name( d->nameSpace, d->currentToken.string );
+    Token nameToken = d->currentToken;
+    ScopedName name( d->nameSpace, d->currentToken.string );
     getNextToken();
     // Next is start bracket
-    if( isOfType( d->currentToken, GTLCore::Token::STARTBRACKET ) )
+    if( isOfType( d->currentToken, Token::STARTBRACKET ) )
     {
       std::vector< AST::FunctionParameter* > params;
       bool needToHaveInitialiser = false;
@@ -459,38 +585,38 @@
       while(true)
       {
         // Next is either a type or a end bracket
-        if( isType(d->currentToken) or d->currentToken.type == GTLCore::Token::OUTPUT or d->currentToken.type == GTLCore::Token::INPUT or d->currentToken.type == GTLCore::Token::VARYING )
+        if( isType(d->currentToken) or d->currentToken.type == Token::OUTPUT or d->currentToken.type == Token::INPUT or d->currentToken.type == Token::VARYING )
         {
           bool output = false;
           bool varying = false;
-          if( d->currentToken.type == GTLCore::Token::OUTPUT )
+          if( d->currentToken.type == Token::OUTPUT )
           {
             output = true;
             getNextToken();
-          } else if( d->currentToken.type == GTLCore::Token::VARYING )
+          } else if( d->currentToken.type == Token::VARYING )
           {
             varying = true;
             getNextToken();
-          }else if( d->currentToken.type == GTLCore::Token::INPUT )
+          }else if( d->currentToken.type == Token::INPUT )
           {
             getNextToken();
           }
           if( isType( d->currentToken ) )
           {
-            const GTLCore::Type* ptype = parseType();
-            if(isOfType( d->currentToken, GTLCore::Token::IDENTIFIER ) )
+            const Type* ptype = parseType();
+            if(isOfType( d->currentToken, Token::IDENTIFIER ) )
             {
-              GTLCore::String pname = d->currentToken.string;
+              String pname = d->currentToken.string;
               getNextToken();
               AST::Expression* initialiser = 0;
               std::list<AST::Expression*> memberArraySize = parseArraySize(true);
               ptype = d->compiler->typeManager()->getArray( ptype, memberArraySize.size() );
-              if( d->currentToken.type == GTLCore::Token::EQUAL )
+              if( d->currentToken.type == Token::EQUAL )
               {
                 getNextToken();
-                if( currentToken().type == GTLCore::Token::STARTBRACE )
+                if( currentToken().type == Token::STARTBRACE )
                 {
-                  GTLCore::AST::CoumpoundExpression* coumpoundExpression = parseCoumpoundExpression( ptype, false );
+                  AST::CoumpoundExpression* coumpoundExpression = parseCoumpoundExpression( ptype, false );
                   initialiser = new AST::GlobalDataExpression( coumpoundExpression );
                 } else {
                   initialiser = parseExpression( false );
@@ -500,17 +626,17 @@
               {
                 reportError( "Parameter need to have default initialiser once a parameter on the left had one.", d->currentToken );
               }
-              if( d->currentToken.type == GTLCore::Token::COMA or d->currentToken.type == GTLCore::Token::ENDBRACKET )
+              if( d->currentToken.type == Token::COMA or d->currentToken.type == Token::ENDBRACKET )
               {
-                if( d->currentToken.type == GTLCore::Token::COMA )
+                if( d->currentToken.type == Token::COMA )
                 {
                   getNextToken();
                 }
-                GTLCore::Value initialiserValue;
+                Value initialiserValue;
                 if( initialiser)
                 {
-                  GTLCore::CodeGenerator cg( 0 );
-                  GTLCore::GenerationContext gc( &cg, 0, 0, 0);
+                  CodeGenerator cg( 0 );
+                  GenerationContext gc( &cg, 0, 0, 0);
                   llvm::Constant* constant = initialiser->generateValue( gc, 0 ).constant();
                   if( constant )
                   {
@@ -525,7 +651,7 @@
                     }
                   }
                 }
-                params.push_back( new AST::FunctionParameter( GTLCore::Parameter(pname, ptype, output, varying, initialiserValue), initialiser ) );
+                params.push_back( new AST::FunctionParameter( Parameter(pname, ptype, output, varying, initialiserValue), initialiser ) );
               } else {
                 GTL_DEBUG("Unexpected");
                 reportUnexpected( d->currentToken );
@@ -541,17 +667,17 @@
             reportUnexpected( d->currentToken );
           }
         }
-        else if( isOfType( d->currentToken, GTLCore::Token::ENDBRACKET ) )
+        else if( isOfType( d->currentToken, Token::ENDBRACKET ) )
         {
           getNextToken();
-          if( isOfType( d->currentToken, GTLCore::Token::STARTBRACE ) )
+          if( isOfType( d->currentToken, Token::STARTBRACE ) )
           {
             AST::FunctionDeclaration* fd = new AST::FunctionDeclaration( name, returnType, params );
             startContext();
             // TODO insert functions arguments in the context
             for( unsigned int i = 0; i < params.size(); ++i)
             {
-              d->contextes.begin()->variables[ GTLCore::ScopedName("",params[i]->parameter().name() )] = fd->parametersVariable()[i];
+              d->contextes.begin()->variables[ ScopedName("",params[i]->parameter().name() )] = fd->parametersVariable()[i];
             }
             AST::Statement* statement = parseStatementList();
             endContext();
@@ -581,10 +707,10 @@
 
 AST::Statement* ParserBase::parseStatementList()
 {
-  GTL_ASSERT( d->currentToken.type == GTLCore::Token::STARTBRACE );
+  GTL_ASSERT( d->currentToken.type == Token::STARTBRACE );
   getNextToken();
   std::list<AST::Statement*> list;
-  while(d->currentToken.type != GTLCore::Token::ENDBRACE)
+  while(d->currentToken.type != Token::ENDBRACE)
   {
     AST::Statement* statement = parseStatement();
     if( not statement )
@@ -599,16 +725,16 @@
 
 AST::Statement* ParserBase::parsePrintStatement()
 {
-  GTL_ASSERT( d->currentToken.type == GTLCore::Token::PRINT );
+  GTL_ASSERT( d->currentToken.type == Token::PRINT );
   getNextToken();
-  if( isOfType( d->currentToken, GTLCore::Token::STARTBRACKET ) )
+  if( isOfType( d->currentToken, Token::STARTBRACKET ) )
   {
     getNextToken(); // eat the '('
     std::list<AST::Expression*> expressions;
     while(true)
     {
       AST::Expression* expr = 0;
-      if( d->currentToken.type == GTLCore::Token::STRING_CONSTANT )
+      if( d->currentToken.type == Token::STRING_CONSTANT )
       {
         expr = new AST::StringExpression( d->currentToken.string );
         getNextToken();
@@ -616,17 +742,17 @@
         expr = parseExpression(false);
       }
       expressions.push_back(expr);
-      if( d->currentToken.type == GTLCore::Token::ENDBRACKET )
+      if( d->currentToken.type == Token::ENDBRACKET )
       {
         getNextToken();
         break;
-      } else if( not isOfType(d->currentToken, GTLCore::Token::COMA) ) {
+      } else if( not isOfType(d->currentToken, Token::COMA) ) {
         getNextToken();
         return 0;
       }
       getNextToken();
     }
-    isOfType( d->currentToken, GTLCore::Token::SEMI);
+    isOfType( d->currentToken, Token::SEMI);
     getNextToken();
     return new AST::PrintStatement( expressions );
   }
@@ -637,7 +763,7 @@
 {
   startContext();
   AST::Statement* statement;
-  if( d->currentToken.type == GTLCore::Token::STARTBRACE )
+  if( d->currentToken.type == Token::STARTBRACE )
   {
     statement = parseStatementList();
   } else {
@@ -649,13 +775,13 @@
 
 AST::Statement* ParserBase::parseWhileStatement()
 {
-  GTL_ASSERT( d->currentToken.type == GTLCore::Token::WHILE );
+  GTL_ASSERT( d->currentToken.type == Token::WHILE );
   getNextToken();
-  if( isOfType( d->currentToken, GTLCore::Token::STARTBRACKET ) )
+  if( isOfType( d->currentToken, Token::STARTBRACKET ) )
   {
     getNextToken(); // eat the '('
     AST::Expression* expression = parseExpression(false);
-    if( isOfType( d->currentToken, GTLCore::Token::ENDBRACKET ) )
+    if( isOfType( d->currentToken, Token::ENDBRACKET ) )
     {
       getNextToken(); // eat the ')'
       AST::Statement* statement = parseStatementOrList();
@@ -668,19 +794,29 @@
 AST::Statement* ParserBase::parseForStatement()
 {
   startContext();
-  GTL_ASSERT( d->currentToken.type == GTLCore::Token::FOR );
+  GTL_ASSERT( d->currentToken.type == Token::FOR );
   getNextToken();
-  if( isOfType( d->currentToken, GTLCore::Token::STARTBRACKET ) )
+  if( isOfType( d->currentToken, Token::STARTBRACKET ) )
   {
     getNextToken(); // eat the '('
-    AST::Statement* initexpression = parseStatement();
+    AST::Statement* initexpression = 0;
+    if( d->currentToken.type == Token::SEMI )
+    {
+      getNextToken(); // eat the ';'
+    } else {
+      initexpression = parseStatement();
+    }
     AST::Expression* comparexpression = parseExpression(false);
-    if( isOfType( d->currentToken, GTLCore::Token::SEMI ) )
+    if( isOfType( d->currentToken, Token::SEMI ) )
     {
       getNextToken(); // eat the ';'
-      AST::Expression* updateexpression = parseExpression(false);
-      if( isOfType( d->currentToken, GTLCore::Token::ENDBRACKET ) )
+      AST::Expression* updateexpression = 0;
+      if( d->currentToken.type != Token::ENDBRACKET )
       {
+        updateexpression = parseExpression(false);
+      }
+      if( isOfType( d->currentToken, Token::ENDBRACKET ) )
+      {
         getNextToken(); // eat the ')'
         AST::Statement* statement = parseStatementOrList();
         endContext();
@@ -697,17 +833,17 @@
 
 AST::Statement* ParserBase::parseIfStatement()
 {
-  GTL_ASSERT( d->currentToken.type == GTLCore::Token::IF );
+  GTL_ASSERT( d->currentToken.type == Token::IF );
   getNextToken();
-  if( isOfType( d->currentToken, GTLCore::Token::STARTBRACKET ) )
+  if( isOfType( d->currentToken, Token::STARTBRACKET ) )
   {
     getNextToken(); // eat the '('
     AST::Expression* expression = parseExpression(false);
-    if( isOfType( d->currentToken, GTLCore::Token::ENDBRACKET ) )
+    if( isOfType( d->currentToken, Token::ENDBRACKET ) )
     {
       getNextToken(); // eat the ')'
       AST::Statement* statement = parseStatementOrList();
-      if( d->currentToken.type == GTLCore::Token::ELSE )
+      if( d->currentToken.type == Token::ELSE )
       {
         getNextToken(); // eat the else
         AST::Statement* elsestatement = parseStatementOrList();
@@ -722,15 +858,15 @@
 
 AST::Statement* ParserBase::parseReturnStatement()
 {
-  GTL_ASSERT( d->currentToken.type == GTLCore::Token::RETURN );
+  GTL_ASSERT( d->currentToken.type == Token::RETURN );
   getNextToken();
-  if( d->currentToken.type == GTLCore::Token::SEMI )
+  if( d->currentToken.type == Token::SEMI )
   { // TODO check type
     getNextToken(); // eat the coma
     return new AST::ReturnStatement( 0 );
   } else {
     AST::Expression* expr = parseExpression(false);
-    if(expr and isOfType( d->currentToken, GTLCore::Token::SEMI ) )
+    if(expr and isOfType( d->currentToken, Token::SEMI ) )
     {
       getNextToken();
       return new AST::ReturnStatement( expr );
@@ -743,7 +879,7 @@
 AST::Statement* ParserBase::parseExpressionStatement()
 {
   AST::Statement* statement = parseExpression(false);
-  if(isOfType( d->currentToken, GTLCore::Token::SEMI ) )
+  if(isOfType( d->currentToken, Token::SEMI ) )
   {
     getNextToken();
     return statement;
@@ -756,18 +892,18 @@
 AST::Statement* ParserBase::parseVariableDeclaration()
 {
   bool constant = false;
-  if( d->currentToken.type == GTLCore::Token::CONST )
+  if( d->currentToken.type == Token::CONST )
   {
     constant = true;
     getNextToken();
   }
   if( isType(d->currentToken) )
   {
-    const GTLCore::Type* type = parseType();
+    const Type* type = parseType();
     GTL_ASSERT(type);
-    if( isOfType( d->currentToken, GTLCore::Token::IDENTIFIER ) )
+    if( isOfType( d->currentToken, Token::IDENTIFIER ) )
     {
-      GTLCore::ScopedName name("", d->currentToken.string);
+      ScopedName name("", d->currentToken.string);
       if( d->contextes.begin()->variables.find( name ) == d->contextes.begin()->variables.end() )
       {
         getNextToken();
@@ -775,13 +911,13 @@
         type = d->compiler->typeManager()->getArray( type, initialsize.size() );
         bool initialised = false;
         AST::Expression* initialiser = 0;
-        if( d->currentToken.type == GTLCore::Token::EQUAL )
+        if( d->currentToken.type == Token::EQUAL )
         {
           getNextToken(); // eat the equal
           // Check if it's a coumpound expression
-          if( currentToken().type == GTLCore::Token::STARTBRACE )
+          if( currentToken().type == Token::STARTBRACE )
           {
-            GTLCore::AST::CoumpoundExpression* coumpoundExpression = parseCoumpoundExpression( type, true );
+            AST::CoumpoundExpression* coumpoundExpression = parseCoumpoundExpression( type, true );
 /*            if( coumpoundExpression->size() != *memberArraySize.begin()) // TODO: recurisvely check other sizes
             {
               GTL_DEBUG( memberArraySize.size() << " " << coumpoundExpression->size() );
@@ -798,8 +934,8 @@
         // Insert the variable in the context
         d->contextes.begin()->variables[name] = variable->variable();
         GTL_ASSERT( variable->variable() );
-        GTL_DEBUG(initialised << " " << GTLCore::Token::typeToString( d->currentToken.type ) );
-        if( d->currentToken.type == GTLCore::Token::COMA and not initialised ) {
+        GTL_DEBUG(initialised << " " << Token::typeToString( d->currentToken.type ) );
+        if( d->currentToken.type == Token::COMA and not initialised ) {
           // it's possible to initialise a variable by calling a function taking as output the variable
           getNextToken(); // eat the coma
           variable->setFunctionIntialiser(parseExpression( false ));
@@ -810,7 +946,7 @@
           reportError( "Unitialised constant.", d->currentToken );
           return 0;
         }
-        if( isOfType(d->currentToken, GTLCore::Token::SEMI ) )
+        if( isOfType(d->currentToken, Token::SEMI ) )
         {
           getNextToken(); // eat the semi
           return variable;
@@ -832,43 +968,43 @@
   }
 }
 
-const GTLCore::Type* ParserBase::parseFunctionType()
+const Type* ParserBase::parseFunctionType()
 {
-  if( d->currentToken.type == GTLCore::Token::VOID )
+  if( d->currentToken.type == Token::VOID )
   {
     getNextToken();
-    return GTLCore::Type::Void;
+    return Type::Void;
   } else {
     return parseType();
   }
 }
 
-const GTLCore::Type* ParserBase::parseType()
+const Type* ParserBase::parseType()
 {
   switch( d->currentToken.type )
   {
-    case GTLCore::Token::BOOL:
+    case Token::BOOL:
       getNextToken();
-      return GTLCore::Type::Boolean;
-    case GTLCore::Token::INT:
+      return Type::Boolean;
+    case Token::INT:
       getNextToken();
-      return GTLCore::Type::Integer32;
-    case GTLCore::Token::HALF:
-    case GTLCore::Token::FLOAT:
+      return Type::Integer32;
+    case Token::HALF:
+    case Token::FLOAT:
       getNextToken();
-      return GTLCore::Type::Float;
-    case GTLCore::Token::UNSIGNED:
+      return Type::Float;
+    case Token::UNSIGNED:
     {
       getNextToken();
-      if( d->currentToken.type == GTLCore::Token::INT )
+      if( d->currentToken.type == Token::INT )
       {
         getNextToken();
       }
-      return GTLCore::Type::UnsignedInteger32;
+      return Type::UnsignedInteger32;
     }
-    case GTLCore::Token::IDENTIFIER:
+    case Token::IDENTIFIER:
     {
-      const GTLCore::Type* type = d->compiler->typeManager()->getStructure( d->currentToken.string );
+      const Type* type = d->compiler->typeManager()->getStructure( d->currentToken.string );
       if( not type )
       {
         reportError("Unknown type : " + d->currentToken.string, d->currentToken );
@@ -877,9 +1013,9 @@
       return type;
     }
     default:
-      reportError("Expected type before " + GTLCore::Token::typeToString( d->currentToken.type ), d->currentToken);
+      reportError("Expected type before " + Token::typeToString( d->currentToken.type ), d->currentToken);
       getNextToken();
-      return GTLCore::Type::Integer32;
+      return Type::Integer32;
   }
 }
 
@@ -887,25 +1023,25 @@
 {
   switch( d->currentToken.type )
   {
-    case GTLCore::Token::INTEGER_CONSTANT:
+    case Token::INTEGER_CONSTANT:
     {
       int v = d->currentToken.i;
       getNextToken();
       return new AST::NumberExpression<int>( v );
     }
-    case GTLCore::Token::FLOAT_CONSTANT:
+    case Token::FLOAT_CONSTANT:
     {
       float v = d->currentToken.f;
       getNextToken();
       return new AST::NumberExpression<float>( v );
     }
-    case GTLCore::Token::TTRUE:
+    case Token::TTRUE:
       getNextToken();
       return new AST::NumberExpression<bool>( true );
-    case GTLCore::Token::TFALSE:
+    case Token::TFALSE:
       getNextToken();
       return new AST::NumberExpression<bool>( false );
-    case GTLCore::Token::IDENTIFIER:
+    case Token::IDENTIFIER:
     {
       if(_constantExpression)
       { // If we are computing a constant expression, we can only use the previously declared constant variable
@@ -929,17 +1065,17 @@
         return 0;
       } else {
         // It can be either a call to a function or a variable access
-        GTLCore::ScopedName name("", d->currentToken.string );
+        ScopedName name("", d->currentToken.string );
         getNextToken(); // eat the identifier
-        if( d->currentToken.type == GTLCore::Token::COLONCOLON )
+        if( d->currentToken.type == Token::COLONCOLON )
         {
           getNextToken(); // eat the ::
-          name = GTLCore::ScopedName( name.name(), d->currentToken.string );
+          name = ScopedName( name.name(), d->currentToken.string );
           getNextToken(); // eat the name
         }
-        if( d->currentToken.type == GTLCore::Token::STARTBRACKET )
+        if( d->currentToken.type == Token::STARTBRACKET )
         { // It's a function call
-          GTLCore::Function* function = d->compiler->function( name );
+          Function* function = d->compiler->function( name );
           if( not function )
           {
             reportError("Unknown function: " + name.toString(), d->currentToken);
@@ -957,7 +1093,7 @@
             return 0;
           }
         } else {
-          GTLCore::VariableNG* var = getVariable( name );
+          VariableNG* var = getVariable( name );
           if(not var)
           {
             AST::Expression* stdconst = d->compiler->standardConstant( name.name() );
@@ -986,7 +1122,7 @@
   std::list<AST::Expression*> arguments;
   while(true)
   {
-    if( d->currentToken.type == GTLCore::Token::ENDBRACKET )
+    if( d->currentToken.type == Token::ENDBRACKET )
     {
       break;
     } else {
@@ -999,10 +1135,10 @@
           reportError( "Parameter of function '" + _name + "' is an output parameter and requires a variable as argument", d->currentToken );
         }
       }
-      if( d->currentToken.type == GTLCore::Token::COMA )
+      if( d->currentToken.type == Token::COMA )
       {
         getNextToken();
-      } else if( d->currentToken.type != GTLCore::Token::ENDBRACKET )
+      } else if( d->currentToken.type != Token::ENDBRACKET )
       {
         GTL_DEBUG("Unexpected");
         reportUnexpected( d->currentToken );
@@ -1010,14 +1146,14 @@
       }
     }
   }
-  GTL_ASSERT( d->currentToken.type == GTLCore::Token::ENDBRACKET );
+  GTL_ASSERT( d->currentToken.type == Token::ENDBRACKET );
   getNextToken(); // eat the end bracket
   return arguments;
 }
 
 void ParserBase::reachNextSemi()
 {
-  while( d->currentToken.type != GTLCore::Token::SEMI and d->currentToken.type != GTLCore::Token::END_OF_FILE )
+  while( d->currentToken.type != Token::SEMI and d->currentToken.type != Token::END_OF_FILE )
   {
     getNextToken();
   }
@@ -1026,13 +1162,13 @@
 
 // Utilities
 
-bool ParserBase::isOfType( const GTLCore::Token& token, GTLCore::Token::Type type )
+bool ParserBase::isOfType( const Token& token, Token::Type type )
 {
   if( token.type == type )
   {
     return true;
   } else {
-    reportError("Expected " + GTLCore::Token::typeToString(type) + " before " + GTLCore::Token::typeToString(token.type)  + ".", token);
+    reportError("Expected " + Token::typeToString(type) + " before " + Token::typeToString(token.type)  + ".", token);
     return false;
   }
 }
@@ -1040,33 +1176,33 @@
 void ParserBase::checkNextTokenIsSemi()
 {
   getNextToken();
-  if( d->currentToken.type != GTLCore::Token::SEMI )
+  if( d->currentToken.type != Token::SEMI )
   {
-    reportError("Expected ';' before " + GTLCore::Token::typeToString(d->currentToken.type) + ".", d->currentToken );
+    reportError("Expected ';' before " + Token::typeToString(d->currentToken.type) + ".", d->currentToken );
   }
 }
 
-void ParserBase::reportError( const GTLCore::String& errMsg, const GTLCore::Token& token )
+void ParserBase::reportError( const String& errMsg, const Token& token )
 {
   if( d->compiler)
   {
-    d->compiler->appendError( GTLCore::ErrorMessage( errMsg, token.line, "" ) );
+    d->compiler->appendError( ErrorMessage( errMsg, token.line, "" ) );
   } else {
     GTL_DEBUG( errMsg);
   }
 }
 
-void ParserBase::reportUnexpected( const GTLCore::Token& token )
+void ParserBase::reportUnexpected( const Token& token )
 {
-  reportError("Unexpected: " + GTLCore::Token::typeToString( token.type ), token );
+  reportError("Unexpected: " + Token::typeToString( token.type ), token );
   getNextToken();
 }
 
-AST::Expression* ParserBase::createBinaryOperator( const GTLCore::Token& token, AST::Expression* lhs, AST::Expression* rhs )
+AST::Expression* ParserBase::createBinaryOperator( const Token& token, AST::Expression* lhs, AST::Expression* rhs )
 {
   switch( token.type )
   {
-    case GTLCore::Token::EQUAL:
+    case Token::EQUAL:
     {
       AST::AccessorExpression* ve = dynamic_cast<AST::AccessorExpression*>( lhs );
       if( ve )
@@ -1076,43 +1212,43 @@
       reportError("Left hand side of an assignement expression must be a variable.", token);
       return 0;
     }
-    case GTLCore::Token::OR:
+    case Token::OR:
       return new AST::OrBinaryExpression( lhs, rhs );
-    case GTLCore::Token::AND:
+    case Token::AND:
       return new AST::AndBinaryExpression( lhs, rhs );
-    case GTLCore::Token::BITOR:
+    case Token::BITOR:
       return new AST::BitOrBinaryExpression( lhs, rhs );
-    case GTLCore::Token::BITXOR:
+    case Token::BITXOR:
       return new AST::BitXorBinaryExpression( lhs, rhs );
-    case GTLCore::Token::BITAND:
+    case Token::BITAND:
       return new AST::BitAndBinaryExpression( lhs, rhs );
-    case GTLCore::Token::EQUALEQUAL:
+    case Token::EQUALEQUAL:
       return new AST::EqualEqualBinaryExpression( lhs, rhs );
-    case GTLCore::Token::DIFFERENT:
+    case Token::DIFFERENT:
       return new AST::DifferentBinaryExpression( lhs, rhs );
-    case GTLCore::Token::INFERIOREQUAL:
+    case Token::INFERIOREQUAL:
       return new AST::InferiorEqualBinaryExpression( lhs, rhs );
-    case GTLCore::Token::INFERIOR:
+    case Token::INFERIOR:
       return new AST::InferiorBinaryExpression( lhs, rhs );
-    case GTLCore::Token::SUPPERIOREQUAL:
+    case Token::SUPPERIOREQUAL:
       return new AST::SupperiorEqualBinaryExpression( lhs, rhs );
-    case GTLCore::Token::SUPPERIOR:
+    case Token::SUPPERIOR:
       return new AST::SupperiorBinaryExpression( lhs, rhs );
-    case GTLCore::Token::RIGHTSHIFT:
+    case Token::RIGHTSHIFT:
       return new AST::RightShiftBinaryExpression( lhs, rhs );
-    case GTLCore::Token::LEFTSHIFT:
+    case Token::LEFTSHIFT:
       return new AST::LeftShiftBinaryExpression( lhs, rhs );
-    case GTLCore::Token::PLUS:
+    case Token::PLUS:
       return new AST::AdditionBinaryExpression( lhs, rhs );
-    case GTLCore::Token::MINUS:
+    case Token::MINUS:
       return new AST::SubstractionBinaryExpression( lhs, rhs );
-    case GTLCore::Token::MULTIPLY:
+    case Token::MULTIPLY:
       return new AST::MultiplicationBinaryExpression( lhs, rhs );
-    case GTLCore::Token::DIVIDE:
+    case Token::DIVIDE:
       return new AST::DivisionBinaryExpression( lhs, rhs );
-    case GTLCore::Token::MODULO:
+    case Token::MODULO:
     {
-      if( lhs->type() != rhs->type() and rhs->type()  != GTLCore::Type::Integer32 )
+      if( lhs->type() != rhs->type() and rhs->type()  != Type::Integer32 )
       {
         reportError( "'~' operator only work with integer" , token );
         return 0;
@@ -1124,9 +1260,9 @@
   }
 }
 
-bool ParserBase::isType( const GTLCore::Token& token )
+bool ParserBase::isType( const Token& token )
 {
-  return token.isNativeType() or ( token.type == GTLCore::Token::IDENTIFIER and d->compiler->typeManager()->d->isKnownType( token.string ) );
+  return token.isNativeType() or ( token.type == Token::IDENTIFIER and d->compiler->typeManager()->d->isKnownType( token.string ) );
 }
 
 // Context management
@@ -1141,13 +1277,13 @@
   d->contextes.pop_front();
 }
 
-GTLCore::VariableNG* ParserBase::getVariable( const GTLCore::ScopedName& n ) const
+VariableNG* ParserBase::getVariable( const ScopedName& n ) const
 {
   GTL_DEBUG("getVariable " << n );
   for( std::list<Context>::const_iterator cit = d->contextes.begin();
        cit != d->contextes.end(); cit++)
   {
-    for( std::map<GTLCore::ScopedName, GTLCore::VariableNG*>::const_iterator it = cit->variables.begin();
+    for( std::map<ScopedName, VariableNG*>::const_iterator it = cit->variables.begin();
          it != cit->variables.end(); ++it)
     {
       GTL_DEBUG( " storage: " << it->first << " namespace: " << d->nameSpace );
@@ -1161,7 +1297,7 @@
   return 0;
 }
 
-void ParserBase::declareVariable( const GTLCore::ScopedName& _scopedName, GTLCore::VariableNG* _variable)
+void ParserBase::declareVariable( const ScopedName& _scopedName, VariableNG* _variable)
 {
   d->contextes.begin()->variables[_scopedName] = _variable;
 }
@@ -1169,8 +1305,8 @@
 std::list<int> ParserBase::expressionsListToIntegersList( const std::list< AST::Expression* >& list )
 {
   std::list<int> integersList;
-  GTLCore::CodeGenerator cg( 0 );
-  GTLCore::GenerationContext gc( &cg, 0, 0, 0);
+  CodeGenerator cg( 0 );
+  GenerationContext gc( &cg, 0, 0, 0);
   for( std::list< AST::Expression* >::const_iterator it = list.begin();
        it != list.end(); ++it)
   {
@@ -1186,12 +1322,12 @@
   return integersList;
 }
 
-void ParserBase::setNameSpace( const GTLCore::String& _nameSpace )
+void ParserBase::setNameSpace( const String& _nameSpace )
 {
   d->nameSpace = _nameSpace;
 }
 
-const GTLCore::String& ParserBase::nameSpace() const
+const String& ParserBase::nameSpace() const
 {
   return d->nameSpace;
 }

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h	2008-06-24 19:30:00 UTC (rev 222)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h	2008-06-24 19:32:08 UTC (rev 223)
@@ -50,24 +50,33 @@
     public:
       ParserBase(CompilerBase* _compiler, LexerBase* _lexer);
       virtual ~ParserBase();
-      virtual GTLCore::AST::Tree* parse() =0;
-      const GTLCore::String& nameSpace() const;
+      virtual AST::Tree* parse() =0;
+      const String& nameSpace() const;
     protected:
       /**
        * Get the next token.
        */
       void getNextToken();
-      const GTLCore::Token& currentToken();
+      const Token& currentToken();
     protected:
-      virtual GTLCore::AST::Tree* tree() = 0;
+      virtual AST::Tree* tree() = 0;
     protected:
     // Parse functions
-      GTLCore::AST::Expression* parseExpression( bool _constantExpression );
-      GTLCore::AST::Expression* parseUnaryOperator( bool _constantExpression );
-      GTLCore::AST::Expression* parseBinaryOperator( bool _constantExpression, GTLCore::AST::Expression* _lhs );
+      AST::Expression* parseExpression( bool _constantExpression );
+      AST::Expression* parseUnaryOperator( bool _constantExpression );
+      /**
+       * Will continiously call \ref parseBinaryOperator until there is no more
+       * binary operator in the tree.
+       */
+      AST::Expression* parseFlatBinaryOperator( bool _constantExpression, AST::Expression* _lhs);
+      /**
+       * Parse for a binary operator, either return when at the end of the expression
+       * or if the next operator has an inferior priority.
+       */
+      AST::Expression* parseBinaryOperator( bool _constantExpression, AST::Expression* _lhs );
       void parseFunction();
-      GTLCore::AST::Statement* parseStatementList();
-      virtual GTLCore::AST::Statement* parseStatement() = 0;
+      AST::Statement* parseStatementList();
+      virtual AST::Statement* parseStatement() = 0;
       /**
        * Parse either an unique statement or a list of statement, depending on wether
        * the current token is a '{' or not. This is usely mostly for if/else/for/while
@@ -75,20 +84,20 @@
        * 
        * It also creates a context.
        */
-      GTLCore::AST::Statement* parseStatementOrList();
-      GTLCore::AST::Statement* parseIfStatement();
-      GTLCore::AST::Statement* parseForStatement();
-      GTLCore::AST::Statement* parseWhileStatement();
-      GTLCore::AST::Statement* parseExpressionStatement();
-      GTLCore::AST::Statement* parseVariableDeclaration();
-      GTLCore::AST::Statement* parseReturnStatement();
-      GTLCore::AST::Statement* parsePrintStatement();
+      AST::Statement* parseStatementOrList();
+      AST::Statement* parseIfStatement();
+      AST::Statement* parseForStatement();
+      AST::Statement* parseWhileStatement();
+      AST::Statement* parseExpressionStatement();
+      AST::Statement* parseVariableDeclaration();
+      AST::Statement* parseReturnStatement();
+      AST::Statement* parsePrintStatement();
       /**
        * Get the type and return it. Also positionate the token flow on the token
        * after the type.
        */
-      virtual const GTLCore::Type* parseType();
-      const GTLCore::Type* parseFunctionType();
+      virtual const Type* parseType();
+      const Type* parseFunctionType();
       void parseStructDefinition();
       /**
        * Parse the arguments of a function.
@@ -105,23 +114,23 @@
       /**
        * Parse coumpound expression ( { 1, 2, { 4, 5, 6 } } )
        */
-      GTLCore::AST::CoumpoundExpression* parseCoumpoundExpression( const GTLCore::Type* _type, bool _constantExpression );
+      AST::CoumpoundExpression* parseCoumpoundExpression( const Type* _type, bool _constantExpression );
       /**
        * Get the constant expression out of the current token. Also positionate the
        * token flow on the token after the constant.
        */
-      GTLCore::AST::Expression* parsePrimaryExpression(bool _constantExpression);
+      AST::Expression* parsePrimaryExpression(bool _constantExpression);
     // Utils function
       /**
        * Check if this is an integer, return false if not and add an error in
        * the compiler.
        */
-      bool isOfType( const GTLCore::Token& , GTLCore::Token::Type type );
+      bool isOfType( const Token& , Token::Type type );
       /**
        * Report an error arround the token and call errorRecovery.
        */
-      void reportError( const GTLCore::String& errMsg, const GTLCore::Token& token );
-      void reportUnexpected( const GTLCore::Token& token );
+      void reportError( const String& errMsg, const Token& token );
+      void reportUnexpected( const Token& token );
       /**
        * Check that the next token is a semicolon (;)
        */
@@ -131,17 +140,17 @@
        * token flow on the token after the semi colon.
        */
       void reachNextSemi();
-      GTLCore::AST::Expression* createBinaryOperator( const GTLCore::Token& token, GTLCore::AST::Expression* lhs, GTLCore::AST::Expression* rhs );
-      bool isType( const GTLCore::Token& token );
+      AST::Expression* createBinaryOperator( const Token& token, AST::Expression* lhs, AST::Expression* rhs );
+      bool isType( const Token& token );
     protected:
       // Context
       struct Context;
-      GTLCore::VariableNG* getVariable( const GTLCore::ScopedName&  ) const;
-      void declareVariable( const GTLCore::ScopedName& , GTLCore::VariableNG* );
+      VariableNG* getVariable( const ScopedName&  ) const;
+      void declareVariable( const ScopedName& , VariableNG* );
       void startContext();
       void endContext();
       std::list<int> expressionsListToIntegersList( const std::list< AST::Expression* >& );
-      void setNameSpace( const GTLCore::String& nameSpace );
+      void setNameSpace( const String& nameSpace );
     private:
       struct Private;
       Private* const d;


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