| 66 | } |
| 67 | |
| 68 | std::vector<Word> text::ParseToIdentifies(std::string_view text) { |
| 69 | std::vector<Word> words; |
| 70 | if (text.length() < 3) { |
| 71 | return words; |
| 72 | } |
| 73 | |
| 74 | // give up check long string |
| 75 | if (text.front() == '\'' || text.front() == '\"') { |
| 76 | text = text.substr(1, text.size() - 2); |
| 77 | } else { |
| 78 | return words; |
| 79 | } |
| 80 | |
| 81 | TextReader reader(text); |
| 82 | |
| 83 | while (true) { |
| 84 | switch (Lex(reader)) { |
| 85 | case TextType::Unknown: { |
| 86 | words.clear(); |
| 87 | goto endLoop; |
| 88 | } |
| 89 | case TextType::Identify: { |
| 90 | auto range = reader.GetTokenRange(); |
| 91 | if (range.Length > 3) { |
| 92 | range.StartOffset++; |
| 93 | words.emplace_back(range, reader.GetSaveText()); |
| 94 | } |
| 95 | break; |
| 96 | } |
| 97 | case TextType::Ignore: { |
| 98 | break; |
| 99 | } |
| 100 | default:// end |
| 101 | { |
| 102 | goto endLoop; |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | endLoop: |
| 107 | return words; |
| 108 | } |
| 109 | |
| 110 | text::TextType text::Lex(TextReader &reader) { |
| 111 | reader.ResetBuffer(); |
nothing calls this directly
no test coverage detected