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 11package example
22
33class 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 ])
56class CVarArg (var x1 : Int )
67
78
Original file line number Diff line number Diff line change @@ -31,14 +31,28 @@ class SourceFile(path: java.nio.file.Path) {
3131
3232 def nextCharacterSkipComments (start : Int ): Int = {
3333 def aux (start : Int ) : Int = {
34- var i = start
34+ var i = start
3535 if (i+ 2 <= sourceCode.length && sourceCode.substring(i, i+ 2 ) == " //" ) {
3636 while (i < sourceCode.length && sourceCode(i) != '\n ' )
37- i += 1
37+ i += 1
3838 return i+ 1
3939 } 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+ }
4154 i += 1
55+ }
4256 return i+ 2
4357 } else {
4458 while (i < sourceCode.length && sourceCode(i).isWhitespace)
You can’t perform that action at this time.
0 commit comments