This subproject contains the Kotlin grammar source files in the ANTLR v4 format and the infrastructure used to test the parser generated from the grammar. The grammar test suite includes Kotlin compiler PSI tests, Kotlin compiler diagnostics tests and grammar custom tests.
To run the grammar tests, do the following:
- Download the Kotlin compiler PSI and diagnostics tests:
./gradlew :grammar:downloadCompilerTests
; - Prepare the diagnostics tests:
./gradlew :grammar:prepareDiagnosticsCompilerTests
; - Remove the not yet included tests if you want:
./gradlew :grammar:syncWithCompilerTests
. If you do not do this, the previously unseen compiler tests, for which the ANTLR parse tree has not yet been built and pushed, will fail on first run; - Run the test suite:
./gradlew :grammar:test
. At this step, the grammar files are automatically copied tosrc/main/antlr
, and parser and lexer are generated tosrc/main/java/{org.jetbrains.kotlin.grammar.parser}
).
After the build, the following artifacts are available:
kotlin-grammar-parser-{version}.jar
containingKotlinLexer
andKotlinParser
classes generated by ANTLR v4 from the grammar.
The artifacts can be downloaded from TeamCity.
An additional artifact available from TeamCity is kotlin-grammar-tools-{version}-{buildNo}.jar
, which represents a simple API to tokenize and parse Kotlin code (for details, see kotlin-grammar-tools repository).