| 205 | } |
| 206 | |
| 207 | static std::pair<std::vector<common_peg_chars_parser::char_range>, bool> parse_char_classes(const std::string & classes) { |
| 208 | std::vector<common_peg_chars_parser::char_range> ranges; |
| 209 | bool negated = false; |
| 210 | |
| 211 | std::string content = classes; |
| 212 | if (content.front() == '[') { |
| 213 | content = content.substr(1); |
| 214 | } |
| 215 | |
| 216 | if (content.back() == ']') { |
| 217 | content.pop_back(); |
| 218 | } |
| 219 | |
| 220 | // Check for negation |
| 221 | if (!content.empty() && content.front() == '^') { |
| 222 | negated = true; |
| 223 | content = content.substr(1); |
| 224 | } |
| 225 | |
| 226 | size_t i = 0; |
| 227 | while (i < content.length()) { |
| 228 | auto [start, start_len] = parse_char_class_char(content, i); |
| 229 | i += start_len; |
| 230 | |
| 231 | if (i + 1 < content.length() && content[i] == '-') { |
| 232 | // Range detected |
| 233 | auto [end, end_len] = parse_char_class_char(content, i + 1); |
| 234 | ranges.push_back(common_peg_chars_parser::char_range{start, end}); |
| 235 | i += 1 + end_len; |
| 236 | } else { |
| 237 | ranges.push_back(common_peg_chars_parser::char_range{start, start}); |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | return {ranges, negated}; |
| 242 | } |
| 243 | |
| 244 | void common_peg_ast_arena::visit(common_peg_ast_id id, const common_peg_ast_visitor & visitor) const { |
| 245 | if (id == COMMON_PEG_INVALID_AST_ID) { |
no test coverage detected