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

commonMain.at.asitplus.jsonpath.implementation.AbstractSyntaxTree.kt Maven / Gradle / Ivy

package at.asitplus.jsonpath.implementation

import org.antlr.v4.kotlinruntime.ParserRuleContext
import org.antlr.v4.kotlinruntime.Token
import org.antlr.v4.kotlinruntime.ast.Position

internal data class AbstractSyntaxTree(
    val text: String,
    val position: Position?,
    val value: T,
    val children: List> = listOf(),
) {
    constructor(
        context: ParserRuleContext?,
        value: T,
        children: List> = listOf(),
    ) : this(
        text = context?.text ?: "",
        position = context?.position,
        value = value,
        children = children,
    )
    constructor(
        token: Token,
        value: T,
        children: List> = listOf(),
    ) : this(
        text = token.text ?: "",
        position = token.startPoint().let { Position(it, token.endPoint() ?: it) },
        value = value,
        children = children,
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy