File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
input/src/main/scala/example Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 1
1
package example
2
2
3
3
class CDep [X ]
4
- class CDependenat [X ](var x1 : CDep [X ])
4
+ class CDependenat [X /* This is a comment /* and a nested comment
5
+ */ */ ](var x1 : CDep [X ])
5
6
class CVarArg (var x1 : Int )
6
7
7
8
Original file line number Diff line number Diff line change @@ -31,14 +31,28 @@ class SourceFile(path: java.nio.file.Path) {
31
31
32
32
def nextCharacterSkipComments (start : Int ): Int = {
33
33
def aux (start : Int ) : Int = {
34
- var i = start
34
+ var i = start
35
35
if (i+ 2 <= sourceCode.length && sourceCode.substring(i, i+ 2 ) == " //" ) {
36
36
while (i < sourceCode.length && sourceCode(i) != '\n ' )
37
- i += 1
37
+ i += 1
38
38
return i+ 1
39
39
} else if (i+ 2 <= sourceCode.length && sourceCode.substring(i, i+ 2 ) == " /*" ) {
40
- while (i + 2 <= sourceCode.length && sourceCode.substring(i, i+ 2 ) != " */" )
40
+ var nestedCount = 0
41
+ i += 2
42
+ while (i + 2 <= sourceCode.length &&
43
+ ! (sourceCode.substring(i, i+ 2 ) == " */" &&
44
+ nestedCount == 0 )) {
45
+ val s = sourceCode.substring(i, i+ 2 )
46
+ if (s == " /*" ) {
47
+ nestedCount += 1
48
+ i += 1
49
+ }
50
+ if (s == " */" ) {
51
+ nestedCount -= 1
52
+ i += 1
53
+ }
41
54
i += 1
55
+ }
42
56
return i+ 2
43
57
} else {
44
58
while (i < sourceCode.length && sourceCode(i).isWhitespace)
You can’t perform that action at this time.
0 commit comments