Is there some technical information about how the ...
# declarative-gradle
s
Is there some technical information about how the declarative syntax was implemented? Specifically, is it actually just a(nother) Kotlin DSL, i.e. is Kotlin used for parsing?
p
It is a strict subset of the Kotlin language but they use a custom parser for faster evaluation
The performance is very impressive and that鈥檚 the main reason I want to write custom software types for my Gradle plugin today
e
the enum syntax isn't a subset of current Kotlin syntax but should be in the future
p
Yeah, it is part of the experimental KEEP https://github.com/Kotlin/KEEP/issues/379
s
Interesting. I wonder whether that custom parser will be suitable to also implement my own subset of the Kotlin language to extend my own application, now that the future of "regular" Kotlin scripting with custom script definitions is a bit unclear.
e
don't expect the DCL to cover general expressions, only syntax useful for declarations in Gradle-like DSL
s
Right, but I wonder whether the framework to parse DCL could also be used / extended to parse other syntaxes, like my own DSL. Basically as a faster replacement for a custom DSL I'm currently using via custom Kotlin script definitions.
j
you can take a look at both the current reference grammar for DCL (here) and the current parser implementation used by Gradle (here)
馃檹 1
p
The DCL parser is implemented reusing the first stage of the Kotlin compiler frontend called "Kotlin Light Parser" which is fast and gives a raw AST without much analysis and no resolution. On top of that, the rest of DCL is custom. Reusing KLP provides "official" kotlin language parsing capabilities, will simplify evolving DCL alongside the Kotlin language, allows us to provide good error messages when unsupported language features are used and makes the parser quite resilient to errors.
@Sebastian Schuberth I recently came accross https://github.com/sunny-chung/kotlite which is a KMP Kotlin language subset parser that looks suitable for embedding
馃憖 1
DCL is not a programming language though, it's a configuration language. So no flow control at all etc...
s
Thanks for the pointers, all!
s
The latter reminds me a bit of https://github.com/cashapp/kotlin-editor.
e
yeah they all build off of the official grammar I believe