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