Add org builder initializer

This commit is contained in:
Florian Schroedl
2022-01-20 17:00:00 +01:00
parent ff1d6845eb
commit b7c0ead7d2
2 changed files with 7 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
import std/sugar
import std/collections/sequtils
import results
import ./org_types
import ../parser/parser_types
@@ -7,7 +7,11 @@ type OrgBuilderT* = OrgElement
type OrgBuilder* = Builder[OrgBuilderT]
type OrgBuilderResult* = BuilderResult[OrgBuilderT]
func makeOrgBuilderToken*(kind: orgElementKind): string -> OrgBuilderT =
func initOrgBuilder*(content: string): OrgBuilderResult =
return OrgBuilderResult.ok(OrgBuilder((
parser: initParser(content),
tree: newSeq[OrgBuilderT](),
)))
func textTokenizer*(kind: orgElementKind): seq[ParserToken] -> seq[OrgBuilderT] =
return func(tokens: seq[ParserToken]): seq[OrgBuilderT] =

View File

@@ -51,7 +51,7 @@ type
func initParserToken*(x: char): ParserToken = ParserToken(kind: parserTokenChar, charValue: x)
func initParserToken*(x: string): ParserToken = ParserToken(kind: parserTokenString, stringValue: x)
proc initParser*(str: string): Parser =
func initParser*(str: string): Parser =
Parser(
state: ParserState(
stream: str,