Create separate classes for a custom Antlr4 target

73 Views Asked by At

I am creating a custom target for Antlr4 based on the Java.stg template. In the Parser part of the template the class for the Parser is generated along with some helper classes (extending for example ParserRuleContext). All these classes are included in one single file.

For the new target language however I cannot include more than one class definition per file. Is there a feature in Antlr4 to generate separate files for every generate class?

1

There are 1 best solutions below

7
Mike Lischke On

The stg files are just sources (templates) for the generation process. What matters is the files that are produced by ANTLR4 and they always contain only one class, unless you manually add another one.