diff options
-rw-r--r-- | src/compiler/scala/reflect/macros/runtime/Parsers.scala | 5 | ||||
-rw-r--r-- | src/reflect/scala/reflect/macros/Parsers.scala | 14 |
2 files changed, 7 insertions, 12 deletions
diff --git a/src/compiler/scala/reflect/macros/runtime/Parsers.scala b/src/compiler/scala/reflect/macros/runtime/Parsers.scala index 5096526fdb..ab9b94ec9f 100644 --- a/src/compiler/scala/reflect/macros/runtime/Parsers.scala +++ b/src/compiler/scala/reflect/macros/runtime/Parsers.scala @@ -10,6 +10,7 @@ trait Parsers { 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) @@ -17,9 +18,7 @@ trait Parsers { importer.importTree(parsed) } catch { case ToolBoxError(msg, cause) => + // todo. provide a position throw new ParseError(universe.NoPosition, msg) } - - case class ParseError(val pos: Position, val msg: String) extends Throwable(msg) - object ParseError extends ParseErrorExtractor } diff --git a/src/reflect/scala/reflect/macros/Parsers.scala b/src/reflect/scala/reflect/macros/Parsers.scala index 1742d07b60..c2d4d8a3ab 100644 --- a/src/reflect/scala/reflect/macros/Parsers.scala +++ b/src/reflect/scala/reflect/macros/Parsers.scala @@ -5,14 +5,10 @@ trait Parsers { self: Context => /** .. */ - // todo. distinguish between `parse` and `parse` + // todo. distinguish between parsing an expression and parsing arbitrary code + // for example, parsing in expression mode will fail on packages def parse(code: String): Tree +} - /** Represents an error during parsing - */ - type ParseError <: Throwable - val ParseError: ParseErrorExtractor - abstract class ParseErrorExtractor { - def unapply(error: ParseError): Option[(Position, String)] - } -}
\ No newline at end of file +// should be path-dependent, otherwise exception handling becomes a mess +case class ParseError(val pos: scala.reflect.api.Position, val msg: String) extends Throwable(msg) |