From 8b6e88fcd4b5e0f7b5a8c2edf9e0e8c2732734a1 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 7 Mar 2016 18:52:58 +0100 Subject: Allow successive opening comments. Fixes #1052. --- src/dotty/tools/dotc/parsing/Scanners.scala | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/dotty/tools/dotc/parsing/Scanners.scala b/src/dotty/tools/dotc/parsing/Scanners.scala index 46274bcc9..489038f1e 100644 --- a/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/src/dotty/tools/dotc/parsing/Scanners.scala @@ -539,21 +539,21 @@ object Scanners { if ((ch != CR) && (ch != LF) && (ch != SU)) skipLine() } @tailrec - def skipBlock(openComments: Int): Unit = { - val last = ch - nextChar() + def skipComment(): Unit = { if (ch == '/') { nextChar() - if (last == '*') { - if (openComments > 0) skipBlock(openComments - 1) - } else { - if (ch == '*') { nextChar(); skipBlock(openComments + 1) } - else skipBlock(openComments) - } + if (ch == '*') nestedComment() + skipComment() + } + else if (ch == '*') { + do nextChar() while (ch == '*') + if (ch == '/') nextChar() + else skipComment() } else if (ch == SU) incompleteInputError("unclosed comment") - else skipBlock(openComments) + else { nextChar(); skipComment() } } + def nestedComment() = { nextChar(); skipComment() } val start = lastCharOffset def finishComment(): Boolean = { if (keepComments) { @@ -565,7 +565,7 @@ object Scanners { } nextChar() if (ch == '/') { skipLine(); finishComment() } - else if (ch == '*') { nextChar(); skipBlock(0); finishComment() } + else if (ch == '*') { nextChar(); skipComment(); finishComment() } else false } -- cgit v1.2.3