Skip to content

Commit f9e86e7

Browse files
refactor: comments
1 parent 0c7c0ef commit f9e86e7

File tree

1 file changed

+24
-1
lines changed
  • core/src/main/kotlin/io/github/cybercodernaj/parkour/lexer

1 file changed

+24
-1
lines changed

core/src/main/kotlin/io/github/cybercodernaj/parkour/lexer/Lexer.kt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,30 @@ class Lexer(
126126
do {
127127
val ignoredMatch = startsWith(ignorePattern)
128128
position = position.copy(col = ignoredMatch.range.last + 1)
129-
// This would break because changing the position can also change currentLine.
129+
// This loop will break because changing the position can also change currentLine.
130+
} while (true)
131+
}
132+
133+
option {
134+
do {
135+
startsWith(singleLineComments)
136+
// If position is pointing at a singleLineComment, then this will continue
137+
position = position.nextLine()
138+
} while (true)
139+
}
140+
141+
option {
142+
startsWith(multilineComments?.first)
143+
// If position is pointing at the beginning of multiline comment
144+
do {
145+
val line = currentLine.bind()
146+
val endMatch = multilineComments!!.second.find(line, startIndex = position.col)
147+
if (endMatch == null) {
148+
position = position.nextLine()
149+
} else {
150+
position = position.copy(col = endMatch.range.last + 1)
151+
break
152+
}
130153
} while (true)
131154
}
132155
}

0 commit comments

Comments
 (0)