summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McDirmid <sean.mcdirmid@gmail.com>2007-09-25 13:46:46 +0000
committerSean McDirmid <sean.mcdirmid@gmail.com>2007-09-25 13:46:46 +0000
commit7845ce31b8c695b42694fb9f305d9e0028858048 (patch)
tree2984f7658305d563201990277b6c55bc198eef81
parentb77116fea1ca3071c29e0cdb0a1b1f0eb3d2333a (diff)
downloadscala-7845ce31b8c695b42694fb9f305d9e0028858048.tar.gz
scala-7845ce31b8c695b42694fb9f305d9e0028858048.tar.bz2
scala-7845ce31b8c695b42694fb9f305d9e0028858048.zip
Fixing interpreter/scanner/XML issues.
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/NewScanners.scala9
2 files changed, 8 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala
index 06a16075ef..761d662a1b 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -351,11 +351,13 @@ class Interpreter(val settings: Settings, out: PrintWriter) {
reporter.withIncompleteHandler((pos,msg) => {justNeedsMore = true}) {
// simple parse: just parse it, nothing else
def simpleParse(code: String): List[Tree] = {
+ //Console.println("CODE<<" + code + ">>")
val unit =
new CompilationUnit(
new BatchSourceFile("<console>", code.toCharArray()))
val scanner = new compiler.syntaxAnalyzer.UnitParser(unit);
val xxx = scanner.templateStatSeq;
+ Console println xxx._2
xxx._2
}
diff --git a/src/compiler/scala/tools/nsc/ast/parser/NewScanners.scala b/src/compiler/scala/tools/nsc/ast/parser/NewScanners.scala
index 0034739cf1..cabb1a075c 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/NewScanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/NewScanners.scala
@@ -21,6 +21,7 @@ trait NewScanners {
def offset : Int
def error(offset : Int, msg : String) : Unit
+ def incompleteError(offset : Int, msg : String) : Unit = error(offset, msg)
def textFor(from : Int, until : Int) : RandomAccessSeq[Char]
}
trait ScannerInput extends CoreScannerInput {
@@ -226,7 +227,7 @@ trait NewScanners {
implicit def in : CoreScannerInput
ScannerConfiguration.hashCode // forces initialization
import ScannerConfiguration._
- var xmlOk = false
+ var xmlOk = true
def iterator = new Iterator[(Int,Int,Int)] { // offset,length,code
val current = new TokenHolder
@@ -328,7 +329,7 @@ trait NewScanners {
var count = 0
if (!empty) while (count != -1) in.next match {
- case SU => in.error(offset, "unterminated comment"); count = -1
+ case SU => in.incompleteError(offset, "unterminated comment"); count = -1
case '*' if in.readIfStartsWith('/') => count -= 1
case '/' if in.readIfStartsWith('*') => count += 1
case c =>
@@ -407,7 +408,7 @@ trait NewScanners {
// multiline
in.scratch setLength 0
while (in.next match {
- case SU if !in.isUnicode => in.error(offset, "unterminated multi-line string"); false
+ case SU if !in.isUnicode => in.incompleteError(offset, "unterminated multi-line string"); false
case '\"' if in.readIfStartsWith('\"') =>
if (in.readIfStartsWith('\"')) false
else {
@@ -869,6 +870,8 @@ trait NewScanners {
implicit val in =
new DefaultInput(new NewCharArrayReader(unit.source.asInstanceOf[BatchSourceFile].content, !settings.nouescape.value, error)) {
override def error(offset : Int, msg : String) : Unit = UnitScanner.this.error(offset, msg)
+ override def incompleteError(offset : Int, msg : String) =
+ unit.incompleteInputError(new OffsetPosition(unit.source, offset), msg)
}
init
private def error(offset : Int, msg : String) : Unit = unit.error(new OffsetPosition(unit.source,offset), msg)