added new expr to test
[ozulis.git] / src / ast / generator-lib.cc
blob06dd57f5deb70609327c23a8a22d42a5eb896b66
1 #include "generator.hh"
2 #include <core/assert.hh>
3 #include <iostream>
5 namespace ag = ast::generator;
7 bool ag::isNode(const std::string & type)
9 return
10 type == "Block *" ||
11 type == "Exp *" ||
12 type == "Node *" ||
13 type == "Type *" ||
14 type == "Symbol *" ||
15 type == "Label *" ||
16 false;
19 bool ag::isPrintable(const std::string & type)
21 return
22 type != "Scope *";
25 bool ag::isVectorOfNode(const std::string & type)
27 return
28 type == "std::vector<Node *> *" ||
29 type == "std::vector<Type *> *" ||
30 type == "std::vector<VarDecl *> *" ||
31 false;
34 const ag::Node *
35 ag::findNodeByName(const std::string & name)
37 for (const ag::Node * node = ag::nodes; !node->name.empty() > 0; node++)
38 if (node->name == name)
39 return node;
40 return 0;
43 std::vector<const ag::Attribute *>
44 ag::allAttributes(const ag::Node * node)
46 std::vector<const ag::Attribute *> attrs;
48 assert(node);
49 do {
50 for (const ag::Attribute * attr = node->attrs; !attr->type.empty(); ++attr)
51 attrs.push_back(attr);
52 } while ((node = findNodeByName(node->parent)));
53 return attrs;
56 void ag::appendGeneratedWarning(std::ostream & out)
58 out << "/* DO NOT MODIFY THIS FILE (GENERATED) */" << std::endl;
61 template class std::vector<ag::Attribute *>;