CMS 3D CMS Logo

expressionParser.h

Go to the documentation of this file.
00001 #ifndef PhysicsTools_Utilities_expressionParset_h
00002 #define PhysicsTools_Utilities_expressionParset_h
00003 #include "PhysicsTools/Utilities/src/ExpressionPtr.h"
00004 #include "PhysicsTools/Utilities/src/Grammar.h"
00005 #include "FWCore/Utilities/interface/EDMException.h"
00006 #include <string>
00007 
00008 namespace reco {
00009   namespace parser {
00010     template<typename T>
00011     bool expressionParser( const std::string & value, ExpressionPtr & expr) {
00012       using namespace boost::spirit;
00013       Grammar grammar(expr, (const T*)(0));
00014       bool returnValue = false;
00015       const char* startingFrom = value.c_str();
00016       try {
00017          returnValue=parse(startingFrom, grammar.use_parser<1>() >> end_p, space_p).full;
00018       } catch(BaseException&e){
00019          throw edm::Exception(edm::errors::Configuration)<<"Expression parser error:"<<baseExceptionWhat(e)<<" (char "<<e.where-startingFrom<<")\n";
00020       }
00021       return returnValue;
00022     }
00023   }
00024 }
00025 
00026 #endif

Generated on Tue Jun 9 17:42:41 2009 for CMSSW by  doxygen 1.5.4