We are trying to parse Cobol sources.
Multiple variations on the syntax of defining COMPRESSION in a SELECT fail to parse, while the compiler has no problems with them.
In the below sample program we have a few examples.
All of these are used in our production code without problems.
Versions used:
Cobol: AcuCobol version 10.2.1, fixed format
SonarQube: Enterprise Edition Version 9.6.1 (build 59531)
– extract from the parser logging –
ERROR: Unable to parse COBOL source file : /build/builds/_NwxSV3v/0/dataserver-utilities/tdeltaplayground/sonar-parse-errors/cobol-src/source/PP0022 at line 8
Original contents starting from line 1 till line 28:
IDENTIFICATION DIVISION.
PROGRAM-ID. PP0022.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INT-FILE ASSIGN TO RANDOM INT-FILE-NAME
* When ' COMPRESSION COMPRESSION ' is in the com-
* pression clause it causes the parser to fail:
WITH COMPRESSION COMPRESSION CONTROL VALUE IS 100
ORGANIZATION IS INDEXED
RECORD KEY IS INT-REC
FILE STATUS IS FILE-STATUS.
SELECT INT-FILE-2 ASSIGN TO RANDOM INT-FILE-NAME
* Specifying a compression value like this causes
* the parser to fail:
COMPRESSION VALUE IS 100
ORGANIZATION IS INDEXED
RECORD KEY IS INT-REC
FILE STATUS IS FILE-STATUS.
SELECT INT-FILE-3 ASSIGN TO RANDOM INT-FILE-NAME
* Specifying a compression value like this also causes
* the parser to fail:
COMPRESSION CONTROL VALUE IS 100
ORGANIZATION IS INDEXED
RECORD KEY IS INT-REC
FILE STATUS IS FILE-STATUS.
DATA DIVISION.
Preprocessed contents:
Parse error at line 8:
1: IDENTIFICATION DIVISION .
2: PROGRAM-ID . PP0022 .
3: INPUT-OUTPUT SECTION .
4: FILE-CONTROL .
5: SELECT INT-FILE ASSIGN TO RANDOM INT-FILE-NAME
8: WITH COMPRESSION COMPRESSION CONTROL VALUE IS 100
^
9: ORGANIZATION IS INDEXED
10: RECORD KEY IS INT-REC
11: FILE STATUS IS FILE-STATUS .
13: SELECT INT-FILE-2 ASSIGN TO RANDOM INT-FILE-NAME
16: COMPRESSION VALUE IS 100
17: ORGANIZATION IS INDEXED
18: RECORD
Please adjust the parser so that these parsing errors do not occur anymore.