progs/matcher/re1.sc
changeset 759 d70dd0b57e35
parent 745 7dc3643a0cc5
child 765 b294cfbb5c01
equal deleted inserted replaced
758:194218161b71 759:d70dd0b57e35
    14 case object ONE extends Rexp                     // matches an empty string
    14 case object ONE extends Rexp                     // matches an empty string
    15 case class CHAR(c: Char) extends Rexp            // matches a character c
    15 case class CHAR(c: Char) extends Rexp            // matches a character c
    16 case class ALT(r1: Rexp, r2: Rexp) extends Rexp  // alternative
    16 case class ALT(r1: Rexp, r2: Rexp) extends Rexp  // alternative
    17 case class SEQ(r1: Rexp, r2: Rexp) extends Rexp  // sequence
    17 case class SEQ(r1: Rexp, r2: Rexp) extends Rexp  // sequence
    18 case class STAR(r: Rexp) extends Rexp            // star
    18 case class STAR(r: Rexp) extends Rexp            // star
       
    19 
    19 
    20 
    20 // nullable function: tests whether a regular 
    21 // nullable function: tests whether a regular 
    21 // expression can recognise the empty string
    22 // expression can recognise the empty string
    22 def nullable(r: Rexp) : Boolean = r match {
    23 def nullable(r: Rexp) : Boolean = r match {
    23   case ZERO => false
    24   case ZERO => false