File tree 2 files changed +21
-11
lines changed
src/dotty/tools/dotc/parsing 2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -539,21 +539,21 @@ object Scanners {
539
539
if ((ch != CR ) && (ch != LF ) && (ch != SU )) skipLine()
540
540
}
541
541
@ tailrec
542
- def skipBlock (openComments : Int ): Unit = {
543
- val last = ch
544
- nextChar()
542
+ def skipComment (): Unit = {
545
543
if (ch == '/' ) {
546
544
nextChar()
547
- if (last == '*' ) {
548
- if (openComments > 0 ) skipBlock(openComments - 1 )
549
- } else {
550
- if (ch == '*' ) { nextChar(); skipBlock(openComments + 1 ) }
551
- else skipBlock(openComments)
552
- }
545
+ if (ch == '*' ) nestedComment()
546
+ skipComment()
547
+ }
548
+ else if (ch == '*' ) {
549
+ do nextChar() while (ch == '*' )
550
+ if (ch == '/' ) nextChar()
551
+ else skipComment()
553
552
}
554
553
else if (ch == SU ) incompleteInputError(" unclosed comment" )
555
- else skipBlock(openComments)
554
+ else { nextChar(); skipComment() }
556
555
}
556
+ def nestedComment () = { nextChar(); skipComment() }
557
557
val start = lastCharOffset
558
558
def finishComment (): Boolean = {
559
559
if (keepComments) {
@@ -565,7 +565,7 @@ object Scanners {
565
565
}
566
566
nextChar()
567
567
if (ch == '/' ) { skipLine(); finishComment() }
568
- else if (ch == '*' ) { nextChar(); skipBlock( 0 ); finishComment() }
568
+ else if (ch == '*' ) { nextChar(); skipComment( ); finishComment() }
569
569
else false
570
570
}
571
571
Original file line number Diff line number Diff line change
1
+ package hello
2
+
3
+ object world extends App {
4
+ println(" hello dotty!" )
5
+ /* /* one
6
+ */
7
+ two
8
+ */
9
+ println(" foo" )
10
+ }
You can’t perform that action at this time.
0 commit comments