blob: 4dd3c3f3784123e23d477d93f05998fe59ea1bc4 (
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
25
26
27
28
29
30
31
32
33
34
35
36
|
/* NSC -- new Scala compiler
* Copyright 2005-2014 LAMP/EPFL, Typesafe Inc.
* @author Adriaan Moors
*/
package scala
package tools.nsc
import scala.reflect.internal.Positions
import scala.tools.nsc.reporters.Reporter
/** Similar to Reporting: gather global functionality specific to parsing.
*/
trait Parsing { self : Positions with Reporting =>
def currentRun: RunParsing
trait RunParsing {
val parsing: PerRunParsing = new PerRunParsing
}
class PerRunParsing {
// for repl
private[this] var incompleteHandler: (Position, String) => Unit = null
def withIncompleteHandler[T](handler: (Position, String) => Unit)(thunk: => T) = {
val saved = incompleteHandler
incompleteHandler = handler
try thunk
finally incompleteHandler = saved
}
def incompleteHandled = incompleteHandler != null
def incompleteInputError(pos: Position, msg: String): Unit =
if (incompleteHandled) incompleteHandler(pos, msg)
else reporter.error(pos, msg)
}
}
|