Return the expression that sp begins with, and update sp to skip it. */
| 395 | |
| 396 | /** Return the expression that sp begins with, and update sp to skip it. */ |
| 397 | Span<const char> Expr(Span<const char>& sp) |
| 398 | { |
| 399 | int level = 0; |
| 400 | auto it = sp.begin(); |
| 401 | while (it != sp.end()) { |
| 402 | if (*it == '(') { |
| 403 | ++level; |
| 404 | } else if (level && *it == ')') { |
| 405 | --level; |
| 406 | } else if (level == 0 && (*it == ')' || *it == ',')) { |
| 407 | break; |
| 408 | } |
| 409 | ++it; |
| 410 | } |
| 411 | Span<const char> ret = sp.first(it - sp.begin()); |
| 412 | sp = sp.subspan(it - sp.begin()); |
| 413 | return ret; |
| 414 | } |
| 415 | |
| 416 | /** Split a string on every instance of sep, returning a vector. */ |
| 417 | std::vector<Span<const char>> Split(const Span<const char>& sp, char sep) |
no test coverage detected