progs/scala/tests.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Wed, 23 Mar 2022 00:09:08 +0000
changeset 463 421397f267b9
parent 312 8b0b414e71b0
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
import scala.language.implicitConversions    
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
import scala.language.reflectiveCalls
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
import scala.annotation.tailrec   
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
import scala.io.Source
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
import scala.util.parsing.combinator._
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
abstract class Rexp 
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
case object ZERO extends Rexp 
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
case object ONE extends Rexp
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
case class CHAR(c: Char) extends Rexp {
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
  override def toString = c.toString 
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
}
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    13
case object ANYCHAR extends Rexp {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    14
  override def toString = "." 
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    15
}
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
case class ALT(r1: Rexp, r2: Rexp) extends Rexp {
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
  override def toString = "(" + r1.toString + "|" + r2.toString + ")" 
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
}
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
case class SEQ(r1: Rexp, r2: Rexp) extends Rexp {
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
  override def toString = "(" + r1.toString + r2.toString +")"
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
} 
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
case class STAR(r: Rexp) extends Rexp 
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    23
case class RECD(x: String, r: Rexp) extends Rexp {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    24
  override def toString = "[" + r.toString +"]"
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    25
}
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    26
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    27
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    28
abstract class Val
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    29
case object Empty extends Val
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    30
case class Chr(c: Char) extends Val
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    31
case class Sequ(v1: Val, v2: Val) extends Val
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    32
case class Left(v: Val) extends Val
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    33
case class Right(v: Val) extends Val
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    34
case class Stars(vs: List[Val]) extends Val
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    35
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    36
   
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    37
def Pos(v: Val) : Set[List[Int]] = v match {
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    38
  case Empty => Set(Nil)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    39
  case Chr(c) => Set(Nil)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    40
  case Left(v) => Set(Nil) ++ Pos(v).map(0::_) 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    41
  case Right(v) => Set(Nil) ++ Pos(v).map(1::_)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    42
  case Sequ(v1, v2) => Set(Nil) ++ Pos(v1).map(0::_) ++ Pos(v2).map(1::_)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    43
  case Stars(vs) => Set(Nil) ++ vs.zipWithIndex.map{ case (v, n) => n::Pos(v) }
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    44
} 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    45
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    46
val v1 = Sequ(Chr('a'), Chr('b'))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    47
val ps1 = Pos(v1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    48
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    49
val v2 = Left(Sequ(Chr('a'), Chr('b')))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    50
val ps2 = Pos(v2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    51
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    52
val v3 = Stars(List(Left(Chr('x')), Right(Left(Chr('y')))))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    53
val v4 = Stars(List(Right(Right(Sequ(Chr('x'), Chr('y'))))))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    54
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    55
val ps3 = Pos(v3)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    56
val ps4 = Pos(v4)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    57
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    58
def At(v: Val, ps: List[Int]) : Val = (v, ps) match {
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    59
  case (v, Nil) => v
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    60
  case (Left(v), 0::ps) => At(v, ps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    61
  case (Right(v), 1::ps) => At(v, ps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    62
  case (Sequ(v1, v2), 0::ps) => At(v1, ps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    63
  case (Sequ(v1, v2), 1::ps) => At(v2, ps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    64
  case (Stars(vs), n::ps) => At(vs(n), ps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    65
} 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    66
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    67
ps1.map(At(v1, _))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    68
ps2.map(At(v2, _))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    69
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    70
import scala.math.Ordering.Implicits._
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    71
ps1.toList.sorted
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    72
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    73
List(List(1, 1), List(1), List(0, 1)).sorted
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    74
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    75
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    76
// nullable function: tests whether the regular 
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    77
// expression can recognise the empty string
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    78
def nullable (r: Rexp) : Boolean = r match {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    79
  case ZERO => false
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    80
  case ONE => true
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    81
  case CHAR(_) => false
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    82
  case ANYCHAR => false
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    83
  case ALT(r1, r2) => nullable(r1) || nullable(r2)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    84
  case SEQ(r1, r2) => nullable(r1) && nullable(r2)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    85
  case STAR(_) => true
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    86
  case RECD(_, r1) => nullable(r1)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    87
}
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    88
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    89
// derivative of a regular expression w.r.t. a character
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    90
def der (c: Char, r: Rexp) : Rexp = r match {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    91
  case ZERO => ZERO
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    92
  case ONE => ZERO
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    93
  case CHAR(d) => if (c == d) ONE else ZERO
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    94
  case ANYCHAR => ONE
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    95
  case ALT(r1, r2) => ALT(der(c, r1), der(c, r2))
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    96
  case SEQ(r1, r2) => 
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    97
    if (nullable(r1)) ALT(SEQ(der(c, r1), r2), der(c, r2))
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    98
    else SEQ(der(c, r1), r2)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    99
  case STAR(r) => SEQ(der(c, r), STAR(r))
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   100
  case RECD(_, r1) => der(c, r1)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   101
}
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   102
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   103
// derivative w.r.t. a string (iterates der)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   104
def ders (s: List[Char], r: Rexp) : Rexp = s match {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   105
  case Nil => r
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   106
  case c::s => ders(s, der(c, r))
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   107
}
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   108
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   109
// extracts a string from value
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   110
def flatten(v: Val) : String = v match {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   111
  case Empty => ""
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   112
  case Chr(c) => c.toString
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   113
  case Left(v) => flatten(v)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   114
  case Right(v) => flatten(v)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   115
  case Sequ(v1, v2) => flatten(v1) + flatten(v2)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   116
  case Stars(vs) => vs.map(flatten).mkString
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   117
}
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   118
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   119
// extracts an environment from a value
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   120
def env(v: Val, r: Rexp) : List[(String, String)] = (v, r) match {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   121
  case (Empty, ONE) => Nil
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   122
  case (Chr(c), CHAR(_)) => Nil
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   123
  case (Chr(c), ANYCHAR) => Nil
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   124
  case (Left(v), ALT(r1, r2)) => env(v, r1)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   125
  case (Right(v), ALT(r1, r2)) => env(v, r2)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   126
  case (Sequ(v1, v2), SEQ(r1, r2)) => env(v1, r1) ::: env(v2, r2)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   127
  case (Stars(vs), STAR(r)) => vs.flatMap(env(_, r))
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   128
  case (v, RECD(x, r)) => (x, flatten(v))::env(v, r)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   129
}
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   130
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   131
// extracts indices for the underlying strings
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   132
def env2(v: Val, r: Rexp, n: Int) : (List[(Int, Int)], Int) = (v, r) match {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   133
  case (Empty, ONE) => (Nil, n)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   134
  case (Chr(c), CHAR(_)) => (Nil, n + 1)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   135
  case (Chr(c), ANYCHAR) => (Nil, n + 1)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   136
  case (Left(v), ALT(r1, r2)) => env2(v, r1, n)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   137
  case (Right(v), ALT(r1, r2)) => env2(v, r2, n)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   138
  case (Sequ(v1, v2), SEQ(r1, r2)) => {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   139
   val (e1, n1) = env2(v1, r1, n) 
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   140
   val (e2, n2) = env2(v2, r2, n1)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   141
   (e1 ::: e2, n2)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   142
  }
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   143
  case (Stars(Nil), STAR(r)) => (Nil, n)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   144
  case (Stars(v :: vs), STAR(r)) => {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   145
   val (e1, n1) = env2(v, r, n) 
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   146
   val (e2, n2) = env2(Stars(vs), STAR(r), n1)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   147
   (e1 ::: e2, n2)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   148
  }
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   149
  case (v, RECD(x, r)) => {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   150
    val (e1, n1) = env2(v, r, n)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   151
    ((n, n + flatten(v).length) :: e1, n1)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   152
  }
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   153
}
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   154
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   155
// injection part
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   156
def mkeps(r: Rexp) : Val = r match {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   157
  case ONE => Empty
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   158
  case ALT(r1, r2) => 
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   159
    if (nullable(r1)) Left(mkeps(r1)) else Right(mkeps(r2))
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   160
  case SEQ(r1, r2) => Sequ(mkeps(r1), mkeps(r2))
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   161
  case STAR(r) => Stars(Nil)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   162
  case RECD(x, r) => mkeps(r)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   163
}
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   164
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   165
def inj(r: Rexp, c: Char, v: Val) : Val = (r, v) match {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   166
  case (STAR(r), Sequ(v1, Stars(vs))) => Stars(inj(r, c, v1)::vs)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   167
  case (SEQ(r1, r2), Sequ(v1, v2)) => Sequ(inj(r1, c, v1), v2)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   168
  case (SEQ(r1, r2), Left(Sequ(v1, v2))) => Sequ(inj(r1, c, v1), v2)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   169
  case (SEQ(r1, r2), Right(v2)) => Sequ(mkeps(r1), inj(r2, c, v2))
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   170
  case (ALT(r1, r2), Left(v1)) => Left(inj(r1, c, v1))
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   171
  case (ALT(r1, r2), Right(v2)) => Right(inj(r2, c, v2))
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   172
  case (CHAR(d), Empty) => Chr(c) 
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   173
  case (ANYCHAR, Empty) => Chr(c) 
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   174
  case (RECD(x, r1), _) => inj(r1, c, v)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   175
}
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   176
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   177
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   178
// main lexing function (produces a value)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   179
def lex(r: Rexp, s: List[Char]) : Val = s match {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   180
  case Nil => if (nullable(r)) mkeps(r) else throw new Exception("Not matched")
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   181
  case c::cs => inj(r, c, lex(der(c, r), cs))
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   182
}
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   183
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   184
def lexing(r: Rexp, s: String) : Val = lex(r, s.toList)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   185
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   186
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   187
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   188
// Regular expression parser
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   189
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   190
case class Parser(s: String) {
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   191
  var i = 0
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   192
  
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   193
  def peek() = s(i)
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   194
  def eat(c: Char) = 
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   195
    if (c == s(i)) i = i + 1 else throw new Exception("Expected " + c + " got " + s(i))
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   196
  def next() = { i = i + 1; s(i - 1) }
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   197
  def more() = s.length - i > 0
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   198
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   199
  def Regex() : Rexp = {
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   200
    val t = Term();
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   201
    if (more() && peek() == '|') {
169
072a701bb153 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   202
      eat ('|') ; 
072a701bb153 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   203
      ALT(t, Regex()) 
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   204
    } 
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   205
    else t
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   206
  }
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   207
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   208
  def Term() : Rexp = {
169
072a701bb153 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   209
    var f : Rexp = 
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   210
      if (more() && peek() != ')' && peek() != '|') Factor() else ONE;
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   211
    while (more() && peek() != ')' && peek() != '|') {
169
072a701bb153 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   212
      f = SEQ(f, Factor()) ;
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   213
    }
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   214
    f
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   215
  }
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   216
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   217
  def Factor() : Rexp = {
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   218
    var b = Base();
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   219
    while (more() && peek() == '*') {
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   220
      eat('*') ;
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   221
      b = STAR(b) ;
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   222
    }
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   223
    while (more() && peek() == '?') {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   224
      eat('?') ;
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   225
      b = ALT(b, ONE) ;
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   226
    }
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   227
    while (more() && peek() == '+') {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   228
      eat('+') ;
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   229
      b = SEQ(b, STAR(b)) ;
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   230
    }
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   231
    b
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   232
  }
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   233
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   234
  def Base() : Rexp = {
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   235
    peek() match {
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   236
      case '(' => { eat('(') ; val r = Regex(); eat(')') ; RECD("",r) }
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   237
      case '.' => { eat('.'); ANYCHAR }
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   238
      case _ => CHAR(next())
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   239
    }
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   240
  }
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   241
}
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   242
197
a35041d5707c updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 196
diff changeset
   243
//test case
312
8b0b414e71b0 added size bounds for partial derivatives
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   244
println(Parser("a|(bc)*").Regex())
8b0b414e71b0 added size bounds for partial derivatives
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   245
println(Parser("(a|b)*(babab(a|b)*bab|bba(a|b)*bab)(a|b)*").Regex())
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   246
196
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   247
def process_line(line: String) : String = {
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   248
  if (line.head == '#') "#" else
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   249
    {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   250
      val line_split = line.split("\\t+")
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   251
      val reg_str = line_split(1)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   252
      val reg = RECD("", Parser(reg_str).Regex())
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   253
      val in_str = if (line_split(2) == "-") "" else line_split(2)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   254
      val res_str = line_split(3)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   255
      val our_val = lexing(reg, in_str)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   256
      val our_result = env2(our_val, reg, 0)._1.mkString("") 
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   257
      if (our_result != res_str) 
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   258
        { 
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   259
          reg_str + ":   " + 
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   260
          reg.toString + ": " + 
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   261
          in_str + "   \n " + 
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   262
          our_result +  
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   263
          " => \n" + res_str + " ! " +
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   264
          our_val + ":" + reg + "\n" 
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   265
        }
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   266
      else "*"
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   267
    }
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   268
}
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   269
196
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   270
def process_file(name : String) : Unit = {
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   271
  println("\nProcessing " + name)
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   272
  val filelines : List[String] = Source.fromFile(name).getLines.toList
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   273
  filelines.foreach((s: String) => print(process_line(s)))
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   274
}
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   275
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   276
196
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   277
val files = List("../tests/forced-assoc.txt",
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   278
                 "../tests/left-assoc.txt",
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   279
                 //"../tests/right-assoc.txt",
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   280
                 "../tests/class.txt",
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   281
                 "../tests/basic3.txt",
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   282
                 "../tests/totest.txt",
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   283
                 "../tests/repetition2.txt",
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   284
                 "../tests/osx-bsd-critical.txt")
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   285
196
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   286
files.foreach(process_file(_))
5fa8344a5176 added test processing
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 195
diff changeset
   287