Skip to content

Commit 3eddd4c

Browse files
committed
Merge pull request scala#4185 from som-snytt/issue/9027
SI-9027 Parser no longer consumes space after multi XML elements
2 parents 40547cd + db8d547 commit 3eddd4c

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,11 @@ trait MarkupParsers {
346346

347347
// parse more XML ?
348348
if (charComingAfter(xSpaceOpt()) == '<') {
349-
xSpaceOpt()
350-
while (ch == '<') {
349+
do {
350+
xSpaceOpt()
351351
nextch()
352352
ts append element
353-
xSpaceOpt()
354-
}
353+
} while (charComingAfter(xSpaceOpt()) == '<')
355354
handle.makeXMLseq(r2p(start, start, curOffset), ts)
356355
}
357356
else {

test/files/run/t9027.check

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
{
3+
val $buf = new _root_.scala.xml.NodeBuffer();
4+
$buf.$amp$plus(new _root_.scala.xml.Elem(null, "a", _root_.scala.xml.Null, $scope, true));
5+
$buf.$amp$plus(new _root_.scala.xml.Elem(null, "b", _root_.scala.xml.Null, $scope, true));
6+
$buf
7+
};
8+
println("hello, world.")
9+
}
10+
{
11+
{
12+
val $buf = new _root_.scala.xml.NodeBuffer();
13+
$buf.$amp$plus(new _root_.scala.xml.Elem(null, "a", _root_.scala.xml.Null, $scope, true));
14+
$buf.$amp$plus(new _root_.scala.xml.Elem(null, "b", _root_.scala.xml.Null, $scope, true));
15+
$buf.$amp$plus(new _root_.scala.xml.Elem(null, "c", _root_.scala.xml.Null, $scope, true));
16+
$buf
17+
};
18+
println("hello, world.")
19+
}

test/files/run/t9027.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
// used to be parsed as .println
3+
object Test extends App {
4+
import reflect.runtime._, universe._
5+
6+
val trees = List(
7+
q"""<a/><b/>
8+
println("hello, world.")""",
9+
q"""<a/>
10+
<b/>
11+
<c/>
12+
println("hello, world.")"""
13+
)
14+
trees foreach println
15+
}

0 commit comments

Comments
 (0)