Closed Gravity-I-Pull-You-Down closed 2 years ago
Hi there 👋
the pipeline looks as follows: COBOL file -> COBOL preprocessor (parser based on CobolPreprocessor.g4 + rewrite engine implemented in Java) -> COBOL parser (based in Cobol.g4) -> abstract syntax tree.
You can get the abstract syntax tree from a COBOL simply by calling analyzeFile
:
java.io.File inputFile = new java.io.File("src/test/resources/io/proleap/cobol/asg/HelloWorld.cbl");
io.proleap.cobol.preprocessor.CobolPreprocessor.CobolSourceFormatEnum format = io.proleap.cobol.preprocessor.CobolPreprocessor.CobolSourceFormatEnum.TANDEM;
io.proleap.cobol.asg.metamodel.Program program = new io.proleap.cobol.asg.runner.impl.CobolParserRunnerImpl().analyzeFile(inputFile, format);
If you want to use CobolPreprocessor.g4 and Cobol.g4 standalone without the surrounding Java code, this would mean that you have to implement the remaining parts of the pipeline on your own, especially the rewrite engine for supporting different line formats, COPY statements, EXEC statements etc.
Best Ulrich
Thank you very much, That makes much more sense now that you have explained what's actually happening.
I am using COBOL grammar with ANTLR V4 and the Cobol.g4 is incapable of handling
EXEC SQL some SQL statement EXEC-END
and is done by CobolPreprocessor.g4 which I have no idea how to use along with the Cobol.g4 as importing does not work. Please provide a manual of sorts for using these grammars outside proleap @uwol that would very heavily boost the usability of these grammars.