progs/token.scala
changeset 550 71fc4a7a7039
parent 549 352d15782d35
child 552 40fa0f628dc4
equal deleted inserted replaced
549:352d15782d35 550:71fc4a7a7039
   102 // derivative w.r.t. a string (iterates der)
   102 // derivative w.r.t. a string (iterates der)
   103 def ders (s: List[Char], r: Rexp) : Rexp = s match {
   103 def ders (s: List[Char], r: Rexp) : Rexp = s match {
   104   case Nil => r
   104   case Nil => r
   105   case c::s => ders(s, der(c, r))
   105   case c::s => ders(s, der(c, r))
   106 }
   106 }
       
   107 
       
   108 val test : Rexp= STAR("a" | "aa")
       
   109 size(test)
       
   110 size(der('a', test))
       
   111 size(der('a', der('a', test)))
       
   112 
       
   113 size(ders("aaaaaa".toList, test)) 
       
   114 string(ders("aaaaaa".toList, test))
       
   115 
   107 
   116 
   108 // extracts a string from value
   117 // extracts a string from value
   109 def flatten(v: Val) : String = v match {
   118 def flatten(v: Val) : String = v match {
   110   case Empty => ""
   119   case Empty => ""
   111   case Chr(c) => c.toString
   120   case Chr(c) => c.toString