commonMain.com.copperleaf.kudzu.parser.SourcePosition.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kudzu-core-js Show documentation
Show all versions of kudzu-core-js Show documentation
A monadic (I think...) recursive-descent parser written in Kotlin
package com.copperleaf.kudzu.parser
data class SourcePosition(
val lineNumber: Int = 1,
val lineColumn: Int = 1
) : Comparable {
override fun toString(): String {
return "$lineNumber:$lineColumn"
}
override fun compareTo(other: SourcePosition): Int {
return compareValuesBy(this, other, { it.lineNumber }, { it.lineColumn })
}
fun incrementColumn(): SourcePosition {
return this.copy(
lineColumn = lineColumn + 1
)
}
fun incrementRow(): SourcePosition {
return this.copy(
lineNumber = lineNumber + 1,
lineColumn = 1
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy