| 52 | } |
| 53 | |
| 54 | EditorconfigPattern::MatchType EditorconfigPattern::Lex(TextReader &reader) { |
| 55 | reader.ResetBuffer(); |
| 56 | int ch = reader.GetCurrentChar(); |
| 57 | switch (ch) { |
| 58 | case '*': { |
| 59 | reader.SaveAndNext(); |
| 60 | if (reader.GetCurrentChar() == '*') { |
| 61 | reader.SaveAndNext(); |
| 62 | return MatchType::AnyChars; |
| 63 | } |
| 64 | |
| 65 | return MatchType::AnyCharsExceptSep; |
| 66 | } |
| 67 | case '{': { |
| 68 | reader.SaveAndNext(); |
| 69 | while (!reader.IsEof()) { |
| 70 | ch = reader.GetCurrentChar(); |
| 71 | reader.SaveAndNext(); |
| 72 | if (ch == '}') { |
| 73 | break; |
| 74 | } |
| 75 | } |
| 76 | return MatchType::StringOf; |
| 77 | } |
| 78 | case '[': { |
| 79 | reader.SaveAndNext(); |
| 80 | MatchType type = MatchType::AnyCharOf; |
| 81 | if (reader.GetCurrentChar() == '!') { |
| 82 | type = MatchType::NotCharOf; |
| 83 | reader.SaveAndNext(); |
| 84 | } |
| 85 | while (!reader.IsEof()) { |
| 86 | ch = reader.GetCurrentChar(); |
| 87 | reader.SaveAndNext(); |
| 88 | if (ch == ']') { |
| 89 | break; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return type; |
| 94 | } |
| 95 | case '?': { |
| 96 | reader.SaveAndNext(); |
| 97 | return MatchType::AnyChar; |
| 98 | } |
| 99 | case EOZ: { |
| 100 | return MatchType::Eof; |
| 101 | } |
| 102 | default: { |
| 103 | reader.SaveAndNext(); |
| 104 | while (!reader.IsEof()) { |
| 105 | ch = reader.GetCurrentChar(); |
| 106 | if (ch == '[' || ch == '{' || ch == '*') { |
| 107 | break; |
| 108 | } |
| 109 | reader.SaveAndNext(); |
| 110 | } |
| 111 |
nothing calls this directly
no test coverage detected