OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Intersection.cpp
Go to the documentation of this file.
2 
3 #include <boost/regex.hpp>
4 
5 namespace mslang {
6  void Intersection::print(int indentwidth) {
7  std::string indent(' ', indentwidth);
8  std::cout << indent << "Intersection\n"
9  << indent << " first operand\n";
10  firstOperand_m->print(indentwidth + 8);
11 
12  std::cout << indent << " second operand\n";
13  secondOperand_m->print(indentwidth + 8);
14  }
15 
16  void Intersection::apply(std::vector<std::shared_ptr<Base> > &bfuncs) {
17  std::vector<std::shared_ptr<Base> > first, firstrep, second;
18 
19  firstOperand_m->apply(first);
20  firstOperand_m->apply(firstrep);
21  secondOperand_m->apply(second);
22 
23  for (auto item: firstrep) {
24  item->divideBy(second);
25  }
26 
27  for (auto item: first) {
28  item->divideBy(firstrep);
29  bfuncs.emplace_back(item->clone());
30  }
31 
32  for (auto item: first)
33  item.reset();
34  for (auto item: firstrep)
35  item.reset();
36  for (auto item: second)
37  item.reset();
38  }
39 
40  bool Intersection::parse_detail(iterator &it, const iterator &end, Function* &fun) {
41  Intersection *inter = static_cast<Intersection*>(fun);
42  if (!parse(it, end, inter->firstOperand_m)) return false;
43 
44  boost::regex argumentList("(,[a-z]+\\(.*)");
45  boost::regex endParenthesis("\\)(.*)");
46  boost::smatch what;
47 
48  std::string str(it, end);
49  if (!boost::regex_match(str, what, argumentList)) return false;
50 
51  iterator it2 = it + 1;
52  if (!parse(it2, end, inter->secondOperand_m)) return false;
53 
54  it = it2;
55  str = std::string(it, end);
56  if (!boost::regex_match(str, what, endParenthesis)) return false;
57 
58  std::string fullMatch = what[0];
59  std::string rest = what[1];
60 
61  it += (fullMatch.size() - rest.size());
62 
63  return true;
64  }
65 }
static bool parse_detail(iterator &it, const iterator &end, Function *&fun)
virtual void print(int indent)=0
Function * secondOperand_m
Definition: Intersection.h:9
Function * firstOperand_m
Definition: Intersection.h:8
virtual void print(int indentwidth)
Definition: Intersection.cpp:6
virtual void apply(std::vector< std::shared_ptr< Base >> &bfuncs)=0
static bool parse(iterator &it, const iterator &end, Function *&fun)
Definition: MSLang.cpp:48
std::string::iterator iterator
Definition: MSLang.h:16
virtual void apply(std::vector< std::shared_ptr< Base > > &bfuncs)