Presentation compiler - possible to get a token iterator?


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

Then the resulting tree of askParsedEntered is printed as

package <empty> {
  class Test extends scala.AnyRef {
    def <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