Evaluate name * @throws std::runtime_error thrown on undefined function-like macro */
| 2731 | * @throws std::runtime_error thrown on undefined function-like macro |
| 2732 | */ |
| 2733 | static void simplifyName(simplecpp::TokenList &expr) |
| 2734 | { |
| 2735 | for (simplecpp::Token *tok = expr.front(); tok; tok = tok->next) { |
| 2736 | if (tok->name) { |
| 2737 | static const std::set<std::string> altop{"and","or","bitand","bitor","compl","not","not_eq","xor"}; |
| 2738 | if (altop.find(tok->str()) != altop.end()) { |
| 2739 | bool alt; |
| 2740 | if (tok->str() == "not" || tok->str() == "compl") { |
| 2741 | alt = isAlternativeUnaryOp(tok,tok->str()); |
| 2742 | } else { |
| 2743 | alt = isAlternativeBinaryOp(tok,tok->str()); |
| 2744 | } |
| 2745 | if (alt) |
| 2746 | continue; |
| 2747 | } |
| 2748 | if (tok->next && tok->next->str() == "(") |
| 2749 | throw std::runtime_error("undefined function-like macro invocation: " + tok->str() + "( ... )"); |
| 2750 | tok->setstr("0"); |
| 2751 | } |
| 2752 | } |
| 2753 | } |
| 2754 | |
| 2755 | /* |
| 2756 | * Reads at least minlen and at most maxlen digits (inc. prefix) in base base |
no test coverage detected