commonMain.piacenti.dslmaker.structures.StepStack.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.structures
import piacenti.dslmaker.abstraction.ProductionStep
import piacenti.dslmaker.removeLast
/**
* @param
* @author Piacenti
*/
@Suppress("unused")
class StepStack {
private val list = mutableListOf()
fun getAsList(): List {
return list.toList()
}
fun getFirstFoundInCallStackFromList(steps: Collection): ProductionStep? {
for (i in list.size - 1 downTo -1 + 1) {
for (step in steps) {
if (step === list[i]) {
return list[i]
}
}
}
return null
}
/**
* @param steps
* @return
*/
fun getFirstFoundInCallStackFromList(vararg steps: ProductionStep): ProductionStep? {
for (i in list.size - 1 downTo -1 + 1) {
for (step in steps) {
if (step === list[i]) {
return list[i]
}
}
}
return null
}
/**
* @return
*/
fun removeLast(): StepStack {
list.removeLast()
return this
}
/**
* @param e
* @return
*/
fun add(e: ProductionStep): StepStack {
list.add(e)
return this
}
override fun toString(): String {
return "StepStack{" +
"stack=" + list +
'}'
}
fun addAll(generalStack: Collection): StepStack {
list.addAll(generalStack)
return this
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy