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