Add whitespaceParser helper

This commit is contained in:
Florian Schroedl
2022-01-20 17:00:00 +01:00
parent 9d6be9707f
commit a24f89f7ff

View File

@@ -177,6 +177,13 @@ proc newline*(parser: Parser): ParserResult =
newlineParser(parser)
.mapErr((x: ParserError) => x.setErrorExpectedField("Newline"))
let whitespaceParser = choice(@[
ch(Whitespace),
newlineParser,
])
proc whitespace*(parser: Parser): ParserResult =
whitespaceParser(parser)
.mapErr((x: ParserError) => x.setErrorExpectedField("Whitespace"))
# when isMainModule:
# proc getTokens(x: ParserResult): seq[string] =