Skip to content

Commit

Permalink
Relocate extension fns **&** add whitespace fn
Browse files Browse the repository at this point in the history
  • Loading branch information
QuickWrite committed Aug 19, 2024
1 parent 541b594 commit 60f2757
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/main/kotlin/lexer/StringJSONLexer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,21 @@ class StringJSONLexer(private val content: CharSequence) : JSONLexer {
}

private fun skipWhitespace() {
while (!(position >= content.length || !Character.isWhitespace(content.getChar(position)))) {
while (!(position >= content.length || !content.getChar(position).isWhitespace())) {
position++
}
}
}

private fun CharSequence.getChar(index: Int): Char {
if (index >= this.length) {
return 0.toChar()
private fun CharSequence.getChar(index: Int): Char {
if (index >= this.length) {
return 0.toChar()
}

return this[index]
}

return this[index]
}
private fun Char.isWhitespace(): Boolean {
return this == ' ' || this == '\r' || this == '\n' || this == '\t'
}
}

0 comments on commit 60f2757

Please sign in to comment.