diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-11-07 22:11:56 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-11-07 22:11:56 +0100 |
commit | 7b6fc865d9871a63c7377ca8d9ebc57dd854d15c (patch) | |
tree | 130e929c815065ddd4450b14eb7bcd2281f0b9ea | |
parent | 5c7df4f7b09d138df58f720260306afdf0f6713a (diff) |
Handle nodes up to expression
-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 + } + }, }; } |