Skip to content
Snippets Groups Projects
Commit d53a135d authored by Régis Blanc's avatar Régis Blanc
Browse files

print post condition as ensuring and precondition as require

parent 92fd83a4
No related branches found
No related tags found
No related merge requests found
...@@ -372,7 +372,7 @@ object ScalaPrinter { ...@@ -372,7 +372,7 @@ object ScalaPrinter {
nsb nsb
} }
case ResultVariable() => sb.append("#res") case ResultVariable() => sb.append("res")
case EpsilonVariable((row, col)) => sb.append("x" + row + "_" + col) case EpsilonVariable((row, col)) => sb.append("x" + row + "_" + col)
case Not(expr) => ppUnary(sb, expr, "\u00AC(", ")", lvl) // \neg case Not(expr) => ppUnary(sb, expr, "\u00AC(", ")", lvl) // \neg
...@@ -434,10 +434,7 @@ object ScalaPrinter { ...@@ -434,10 +434,7 @@ object ScalaPrinter {
defn match { defn match {
case Program(id, mainObj) => { case Program(id, mainObj) => {
assert(lvl == 0) assert(lvl == 0)
sb.append("package ") pp(mainObj, sb, lvl)
sb.append(id)
sb.append(" {\n")
pp(mainObj, sb, lvl+1).append("}\n")
} }
case ObjectDef(id, defs, invs) => { case ObjectDef(id, defs, invs) => {
...@@ -502,19 +499,6 @@ object ScalaPrinter { ...@@ -502,19 +499,6 @@ object ScalaPrinter {
nsb.append("@" + a + "\n") nsb.append("@" + a + "\n")
} }
pre.foreach(prec => {
ind(nsb, lvl)
nsb.append("@pre : ")
nsb = pp(prec, nsb, lvl)
nsb.append("\n")
})
post.foreach(postc => {
ind(nsb, lvl)
nsb.append("@post: ")
nsb = pp(postc, nsb, lvl)
nsb.append("\n")
})
ind(nsb, lvl) ind(nsb, lvl)
nsb.append("def ") nsb.append("def ")
...@@ -538,10 +522,31 @@ object ScalaPrinter { ...@@ -538,10 +522,31 @@ object ScalaPrinter {
nsb.append(") : ") nsb.append(") : ")
nsb = pp(rt, nsb, lvl) nsb = pp(rt, nsb, lvl)
nsb.append(" = ") nsb.append(" = ")
if(body.isDefined) if(body.isDefined) {
pp(body.get, nsb, lvl) pre match {
else case None => pp(body.get, nsb, lvl)
case Some(prec) => {
nsb.append("{\n")
ind(nsb, lvl+1)
nsb.append("require(")
nsb = pp(prec, nsb, lvl+1)
nsb.append(")\n")
pp(body.get, nsb, lvl+1)
nsb.append("\n")
ind(nsb, lvl)
nsb.append("}")
}
}
} else
nsb.append("[unknown function implementation]") nsb.append("[unknown function implementation]")
post.foreach(postc => {
nsb.append(" ensuring(res => ") //TODO, not very general solution...
nsb = pp(postc, nsb, lvl)
nsb.append(")")
})
nsb
} }
case _ => sb.append("Defn?") case _ => sb.append("Defn?")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment