mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Attempts to implement tree construction.
This commit is contained in:
parent
f4db4c3a73
commit
2e999889bd
@ -18,14 +18,29 @@ Request::Request(Name name, bool optional) {
|
||||
node.is_optional = optional;
|
||||
}
|
||||
|
||||
Request Request::append(Node::Type type, const Request &rhs) {
|
||||
// Start with the easiest case: this is already an ::All request, and
|
||||
// so is the new thing.
|
||||
if(node.type == type && rhs.node.type == type) {
|
||||
Request new_request = *this;
|
||||
new_request.node.children.insert(new_request.node.children.end(), rhs.node.children.begin(), rhs.node.children.end());
|
||||
return new_request;
|
||||
}
|
||||
|
||||
// Otherwise create a new parent node.
|
||||
Request parent;
|
||||
parent.node.type = type;
|
||||
parent.node.children.push_back(this->node);
|
||||
parent.node.children.push_back(rhs.node);
|
||||
return parent;
|
||||
}
|
||||
|
||||
Request Request::operator &&(const Request &rhs) {
|
||||
(void)rhs;
|
||||
return *this;
|
||||
return append(Node::Type::All, rhs);
|
||||
}
|
||||
|
||||
Request Request::operator ||(const Request &rhs) {
|
||||
(void)rhs;
|
||||
return *this;
|
||||
return append(Node::Type::Any, rhs);
|
||||
}
|
||||
|
||||
bool Request::validate(Map &map) const {
|
||||
|
@ -179,6 +179,8 @@ struct Request {
|
||||
bool validate(Map &) const;
|
||||
};
|
||||
Node node;
|
||||
|
||||
Request append(Node::Type type, const Request &rhs);
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user