re2.scala
changeset 59 b64e876832cc
parent 49 d2c6852ca8da
equal deleted inserted replaced
58:f516892da470 59:b64e876832cc
    77 //one or zero
    77 //one or zero
    78 def OPT(r: Rexp) = ALT(r, EMPTY)
    78 def OPT(r: Rexp) = ALT(r, EMPTY)
    79 
    79 
    80 //n-times
    80 //n-times
    81 def NTIMES(r: Rexp, n: Int) : Rexp = n match {
    81 def NTIMES(r: Rexp, n: Int) : Rexp = n match {
    82   case 0 => NULL
    82   case 0 => EMPTY
    83   case 1 => r
    83   case 1 => r
    84   case n => SEQ(r, NTIMES(r, n - 1))
    84   case n => SEQ(r, NTIMES(r, n - 1))
    85 }
    85 }
    86 
    86 
    87 def RTEST(n: Int) = SEQ(NTIMES(OPT("a"), n), NTIMES("a", n))
    87 def RTEST(n: Int) = SEQ(NTIMES(OPT("a"), n), NTIMES("a", n))