Fahad/Eclipse/ScalaProjects/src/Handouts/Handout2.sc
changeset 39 56afb5950289
parent 36 d205c05e13d6
equal deleted inserted replaced
38:b48939cca0cf 39:56afb5950289
    13   case class SEQ(r1: Rexp, r2: Rexp) extends Rexp
    13   case class SEQ(r1: Rexp, r2: Rexp) extends Rexp
    14   case class STAR(r: Rexp) extends Rexp
    14   case class STAR(r: Rexp) extends Rexp
    15   case class NTIMES(r: Rexp, n: Int) extends Rexp
    15   case class NTIMES(r: Rexp, n: Int) extends Rexp
    16 
    16 
    17   def OPT(r: Rexp) = ALT(r, EMPTY)                //> OPT: (r: Handouts.Handout2.Rexp)Handouts.Handout2.ALT
    17   def OPT(r: Rexp) = ALT(r, EMPTY)                //> OPT: (r: Handouts.Handout2.Rexp)Handouts.Handout2.ALT
    18 
       
    19   /*
       
    20   def NTIMES(r: Rexp, n: Int): Rexp = n match {
       
    21     case 0 => EMPTY
       
    22     case 1 => r
       
    23     case n => SEQ(r, NTIMES(r, n - 1))
       
    24   }
       
    25   */
       
    26 
    18 
    27   def nullable(r: Rexp): Boolean = r match {
    19   def nullable(r: Rexp): Boolean = r match {
    28     case NULL => false
    20     case NULL => false
    29     case EMPTY => true
    21     case EMPTY => true
    30     case CHAR(_) => false
    22     case CHAR(_) => false