author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Wed, 27 Nov 2013 21:36:30 +0000 | |
changeset 208 | bd5a8a6b3871 |
parent 95 | dbe49327b6c5 |
permissions | -rw-r--r-- |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
import scala.language.implicitConversions |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
import scala.language.reflectiveCalls |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3 |
|
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
abstract class Rexp |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
|
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
case object NULL extends Rexp |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
7 |
case object EMPTY extends Rexp |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
case class CHAR(c: Char) extends Rexp |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
case class ALT(r1: Rexp, r2: Rexp) extends Rexp |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
case class SEQ(r1: Rexp, r2: Rexp) extends Rexp |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
case class STAR(r: Rexp) extends Rexp |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
12 |
|
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
13 |
abstract class Pat |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
14 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
15 |
case class VAR(x: String, r: Rexp) extends Pat |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
16 |
case class GRP(x: String, p: Pat) extends Pat |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
17 |
case class PSEQ(p1: Pat, p2: Pat) extends Pat |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
18 |
case class PALT(p1: Pat, p2: Pat) extends Pat |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
19 |
case class PSTAR(p: Pat) extends Pat |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
20 |
|
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
21 |
|
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
def nullable (r: Rexp) : Boolean = r match { |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
23 |
case NULL => false |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
24 |
case EMPTY => true |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
25 |
case CHAR(_) => false |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
26 |
case ALT(r1, r2) => nullable(r1) || nullable(r2) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
27 |
case SEQ(r1, r2) => nullable(r1) && nullable(r2) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
28 |
case STAR(_) => true |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
29 |
} |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
30 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
31 |
def down (p: Pat) : Rexp = p match { |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
32 |
case VAR(x: String, w: String, r: Rexp) => r |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
33 |
case GRP(x: String, w: String, p: Pat) => down(p) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
34 |
case PSEQ(p1: Pat, p2: Pat) => SEQ(down(p1), down(p2)) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
35 |
case PALT(p1: Pat, p2: Pat) => ALT(down(p1), down(p2)) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
36 |
case PSTAR(p: Pat) => STAR(down(p)) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
37 |
} |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
38 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
39 |
def patnullable (p: Pat) : Boolean = p match { |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
40 |
case PVar(_, r) => nullable(r) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
41 |
case PSEQ(p1, p2) => patnullable(p1) && patnullable(p2) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
42 |
case PCHOICE(p1, p2) => patnullable(p1) || patnullable(p2) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
43 |
case PSTAR(p) => true |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
44 |
case PatVar(_, p) => patnullable(p) |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
45 |
} |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
46 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
47 |
//type Env = Set[List[(String, String)]] |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
48 |
type Env = Map[Int, String] |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
49 |
|
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
50 |
def update(n: Int, c: Char) (env: Env) = |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
51 |
env + (n -> (env.getOrElse(n, "") + c.toString)) |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
52 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
53 |
def pderivPat (p: Pat, c: Char) : Set[(Pat, Env => Env)] = p match { |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
54 |
case PVar(n: Int, r: Rexp) => { |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
55 |
val pds = pderiv(r, c) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
56 |
if (pds.isEmpty) Set() |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
57 |
else Set((PVar(n, toRexp(pds.toList)), update(n, c))) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
58 |
} |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
59 |
case PSEQ(p1: Pat, p2: Pat) => { |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
60 |
val pats : Set[(Pat, Env => Env)] = |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
61 |
for ((p, f) <- pderivPat(p1, c)) yield (PSEQ(p, p2), f) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
62 |
if (nullable(strip(p1))) pats ++ pderivPat(p2, c) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
63 |
else pats |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
64 |
} |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
65 |
case PCHOICE(p1: Pat, p2: Pat) => pderivPat(p1, c) ++ pderivPat(p2, c) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
66 |
case PSTAR(p1: Pat) => |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
67 |
for ((p, f) <- pderivPat(p1, c)) yield (PSEQ(p, PSTAR(p1)), f) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
68 |
case PatVar(n: Int, p1: Pat) => |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
69 |
for ((p, f) <- pderivPat(p1, c)) yield (PatVar(n, p), f compose (update (n, c))) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
70 |
} |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
71 |
|
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
72 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
73 |
val p2 = PSEQ(PVar(1, STAR("A")), PVar(2, STAR("A"))) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
74 |
pderivPat(p2, 'A').mkString("\n") |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
75 |
|
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
76 |
|
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
77 |
def greedy_aux(env: Set[(Pat, Env)], w: List[Char]) : Set[Env] = w match { |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
78 |
case Nil => |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
79 |
for ((p, e) <- env if patnullable(p)) yield e |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
80 |
case c::cs => { |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
81 |
val env2 = for ((p, e) <- env; (p1, f) <- pderivPat(p, c)) yield (p1, f(e)) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
82 |
greedy_aux(env2, cs) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
83 |
} |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
84 |
} |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
85 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
86 |
def greedy(p: Pat, w: String) = { |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
87 |
val res = greedy_aux(Set((p, Map())), w.toList) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
88 |
if (res.isEmpty) None else Some(res) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
89 |
} |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
90 |
|
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
91 |
// some convenience for typing in regular expressions |
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
92 |
def charlist2rexp (s : List[Char]) : Rexp = s match { |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
93 |
case Nil => EMPTY |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
94 |
case c::Nil => CHAR(c) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
95 |
case c::s => SEQ(CHAR(c), charlist2rexp(s)) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
96 |
} |
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
97 |
implicit def string2rexp (s : String) : Rexp = charlist2rexp(s.toList) |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
98 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
99 |
implicit def RexpOps (r: Rexp) = new { |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
100 |
def | (s: Rexp) = ALT(r, s) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
101 |
def % = STAR(r) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
102 |
def ~ (s: Rexp) = SEQ(r, s) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
103 |
} |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
104 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
105 |
implicit def stringOps (s: String) = new { |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
106 |
def | (r: Rexp) = ALT(s, r) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
107 |
def | (r: String) = ALT(s, r) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
108 |
def % = STAR(s) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
109 |
def ~ (r: Rexp) = SEQ(s, r) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
110 |
def ~ (r: String) = SEQ(s, r) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
111 |
} |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
112 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
113 |
implicit def PatOps (p: Pat) = new { |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
114 |
def | (q: Pat) = PALT(p, q) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
115 |
def % = PSTAR(p) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
116 |
def ~ (q: Pat) = PSEQ(p, q) |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
117 |
} |
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
118 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
119 |
val p3 = PSTAR(PSEQ(PVar(1, "A"), PVar(2, "B"))) |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
120 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
121 |
greedy2(Set((p3, Map())), "ABAB".toList) |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
122 |
|
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
123 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
124 |
val p4 = PVar(1, "A") |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
125 |
greedy2(Set((p4, Map())), "A".toList) |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
126 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
127 |
val p5 = PSEQ(PVar(1, "A"), PVar(1, "B")) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
128 |
greedy2(Set((p5, Map())), "AB".toList) |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
129 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
130 |
val res = pderivPat(p5, 'A') |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
131 |
for ((_, f) <- res) yield f(Map()) |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
132 |
|
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
133 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
134 |
val p6 = PatVar(4,PSTAR(PCHOICE(PCHOICE(PVar(1, "A"), PVar(2, "AB")), PVar(3, "B")))) |
94
9ea667baf097
added first part of the Sulzmann paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
135 |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
136 |
greedy(p6, "ABA") |