joinToString

fun <T> EvalPE<List<T>>.joinToString(separator: CharSequence = "", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: (T) -> CharSequence? = null): EvalPE<String>

This function works just like the joinToString from the standard library, but for the parsing expressions.

Samples

import io.kpeg.pe.Symbol.Rule
fun main() { 
   //sampleStart 
   //      - FAIL
// a    - OK   - a
// aa   - OK   - a|a
// aaa  - OK   - a|a|a
// aaaa - FAIL

char('a')                          // EvalPE<Char>
    .repeated(range = 1u..3u)      // EvalPE<List<Char>>
    .joinToString(separator = "|") // EvalPE<String> 
   //sampleEnd
}

Sources

JVM source
Link copied to clipboard