All Downloads are FREE. Search and download functionalities are using the official Maven repository.

h.kind-projector_2.11.0.7.0.source-code.StringParser.scala Maven / Gradle / Ivy

There is a newer version: 0.9.10
Show newest version
package d_m

import scala.reflect.macros.ParseException
import scala.tools.nsc.Global
import scala.tools.nsc.reporters.StoreReporter

class StringParser[G <: Global](val global: G) {
  import global._
  def parse(code: String): Option[Tree] = {
    val oldReporter = global.reporter
    try {
      val r = new StoreReporter()
      global.reporter = r
      val tree = newUnitParser(code).templateStats().headOption
      if (r.infos.isEmpty) tree else None
    } finally {
      global.reporter = oldReporter
    }
  }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy