Hey, as I know arrow-meta have quasi quotes dsl, b...
# arrow-meta
s
Hey, as I know arrow-meta have quasi quotes dsl, but it requires user to be in the compiler context already. I was thinking that it is possible to add user created macros to the language similar to how scala or rust do it, without going through troubles of gradle/compiler plugins. I experimented with applying those in a similar way to quasi quotes implementation: client code: https://github.com/ShikaSD/kotlin-compiler-di/blob/macro-experiment/src/main/kotlin/AnotherThing.kt compiler code: https://github.com/ShikaSD/kotlin-compiler-di/blob/macro-experiment/buildSrc/compiler-plugin/kotlin-plugin/src/main/java/me/shika/di/TestMacroAnalysisExtension.kt Of course, I used regex for poc (:D), but it can be defined with proper grammar, which is parsed in the compiler plugin (for example using antlr or similar parsers).
d
Have a look at https://github.com/kotlinx/ast, there is an kotlin to AST Parser using antlr.
r
@shikasd we are gonna support user level macros without plugins by reading from the plugin the macro function with an actual quote and turning it into a quote . If you use other format that is not PSI none of the compiler and IDEA tooling works and all you can do is source code gen. The descriptors thenselfs are PSI
In the sense that is the next step
👍 2
If you manually parse you have to write more code or have an equivalence between a node in your tree and PSI
s
I guess if you are going to get the quote from defined function, that should work out better. I was just curious if you already planned something on this idea :)
r
yes, we added it to one of our slides in the talk, to support local macros so people can do transformations without having to write plugins
👍 2
and you will have access to the compiler plugin api so you can use the quote system directly
essentially removing the need to write compiler plugins unless you are gonna do something very complex