![JAR search and dependency download from the Maven repository](/logo.png)
scala.reflect.macros.contexts.Parsers.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scala-compiler Show documentation
Show all versions of scala-compiler Show documentation
Compiler for the SubScript extension of the Scala Programming Language
The newest version!
package scala.reflect.macros
package contexts
import scala.tools.nsc.reporters.StoreReporter
trait Parsers {
self: Context =>
import global._
def parse(code: String) = {
val sreporter = new StoreReporter()
val oldReporter = global.reporter
try {
global.reporter = sreporter
val parser = newUnitParser(new CompilationUnit(newSourceFile(code, "")))
val tree = gen.mkTreeOrBlock(parser.parseStatsOrPackages())
sreporter.infos.foreach {
case sreporter.Info(pos, msg, sreporter.ERROR) => throw ParseException(pos, msg)
}
tree
} finally global.reporter = oldReporter
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy