mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
Poincare: The rules compiler checks for wildcard consistency
Change-Id: I9de57987b10fced3f1e63358b9d0158f97c3db15
This commit is contained in:
@@ -9,6 +9,9 @@ Node::Node(std::string * name, std::vector<Node *> * children) :
|
||||
if (children == nullptr) {
|
||||
m_children = new std::vector<Node *>();
|
||||
}
|
||||
for (Node * child : *m_children) {
|
||||
child->m_parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
Node::~Node() {
|
||||
|
||||
@@ -15,9 +15,9 @@ public:
|
||||
int flatIndexOfChildNamed(std::string name);
|
||||
protected:
|
||||
virtual void generateFields(Rule * context, std::string &indentation) = 0;
|
||||
protected:
|
||||
std::string * m_name;
|
||||
std::vector<Node *> * m_children;
|
||||
Node * m_parent;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,12 +9,15 @@ Selector::Selector(Type type, std::string * name, std::vector<Selector *> * chil
|
||||
}
|
||||
|
||||
void Selector::generateFields(Rule * context, std::string &indentation) {
|
||||
Selector * parent = (Selector *)m_parent;
|
||||
switch (m_type) {
|
||||
case Type::Variable:
|
||||
std::cout << indentation << ".m_match = ExpressionSelector::Match::Any," << std::endl;
|
||||
break;
|
||||
case Type::Wildcard:
|
||||
std::cout << indentation << ".m_match = ExpressionSelector::Match::Wildcard," << std::endl;
|
||||
// Wildcard should always be the last element of a parent
|
||||
assert(parent->m_children->back() == this);
|
||||
break;
|
||||
case Type::ExpressionType:
|
||||
std::cout << indentation << ".m_match = ExpressionSelector::Match::TypeAndValue," << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user