Skip to content

Instantly share code, notes, and snippets.

@jsuereth
Created September 11, 2012 18:36
Show Gist options
  • Select an option

  • Save jsuereth/3700672 to your computer and use it in GitHub Desktop.

Select an option

Save jsuereth/3700672 to your computer and use it in GitHub Desktop.
Parse a string to a tree
scala> import reflect.runtime.currentMirror
import reflect.runtime.currentMirror
scala> import scala.tools.reflect.ToolBox
import scala.tools.reflect.ToolBox
scala> currentMirror.mkToolBox()
res5: scala.tools.reflect.ToolBox[reflect.runtime.universe.type] = scala.tools.reflect.ToolBoxFactory$ToolBoxImpl@2288e718
scala> res5.parseExpr("def x = 'c'")
res6: res5.u.Tree = def x = 'c'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment