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

main.com.enniovisco.dsl.Parser.kt Maven / Gradle / Ivy

The newest version!
package com.enniovisco.dsl


typealias Language = org.intellij.lang.annotations.Language

private val log = io.github.oshai.kotlinlogging.KotlinLogging.logger {}

fun parseSelector(queryString: String): List {
    try {
        val sanitized = queryString
            .replace("\\s+".toRegex(), " ")
            .split("$", "<=", ">=", "<<", ">>", "==", "&", limit = 3)
            .map { it.trim() }
        val isBinding = queryString.contains('&').toString()
        return if (sanitized.size < 2) {
            listOf(sanitized[0], "", "", isBinding)
        } else {
            sanitized + isBinding
        }
    } catch (e: Exception) {
        throw Exception("Error parsing selector: $queryString", e)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy