All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.copperleaf.kudzu.parser.SourcePosition.kt Maven / Gradle / Ivy

There is a newer version: 5.3.0
Show newest version
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