re1.scala
changeset 59 b64e876832cc
parent 54 485f38b530ab
child 85 1a4065f965fb
equal deleted inserted replaced
58:f516892da470 59:b64e876832cc
    53 //one or zero
    53 //one or zero
    54 def OPT(r: Rexp) = ALT(r, EMPTY)
    54 def OPT(r: Rexp) = ALT(r, EMPTY)
    55 
    55 
    56 //n-times
    56 //n-times
    57 def NTIMES(r: Rexp, n: Int) : Rexp = n match {
    57 def NTIMES(r: Rexp, n: Int) : Rexp = n match {
    58   case 0 => NULL
    58   case 0 => EMPTY
    59   case 1 => r
    59   case 1 => r
    60   case n => SEQ(r, NTIMES(r, n - 1))
    60   case n => SEQ(r, NTIMES(r, n - 1))
    61 }
    61 }
    62 
    62 
    63 def RTEST(n: Int) = SEQ(NTIMES(OPT("a"), n), NTIMES("a", n))
    63 def RTEST(n: Int) = SEQ(NTIMES(OPT("a"), n), NTIMES("a", n))