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