Build text parser

This commit is contained in:
Florian Schroedl
2022-01-20 17:00:00 +01:00
parent 647c5cdf00
commit 7c16ece752
8 changed files with 126 additions and 5 deletions

View File

@@ -19,3 +19,13 @@ proc initStringBuilder*(str: string): StringBuilderResult =
parser: initParser(str),
tree: newSeq[StringBuilderT](),
)))
proc fold*[T, E, T2](
self: Result[T, E],
onError: E -> T2,
onSuccess: T -> T2,
): T2 =
if self.isOk():
onSuccess(self.unsafeGet())
else:
onError(self.error())