From 7845ce31b8c695b42694fb9f305d9e0028858048 Mon Sep 17 00:00:00 2001 From: Sean McDirmid Date: Tue, 25 Sep 2007 13:46:46 +0000 Subject: Fixing interpreter/scanner/XML issues. --- src/compiler/scala/tools/nsc/Interpreter.scala | 2 ++ src/compiler/scala/tools/nsc/ast/parser/NewScanners.scala | 9 ++++++--- 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("", 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) -- cgit v1.2.3