mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-01 11:49:58 +00:00
Fix composition with empty nodes.
This commit is contained in:
parent
23e26e0333
commit
42a98e1676
@ -27,8 +27,15 @@ Request::Request(Name name, bool optional) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Request Request::append(Node::Type type, const Request &rhs) {
|
Request Request::append(Node::Type type, const Request &rhs) {
|
||||||
// Start with the easiest case: this is already an appropriate
|
// If either side is empty, act appropriately.
|
||||||
// request, and so is the new thing.
|
if(node.empty() && !rhs.node.empty()) {
|
||||||
|
return rhs;
|
||||||
|
}
|
||||||
|
if(rhs.node.empty()) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Just copy in the RHS child nodes if types match.
|
||||||
if(node.type == type && rhs.node.type == type) {
|
if(node.type == type && rhs.node.type == type) {
|
||||||
Request new_request = *this;
|
Request new_request = *this;
|
||||||
new_request.node.children.insert(new_request.node.children.end(), rhs.node.children.begin(), rhs.node.children.end());
|
new_request.node.children.insert(new_request.node.children.end(), rhs.node.children.begin(), rhs.node.children.end());
|
||||||
|
@ -240,6 +240,10 @@ struct Request {
|
|||||||
bool is_optional = false;
|
bool is_optional = false;
|
||||||
std::vector<Node> children;
|
std::vector<Node> children;
|
||||||
|
|
||||||
|
bool empty() const {
|
||||||
|
return type == Type::One && name == Name::None;
|
||||||
|
}
|
||||||
|
|
||||||
void add_descriptions(std::vector<Description> &) const;
|
void add_descriptions(std::vector<Description> &) const;
|
||||||
bool validate(Map &) const;
|
bool validate(Map &) const;
|
||||||
void visit(
|
void visit(
|
||||||
|
Loading…
Reference in New Issue
Block a user