commonMain.com.copperleaf.kudzu.node.NodeContext.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.node
import com.copperleaf.kudzu.parser.ParserContext
import com.copperleaf.kudzu.parser.SourcePosition
/**
* Contains the start and end positions of the input that this Node was parsed from. For terminal nodes, this will be
* exactly the source positions surrounding the text parsed. For non-terminal nodes, the [startPosition] is the position
* before any parsing started and the [endPosition] is the position after all children parsers have finished, and the
* range of the parent node completely encapsulates the ranges of all its children nodes which will fall somewhere in
* the parent's range.
*/
data class NodeContext(
val startPosition: SourcePosition,
val endPosition: SourcePosition
) {
constructor(
startContext: ParserContext,
endContext: ParserContext
) : this(startContext.sourcePosition, endContext.sourcePosition)
override fun toString(): String {
return "NodeContext($startPosition to $endPosition)"
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy