progs/re3.scala
changeset 458 896a5f91838d
parent 454 edb4ad356c56
child 467 b5ec11e89768
equal deleted inserted replaced
457:921fdd17d2b8 458:896a5f91838d
    61 
    61 
    62 // main matcher function
    62 // main matcher function
    63 def matcher(r: Rexp, s: String) : Boolean = nullable(ders(s.toList, r))
    63 def matcher(r: Rexp, s: String) : Boolean = nullable(ders(s.toList, r))
    64 
    64 
    65 
    65 
       
    66 var regex = NTIMES(CHAR('a'),5)
       
    67 println(matcher(regex,"aaaaa"))
       
    68 
    66 //one or zero
    69 //one or zero
    67 def OPT(r: Rexp) = ALT(r, ONE)
    70 def OPT(r: Rexp) = ALT(r, ONE)
    68 
    71 
    69 //evil regular expressions
    72 //evil regular expressions
    70 def EVIL1(n: Int) = SEQ(NTIMES(OPT(CHAR('a')), n), NTIMES(CHAR('a'), n))
    73 def EVIL1(n: Int) = SEQ(NTIMES(OPT(CHAR('a')), n), NTIMES(CHAR('a'), n))