Skip to content

Commit e184561

Browse files
Fixed default corrupt parse result for try
1 parent 0434d05 commit e184561

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

APCSharp/Parser/PResult.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public class PResult : PResultBase<ParserBuilder, Combiner, PResult, Node, NodeT
104104
/// </summary>
105105
/// <returns>Empty parse result</returns>
106106
public static PResult Empty(StreamReader stream) => Succeeded(Node.Empty, StreamReader.Null);
107+
public static PResult Corrupt(StreamReader stream) => Failed(string.Empty, string.Empty, stream);
107108
}
108109

109110
/// <summary>

APCSharp/Parser/ParserBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ public ParserBuilder Try<T>(Func<T, StreamReader, PResult> whenFail)
264264
/// <param name="whenFail"></param>
265265
/// <returns></returns>
266266
public ParserBuilder Try(Func<StreamReader, PResult> whenFail) => Try<Exception>((_, s) => whenFail(s));
267+
public ParserBuilder Try() => Try(PResult.Corrupt);
267268
/// <summary>
268269
/// Match a any amount of trailing whitespace, this will be appended on the previous parsed result.
269270
/// If you only want to allow trailing whitespaces, use IgnoredWhitespaces().

0 commit comments

Comments
 (0)