Got continous parsing working

This commit is contained in:
Florian Schroedl
2022-10-17 15:30:17 +02:00
parent fe2b7d065d
commit 065b298d1f
3 changed files with 25 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import std/[
collections/sequtils,
strformat,
sugar,
]
import fp/[
@@ -50,6 +51,22 @@ func initOrgBuilder*(content: string): OrgBuilderResult =
tree: newSeq[OrgBuilderT](),
)))
func pprint*(x: OrgBuilder): string =
&"""OrgBuilder(
parser: {x.parser}
tree: {x.tree}
)"""
func `$`*(x: OrgBuilder): string = pprint(x)
func pprint*(x: OrgBuilderError): string =
&"""OrgBuilderError(
parser: {x.parser}
tree: {x.tree}
)"""
func `$`*(x: OrgBuilderError): string = pprint(x)
# # proc orgBuilderConcat*(typeInfo: OrgBuilderT, concatFn: (ParserToken, OrgBuilderT) -> OrgBuilderT):
# # (seq[ParserToken], OrgBuilderT) -> OrgBuilderT =
# # return proc(xs: seq[ParserToken], builder: OrgBuilderT): OrgBuilderT =

View File

@@ -123,5 +123,5 @@ when isMainModule:
block testParsers:
let test = initOrgBuilder("""- List item
1. List item
random stuff""").flatMap((builder: OrgBuilder) => builder.buildParagraph(paragraphBuilders))
echo test.isOk()
- random stuff""").flatMap((builder: OrgBuilder) => builder.buildParagraph(paragraphBuilders))
echo test

View File

@@ -83,6 +83,12 @@ proc tryTokenize*[T](
),
))
# -- Stringifiers
func pprint[T](x: Builder): string =
&"""Builder()
"""
when isMainModule:
type TestStringBuilderT* = string
type TestStringBuilder* = Builder[TestStringBuilderT]