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

commonMain.piacenti.dslmaker.interfaces.GrammarInventory.kt Maven / Gradle / Ivy

Go to download

Kotlin multiplatform library to facilitate creation of DSLs with ANTLR or a simple built in parser

There is a newer version: 1.1.55
Show newest version
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