Kotlin parser


#1

Hi there,

my name is Marcin and I lead development of codebeat which is a hosted static analysis platform for web (Ruby, Python, Go) and mobile (Swift, Objective-C, Java) apps. I recently got quite excited about Kotlin and its’ potential in Android development and I started looking into the possibility of supporting Kotlin in my product.

In fact, all I need to have (beyond learning the language, OFC) to add this support is a good parser. So the question is - where can I find one :wink: Apologies if this an obvious question but I’m fairly new to Kotlin and I don’t know where to look.

Thank you in advance!

Best,
Marcin


#2

Would org.jetbrains.kotlin.parsing.KotlinParser be a good start? If so, would you have any tutorials or examples how to use it?


#3

Yes, this is the Kotlin parser. Unfortunately it requires quite a lof of environment setup in order to work, and even though it’s possible to perform that setup in an external environment, we don’t have any documentation or examples for this process at this time.


#4

I see. Would you please be able to point me to some example usage? I might be able to figure things myself given some time and effort.


#5

It would be great to have a static code analysis tool for kotlin


#6

I ended up patching an existing ANTLR grammar so we have a parser. We should be able to add Kotlin support over the next two weeks. codebeat is free for open source so your wish should be granted soon, @lhornyak :wink:


#7

@marcinwyszynski will it be possible to share how you were able to parse the Kotlin in standalone setting?


#8

@singularity - sure, you can check out the open source grammar here -

The version I used at codebeat was fairly similar, with a few fixes here
and there, and some things that were specific to our use case.

Marcin


#9

Any news regarding an official Kotlin parser and/or code generation facilities ? :slight_smile: