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

me.tomassetti.kolasu.mapping.Mapping.kt Maven / Gradle / Ivy

There is a newer version: 0.2.2
Show newest version
package me.tomassetti.kolasu.mapping

import me.tomassetti.kolasu.model.Node
import me.tomassetti.kolasu.model.Point
import me.tomassetti.kolasu.model.Position
import org.antlr.v4.runtime.ParserRuleContext
import org.antlr.v4.runtime.Token

interface ParseTreeToAstMapper {
    fun map(parseTreeNode: PTN) : ASTN
}

fun Token.startPoint() = Point(line, charPositionInLine)

fun Token.endPoint() = Point(line, charPositionInLine + text.length)

fun ParserRuleContext.toPosition(considerPosition: Boolean) : Position? {
    return if (considerPosition) Position(start.startPoint(), stop.endPoint()) else null
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy