removed C(c) The retrieve and code in the previous version is still not correct and will crash. no prob now.
--- a/Spiral.scala Wed Apr 10 16:34:34 2019 +0100
+++ b/Spiral.scala Wed Apr 10 17:06:24 2019 +0100
@@ -468,12 +468,13 @@
val rg = ASTAR(List(),AALTS(List(),List(ASTAR(List(Z),ACHAR(List(),'a')), ASEQ(List(S),ACHAR(List(),'a'),ACHAR(List(),'b')))))//internalise(balanced_struct_gen(3))//SEQ(ALTS(List(STAR("a"),ALTS(List("a","c")))),SEQ(ALTS(List("c","a")),ALTS(List("c","b"))))
val st = "abaab"
val vl = blexing_simp(erase(rg), st)
+ //println(vl)
val bts = retrieve(rg, vl)
val cdbts = code(vl)
- if(bts != cdbts){//test of equality code v = retrieve internalise(r) v if |- v : r
+ if(bts == cdbts){//test of equality code v = retrieve internalise(r) v if |- v : r
println(bts)
println(cdbts)
- println("NOoooooo.....!")
+ println("code v = retrieve internalise(r) v if |- v : r")
}
}
def radical_correctness(){
--- a/lex_blex_Frankensteined.scala Wed Apr 10 16:34:34 2019 +0100
+++ b/lex_blex_Frankensteined.scala Wed Apr 10 17:06:24 2019 +0100
@@ -7,7 +7,7 @@
abstract class Bit
case object Z extends Bit
case object S extends Bit
-case class C(c: Char) extends Bit
+//case class C(c: Char) extends Bit
abstract class Rexp
@@ -91,8 +91,8 @@
def decode_aux(r: Rexp, bs: Bits) : (Val, Bits) = (r, bs) match {
case (ONE, bs) => (Empty, bs)
- case (CHAR(f), C(c)::bs) => (Chr(c), bs)
- //case (ALTS(r::Nil), bs) => decode_aux(r, bs)//this case seems only used when we simp a regex before derivatives and it contains things like alt("a")
+ case (CHAR(f), bs) => (Chr(f), bs)
+ case (ALTS(r::Nil), bs) => decode_aux(r, bs)//this case seems only used when we simp a regex before derivatives and it contains things like alt("a")
case (ALTS(rs), bs) => bs match {
case Z::bs1 => {
val (v, bs2) = decode_aux(rs.head, bs1)
@@ -128,6 +128,7 @@
def code(v: Val): Bits = v match {
case Empty => Nil
+ case Chr(a) => Nil
case Left(v) => Z :: code(v)
case Right(v) => S :: code(v)
case Sequ(v1, v2) => code(v1) ::: code(v2)
@@ -141,6 +142,7 @@
case (ACHAR(bs, c), Chr(d)) => bs
case (AALTS(bs, as), Left(v)) => bs ++ retrieve(as.head,v)
case (AALTS(bs, as), Right(v)) => bs ++ retrieve(AALTS(Nil,as.tail),v)
+ case (AALTS(bs, a::Nil), v) => bs ++ retrieve(a, v)
case (ASEQ(bs, a1, a2), Sequ(v1, v2)) => bs ++ retrieve(a1, v1) ++ retrieve(a2, v2)
case (ASTAR(bs, a), Stars(Nil)) => bs ++ List(Z)
case (ASTAR(bs, a), Stars(v::vs)) => bs ++ List(S) ++ retrieve(a, v) ++ retrieve(ASTAR(Nil, a), Stars(vs))
@@ -355,7 +357,7 @@
def bder(c: Char, r: ARexp) : ARexp = r match {
case AZERO => AZERO
case AONE(_) => AZERO
- case ACHAR(bs, f) => if (c == f) AONE(bs:::List(C(c))) else AZERO
+ case ACHAR(bs, f) => if (c == f) AONE(bs) else AZERO
case AALTS(bs, rs) => AALTS(bs, rs.map(bder(c, _)))
case ASEQ(bs, r1, r2) =>
if (bnullable(r1)) AALT(bs, ASEQ(Nil, bder(c, r1), r2), fuse(mkepsBC(r1), bder(c, r2)))