File indexing completed on 2024-04-06 12:01:19
0001 #include "CommonTools/Utils/interface/parser/Grammar.h"
0002 #include "FWCore/Utilities/interface/EDMException.h"
0003 #include "CommonTools/Utils/interface/expressionParser.h"
0004
0005 using namespace reco::parser;
0006
0007 bool reco::parser::expressionParser(const edm::TypeWithDict& t,
0008 const std::string& value,
0009 ExpressionPtr& expr,
0010 bool lazy) {
0011 using namespace boost::spirit::classic;
0012 Grammar grammar(expr, t, lazy);
0013 bool returnValue = false;
0014 const char* startingFrom = value.c_str();
0015 try {
0016 returnValue = parse(startingFrom, grammar.use_parser<1>() >> end_p, space_p).full;
0017 } catch (BaseException& e) {
0018 throw edm::Exception(edm::errors::Configuration)
0019 << "Expression parser error:" << baseExceptionWhat(e) << " (char " << e.where - startingFrom << ")\n";
0020 }
0021 return returnValue;
0022 }