如何解析Kotlin代码? [英] how to parse kotlin code?

查看:125
本文介绍了如何解析Kotlin代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要分析kotlin文件代码,以检测关键字"data"和?".

I need to analyse kotlin files code, to detect the keyword "data" and "?".

问题是我找不到像JavaParser这样的库. 我不需要功能强大的工具,只需一些可以让我返回行数的工具即可.

The issue is I don't find any libs like JavaParser. I don't need powerfull tools, just something who return me the number of the lines.

有什么主意吗?

推荐答案

我使用antlr4来做到这一点.我创建了一个开源库: https://github.com/sarahBuisson/kotlin-parser

I use antlr4 to do it. And I create an open source lib: https://github.com/sarahBuisson/kotlin-parser

<dependency
   <groupId>com.github.sarahbuisson</groupId>
   <artifactId>kotlin-parser</artifactId>
</dependency>

这篇关于如何解析Kotlin代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆