orDefault

fun <T> EvalPE<T>.orDefault(value: T): EvalPE<T>

Optional parsing expression with the default value.

Samples

import io.kpeg.pe.Symbol.Rule
fun main() { 
   //sampleStart 
   // a - OK - 'a'
// A - OK - '?'
// b - OK - '?'

char('a')                   // EvalPE<Char>
    .orDefault(value = '?') // EvalPE<Char> 
   //sampleEnd
}

Sources

JVM source
Link copied to clipboard