Strumenta / antlr-kotlin

Support for Kotlin as a target for ANTLR 4
Apache License 2.0
222 stars 47 forks source link

Support ANTLR 4.13.1 and modernize the project setup #107

Closed lppedd closed 9 months ago

lppedd commented 9 months ago

This is a fairly big PR, so I recommend going through it commit by commit, each being self-descriptive.

What has been done:

  1. Updated Kotlin to 1.9.21
  2. Ditched the custom Gradle plugin
  3. Updated Gradle to 8.3 and modernized the build scripts
  4. Applied a bunch of currently opened PRs from this repo, and one PR from the ANTLR4 repo

    77

    75

  5. Solved a couple of issues

    81

    93

    106

  6. Set up a skeleton to publish to a Maven repository
  7. Restructured the Kotlin template (Kotlin.stg) to output working, beautified and readable code
  8. Updated the runtime, commit by commit, to align to the Java runtime - version 4.13.1

Testing

I've set up an additional module antlr-kotlin-tests, which is supposed to host all the multiplatform tests.
I've only ported the MiniCalc* ones, but I don't think there are others to move.

TO-DO

lppedd commented 9 months ago

I encourage you to checkout the branch and experiment with it.

ftomassetti commented 9 months ago

Wow @lppedd what an amazing contribution: THANK YOU!

Restore Travis (or another CI) build, and maybe Jitpack, although I'd like to avoid it and publish straight to Central

I would suggest we use GitHub actions and we publish to Maven Central

Possibly restore example projects (or agree to move them to another repository - preferred IMO)

Let's move them to another repository. We actually created the repository some time ago: https://github.com/strumenta/antlr-kotlin-examples

lppedd commented 9 months ago

Just pushed another couple of commits to add back the previously enabled Native targets.
As with JS, Native targets lack proper implementations for IdentityHashMap and WeakHashMap.

WeakHashMap is tracked at https://youtrack.jetbrains.com/issue/KT-48075
IdentityMap is tracked at https://youtrack.jetbrains.com/issue/KT-8435

Plus, native targets are not thread safe. I'll have to check what can be done with Kotlin's AtomicFU, but not now, maybe in some months.

lppedd commented 9 months ago

Regarding example projects, I'd say let's get this merged first (and published possibly), and then I can go back and update them in the other repo. I'll do some manual testing tho, to verify that they still work.

ftomassetti commented 9 months ago

I think once this PR is in, we could consider starting the process to get this included in the list of official targets

lppedd commented 9 months ago

I've updated the readme, let me know if it's good enough.
I think it's up to you now to add the publishing/signing bits and the Actions stuff.

I'll experiment with build + publication to see what's the best chain of commands, but we also need to consider we are building on two machines (at least).

Do some experimentation with a private Maven repo first.

ftomassetti commented 9 months ago

Ok, let's merge this one and then add GitHub actions and publishing

lppedd commented 9 months ago

Sounds good! Thanks! I'll open another PR soon to address #104 and #38.