We are trying to parse Cobol sources.
Displaying multiple array-elements in combination with reference-modification
causes the parser to fail, while the compiler has no problems with it.
Please note that the failure is triggered when more than one element is displayed.
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/PP0032 at line 10
Original contents starting from line 1 till line 11:
IDENTIFICATION DIVISION.
PROGRAM-ID. PP0032.
WORKING-STORAGE SECTION.
01 VARIABLE-ARRAY.
03 VARIABLE-ARRAY-ELEMENT PIC X(05) OCCURS 3.
PROCEDURE DIVISION.
* The use of multiple array-elements with reference-
* modification causes a parser error:
DISPLAY VARIABLE-ARRAY-ELEMENT(2)(1:3)
VARIABLE-ARRAY-ELEMENT(2)(4:2)
GOBACK.
Preprocessed contents:
Parse error at line 10:
4: 01 VARIABLE-ARRAY .
5: 03 VARIABLE-ARRAY-ELEMENT PIC X ( 05 ) OCCURS 3 .
6: PROCEDURE DIVISION .
9: DISPLAY VARIABLE-ARRAY-ELEMENT ( 2 ) ( 1 : 3 )
10: VARIABLE-ARRAY-ELEMENT ( 2 ) ( 4 : 2 )
^
11: GOBACK .
12: EOF
Please fix this parse-error