main.com.enniovisco.dsl.Parser.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webmonitor Show documentation
Show all versions of webmonitor Show documentation
A formal approach to monitoring web pages as spatio-temporal traces.
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)
}
}