aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-03-07 18:52:58 +0100
committerMartin Odersky <odersky@gmail.com>2016-03-07 18:53:03 +0100
commit8b6e88fcd4b5e0f7b5a8c2edf9e0e8c2732734a1 (patch)
treec5b86c9c0e143f7b5cd6e7722b06b121a272e115 /src
parent742ae7552cc0ebea700ddcb5892a673a1eaca967 (diff)
downloaddotty-8b6e88fcd4b5e0f7b5a8c2edf9e0e8c2732734a1.tar.gz
dotty-8b6e88fcd4b5e0f7b5a8c2edf9e0e8c2732734a1.tar.bz2
dotty-8b6e88fcd4b5e0f7b5a8c2edf9e0e8c2732734a1.zip
Allow successive opening comments.
Fixes #1052.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/parsing/Scanners.scala22
1 files changed, 11 insertions, 11 deletions
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
}