CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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) :
25  conjInfo_(iVect), mode_(iMode) {}
26  void operator()( const char ) const {
27  conjInfo_.back().mode_ = mode_;
28  }
29  private:
30  vector<ConjInfo>& conjInfo_;
32  };
33 
34  typedef scanner_policies<skip_parser_iteration_policy<nothing_parser,
35  iteration_policy>,
36  match_policy, action_policy> ScannerPolicy;
37  typedef scanner<const char*, ScannerPolicy > ScannerUsed_1;
38  typedef rule<ScannerUsed_1> Rule_1;
39 
40  bool decayParser( const string& iValue, vector<ConjInfo>& oStrings ) {
41  using namespace boost::spirit;
42 
43  Rule_1 label = ((+alnum_p) >> *ch_p(':') >> *ch_p('_') >>*alnum_p)[push_back_a(oStrings)];
44  Rule_1 conj = (ch_p('@') >> !((ch_p('b')>>ch_p('a')>>ch_p('r')[ModeSetter(oStrings,ConjInfo::kBar)] )|
45  ch_p('+')[ModeSetter(oStrings,ConjInfo::kPlus)] |
46  ch_p('-')[ModeSetter(oStrings,ConjInfo::kMinus)]) );
47 
48  return parse( iValue.c_str(),
49  (
50  (label >> ! conj)
51  % blank_p
52  )
53  ,
54  nothing_p).full;
55  }
56  }
57 }
rule< ScannerUsed_1 > Rule_1
Definition: decayParser.cc:38
Evaluator * parse(const T &text)
const double kPlus
Definition: ParticleMasses.h:8
ConjInfo::Mode mode_
Definition: decayParser.cc:31
ModeSetter(vector< ConjInfo > &iVect, ConjInfo::Mode iMode)
Definition: decayParser.cc:24
Definition: GenABIO.cc:180
vector< ConjInfo > & conjInfo_
Definition: decayParser.cc:30
void operator()(const char) const
Definition: decayParser.cc:26
bool decayParser(const std::string &iValue, std::vector< ConjInfo > &oStrings)
scanner_policies< skip_parser_iteration_policy< nothing_parser, iteration_policy >, match_policy, action_policy > ScannerPolicy
Definition: decayParser.cc:36
scanner< const char *, ScannerPolicy > ScannerUsed_1
Definition: decayParser.cc:37