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

adding tree support and printing

parent f6fc0c92
No related branches found
No related tags found
No related merge requests found
......@@ -81,7 +81,12 @@ object PrettyPrinter {
case IntLiteral(v) => sb.append(v)
case BooleanLiteral(v) => sb.append(v)
case StringLiteral(s) => sb.append("\"" + s + "\"")
case Tuple(exprs) => ppNary(sb, exprs, "(", ", ", ")", lvl)
case TupleSelect(t, i) => {
pp(t, sb, lvl)
sb.append("._" + i)
sb
}
case OptionSome(a) => {
var nsb = sb
nsb.append("Some(")
......@@ -297,6 +302,7 @@ object PrettyPrinter {
nsb.append(" => ")
pp(tt, nsb, lvl)
}
case TupleType(tpes) => ppNaryType(sb, tpes, "(", ", ", ")", lvl)
case c: ClassType => sb.append(c.classDef.id)
case _ => sb.append("Type?")
}
......
......@@ -37,6 +37,7 @@ object Trees {
case class IfExpr(cond: Expr, then: Expr, elze: Expr) extends Expr
case class Tuple(exprs: Seq[Expr]) extends Expr
case class TupleSelect(tuple: Expr, index: Int) extends Expr
object MatchExpr {
def apply(scrutinee: Expr, cases: Seq[MatchCase]) : MatchExpr = {
......@@ -359,6 +360,7 @@ object Trees {
case SetMax(s) => Some((s,SetMax))
case CaseClassSelector(cd, e, sel) => Some((e, CaseClassSelector(cd, _, sel)))
case CaseClassInstanceOf(cd, e) => Some((e, CaseClassInstanceOf(cd, _)))
case TupleSelect(t, i) => Some((t, TupleSelect(_, i)))
case _ => None
}
}
......@@ -410,6 +412,7 @@ object Trees {
case FiniteMap(args) => Some((args, (as : Seq[Expr]) => FiniteMap(as.asInstanceOf[Seq[SingletonMap]])))
case FiniteMultiset(args) => Some((args, FiniteMultiset))
case Distinct(args) => Some((args, Distinct))
case Tuple(args) => Some((args, Tuple))
case _ => None
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment