What is minimal sample Gradle project for ANTLR4 (with antlr plugin)?

后端 未结 7 1439
陌清茗
陌清茗 2021-02-14 03:47

I have created new Gradle project, added

apply plugin: \'antlr\'

and

dependencies {
    antlr \"org.antlr:antlr4:4.5.3\"
         


        
7条回答
  •  日久生厌
    2021-02-14 04:32

    Add this to your build.gradle

    generateGrammarSource {
        outputDirectory = file("src/main/java/com/example/parser")
    }
    

    add this to your grammar after your "grammar ";

    @header {
        package com.example.parser;
    }
    

    Tested and working with Java8 grammar from antlr example grammars

    Additional Link(s):

    Here is a short guide of the Antlr plugin from docs.gradle.org

提交回复
热议问题