-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse error: Muliple annotations with line comment #33
Comments
I am not really doing much to this library these days (my day job has taken me away fro Kotlin mostly). It appears this might be a bug in the Kotlin PSI libraries, but admittedly I probably use an old version and this may have been fixed in the meantime. |
I have hit this same issue and have found another case when the comment crashes the parser, when the line comment is between the lines with annotations:
|
I have changed Kotlin to the latest The crash is because of the line Unit tests fail for this case because
|
Hi @martinflorek, maybe my Kotlin parsing library can help you: It is a generic AST parsing library, Kotlin is currently the only supported language. The library is designed that other languages can be easily added. kotlinx.ast does not use the kotlin compiler for paring, it is using ANTLR (the kotlin variant https://github.com/Strumenta/antlr-kotlin) using the official kotlin grammer (https://kotlinlang.org/docs/reference/grammar.html) One Component is "Klass", a collection of language independent data classes used to represent and easily access the AST. Your example code will be parsed fine: kotlinx/ast@d4da88a
using kotlin code, this is:
There are some parts missing, for example the importList is not converted into an easy-to-use data class. But I'm already using the library for AST parsing. You can just open the project in IDEA or run Please let me know if you have any questions, or just open an issue :-) |
@drieks I tried it but it complains "Could not find com.strumenta.antlr-kotlin:antlr-kotlin-gradle-plugin:0.0.5". I added the jitpack repo into repositories ( |
@martinflorek : Oh sorry, please try to replace version "0.0.5" of antlr-kotlin with "2e25fd550f" (the latest revision listed here: https://jitpack.io/#com.strumenta/antlr-kotlin when clicking on "Commits") |
@drieks there are more and more issues...
|
Hi @martinflorek, it seems that I have always used the locally build version of I fixed the bug in I added In
You have to add jitpack to
Now, you can add the dependency to
This should add (currently, for multiplatform only common and jvm is supported, but native and js support should be possible without too much work) If you don't use |
@drieks it works now, thank you. But it crashes on parsing annotation values with |
Hi @martinflorek, fixed, please try Version I added
|
@drieks Now the parsing of "escaped" values in annotations work, but I have found another issue. It does not belong here, so I created a new issue in your repo kotlinx/ast#1 @cretz I still prefer your parser, especially its speed, and it handles everything I have thrown at it except for the comments after annotations. Thank you for this library. |
Thanks (it's the Kotlin core code that I use, I didn't write the parser)...I apologize as I have left the JVM ecosystem for the time being and don't have time to work on this or any of my other Kotlin libs. |
That code can not be parsed:
If the both annotations are switched, it works just fine.
--> The exception occurs if:
Stack trace:
`
ava.lang.IllegalStateException: Unrecognized modifier: // public API
`
The text was updated successfully, but these errors were encountered: