CMS 3D CMS Logo

decayParser.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CandCombiner
4 // Class : decayParser
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author:
10 // Created: Sun Aug 7 20:26:31 EDT 2005
11 // $Id: decayParser.cc,v 1.1 2009/03/03 13:50:55 llista Exp $
12 //
14 
15 #include <boost/spirit/include/classic_core.hpp>
16 #include <boost/spirit/include/classic_push_back_actor.hpp>
17 
18 #include <vector>
19 
20 using namespace boost::spirit;
21 using namespace std;
22 using namespace boost::spirit::classic;
23 namespace cand {
24  namespace parser {
25 
26  class ModeSetter {
27  public:
28  ModeSetter(vector<ConjInfo>& iVect, ConjInfo::Mode iMode) : conjInfo_(iVect), mode_(iMode) {}
29  void operator()(const char) const { conjInfo_.back().mode_ = mode_; }
30 
31  private:
32  vector<ConjInfo>& conjInfo_;
34  };
35 
36  typedef scanner_policies<skip_parser_iteration_policy<nothing_parser, iteration_policy>, match_policy, action_policy>
38  typedef scanner<const char*, ScannerPolicy> ScannerUsed_1;
39  typedef rule<ScannerUsed_1> Rule_1;
40 
41  bool decayParser(const string& iValue, vector<ConjInfo>& oStrings) {
42  using namespace boost::spirit;
43 
44  Rule_1 label = ((+alnum_p) >> *ch_p(':') >> *ch_p('_') >> *alnum_p)[push_back_a(oStrings)];
45  Rule_1 conj = (ch_p('@') >> !((ch_p('b') >> ch_p('a') >> ch_p('r')[ModeSetter(oStrings, ConjInfo::kBar)]) |
46  ch_p('+')[ModeSetter(oStrings, ConjInfo::kPlus)] |
47  ch_p('-')[ModeSetter(oStrings, ConjInfo::kMinus)]));
48 
49  return parse(iValue.c_str(), ((label >> !conj) % blank_p), nothing_p).full;
50  }
51  } // namespace parser
52 } // namespace cand
vector< string > parse(string line, const string &delimiter)
rule< ScannerUsed_1 > Rule_1
Definition: decayParser.cc:39
const double kPlus
Definition: ParticleMasses.h:8
ConjInfo::Mode mode_
Definition: decayParser.cc:33
ModeSetter(vector< ConjInfo > &iVect, ConjInfo::Mode iMode)
Definition: decayParser.cc:28
bool decayParser(const string &iValue, vector< ConjInfo > &oStrings)
Definition: decayParser.cc:41
char const * label
Definition: GenABIO.cc:168
vector< ConjInfo > & conjInfo_
Definition: decayParser.cc:32
void operator()(const char) const
Definition: decayParser.cc:29
scanner< const char *, ScannerPolicy > ScannerUsed_1
Definition: decayParser.cc:38
scanner_policies< skip_parser_iteration_policy< nothing_parser, iteration_policy >, match_policy, action_policy > ScannerPolicy
Definition: decayParser.cc:37