summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/macros/Parsers.scala
blob: bf73c36b1b5246ad6b681e220e57996df30ecc2a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package scala.reflect
package macros

/** A slice of [[scala.reflect.macros.Context the Scala macros context]] that
 *  exposes functions to parse strings with Scala code into trees.
 */
trait Parsers {
  self: Context =>

  /** Parses a string with a Scala expression into an abstract syntax tree.
   *  Only works for expressions, i.e. parsing a package declaration will fail.
   *  @throws [[scala.reflect.macros.ParseException]]
   */
  def parse(code: String): Tree
}

/** Indicates an error during [[scala.reflect.macros.Parsers#parse]].
 */
case class ParseException(val pos: scala.reflect.api.Position, val msg: String) extends Exception(msg)