00001 #include "CommonTools/Utils/src/Grammar.h" 00002 #include "FWCore/Utilities/interface/EDMException.h" 00003 #include "CommonTools/Utils/interface/expressionParser.h" 00004 00005 using namespace reco::parser; 00006 00007 bool reco::parser::expressionParser(const edm::TypeWithDict &t, const std::string & value, ExpressionPtr & expr, bool lazy) { 00008 using namespace boost::spirit::classic; 00009 Grammar grammar(expr, t, lazy); 00010 bool returnValue = false; 00011 const char* startingFrom = value.c_str(); 00012 try { 00013 returnValue=parse(startingFrom, grammar.use_parser<1>() >> end_p, space_p).full; 00014 } catch(BaseException&e){ 00015 throw edm::Exception(edm::errors::Configuration)<<"Expression parser error:"<<baseExceptionWhat(e)<<" (char "<<e.where-startingFrom<<")\n"; 00016 } 00017 return returnValue; 00018 }