def OPT(r: Rexp) = ALT(r, ONE) def NTIMES(r: Rexp, n: Int) : Rexp = n match { case 0 => ONE case 1 => r case n => SEQ(r, NTIMES(r, n - 1)) }