Remove concatination from the builder, it's now the duty of the internal method

This commit is contained in:
Florian Schroedl
2022-01-20 17:00:00 +01:00
parent 6fe5df066a
commit ff1d6845eb
3 changed files with 47 additions and 37 deletions

View File

@@ -8,12 +8,19 @@ type OrgBuilder* = Builder[OrgBuilderT]
type OrgBuilderResult* = BuilderResult[OrgBuilderT]
func makeOrgBuilderToken*(kind: orgElementKind): string -> OrgBuilderT =
func textTokenizer*(kind: orgElementKind): seq[ParserToken] -> seq[OrgBuilderT] =
return func(tokens: seq[ParserToken]): seq[OrgBuilderT] =
return @[
OrgBuilderT(
kind: kind,
content: tokens.tokensToString(),
)
]
func rawTextTokenizer*(kind: orgElementKind): string -> OrgBuilderT =
return func(content: string): OrgBuilderT =
return OrgBuilderT(
kind: orgRawText,
kind: kind,
content: content,
)
proc mergeOrgTokens*(tokenizer: string -> OrgBuilderT): (seq[ParserToken], seq[OrgBuilderT]) -> seq[OrgBuilderT] =
return proc(parserTokens: seq[ParserToken], builderTokens: seq[OrgBuilderT]): seq[OrgBuilderT] =
return builderTokens & tokenizer(parserTokens.tokensToString())