Object definitions are written using OBJECTDEF(...)
:
scala> import treehugger.forest._, definitions._, treehuggerDSL._
import treehugger.forest._
import definitions._
import treehuggerDSL._
scala> val tree = OBJECTDEF("Main") withParents("App") := BLOCK(
LIT(0)
)
[1m[34mtree[0m: [1m[32mtreehugger.forest.ModuleDef[0m = ModuleDef(Modifiers(, , Map()),Main,Template(List(TypeTree()),ValDef(Modifiers(private, , Map()),Ident(_),EmptyTree),List(Literal(Constant(0)))))
scala> treeToString(tree)
[1m[34mres0[0m: [1m[32mString[0m =
object Main extends App {
0
}
Case object definitions are written using CASEOBJECTDEF(...)
:
scala> val tree2 = (CASEOBJECTDEF("C"): Tree)
[1m[34mtree2[0m: [1m[32mtreehugger.forest.Tree[0m = ModuleDef(Modifiers(case, , Map()),C,Template(List(),ValDef(Modifiers(private, , Map()),Ident(_),EmptyTree),List()))
scala> treeToString(tree2)
[1m[34mres1[0m: [1m[32mString[0m = case object C