mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-10-10 16:19:37 +00:00
24 lines
458 B
Kotlin
24 lines
458 B
Kotlin
package gay.pizza.pork.parse
|
|
|
|
class StringCharSource(val input: String) : CharSource {
|
|
private var index = 0
|
|
override val currentIndex: Int
|
|
get() = index
|
|
|
|
override fun next(): Char {
|
|
if (index == input.length) {
|
|
return CharSource.NullChar
|
|
}
|
|
val char = input[index]
|
|
index++
|
|
return char
|
|
}
|
|
|
|
override fun peek(): Char {
|
|
if (index == input.length) {
|
|
return CharSource.NullChar
|
|
}
|
|
return input[index]
|
|
}
|
|
}
|