Convert tokens tail
This commit is contained in:
@@ -93,7 +93,7 @@ proc parseText[T](
|
||||
)
|
||||
|
||||
found = true
|
||||
parserAcc = parseResult
|
||||
parserAcc = parseResult.map(emptyTokens)
|
||||
builderAcc = builder.initBuilder(
|
||||
okParser,
|
||||
tokenFoldFn(
|
||||
@@ -106,7 +106,16 @@ proc parseText[T](
|
||||
if not found:
|
||||
parserAcc = parserAcc.flatMap(anyCh)
|
||||
|
||||
BuilderResult[T].ok(builderAcc)
|
||||
let textTokens = parserAcc
|
||||
.foldTokens(
|
||||
onError = _ => newSeq[T](),
|
||||
onSuccess = otherWiseFn,
|
||||
)
|
||||
|
||||
BuilderResult[T].ok(builder.initBuilder(
|
||||
builderAcc[0],
|
||||
builderAcc[1] & textTokens,
|
||||
))
|
||||
|
||||
proc makeRawTokenOrEmpty(xs: seq[ParserToken]): seq[OrgBuilderT] =
|
||||
let str = xs.foldl(a & b.tokenStringValue(), "")
|
||||
@@ -116,7 +125,7 @@ proc makeRawTokenOrEmpty(xs: seq[ParserToken]): seq[OrgBuilderT] =
|
||||
when isMainModule:
|
||||
|
||||
let foo = OrgBuilderResult.ok(OrgBuilder((
|
||||
parser: initParser("Just *some text* here"),
|
||||
parser: initParser("Just *some text* here *right*"),
|
||||
tree: newSeq[OrgBuilderT](),
|
||||
)))
|
||||
.flatMap((builder: OrgBuilder) => parseText(
|
||||
@@ -127,7 +136,7 @@ when isMainModule:
|
||||
otherWiseFn = makeRawTokenOrEmpty,
|
||||
))
|
||||
# .foldBuilder(
|
||||
# err => &"Error Parsing: {err}",
|
||||
# err => "",
|
||||
# xs => $xs
|
||||
# )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user