OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
Union.cpp
Go to the documentation of this file.
2 
3 #include <boost/regex.hpp>
4 
5 namespace mslang {
6  void Union::print(int indentwidth) {
7  std::string indent(indentwidth, ' ');
8  std::string indent2(indentwidth + 8, ' ');
9  std::string indent3(indentwidth + 16, ' ');
10  std::cout << indent << "union, " << std::endl;
11  std::cout << indent2 << "funcs: {\n";
12  funcs_m.front()->print(indentwidth + 16);
13  for (unsigned int i = 1; i < funcs_m.size(); ++ i) {
14  std::cout << "\n"
15  << indent3 << "," << std::endl;
16  funcs_m[i]->print(indentwidth + 16);
17  }
18  std::cout << "\n"
19  << indent2 << "} ";
20  }
21 
22  void Union::apply(std::vector<std::shared_ptr<Base> > &bfuncs) {
23  for (unsigned int i = 0; i < funcs_m.size(); ++ i) {
24  std::vector<std::shared_ptr<Base> > children;
25  Function *func = funcs_m[i];
26  func->apply(children);
27  bfuncs.insert(bfuncs.end(), children.begin(), children.end());
28  }
29  }
30 
32  Union *unin = static_cast<Union*>(fun);
33  unin->funcs_m.push_back(nullptr);
34  if (!parse(it, end, unin->funcs_m.back())) return false;
35 
36  boost::regex argumentList("(,[a-z]+\\(.*)");
37  boost::regex endParenthesis("\\)(.*)");
38  boost::smatch what;
39 
40  std::string str(it, end);
41  while (boost::regex_match(str, what, argumentList)) {
42  iterator it2 = it + 1;
43  unin->funcs_m.push_back(nullptr);
44 
45  if (!parse(it2, end, unin->funcs_m.back())) return false;
46 
47  it = it2;
48  str = std::string(it, end);
49  }
50 
51  str = std::string(it, end);
52  if (!boost::regex_match(str, what, endParenthesis)) return false;
53 
54  std::string fullMatch = what[0];
55  std::string rest = what[1];
56 
57  it += (fullMatch.size() - rest.size());
58 
59  return true;
60  }
61 }
virtual void print(int indentwidth)
Definition: Union.cpp:6
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of it
Definition: LICENSE:43
static bool parse_detail(iterator &it, const iterator &end, Function *&fun)
Definition: Union.cpp:31
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
static bool parse(iterator &it, const iterator &end, Function *&fun)
Definition: MSLang.cpp:48
virtual void apply(std::vector< std::shared_ptr< Base > > &bfuncs)
Definition: Union.cpp:22
std::string::iterator iterator
Definition: MSLang.h:15
std::vector< Function * > funcs_m
Definition: Union.h:8
virtual void apply(std::vector< std::shared_ptr< Base >> &bfuncs)=0
end
Definition: multipole_t.tex:9