Commit 083df74b authored by Christian Müller's avatar Christian Müller

Merge branch 'master' of versioncontrolseidl.in.tum.de:mueller/loopingworkflows

parents 1d95e01f 3cdc3e19
......@@ -29,6 +29,11 @@ object Encoding extends LazyLogging {
def makeblock(b: Block, n1: Int, n2:Int, makeNode: (() => Int), makeId: (() => Block)):(List[LDiEdge[Int]]) = {
b match {
// single edge
case b: SimpleBlock => {
List((n1 ~+> n2)(b))
}
case Loop(steps) => {
// add empty statement if loop ends with loop
val adjsteps = steps.last match {
......@@ -45,9 +50,19 @@ object Encoding extends LazyLogging {
}
edges.flatten :+ (n1 ~+> n2)(makeId())
}
// single edge
case b:Block => {
List((n1 ~+> n2)(b))
case NondetChoice(l1, l2) => {
val newnodes1 = n1 +: (0 until l1.size - 1).toList.map(_ => makeNode()) :+ n2
val edgenodes1 = newnodes1.sliding(2).toList
val edges1 = for ((step, List(start, end)) <- l1.zip(edgenodes1)) yield {
makeblock(step, start, end, makeNode, makeId)
}
val newnodes2 = n1 +: (0 until l2.size - 1).toList.map(_ => makeNode()) :+ n2
val edgenodes2 = newnodes2.sliding(2).toList
val edges2 = for ((step, List(start, end)) <- l2.zip(edgenodes2)) yield {
makeblock(step, start, end, makeNode, makeId)
}
edges1.flatten ++ edges2.flatten
}
}
}
......
......@@ -153,7 +153,7 @@ object WorkflowParser extends RegexParsers with LazyLogging {
def LOOP = "loop" ~> "{" ~> (BLOCK+) <~ "}" ^^ { case bs => Loop(bs) }
def NDCHOICE = "choose" ~> "{" ~> ((BLOCK+) <~ "}" <~ "{")~ (BLOCK+) <~ "}" ^^ { case l ~ r => NondetChoice(l,r) }
def WORKFLOW = rep(BLOCK | LOOP) ^? {
def WORKFLOW = rep(BLOCK | LOOP | NDCHOICE) ^? {
case blocks if checkSig(blocks) => {
val choiceblocks = addChoicePredicates(blocks)
Workflow(buildSig(choiceblocks), choiceblocks)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment