Contains examples of Kabu usage.
Kabu is an annotation processor for Kotlin which embraces a declarative way of DSLs creation.
Example project contains 2 modules:
- simple - demonstrates basic pattern syntax capabilities
- complex - shows how to build more complex DSLs via patterns with extension points
Each example has a unique permanent code (Example-XXX
).
Take a look at pattern samples used to test Kabu itself.
Each sample consists of three parts:
raw
- pattern itself and encoded parameters of target function placed after//
separatorsample
- actual runtime Kotlin statement (or expression) which must match designated patterntermination
- arguments which will be passed to the target function during termination
For example:
{
"raw" : "s..b + i // s b i",
"sample" : "\"bbb\"..true + 13",
"termination" : "bbb, true, 13"
}
may be interpreted as following:
@Pattern("s..b + i")
fun targetFunction(s: String, b: Boolean, i: Int) {
print(listOf(s, b, i).joinToString())
}
fun main() {
"bbb"..true + 13 // prints: bbb, true, 13
}