h0tk3y / better-parse

A nice parser combinator library for Kotlin
Apache License 2.0
419 stars 42 forks source link

reuse parser result in other delegate #49

Open asm0dey opened 2 years ago

asm0dey commented 2 years ago

Say I have a synthetic situation: number n says how many symbols x will be after this number. After that, I want to drop all other xs.

For example:

val digit by regexToken("\\d")
val n by literalToken("n")
val found by digit map {it.toInt()}
val result by found and (found times n) and -zeroOrMore(n)
//                       ^ can't do