| 842 | } |
| 843 | |
| 844 | std::vector<std::pair<std::string, std::string>> polyspace::Parser::parseFamilyRules(const std::string& comment, std::string::size_type& pos) { |
| 845 | std::vector<std::pair<std::string, std::string>> fr; |
| 846 | std::string family; |
| 847 | std::string rule; |
| 848 | enum class State: uint8_t { family, colon, rule, rule_or_family } state = State::family; |
| 849 | const std::string::size_type endpos = startsWith(comment, "/*") ? comment.size() - 2 : comment.size(); |
| 850 | for (; pos <= endpos; ++pos) { |
| 851 | const char c = comment[pos]; |
| 852 | if (std::strchr("[\"", c)) |
| 853 | break; |
| 854 | switch (state) { |
| 855 | case State::family: |
| 856 | if (std::isalnum(c) || std::strchr("-_.",c)) |
| 857 | family += c; |
| 858 | else if (!family.empty() && std::strchr(" \t:",c)) |
| 859 | state = State::colon; |
| 860 | break; |
| 861 | case State::colon: |
| 862 | if (!std::strchr(" \t:", c)) { |
| 863 | rule.clear(); |
| 864 | --pos; |
| 865 | state = State::rule; |
| 866 | } |
| 867 | break; |
| 868 | case State::rule: |
| 869 | if (std::strchr(", \t",c)) { |
| 870 | if (!rule.empty()) { |
| 871 | fr.emplace_back(family,rule); |
| 872 | rule.clear(); |
| 873 | if (c != ',') |
| 874 | state = State::rule_or_family; |
| 875 | } |
| 876 | } |
| 877 | else |
| 878 | rule += c; |
| 879 | break; |
| 880 | case State::rule_or_family: |
| 881 | rule.clear(); |
| 882 | if (std::isalnum(c)) { |
| 883 | --pos; |
| 884 | family.clear(); |
| 885 | state = State::family; |
| 886 | } else if (c == ',') { |
| 887 | --pos; |
| 888 | state = State::rule; |
| 889 | } |
| 890 | break; |
| 891 | } |
| 892 | } |
| 893 | if (!family.empty() && !rule.empty()) |
| 894 | fr.emplace_back(family,rule); |
| 895 | return fr; |
| 896 | } |
| 897 | |
| 898 | std::set<std::string> polyspace::Parser::parseIds(const std::string& comment, std::string::size_type& pos) const { |
| 899 | std::set<std::string> ids; |
nothing calls this directly
no test coverage detected