Render items with react
This commit is contained in:
@@ -108,6 +108,32 @@ func ignore*(parserFn: Parser -> ParserResult): (Parser -> ParserResult) {.inlin
|
||||
tokens: parser.tokens,
|
||||
))
|
||||
|
||||
func manyUntilPerformant*(acceptFn: Parser -> ParserResult, stopFn: Parser -> ParserResult): (Parser -> ParserResult) {.inline.} =
|
||||
## Parse characters but throw success tokens away
|
||||
return proc(parser: Parser): ParserResult =
|
||||
let startPosition = parser.state.position
|
||||
var res: ParserResult = parser.ok()
|
||||
|
||||
while res.isOk() and res.flatMap(stopFn).isErr():
|
||||
res = res.flatMap(acceptFn)
|
||||
|
||||
return res.map((p: Parser) => Parser(
|
||||
state: ParserState(
|
||||
stream: p.state.stream,
|
||||
position: p.state.position,
|
||||
lastPosition: p.state.lastPosition,
|
||||
),
|
||||
tokens: @[
|
||||
ParserToken(
|
||||
kind: parserTokenString,
|
||||
stringValue: p.state.stream[(startPosition - 1)..p.state.position],
|
||||
)
|
||||
]
|
||||
))
|
||||
|
||||
proc anyUntilPerformant*(stopFn: Parser -> ParserResult): (Parser -> ParserResult) {.inline.} =
|
||||
manyUntilPerformant(anyCh, stopFn)
|
||||
|
||||
func manyUntil*(acceptFn: Parser -> ParserResult, stopFn: Parser -> ParserResult): (Parser -> ParserResult) {.inline.} =
|
||||
## Parse characters but throw success tokens away
|
||||
return proc(parser: Parser): ParserResult =
|
||||
|
||||
Reference in New Issue
Block a user