ANTLR writes files to the current directory by default. But, the output filename is sensitive to the output directory and the directory where the grammar file was found. If you reference a grammar with a (relative or absolute) path,
ANTLR will pull the grammar from that directory and write the output to that directory:
If you specify an output directory with -o then ANTLR will put the output files in that directory or underneath if you have a relative path on the grammar file:
The output directory -o value takes precedence over the grammar's path when the output directory is absolute.
Use -fo option to force output to go explicitly into a directory, ignoring any path on the input grammar name.
Note: If the outputDir set by -o is not present it will be created.