| 35 | } |
| 36 | |
| 37 | identify::IdentifyType identify::Lex(TextReader &reader) { |
| 38 | reader.ResetBuffer(); |
| 39 | do { |
| 40 | auto ch = reader.GetCurrentChar(); |
| 41 | |
| 42 | if (ch == EOZ) { |
| 43 | return IdentifyType::End; |
| 44 | } else if (ch == '_') { |
| 45 | reader.NextChar(); |
| 46 | continue; |
| 47 | } else if (ch > CHAR_MAX || !std::isalnum(ch)) { |
| 48 | return IdentifyType::Unknown; |
| 49 | } |
| 50 | reader.SaveAndNext(); |
| 51 | |
| 52 | if (islower(ch)) { |
| 53 | reader.EatWhile(islower); |
| 54 | return IdentifyType::Ascii; |
| 55 | } else if (isdigit(ch)) { |
| 56 | reader.EatWhile(isdigit); |
| 57 | return IdentifyType::Ignore; |
| 58 | } else if (isupper(ch)) { |
| 59 | auto upperCount = reader.EatWhile(isupper); |
| 60 | reader.EatWhile(islower); |
| 61 | return upperCount > 0 ? IdentifyType::Ignore : IdentifyType::Ascii; |
| 62 | } |
| 63 | |
| 64 | return IdentifyType::Unknown; |
| 65 | } while (true); |
| 66 | } |
| 67 | |
| 68 | std::vector<Word> text::ParseToIdentifies(std::string_view text) { |
| 69 | std::vector<Word> words; |
nothing calls this directly
no test coverage detected