uwol / proleap-cobol-parser

ProLeap ANTLR4-based parser for COBOL
MIT License
136 stars 74 forks source link

$SET Compiler directives in cobol-sources should be ignored/processed #29

Closed Reinhard-Prehofer closed 6 years ago

Reinhard-Prehofer commented 7 years ago

Some programs tend to have compiler directives in the very first line of a COBOL-source, thus starting with $SET, the $ being positioned in the 7th column (like a comment). The parser should either ignore such statements - treat them like a comment (first and easys tep) or consider the semantics of the various options (some options are very "doubtful" - like NOCHECKNUM, SPZERO etc etc and even influence the runtime behaviour)

2017-08-03 12:33:22.010 [main] ERROR com.csi.parser.CobolParseXXX.parseFile (79) - Cobolfile: XXXXASX.CBL threw exception: {}
java.lang.RuntimeException: Is FIXED the correct line format? Could not parse line 1:       $SET DIALECT(MF) NOTRUNC NOBOUND                                          
    at io.proleap.cobol.preprocessor.sub.line.reader.impl.CobolLineReaderImpl.parseLine(CobolLineReaderImpl.java:64)
    at io.proleap.cobol.preprocessor.sub.line.reader.impl.CobolLineReaderImpl.processLines(CobolLineReaderImpl.java:100)
    at io.proleap.cobol.preprocessor.impl.CobolPreprocessorImpl.readLines(CobolPreprocessorImpl.java:110)
    at io.proleap.cobol.preprocessor.impl.CobolPreprocessorImpl.process(CobolPreprocessorImpl.java:99)
    at io.proleap.cobol.preprocessor.impl.CobolPreprocessorImpl.process(CobolPreprocessorImpl.java:86)
    at io.proleap.cobol.preprocessor.impl.CobolPreprocessorImpl.process(CobolPreprocessorImpl.java:65)
uwol commented 6 years ago

Thanks, fixed in fb735cf214d2a0424996b2f7f0c72716d989ac94. Added a unit test. With this fix, lines with a $ line indicator are blanked by the preprocessor, i. e. ignored by the parser.

Some refactoring in the preprocessor would be necessary to provide the original lines/compiler directives to the ASG. The implementation has to be done together with fixing issue #41.