diff options
-rw-r--r-- | cpp.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
@@ -420,6 +420,90 @@ std::unordered_map<std::string, std::function<std::any(index_t)>> CPP::getNodeEv throw std::runtime_error("ICE: Unsupported childs: "s + ruleString(index)); // TODO } }, + { "shift-expression", [&](index_t index) -> std::any + { + if (childTypesOfNodeMatch(index, {"additive-expression", ""}) && !getValue(index, 1).has_value()) + return getValue(index, 0); + throw std::runtime_error("ICE: Unsupported childs: "s + ruleString(index)); // TODO + } + }, + { "compare-expression", [&](index_t index) -> std::any + { + if (childTypesOfNodeMatch(index, {"shift-expression", ""}) && !getValue(index, 1).has_value()) + return getValue(index, 0); + throw std::runtime_error("ICE: Unsupported childs: "s + ruleString(index)); // TODO + } + }, + { "relational-expression", [&](index_t index) -> std::any + { + if (childTypesOfNodeMatch(index, {"compare-expression", ""}) && !getValue(index, 1).has_value()) + return getValue(index, 0); + throw std::runtime_error("ICE: Unsupported childs: "s + ruleString(index)); // TODO + } + }, + { "equality-expression", [&](index_t index) -> std::any + { + if (childTypesOfNodeMatch(index, {"relational-expression", ""}) && !getValue(index, 1).has_value()) + return getValue(index, 0); + throw std::runtime_error("ICE: Unsupported childs: "s + ruleString(index)); // TODO + } + }, + { "and-expression", [&](index_t index) -> std::any + { + if (childTypesOfNodeMatch(index, {"equality-expression", ""}) && !getValue(index, 1).has_value()) + return getValue(index, 0); + throw std::runtime_error("ICE: Unsupported childs: "s + ruleString(index)); // TODO + } + }, + { "exclusive-or-expression", [&](index_t index) -> std::any + { + if (childTypesOfNodeMatch(index, {"and-expression", ""}) && !getValue(index, 1).has_value()) + return getValue(index, 0); + throw std::runtime_error("ICE: Unsupported childs: "s + ruleString(index)); // TODO + } + }, + { "inclusive-or-expression", [&](index_t index) -> std::any + { + if (childTypesOfNodeMatch(index, {"exclusive-or-expression", ""}) && !getValue(index, 1).has_value()) + return getValue(index, 0); + throw std::runtime_error("ICE: Unsupported childs: "s + ruleString(index)); // TODO + } + }, + { "logical-and-expression", [&](index_t index) -> std::any + { + if (childTypesOfNodeMatch(index, {"inclusive-or-expression", ""}) && !getValue(index, 1).has_value()) + return getValue(index, 0); + throw std::runtime_error("ICE: Unsupported childs: "s + ruleString(index)); // TODO + } + }, + { "logical-or-expression", [&](index_t index) -> std::any + { + if (childTypesOfNodeMatch(index, {"logical-and-expression", ""}) && !getValue(index, 1).has_value()) + return getValue(index, 0); + throw std::runtime_error("ICE: Unsupported childs: "s + ruleString(index)); // TODO + } + }, + { "conditional-expression", [&](index_t index) -> std::any + { + if (childTypesOfNodeMatch(index, {"logical-or-expression"})) + return getValue(index, 0); + throw std::runtime_error("ICE: Unsupported childs: "s + ruleString(index)); // TODO + } + }, + { "assignment-expression", [&](index_t index) -> std::any + { + if (childTypesOfNodeMatch(index, {"conditional-expression"})) + return getValue(index, 0); + throw std::runtime_error("ICE: Unsupported childs: "s + ruleString(index)); // TODO + } + }, + { "expression", [&](index_t index) -> std::any + { + if (childTypesOfNodeMatch(index, {"assignment-expression", ""}) && !getValue(index, 1).has_value()) + return getValue(index, 0); + throw std::runtime_error("ICE: Unsupported childs: "s + ruleString(index)); // TODO + } + }, }; } |