[opengtl-commits] [606] parse the name of a Kernel/Library

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


Revision: 606
Author:   cyrille
Date:     2009-03-13 17:56:46 +0100 (Fri, 13 Mar 2009)

Log Message:
-----------
parse the name of a Kernel/Library

Modified Paths:
--------------
    trunk/OpenGTL/OpenShiva/OpenShiva/LightParser_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Source.cpp


Modified: trunk/OpenGTL/OpenShiva/OpenShiva/LightParser_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/LightParser_p.cpp	2009-03-13 16:48:42 UTC (rev 605)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/LightParser_p.cpp	2009-03-13 16:56:46 UTC (rev 606)
@@ -19,6 +19,7 @@
 
 #include "LightParser_p.h"
 
+#include "Debug.h"
 #include "Lexer_p.h"
 
 using namespace OpenShiva;
@@ -47,6 +48,59 @@
   d->sourceType = Source::InvalidSource;
   d->outputImageType = Source::InvalidImage;
   d->inputImageTypes.clear();
+  
+  getNextToken();
+  // Start by ingoring metadata if any
+  if( currentToken().type == GTLCore::Token::INFERIOR )
+  {
+    int count = 0;
+    do
+    {
+      switch( currentToken().type )
+      {
+        case GTLCore::Token::INFERIOR:
+          ++count;
+          break;
+        case GTLCore::Token::SUPPERIOR:
+          --count;
+          break;
+        default:
+          break;
+      }
+      getNextToken();
+    } while( count > 0 and currentToken().type != GTLCore::Token::END_OF_FILE  );
+    if( isOfType( currentToken(), GTLCore::Token::SEMI ) )
+    {
+      getNextToken();
+    }
+  }
+  
+  // Parse "import"
+  while( currentToken().type == GTLCore::Token::IMPORT )
+  {
+    getNextToken();
+    if( isOfType( currentToken(), GTLCore::Token::STRING_CONSTANT ) )
+    {
+    }
+    checkNextTokenIsSemi();
+    getNextToken();
+  }
+  
+  SHIVA_DEBUG("Parse body");
+  bool isKernel = false;
+  if( currentToken().type == GTLCore::Token::LIBRARY ) {
+    d->sourceType = Source::Library;
+  } else {
+    isKernel = true;
+  }
+  getNextToken();
+  if( isOfType( currentToken(), GTLCore::Token::IDENTIFIER ) )
+  {
+    d->name = currentToken().string;
+  }
+  
+  
+  
   return 0;
 }
 

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Source.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Source.cpp	2009-03-13 16:48:42 UTC (rev 605)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Source.cpp	2009-03-13 16:56:46 UTC (rev 606)
@@ -77,6 +77,7 @@
   std::istringstream iss(source);
   Lexer lexer( &iss );
   LightParser parser(&lexer);
+  parser.parse();
   name = parser.name();
   type = parser.sourceType();
   outputImageType = parser.outputImageType();


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