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

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

Go to download

Kotlin Multiplatform library for using Json Paths as specified in [RFC9535](https://datatracker.ietf.org/doc/rfc9535/)

The newest version!
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 - 2025 Weber Informatics LLC | Privacy Policy