summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-12-04 18:33:23 +0000
committerPaul Phillips <paulp@improving.org>2010-12-04 18:33:23 +0000
commitb1e969a11b2b24f5883198dc0b90d9ab5513498b (patch)
tree434257c2afc84c4d86e55cd2bf78d9e29ca66dc9 /src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
parent3d97123034a9d82e6e6961d589ccd3a1afde4390 (diff)
downloadscala-b1e969a11b2b24f5883198dc0b90d9ab5513498b.tar.gz
scala-b1e969a11b2b24f5883198dc0b90d9ab5513498b.tar.bz2
scala-b1e969a11b2b24f5883198dc0b90d9ab5513498b.zip
A foot in the door with Parsers/JavaParsers and...
A foot in the door with Parsers/JavaParsers and Scanners/JavaScanners. Recently clued in as to how this situation came to be, I now know there's no reason not to start containing the damage. Also more work on names: made a general method for transforming Trees into type-named Trees and put it to work. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Scanners.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index 25b65f0791..0835a1b2d0 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -12,7 +12,26 @@ import scala.annotation.switch
import scala.collection.mutable.{ListBuffer, ArrayBuffer}
import scala.xml.Utility.{ isNameStart }
-trait Scanners {
+/** See Parsers.scala / ParsersCommon for some explanation of ScannersCommon.
+ */
+trait ScannersCommon {
+ val global : Global
+ import global._
+
+ trait CommonTokenData {
+ def token: Int
+ def name: TermName
+ }
+
+ trait ScannerCommon extends CommonTokenData {
+ // things to fill in, in addition to buf, decodeUni
+ def warning(off: Int, msg: String): Unit
+ def error (off: Int, msg: String): Unit
+ def incompleteInputError(off: Int, msg: String): Unit
+ }
+}
+
+trait Scanners extends ScannersCommon {
val global : Global
import global._
@@ -22,7 +41,7 @@ trait Scanners {
/** An undefined offset */
val NoOffset: Offset = -1
- trait TokenData {
+ trait TokenData extends CommonTokenData {
/** the next token */
var token: Int = EMPTY
@@ -52,7 +71,7 @@ trait Scanners {
}
}
- abstract class Scanner extends CharArrayReader with TokenData {
+ abstract class Scanner extends CharArrayReader with TokenData with ScannerCommon {
def flush = { charOffset = offset; nextChar(); this }
@@ -62,12 +81,6 @@ trait Scanners {
nextToken()
}
- // things to fill in, in addition to buf, decodeUni
- def warning(off: Offset, msg: String): Unit
- def error (off: Offset, msg: String): Unit
- def incompleteInputError(off: Offset, msg: String): Unit
- def deprecationWarning(off: Offset, msg: String): Unit
-
/** the last error offset
*/
var errOffset: Offset = NoOffset
@@ -1022,7 +1035,6 @@ trait Scanners {
def warning(off: Offset, msg: String) = unit.warning(unit.position(off), msg)
def error (off: Offset, msg: String) = unit.error(unit.position(off), msg)
def incompleteInputError(off: Offset, msg: String) = unit.incompleteInputError(unit.position(off), msg)
- def deprecationWarning(off: Offset, msg: String) = unit.deprecationWarning(unit.position(off), msg)
private var bracePatches: List[BracePatch] = patches