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

commonMain.com.copperleaf.kudzu.node.NodeContext.kt Maven / Gradle / Ivy

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