How to create Kotlin DSL that looks like the syntax of a programming language?
I would like to talk about advanced techniques for creating any kind of Kotlin DSL(s) in this talk.
As an example, we will see how to build a DSL that looks like a Starlark programming language, a Python dialect used for writing build scripts for Bazel build system. This DSL is a declarative code generator that builds an abstract syntax tree of a Starlark language and then generates a formatted code based on it.
However, all the concepts described in this talk are applicable to any kind of Kotlin DSL(s) including ones for Android projects.
Such a DSL was briefly mentioned in my talk at droidcon SF 2022: https://www.sf.droidcon.com/speaker/pavlo-stavytskyi/automated-migration-of-android-apps-to-bazel-build-system However, In this talk, I would like to dive deeper into the implementation details of such a DSL to demonstrate some neat things Kotlin allows to achieve in this area.