MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / Lex

Method Lex

CodeFormatCore/src/Diagnostic/Spell/Util.cpp:37–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37identify::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
68std::vector<Word> text::ParseToIdentifies(std::string_view text) {
69 std::vector<Word> words;

Callers

nothing calls this directly

Calls 5

ResetBufferMethod · 0.80
GetCurrentCharMethod · 0.80
NextCharMethod · 0.80
SaveAndNextMethod · 0.80
EatWhileMethod · 0.80

Tested by

no test coverage detected