This GitLab instance reached the end of its service life. It won't be possible to create new users or projects.

Please read the deprecation notice for more information concerning the deprecation timeline

Visit migration.git.tu-berlin.de (internal network only) to import your old projects to the new GitLab platform 📥

DirectTSImporter.scala 822 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
package de.bbisping.coupledsim.ts

import de.bbisping.coupledsim.util.LabeledRelation


class DirectTSImporter(
    tsFileContent: String
  ) {
  
  val silentActions = Set(Symbol("i"))
  
  
  def result(): WeakTransitionSystem[Int, Symbol, Symbol] = {
    
    val transitionMatcher = """(\d*)\s*,\s*(\d*)\s*,\s*\"?([^\"]*)\"?""".r
    
    val transitions = for {
18
      l <- tsFileContent.linesIterator
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
      val transitionMatcher(srcS, tarS, actionS) = l
      val src = srcS.toInt
      val tar = tarS.toInt
      val action = Symbol(actionS)
    } yield {
      (src, action, tar)
    }
    
    val trans = new LabeledRelation(transitions.toSet)

    val labels = (trans.lhs ++ trans.rhs) map { n => (n, Symbol("")) } toMap
    
    new WeakTransitionSystem[Int, Symbol, Symbol](trans, labels, silentActions)
  }
}