antlr-kotlin
antlr-kotlin copied to clipboard
Add a test using a large grammar
For example, MySql sample: https://github.com/oleg-zinovev/antlr-kotlin-mysql-example
Hi @ftomassetti,
I'm using antlr-kotlin to parse kotlin code itself using the official kotlin grammer, it's working fine :-) https://kotlinlang.org/docs/reference/grammar.html https://github.com/Kotlin/kotlin-spec/tree/master/grammar/src/main/antlr
I have written a small wrapper on top of antlr-kotlin that converts the parsed antlr data into an easy-to-use data class: https://github.com/kotlinx/ast/tree/master/kotlin
Regarding using the Kotlin grammar this is good but we should have a test here doing so.
Regarding converting to data classes, normally I write data classes manually and then map my context classes to my data classes but originally I planned to change how we generate classes directly into ANTLR Kotlin. I think it would make the life of users easier
@ftomassetti TSQL looks big enough 👀
I would agree :D
I don't think it's a good idea to use big, real files as unit-tests, such tests should cover only one aspect but not several. For the case from this issue, test should be generated.
But the entire grammars repository can be used for integrational test.
The tests under the antlr-kotlin-tests module (where the TSQL grammar is located now) are integration tests and follow the same approach of the ANTLR Grammars repository + antlr4test-maven-plugin. Same .tree and .errors files to match the output.
It looks like your repository is not covered by unit-tests from official ANTLR repository at all, see descriptors. I've only discovered tests on big grammars. It looks sad.
This repo would need the same infra from the ANTLR repo, so I'd need to come up with a different way to do the same, or the ANTLR team need to invest time to merge this target.
I've written some thoughts about porting: https://github.com/antlr/antlr5/issues/1#issuecomment-1900652729