ANTLR Kotlin

This project contains everything needed to support Kotlin as a target for ANTLR.
- Kotlin Target: a plugin for the ANTLR code generator that produces lexers, parsers, listeners, and visitors
- Kotlin Runtime: a multiplatform library needed by the generated lexers and parsers
This being a fully multiplatform project, the code written using the Kotlin target for ANTLR
will run on the JVM (including Android), in the browser, in Node.js, and natively on Mac, Windows, and Linux.
Want to start experimenting immediately? See Gradle Setup.
Status
The runtime and target's template are up-to-date with mainstream commit: master/e9df464
Kotlin Target
The Kotlin target is a plugin for the ANTLR generator.
It should be added to the classpath used to run the ANTLR Tool.
You will need to specify the target language to be Kotlin (-Dlanguage=Kotlin),
or use the com.strumenta.antlr-kotlin plugin, which instructs ANTLR automatically.
Kotlin Runtime
The Kotlin runtime for the Kotlin target is derived from the Java runtime, and is built
as a multiplatform project running on JVM, JS, WebAssembly (including WASI), and Native.
[!WARNING]
The Kotlin ANTLR runtime is not thread safe
The supported Native platforms are:
[!NOTE]
The linuxArm32Hfp platform is deprecated
Gradle Setup
To start using ANTLR Kotlin:
Benchmarks
The antlr-kotlin-benchmarks module contains benchmarking code
for JVM, JS, WebAssembly and Native targets.
The benchmark scenario has been adapted from antlr4ng.
To run benchmarks, use:
./gradlew :antlr-kotlin-benchmarks:jvmBenchmark
or
./gradlew :antlr-kotlin-benchmarks:jsBenchmark
or
./gradlew :antlr-kotlin-benchmarks:wasmJsBenchmark
or
./gradlew :antlr-kotlin-benchmarks:mingwX64Benchmark
Maven Central Publication
Publication can be performed running:
./gradlew publishAllPublicationsToMavenCentralRepository --no-configuration-cache
However, it is recommended to use the releases plugin and run:
./gradlew release
Contributors
You can see the complete list on GitHub, but here we list those who contributed ten commits or more.
- Dennis Rieks (@driekds)
- Edoardo Luppi (@lppedd)
- @phyrian
- Patrick Del Conte @exaV
License
Consumers of this project may choose the most appropriate license: either the Apache License 2.0, or the 3-Clause BSD License.