Skip to content

Commit 5e69aee

Browse files
committed
Add documenting comments to spanparsing.h
1 parent 230d43f commit 5e69aee

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/util/spanparsing.h

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,37 @@
1212

1313
namespace spanparsing {
1414

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+
*/
1620
bool Const(const std::string& str, Span<const char>& sp);
1721

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+
*/
1928
bool Func(const std::string& str, Span<const char>& sp);
2029

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+
*/
2237
Span<const char> Expr(Span<const char>& sp);
2338

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+
*/
2546
std::vector<Span<const char>> Split(const Span<const char>& sp, char sep);
2647

2748
} // namespace spanparsing

0 commit comments

Comments
 (0)