support: basic idea plugin

This commit is contained in:
2023-09-10 01:27:53 -04:00
parent 0024a8b141
commit 0bc3128b9d
17 changed files with 298 additions and 9 deletions

View File

@ -1,12 +1,16 @@
package gay.pizza.pork.parser
class StringCharSource(val input: String) : CharSource {
private var index = 0
class StringCharSource(
val input: CharSequence,
val startIndex: Int = 0,
val endIndex: Int = input.length - 1
) : CharSource {
private var index = startIndex
override val currentIndex: Int
get() = index
override fun next(): Char {
if (index == input.length) {
if (index == endIndex) {
return CharSource.NullChar
}
val char = input[index]
@ -15,7 +19,7 @@ class StringCharSource(val input: String) : CharSource {
}
override fun peek(): Char {
if (index == input.length) {
if (index == endIndex) {
return CharSource.NullChar
}
return input[index]