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

Function parse_char_classes

common/peg-parser.cpp:222–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220}
221
222static std::pair<std::vector<common_peg_chars_parser::char_range>, bool> parse_char_classes(const std::string & classes) {
223 std::vector<common_peg_chars_parser::char_range> ranges;
224 bool negated = false;
225
226 std::string content = classes;
227 if (content.front() == '[') {
228 content = content.substr(1);
229 }
230
231 if (content.back() == ']') {
232 content.pop_back();
233 }
234
235 // Check for negation
236 if (!content.empty() && content.front() == '^') {
237 negated = true;
238 content = content.substr(1);
239 }
240
241 size_t i = 0;
242 while (i < content.length()) {
243 auto [start, start_len] = parse_char_class_char(content, i);
244 i += start_len;
245
246 if (i + 1 < content.length() && content[i] == '-') {
247 // Range detected
248 auto [end, end_len] = parse_char_class_char(content, i + 1);
249 ranges.push_back(common_peg_chars_parser::char_range{start, end});
250 i += 1 + end_len;
251 } else {
252 ranges.push_back(common_peg_chars_parser::char_range{start, start});
253 }
254 }
255
256 return {ranges, negated};
257}
258
259common_peg_ast_id common_peg_ast_arena::find_by_tag(const common_peg_ast_node & parent, const std::string & tag, int max_depth) const {
260 for (auto child_id : parent.children) {

Callers 1

charsMethod · 0.85

Calls 4

parse_char_class_charFunction · 0.85
lengthMethod · 0.80
emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected