I am trying to write a consistent, platform-independent and target-independent experience in testing a grammar. I just ran across an inconsistency that boggles my mind. To reproduce what I am doing, first clone and cd to the mysql code in grammars-v4 (on Windows, use Msys2 or Ubuntu, use Bash): git clone https://github.com/antlr/grammars-v4.git; cd grammars-v4/sql/mysql. Also, download the antlr-*-jar for both Windows and Ubuntu. Place it where ever you like, and substitute the paths in the commands below.
Then:
- On Windows,
java -jar c:/Users/kenne/Downloads/antlr-4.9.2-complete.jar Positive-Technologies/*.g4. Observe that the generated files are in the current directory. I can use the -o option to place the files in Positive-Technologies/ (java -jar c:/Users/kenne/Downloads/antlr-4.9.2-complete.jar -o Positive-Technologies Positive-Technologies/*.g4). This is great. It does exactly what I tell it to do.
- On Ubuntu,
java -jar /tmp/antlr-4.9.2-complete.jar Positive-Technologies/*.g4. Observe that the generated files are in the directory Positive-Technologies, which is different from what is done on Windows. But, worse, you cannot use the -o . option to change the location of the output files to the current directory. The tool ignores the -o . option. Playing around with this further, I cannot "trick" the Antlr tool to stuff the generated files at all where I want, e.g., cd Generated; java -jar ... -o ../Generated Positive-Techonologies/*.g4. (But, see the next comment.)
- On Ubuntu and Windows,
cd Positive-Technologies; java -jar /tmp/antlr-4.9.2-complete.jar -o .. Positive-Technologies/*.g4 places the files in ... Goody.
- I'd like to point out the poorly worded help instructions of the
-lib option. The tool says "-lib ___ specify location of grammars, tokens files". This makes almost no sense because one can specify the location of the grammar files using a path, e.g., see the above examples where one is in one directory and the grammars are in Postive-Technologies/. It should be clarified to mean the location of grammars required on import statements in an Antlr grammar.
A consistent presentation is first and foremost what a tool should provide, but this is not done for the Antlr tool. The Antlr tool seems to ignore the -o option sometimes on Ubuntu.
--Ken
I am trying to write a consistent, platform-independent and target-independent experience in testing a grammar. I just ran across an inconsistency that boggles my mind. To reproduce what I am doing, first clone and cd to the mysql code in grammars-v4 (on Windows, use Msys2 or Ubuntu, use Bash):
git clone https://github.com/antlr/grammars-v4.git; cd grammars-v4/sql/mysql. Also, download the antlr-*-jar for both Windows and Ubuntu. Place it where ever you like, and substitute the paths in the commands below.Then:
java -jar c:/Users/kenne/Downloads/antlr-4.9.2-complete.jar Positive-Technologies/*.g4. Observe that the generated files are in the current directory. I can use the-ooption to place the files in Positive-Technologies/ (java -jar c:/Users/kenne/Downloads/antlr-4.9.2-complete.jar -o Positive-Technologies Positive-Technologies/*.g4). This is great. It does exactly what I tell it to do.java -jar /tmp/antlr-4.9.2-complete.jar Positive-Technologies/*.g4. Observe that the generated files are in the directory Positive-Technologies, which is different from what is done on Windows. But, worse, you cannot use the-o .option to change the location of the output files to the current directory. The tool ignores the-o .option. Playing around with this further, I cannot "trick" the Antlr tool to stuff the generated files at all where I want, e.g.,cd Generated; java -jar ... -o ../Generated Positive-Techonologies/*.g4. (But, see the next comment.)cd Positive-Technologies; java -jar /tmp/antlr-4.9.2-complete.jar -o .. Positive-Technologies/*.g4places the files in... Goody.-liboption. The tool says "-lib ___ specify location of grammars, tokens files". This makes almost no sense because one can specify the location of the grammar files using a path, e.g., see the above examples where one is in one directory and the grammars are inPostive-Technologies/. It should be clarified to mean the location of grammars required onimportstatements in an Antlr grammar.A consistent presentation is first and foremost what a tool should provide, but this is not done for the Antlr tool. The Antlr tool seems to ignore the
-ooption sometimes on Ubuntu.--Ken