@@ -33,13 +33,17 @@ pub fn Parser(comptime _T: type) type {
33
33
};
34
34
}
35
35
36
- /// The result of a parse where `ok` corresponds to a successful parse
36
+ /// The result of a parse. where `ok` corresponds to a successful parse
37
37
/// and `err` denotes a failure. The result will be placed in `value`
38
38
/// and `rest` will contain the unparsed input. On error, `pos` will contain
39
39
/// the position where the parser stopped and the next parser can pick up.
40
40
pub fn Result (comptime T : type ) type {
41
41
return struct {
42
+ /// An index into the input string pointing to the end of what was parsed.
42
43
index : usize ,
44
+
45
+ /// The value parsed. Can either be `ok`, meaning parsing was successful, or `err` meaning
46
+ /// the string could not be parsed.
43
47
value : union (enum ) {
44
48
ok : T ,
45
49
err ,
@@ -463,9 +467,9 @@ test "combine" {
463
467
464
468
/// Takes a tuple of `Parser(T)` and constructs a parser that
465
469
/// succeeds when at least one of the child parsers succeeds.
466
- /// Note that /// parsers will be called in order, with `str`
470
+ /// Note that parsers will be called in order, with `str`
467
471
/// as input. The parser will return with the type of the first
468
- // child parser and the result of the first child parser
472
+ /// child parser and the result of the first child parser
469
473
/// that succeeds. The parser result will be `Result(T)`.
470
474
pub fn oneOf (comptime parsers : anytype ) Parser (ParserResult (@TypeOf (parsers [0 ]))) {
471
475
inline for (parsers ) | parser |
0 commit comments