Skip to content

antlr plugin should support Antlr 3 and 4 #1240

@eriwen

Description

@eriwen

From the forum: https://discuss.gradle.org/t/antlr-4-behavior-change-between-gradle-2-4-and-2-7/11966/5

Antlr 4 and Gradle 2.7+ do not work together using the Gradle AntlrPlugin.

Expected Behavior

The Gradle antlr plugin should support the latest versions of Antlr fully.

Current Behavior

The antlr plugin is broken if users try to use Antlr features in newer versions

Context

From @breskeby:

The importVocab statement cannot be used if referencing grammar with package declaration. possible solution:

  1. the generated source must be generated in an order that respects importVocab dependencies in the grammar.
  2. gradle should pass the output directory of a grammar file as -lib folder to allow referencing grammar from same package that has been generated before

From @sebersole:

I have already...

My plugin (1st link) has some poor design points in the sake of ease-of-use in Hibernate, which is what I needed this for.

A more generally useful plugin/task for Antlr v4 (and v3 I believe) would perform discovery and actually inspect the grammar files to figure out things like generation-order, package names and corresponding directory structure, etc. Antlr uses itself at runtime to parse these grammar files; you can manually perform all these steps yourself which gives you access to valuable information.
I can help some with that. I might be beneficial to reach out the Antlr team and see if they are willing to take over that plugin. Contribution is how they started supporting the Maven plugin.

I just mean that discussion and that plugin are a good start on specifically Antlr v4 that actually works between Gradle 2 and 3.

I know compat with older versions of Gradle is not the top priority of the Gradle team, but it is an amazing thing when it happens to happen with no extra work

As I said on the forum thread (2nd link) I personally think this needs specific plugins/tasks for each version of Antlr. But honestly that's the same thing I suggested when it was decided to fold Antlr v3 support into the same v2-based plugin. The plugin I wrote for Hibernate would not work at all against versions of Antlr prior to v4.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions