uwol / proleap-cobol-parser

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

MOVE CORR tab(ind1,ind2) - Statement not parsed #49

Closed Reinhard-Prehofer closed 6 years ago

Reinhard-Prehofer commented 6 years ago

the following two move corr (using an INDEX) statements lead to parsing errors.

error * move corr with indexed expression leads to parsing error
error       MOVE CORR PG1122-BETRAEGE   (X-H, X-1) TO TAB-ALL-1122    
error       MOVE CORR PG1122-ERGEBNISSE (X-H, X-1) TO TAB-ALL-1122   
error * move corr with indexed expression leads to parsing error

looks like an indexed expression ist not allowed in the grammar for the move-corr-statement:

Parsing file a2612051.CBL.
line 3585:40 mismatched input '(' expecting TO
line 3585:46 mismatched input 'X-1' expecting SECTION
line 3585:49 mismatched input ')' expecting SECTION
line 3586:12 mismatched input 'MOVE' expecting SECTION
line 3586:40 mismatched input '(' expecting SECTION
line 3586:46 mismatched input 'X-1' expecting SECTION
line 3586:49 mismatched input ')' expecting SECTION
line 3589:13 mismatched input 'move' expecting SECTION
line 3589:36 mismatched input '(' expecting SECTION
line 3589:42 mismatched input 'X-1' expecting SECTION
line 3589:45 mismatched input ')' expecting SECTION
line 3591:13 mismatched input 'COMPUTE' expecting SECTION
line 3591:27 mismatched input 'IN' expecting SECTION
line 3591:43 mismatched input '=' expecting SECTION
line 3591:51 mismatched input 'IN' expecting SECTION
line 3591:67 mismatched input '/' expecting SECTION
line 3592:13 mismatched input 'COMPUTE' expecting SECTION
line 3592:27 mismatched input 'IN' expecting SECTION
line 3592:43 mismatched input '=' expecting SECTION
line 3592:51 mismatched input 'IN' expecting SECTION
line 3592:67 mismatched input '/' expecting SECTION
line 3593:13 mismatched input 'MOVE' expecting SECTION
line 3593:26 mismatched input '(' expecting SECTION
line 3593:32 mismatched input 'X-1' expecting SECTION
line 3593:35 mismatched input ')' expecting SECTION
line 3594:13 mismatched input 'MOVE' expecting SECTION
line 3594:48 mismatched input 'TO' expecting SECTION
line 3595:13 mismatched input 'MOVE' expecting SECTION
line 3595:48 mismatched input 'TO' expecting SECTION
line 3596:11 mismatched input 'END-PERFORM' expecting SECTION
Collecting units in file a2612051.CBL.
uwol commented 6 years ago

In 2299b5bdca5d4d3efa452402d609843e1ba16aeb I added 1 AST and 1 ASG unit test for the statement given by you.

Unfortunately, both unit tests pass. Especially the AST test shows, that the parser correctly parses the qualified data name, i. e. "A in B" qualifier.

So I assume that another statement surrounding the COMPUTE statement is the culprit. If you can, please feel free to issue the surrounding parts, or send them to me via email so that I can extract a generalized unit test.

Reinhard-Prehofer commented 6 years ago

I will reduce the huge program to a sample to isolate the erroneous Part in the late evening!Best regards, Reinhard

Reinhard-Prehofer commented 6 years ago

Attached find a cobol file to reproduce the error. I also renamed the issue description to index move-corr, since obviously the compute-Statement is not the culprit ...

a2612051.zip

uwol commented 6 years ago

You are right, the bug was about the missing identifier in MOVE CORR. Fixed in 64d1c1ad47625520ed40bd7facf7d6afe7cb54cd and added a unit test.

Just deployed as:

<dependency>
    <groupId>io.github.uwol</groupId>
    <artifactId>cobol85parser</artifactId>
    <version>2.4.0-SNAPSHOT</version>
</dependency>

Will be part of version 2.4.0, which probably will be available until end of this month.