antlr-kotlin icon indicating copy to clipboard operation
antlr-kotlin copied to clipboard

Add a test using a large grammar

Open ftomassetti opened this issue 7 years ago • 2 comments
trafficstars

For example, MySql sample: https://github.com/oleg-zinovev/antlr-kotlin-mysql-example

ftomassetti avatar Oct 26 '18 06:10 ftomassetti

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

drieks avatar Sep 10 '19 19:09 drieks

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 avatar Sep 18 '19 10:09 ftomassetti

@ftomassetti TSQL looks big enough 👀

lppedd avatar Jan 18 '24 14:01 lppedd

I would agree :D

ftomassetti avatar Jan 18 '24 14:01 ftomassetti

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.

KvanTTT avatar Jan 18 '24 16:01 KvanTTT

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.

lppedd avatar Jan 18 '24 16:01 lppedd

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.

KvanTTT avatar Jan 19 '24 14:01 KvanTTT

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.

lppedd avatar Jan 19 '24 15:01 lppedd

I've written some thoughts about porting: https://github.com/antlr/antlr5/issues/1#issuecomment-1900652729

KvanTTT avatar Jan 19 '24 15:01 KvanTTT