| 220 | } |
| 221 | |
| 222 | static 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 | |
| 259 | common_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) { |
no test coverage detected