diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-01-22 00:33:18 +0100 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-06-20 15:46:26 -0700 |
commit | 9b72669a076206f1edbe34464717375c97997cea (patch) | |
tree | 9b62ed2461f2e06e289c504b14d38a757ae02801 /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | |
parent | 4e9b33ab24bb3bf922c37a05a79af364b7b32b84 (diff) | |
download | scala-9b72669a076206f1edbe34464717375c97997cea.tar.gz scala-9b72669a076206f1edbe34464717375c97997cea.tar.bz2 scala-9b72669a076206f1edbe34464717375c97997cea.zip |
Set scene for Predef.$scope's demise.
When there's no Predef.$scope but xml is being used,
the compiler aliases scala.xml.TopScope to $scope.
There must be a scala.xml package when xml literals were parsed.
For compatibility with the old library, which relied on $scope being in scope,
synthesize a `import scala.xml.{TopScope => $scope}` when xml is needed,
but there's no Predef.$scope and the old library is detected (scala.xml.TopScope exists).
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index fc532f5d44..ef5872986c 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -166,13 +166,20 @@ self => def syntaxError(offset: Int, msg: String): Unit = throw new MalformedInput(offset, msg) def incompleteInputError(msg: String): Unit = throw new MalformedInput(source.content.length - 1, msg) - /** the markup parser */ - lazy val xmlp = new MarkupParser(this, preserveWS = true) - object symbXMLBuilder extends SymbolicXMLBuilder(this, preserveWS = true) { // DEBUG choices val global: self.global.type = self.global } + /** the markup parser + * The first time this lazy val is accessed, we assume we were trying to parse an xml literal. + * The current position is recorded for later error reporting if it turns out + * that we don't have the xml library on the compilation classpath. + */ + private[this] lazy val xmlp = { + currentUnit.encounteredXml(o2p(in.offset)) + new MarkupParser(this, preserveWS = true) + } + def xmlLiteral() : Tree = xmlp.xLiteral def xmlLiteralPattern() : Tree = xmlp.xLiteralPattern } |