Presentation compiler - possible to get a token iterator?

Hi,

my understanding is that the “minimum parsing effort” of CompilerControl is askParsedEntered, which returns a Tree. I wonder if the scala compiler provides some means of getting an iterator over parsed tokens, or whether I have to do the effort myself, pattern matching the tree into a “linear” flat sequence of tree leaves?

best, …h.h…

For example, say the source is

    val src =
      """class Test {
        |  val x = // missing RHS
        |}""".stripMargin

Then the resulting tree of askParsedEntered is printed as

package <empty> {
  class Test extends scala.AnyRef {
    def <init>() = {
      super.<init>();
      ()
    };
    private[this] val x = null
  }
}

How do I get for this tree a token iterator that allows me to render a syntax colourised text, including the error of the missing value, and including the comment?

This may give an idea how to extract tokens with UnitScanner https://github.com/harrah/browse/blob/8ffa3d4ece87daa8f0e2247f15332d76c8942f65/src/main/scala/Browse.scala#L107-L148