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 #include <vector>
15 
16 using namespace boost::spirit;
17 using namespace std;
18 using namespace boost::spirit::classic;
19 namespace cand {
20  namespace parser {
21 
22  class ModeSetter {
23  public:
24  ModeSetter(vector<ConjInfo>& iVect, ConjInfo::Mode iMode) : conjInfo_(iVect), mode_(iMode) {}
25  void operator()(const char) const { conjInfo_.back().mode_ = mode_; }
26 
27  private:
28  vector<ConjInfo>& conjInfo_;
30  };
31 
32  typedef scanner_policies<skip_parser_iteration_policy<nothing_parser, iteration_policy>, match_policy, action_policy>
34  typedef scanner<const char*, ScannerPolicy> ScannerUsed_1;
35  typedef rule<ScannerUsed_1> Rule_1;
36 
37  bool decayParser(const string& iValue, vector<ConjInfo>& oStrings) {
38  using namespace boost::spirit;
39 
40  Rule_1 label = ((+alnum_p) >> *ch_p(':') >> *ch_p('_') >> *alnum_p)[push_back_a(oStrings)];
41  Rule_1 conj = (ch_p('@') >> !((ch_p('b') >> ch_p('a') >> ch_p('r')[ModeSetter(oStrings, ConjInfo::kBar)]) |
42  ch_p('+')[ModeSetter(oStrings, ConjInfo::kPlus)] |
43  ch_p('-')[ModeSetter(oStrings, ConjInfo::kMinus)]));
44 
45  return parse(iValue.c_str(), ((label >> !conj) % blank_p), nothing_p).full;
46  }
47  } // namespace parser
48 } // namespace cand
rule< ScannerUsed_1 > Rule_1
Definition: decayParser.cc:35
const double kPlus
Definition: ParticleMasses.h:8
ConjInfo::Mode mode_
Definition: decayParser.cc:29
ModeSetter(vector< ConjInfo > &iVect, ConjInfo::Mode iMode)
Definition: decayParser.cc:24
bool decayParser(const string &iValue, vector< ConjInfo > &oStrings)
Definition: decayParser.cc:37
char const * label
Definition: GenABIO.cc:168
vector< ConjInfo > & conjInfo_
Definition: decayParser.cc:28
void operator()(const char) const
Definition: decayParser.cc:25
def parse(path, config)
Definition: dumpparser.py:13
scanner< const char *, ScannerPolicy > ScannerUsed_1
Definition: decayParser.cc:34
scanner_policies< skip_parser_iteration_policy< nothing_parser, iteration_policy >, match_policy, action_policy > ScannerPolicy
Definition: decayParser.cc:33