I'm learning on how to use Antlr4 to parse COBOL source codes. Currently, I'm following the steps, exactly as demonstrated by Enam Biswas in his Youtube video.
Basically, I've downloaded antlr-4.7.1-complete.jar
and placed it in C:\Javalib
. Yes, I've also include the path into my Windows environment and created the antlr.bat
and grun.bat
files.
For the grammar files, I'm using Cobol85.g4 and Cobol85Preprocessor.g4 which were taken from Ulrich Wolffgang github. On the same time, I use HellowWorl.cbl sample source code to see how the parsing works.
After running the antlr.bat
, I executed the command below:
C:\Users\ffa\Desktop\COBOL>grun Cobol85Preprocessor startRule HellowWorld.cbl
As the result, I received the error message as shown below:
Warning: TestRig moved to org.antlr.v4.gui.TestRig; calling automatically
Can't load Cobol85.g4 as lexer or parser
As I'm not sure why I can't get it parsed as shown in the video, I also attempted below commands:
C:\Users\ffa\Desktop\COBOL>grun Cobol85 startRule HellowWorld.cbl
and
C:\Users\ffa\Desktop\COBOL>grun Cobol85* startRule HellowWorld.cbl
End up, I still get the same error message. So, I did my search through Google and found a suggestion to download antlr-runtime-4.7.1.jar
. So, I downloaded the file and placed it in the same directory which is located at C:\Javalib
.
When I executed the commands above, this time, I received a different message
Error: Could not find or load main class org.antlr.v4.runtime.misc.TestRig
Could anyone please assist me to parse the COBOL source code with Antlr4? It would also be good if someone could explain the difference between Cobol85.g4
and Cobol85Preprocessor.g4
.