LARA

object SimpleCFG {
  type Variable = String // for simplicity
 
  sealed abstract class SimpleValue
  case class VarValue(v : Variable) extends SimpleValue {
    override def toString = v
  }
  case class Const(c : Int) extends SimpleValue {
    override def toString = { "" + c }
  }
 
  sealed abstract class Operation
  sealed case class ArithOp extends Operation
  case object PlusOp extends ArithOp {
    override def toString = "+"
  }
  abstract case class RelOp extends Operation 
  case object EqOp extends RelOp {
    override def toString = "=="
  }
  case object NeqOp extends RelOp {
    override def toString = "!="
  }
  case object LeqOp extends RelOp {
    override def toString = "<="
  }
  case object LTOp extends RelOp {
    override def toString = "<"
  }
 
  sealed abstract class CfgStmt
  case class AssignBin(res : Variable, 
		       x : SimpleValue,
		       op : Operation,
		       y : SimpleValue) extends CfgStmt {
    override def toString = { res + " := " + x + " " + op + " " + y }
  }
  case class Copy(res : Variable,
		  x : SimpleValue) extends CfgStmt {
    override def toString = { res + " := " + x }
  }
  // test for condition
  case class Assume(x : SimpleValue, 
		    relOp : RelOp,
		    y : SimpleValue) extends CfgStmt {
    override def toString = { "[" + x + " " + relOp + " " + y + "]" }
  }
  case class Print(x : SimpleValue) extends CfgStmt
  case object Skip extends CfgStmt
 
  class Cfg extends LabDiGraphImp[CfgStmt] {
    var entry : Vertex = newVertex
    var exit : Vertex = newVertex
    override def toString = "[>" + entry + super.toString + exit + "<]"    
  }
 
  def main(args : Array[String]) = {
    val c = new Cfg
    println(c)
    val st = AssignBin("x", VarValue("y"),PlusOp,Const(42))
    c += (c.entry, st, c.exit)
    println(c)
  }
}