ihji / sbt-antlr4

Antlr4 plugin for sbt 1.1+ and 0.13.x
57 stars 35 forks source link

Infer package name from file location #3

Closed ammachado closed 7 months ago

ammachado commented 10 years ago

Instead of specify package name parameter, infer the package name from the file path, as src/main/antlr4/org/sample/grammar.g4 generates package name org.sample

petrbel commented 9 years ago

I don't think this is good point - one should specify package in .g4 grammar (not using path)

ihji commented 9 years ago

The .g4 file location is not a reliable source for inferring the package name parameter. So I agree with @petrbel.

zyguan commented 6 years ago

I also agree with @petrbel , but can we reserve the directory structrue if antlr4PackageName is not configured? Consider that I have multiple grammars and want to keep them in different package. Currently I need to keep antlr4PackageName as its default value None and specify package in each .g4 files so that the generated .java files (note that they are all located in the root of target base directory in this case) could have different package declarations. Although the compiler can generate .class files with right package layout finally, it's weird to see all generated .java files are in the same folder. @petrbel