blob: ab9b94ec9f6b8fa94455353a25f8547043835ba3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package scala.reflect.macros
package runtime
import scala.language.existentials
import scala.tools.reflect.ToolBox
import scala.tools.reflect.ToolBoxError
trait Parsers {
self: Context =>
def parse(code: String): Tree =
// todo. provide decent implementation
// see `Typers.typedUseCase` for details
try {
import scala.reflect.runtime.{universe => ru}
val parsed = ru.rootMirror.mkToolBox().parse(code)
val importer = universe.mkImporter(ru)
importer.importTree(parsed)
} catch {
case ToolBoxError(msg, cause) =>
// todo. provide a position
throw new ParseError(universe.NoPosition, msg)
}
}
|