25 case class Right(v: Val) extends Val |
26 case class Right(v: Val) extends Val |
26 case class Stars(vs: List[Val]) extends Val |
27 case class Stars(vs: List[Val]) extends Val |
27 case class Rec(x: String, v: Val) extends Val |
28 case class Rec(x: String, v: Val) extends Val |
28 |
29 |
29 |
30 |
30 // Convenience typing |
31 // Convenience for typing |
31 def charlist2rexp(s : List[Char]): Rexp = s match { |
32 def charlist2rexp(s : List[Char]): Rexp = s match { |
32 case Nil => ONE |
33 case Nil => ONE |
33 case c::Nil => CHAR(c) |
34 case c::Nil => CHAR(c) |
34 case c::s => SEQ(CHAR(c), charlist2rexp(s)) |
35 case c::s => SEQ(CHAR(c), charlist2rexp(s)) |
35 } |
36 } |
134 case (CHAR(d), Empty) => Chr(c) |
135 case (CHAR(d), Empty) => Chr(c) |
135 case (RECD(x, r1), _) => Rec(x, inj(r1, c, v)) |
136 case (RECD(x, r1), _) => Rec(x, inj(r1, c, v)) |
136 |
137 |
137 case (RANGE(_), Empty) => Chr(c) |
138 case (RANGE(_), Empty) => Chr(c) |
138 case (PLUS(r), Sequ(v1, Stars(vs))) => Stars(inj(r, c, v1)::vs) |
139 case (PLUS(r), Sequ(v1, Stars(vs))) => Stars(inj(r, c, v1)::vs) |
139 case (OPTIONAL(r), Left(v1)) => Stars(List(inj(r, c, v1))) |
140 case (OPTIONAL(r), v1) => Stars(List(inj(r, c, v1))) |
140 case (NTIMES(r, n), Sequ(v1, Stars(vs))) => Stars(inj(r, c, v1)::vs) |
141 case (NTIMES(r, n), Sequ(v1, Stars(vs))) => Stars(inj(r, c, v1)::vs) |
141 } |
142 } |
142 |
143 |
143 // Rectification functions |
144 // Rectification functions |
144 def F_ID(v: Val): Val = v |
145 def F_ID(v: Val): Val = v |