progs/token2.scala
changeset 388 66f66f1710ed
parent 385 7f8516ff408d
child 392 2d0a59127694
equal deleted inserted replaced
387:8aa406adfde0 388:66f66f1710ed
   152 def lexing(r: Rexp, s: String) : Val = lex(r, s.toList)
   152 def lexing(r: Rexp, s: String) : Val = lex(r, s.toList)
   153 
   153 
   154 lexing(("ab" | "ab") ~ ("b" | EMPTY), "ab")
   154 lexing(("ab" | "ab") ~ ("b" | EMPTY), "ab")
   155 
   155 
   156 lexing(OPT("ab"), "ab")
   156 lexing(OPT("ab"), "ab")
       
   157 
       
   158 lexing(NTIMES("1", 3), "111")
       
   159 lexing(NTIMES("1" | EMPTY, 3), "11")
   157 
   160 
   158 // some "rectification" functions for simplification
   161 // some "rectification" functions for simplification
   159 def F_ID(v: Val): Val = v
   162 def F_ID(v: Val): Val = v
   160 def F_RIGHT(f: Val => Val) = (v:Val) => Right(f(v))
   163 def F_RIGHT(f: Val => Val) = (v:Val) => Right(f(v))
   161 def F_LEFT(f: Val => Val) = (v:Val) => Left(f(v))
   164 def F_LEFT(f: Val => Val) = (v:Val) => Left(f(v))