Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:03

0001 // -*- C++ -*-
0002 //
0003 // Package:     CandCombiner
0004 // Class  :     decayParser
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:
0010 //         Created:  Sun Aug  7 20:26:31 EDT 2005
0011 // $Id: decayParser.cc,v 1.1 2009/03/03 13:50:55 llista Exp $
0012 //
0013 #include "CommonTools/CandAlgos/interface/decayParser.h"
0014 
0015 #include <boost/spirit/include/classic_core.hpp>
0016 #include <boost/spirit/include/classic_push_back_actor.hpp>
0017 
0018 #include <vector>
0019 
0020 using namespace boost::spirit;
0021 using namespace std;
0022 using namespace boost::spirit::classic;
0023 namespace cand {
0024   namespace parser {
0025 
0026     class ModeSetter {
0027     public:
0028       ModeSetter(vector<ConjInfo>& iVect, ConjInfo::Mode iMode) : conjInfo_(iVect), mode_(iMode) {}
0029       void operator()(const char) const { conjInfo_.back().mode_ = mode_; }
0030 
0031     private:
0032       vector<ConjInfo>& conjInfo_;
0033       ConjInfo::Mode mode_;
0034     };
0035 
0036     typedef scanner_policies<skip_parser_iteration_policy<nothing_parser, iteration_policy>, match_policy, action_policy>
0037         ScannerPolicy;
0038     typedef scanner<const char*, ScannerPolicy> ScannerUsed_1;
0039     typedef rule<ScannerUsed_1> Rule_1;
0040 
0041     bool decayParser(const string& iValue, vector<ConjInfo>& oStrings) {
0042       using namespace boost::spirit;
0043 
0044       Rule_1 label = ((+alnum_p) >> *ch_p(':') >> *ch_p('_') >> *alnum_p)[push_back_a(oStrings)];
0045       Rule_1 conj = (ch_p('@') >> !((ch_p('b') >> ch_p('a') >> ch_p('r')[ModeSetter(oStrings, ConjInfo::kBar)]) |
0046                                     ch_p('+')[ModeSetter(oStrings, ConjInfo::kPlus)] |
0047                                     ch_p('-')[ModeSetter(oStrings, ConjInfo::kMinus)]));
0048 
0049       return parse(iValue.c_str(), ((label >> !conj) % blank_p), nothing_p).full;
0050     }
0051   }  // namespace parser
0052 }  // namespace cand