[opengtl-commits] [607] parse evaluatePixel parameters |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 607
Author: cyrille
Date: 2009-03-13 19:26:33 +0100 (Fri, 13 Mar 2009)
Log Message:
-----------
parse evaluatePixel parameters
Modified Paths:
--------------
trunk/OpenGTL/OpenShiva/OpenShiva/LightParser_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/LightParser_p.h
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/LightParser_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/LightParser_p.cpp 2009-03-13 16:56:46 UTC (rev 606)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/LightParser_p.cpp 2009-03-13 18:26:33 UTC (rev 607)
@@ -53,22 +53,7 @@
// 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 );
+ eatLoopOf( GTLCore::Token::INFERIOR, GTLCore::Token::SUPPERIOR );
if( isOfType( currentToken(), GTLCore::Token::SEMI ) )
{
getNextToken();
@@ -99,11 +84,124 @@
d->name = currentToken().string;
}
+ getNextToken();
+ if( isOfType( currentToken(), GTLCore::Token::STARTBRACE ) )
+ {
+ getNextToken();
+ while(true)
+ {
+ switch(currentToken().type)
+ {
+ case GTLCore::Token::END_OF_FILE:
+ case GTLCore::Token::ENDBRACE:
+ return 0;
+ case GTLCore::Token::DEPENDENT:
+ case GTLCore::Token::CONST:
+ eatUntil(GTLCore::Token::SEMI, GTLCore::Token::SEMI);
+ break;
+ case GTLCore::Token::STRUCT:
+ eatUntil(GTLCore::Token::ENDBRACE, GTLCore::Token::ENDBRACE);
+ getNextToken(); // eat the ';'
+ break;
+ default:
+ {
+ getNextToken(); // Return type
+ if( currentToken().type == GTLCore::Token::IDENTIFIER )
+ {
+ bool isEvaluateParam = ("evaluatePixel" == currentToken().string);
+ GTL_DEBUG(currentToken().string);
+ getNextToken();
+ if( isEvaluateParam and isOfType( currentToken(), GTLCore::Token::STARTBRACKET ) )
+ {
+ getNextToken();
+ while(currentToken().type != GTLCore::Token::ENDBRACE and currentToken().type != GTLCore::Token::END_OF_FILE )
+ {
+ // Next is either a type or a end bracket
+ if( isType(currentToken()) or currentToken().type == GTLCore::Token::OUTPUT or currentToken().type == GTLCore::Token::INPUT or currentToken().type == GTLCore::Token::VARYING )
+ {
+ bool output = false;
+ bool varying = false;
+ if( currentToken().type == GTLCore::Token::OUTPUT )
+ {
+ output = true;
+ getNextToken();
+ } else if( currentToken().type == GTLCore::Token::VARYING )
+ {
+ varying = true;
+ getNextToken();
+ }else if( currentToken().type == GTLCore::Token::INPUT )
+ {
+ getNextToken();
+ }
+ if( currentToken().type == GTLCore::Token::IDENTIFIER )
+ {
+ Source::ImageType image;
+ if( currentToken().string == "image" or currentToken().string == "pixel" )
+ {
+ image = Source::Image;
+ } else if( currentToken().string == "image1" or currentToken().string == "pixel1" )
+ {
+ image = Source::Image1;
+ } else if( currentToken().string == "image2" or currentToken().string == "pixel2" )
+ {
+ image = Source::Image2;
+ } else if( currentToken().string == "image3" or currentToken().string == "pixel3" )
+ {
+ image = Source::Image3;
+ } else if( currentToken().string == "image4" or currentToken().string == "pixel4" )
+ {
+ image = Source::Image4;
+ } else {
+ image = Source::InvalidImage;
+ }
+ if( output )
+ {
+ d->outputImageType = image;
+ } else {
+ d->inputImageTypes.push_back(image);
+ }
+ eatUntil( GTLCore::Token::ENDBRACE, GTLCore::Token::COMA );
+ }
+ }
+ }
+ } else {
+ eatUntil( GTLCore::Token::ENDBRACKET, GTLCore::Token::ENDBRACKET );
+ }
+ eatLoopOf( GTLCore::Token::STARTBRACE, GTLCore::Token::ENDBRACE );
+ }
+ }
+ }
+
+ }
+ }
-
return 0;
}
+void LightParser::eatUntil( GTLCore::Token::Type type1, GTLCore::Token::Type type2)
+{
+ while( currentToken().type != type1 and currentToken().type != type2 and currentToken().type != GTLCore::Token::END_OF_FILE )
+ {
+ getNextToken();
+ }
+ getNextToken();
+}
+
+void LightParser::eatLoopOf( GTLCore::Token::Type start, GTLCore::Token::Type end)
+{
+ int count = 0;
+ do
+ {
+ if( currentToken().type == start )
+ {
+ ++count;
+ } else if( currentToken().type == end ) {
+ --count;
+ }
+ getNextToken();
+ } while( count > 0 and currentToken().type != GTLCore::Token::END_OF_FILE );
+}
+
const GTLCore::String& LightParser::name() const
{
return d->name;
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/LightParser_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/LightParser_p.h 2009-03-13 16:56:46 UTC (rev 606)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/LightParser_p.h 2009-03-13 18:26:33 UTC (rev 607)
@@ -42,6 +42,9 @@
Source::ImageType outputImageType() const;
const std::vector<Source::ImageType>& inputImageTypes() const;
private:
+ void eatUntil( GTLCore::Token::Type type1, GTLCore::Token::Type type2);
+ void eatLoopOf( GTLCore::Token::Type start, GTLCore::Token::Type end);
+ private:
struct Private;
Private* const d;
};