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

17
src/org/org_builder.nim Normal file
View File

@@ -0,0 +1,17 @@
import ./org_types
import ../parser/parser_types
type OrgBuilderT* = seq[OrgElement]
type StringBuilder* = Builder[OrgBuilderT]
type OrgBuilderResult* = BuilderResult[OrgBuilderT]
proc concat*(typeInfo: OrgBuilderT): (seq[ParserToken], seq[OrgBuilderT]) -> seq[OrgBuilderT] =
return proc(xs: seq[ParserToken], ys: seq[OrgBuilderT]): seq[OrgBuilderT] =
return ys & xs.foldl(a & b.tokenStringValue() & seperator, typeInfo)
proc initStringBuilder*(str: string): StringBuilderResult =
StringBuilderResult
.ok(StringBuilder((
parser: initParser(str),
tree: newSeq[OrgBuilderT](),
)))