|
12 | 12 |
|
13 | 13 | namespace spanparsing {
|
14 | 14 |
|
15 |
| -/** Parse a constant. If successful, sp is updated to skip the constant and return true. */ |
| 15 | +/** Parse a constant. |
| 16 | + * |
| 17 | + * If sp's initial part matches str, sp is updated to skip that part, and true is returned. |
| 18 | + * Otherwise sp is unmodified and false is returned. |
| 19 | + */ |
16 | 20 | bool Const(const std::string& str, Span<const char>& sp);
|
17 | 21 |
|
18 |
| -/** Parse a function call. If successful, sp is updated to be the function's argument(s). */ |
| 22 | +/** Parse a function call. |
| 23 | + * |
| 24 | + * If sp's initial part matches str + "(", and sp ends with ")", sp is updated to be the |
| 25 | + * section between the braces, and true is returned. Otherwise sp is unmodified and false |
| 26 | + * is returned. |
| 27 | + */ |
19 | 28 | bool Func(const std::string& str, Span<const char>& sp);
|
20 | 29 |
|
21 |
| -/** Return the expression that sp begins with, and update sp to skip it. */ |
| 30 | +/** Extract the expression that sp begins with. |
| 31 | + * |
| 32 | + * This function will return the initial part of sp, up to (but not including) the first |
| 33 | + * comma or closing brace, skipping ones that are surrounded by braces. So for example, |
| 34 | + * for "foo(bar(1),2),3" the initial part "foo(bar(1),2)" will be returned. sp will be |
| 35 | + * updated to skip the initial part that is returned. |
| 36 | + */ |
22 | 37 | Span<const char> Expr(Span<const char>& sp);
|
23 | 38 |
|
24 |
| -/** Split a string on every instance of sep, returning a vector. */ |
| 39 | +/** Split a string on every instance of sep, returning a vector. |
| 40 | + * |
| 41 | + * If sep does not occur in sp, a singleton with the entirety of sp is returned. |
| 42 | + * |
| 43 | + * Note that this function does not care about braces, so splitting |
| 44 | + * "foo(bar(1),2),3) on ',' will return {"foo(bar(1)", "2)", "3)"}. |
| 45 | + */ |
25 | 46 | std::vector<Span<const char>> Split(const Span<const char>& sp, char sep);
|
26 | 47 |
|
27 | 48 | } // namespace spanparsing
|
|
0 commit comments