Hi Rintcius,
treehugger> console
[info] Starting scala interpreter...
[info]
import treehugger.forest._
import definitions._
import treehuggerDSL._
scala> VAL("s") := SOME(LIT("str"))
res1: treehugger.forest.ValDef = ValDef(Modifiers(, , Map()),Ident(s),Apply(Ident(Some),List(Literal(Constant(str)))))
scala> treeToString(res1)
res2: String = val s = Some("str")
scala> VAL("n") := NONE
res3: treehugger.forest.ValDef = ValDef(Modifiers(, , Map()),Ident(n),Ident(None))
scala> treeToString(res3)
res4: String = val n = None
As you might noticed, BLOCK(...) accepts both repeated parameters and Iterable[Tree]:
scala> List(VAL("x") := LIT("x"), VAL("a") := LIT("a"), VAL("b") := LIT("b"))
res5: List[treehugger.forest.ValDef] = List(ValDef(Modifiers(, , Map()),Ident(x),Literal(Constant(x))), ValDef(Modifiers(, , Map()),Ident(a),Literal(Constant(a))), ValDef(Modifiers(, , Map()),Ident(b),Literal(Constant(b))))
scala> BLOCK(res5)
res6: treehugger.forest.Block = Block(List(ValDef(Modifiers(, , Map()),Ident(x),Literal(Constant(x))), ValDef(Modifiers(, , Map()),Ident(a),Literal(Constant(a)))),ValDef(Modifiers(, , Map()),Ident(b),Literal(Constant(b))))
scala> treeToString(res6)
res7: String =
{
val x = "x"
val a = "a"
val b = "b"
}
scala> BLOCK(res5: _*)
res8: treehugger.forest.Block = Block(List(ValDef(Modifiers(, , Map()),Ident(x),Literal(Constant(x))), ValDef(Modifiers(, , Map()),Ident(a),Literal(Constant(a)))),ValDef(Modifiers(, , Map()),Ident(b),Literal(Constant(b))))
scala> treeToString(res8)
res9: String =
{
val x = "x"
val a = "a"
val b = "b"
}
-eugene