uwol / proleap-cobol-parser

ProLeap ANTLR4-based parser for COBOL
MIT License
137 stars 76 forks source link

Comments look different than Cobol85 #72

Closed fornof closed 5 years ago

fornof commented 5 years ago

In the .g4 , there is: COMMENTENTRYTAG : '>CE'; COMMENTTAG : '>' example_db.txt https://public.support.unisys.com/aseries/docs/clearpath-mcp-18.0/82223827-002/section-000021793.html

This says a comment is a on the 7th column: https://www.tutorialspoint.com/cobol/cobol_basic_syntax.htm I tried both and I get the error: line 32:1 mismatched input '' expecting Am I missing something or are * comments not supported?

uwol commented 5 years ago

Comments are definitely supported by the parser, both as comments with * on column 7 as well as comment entries.

However, comments have to be preprocessed by the COBOL preprocessor contained in this repo to be parseable by the .g4 afterwards. This can be achieved as shown in the readme as such:

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);