commonMain.piacenti.dslmaker.interfaces.GrammarInventory.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dsl-maker-js Show documentation
Show all versions of dsl-maker-js Show documentation
Kotlin multiplatform library to facilitate creation of DSLs with ANTLR or a simple built in parser
package piacenti.dslmaker.interfaces
import piacenti.dslmaker.abstraction.ProductionStep
interface GrammarInventory {
val tokens: MutableList
val productions: MutableList
val rules: MutableList
get() {
return productions
}
fun createToken(name: String, regex: String, matchIndex: Int = 0, context: String? = null,
addContext: String? = null, removeContext: String? = null, validateToken: ((String) -> Boolean)?=null): ProductionStep {
val baseProductionStep = ProductionStep(name, regex, matchIndex, false, context, addContext, removeContext, validateToken)
tokens.add(baseProductionStep)
return baseProductionStep
}
fun createProduction(name: String): ProductionStep {
val baseProductionStep = ProductionStep(name)
productions.add(baseProductionStep)
return baseProductionStep
}
@Suppress("unused")
fun createRule(name: String): ProductionStep {
return createProduction(name)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy