Generating ANTLR4 grammar files with package declaration in gradle -
i try use gradle antlr plugin, run several problems.
i have grammar file called wls.g4
:
grammar wlsscript; @header { package hu.pmi.wls.antlr.ws; } program : 'statementlist'? eof ; // several more grammar , lexer rules
(note: made statementlist keyword make correct grammer without including whole grammar. ;-))
this file located in /src/main/antlr (as default source folder of antlr production grammar files).
here snippet build.gradle
:
project('common') { apply plugin: 'antlr' dependencies { // dependencies antlr "org.antlr:antlr4:4.5" } }
when use generategrammarsource
gradle task (comming antlr
plugin) generate source files generates files in build/generated-src/antlr/main
folder default.
what goes wrong, doesn't create folders of java package (hu/pmi/wls/antlr/ws
in our case) source incorrectly located in eclipse.
my primary question how force task generate source files in package-structured way? in other words, how can configure gradle task use package declaration grammar?
thanks!
i had exact same question , able change outputdirectory
used antlrtask package name in there.
generategrammarsource { outputdirectory = new file("${project.builddir}/generated-src/antlr/main/net/example".tostring()) }
i found no easy way extract grammar package files had hardcode in task.
Comments
Post a Comment