MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / check_at

Method check_at

common/peg-parser.cpp:54–89  ·  view source on GitHub ↗

Check if a delimiter starts at the given position

Source from the content-addressed store, hash-verified

52
53 // Check if a delimiter starts at the given position
54 match_result check_at(std::string_view sv, size_t start_pos) const {
55 size_t current = 0; // Start at root
56 size_t pos = start_pos;
57
58 // LOG_DBG("%s: checking at pos %zu, sv='%s'\n", __func__, start_pos, std::string(sv).c_str());
59
60 while (pos < sv.size()) {
61 auto result = common_parse_utf8_codepoint(sv, pos);
62 if (result.status != utf8_parse_result::SUCCESS) {
63 break;
64 }
65
66 auto it = nodes[current].children.find(result.codepoint);
67 if (it == nodes[current].children.end()) {
68 // Can't continue matching
69 return match_result{match_result::NO_MATCH};
70 }
71
72 current = it->second;
73 pos += result.bytes_consumed;
74
75 // Check if we've matched a complete word
76 if (nodes[current].is_word) {
77 return match_result{match_result::COMPLETE_MATCH};
78 }
79 }
80
81 // Reached end of input while still in the trie (not at root)
82 if (current != 0) {
83 // We're in the middle of a potential match
84 return match_result{match_result::PARTIAL_MATCH};
85 }
86
87 // Reached end at root (no match)
88 return match_result{match_result::NO_MATCH};
89 }
90
91 struct prefix_and_next {
92 std::vector<uint32_t> prefix;

Callers 1

operator()Method · 0.80

Calls 4

findMethod · 0.80
endMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected