uwol / proleap-cobol-parser

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

END-<statement> considered error #9

Closed albertolovato closed 6 years ago

albertolovato commented 7 years ago

Sometimes putting END-<statement> stops parsing, for example with PERFORM UNTIL x NOT = SPACE END-PERFORM.

The same happens with END-ACCEPT and END-IF

Reinhard-Prehofer commented 7 years ago

ISSUE09.CBL.txt

I am rather sure the parser requires at least a "null-statement" like CONTINUE between a block statement.

      * An "empty" loop is not recognised
      * the parser expects at least one Statement
      * so if your remove the comment on CONTINUE => it works    
           PERFORM VARYING X-3 FROM 1 BY 1  UNTIL X-3  > Z-T-MAX  
      *       CONTINUE
           END-PERFORM

errormessage is:

Preprocessing file ISSUE09.CBL.
Parsing file ISSUE09.CBL.
line 28:11 no viable alternative at input 'Z-T-MAXEND-PERFORM'
Collecting units in file ISSUE09.CBL.
uwol commented 6 years ago

You found a bug with perform statements. Perform statements required at least one nested statement to be parsed.

Fixed in 1eef9037af6bd8332f8637d68863eb9b100ec749. Added a unit test for the code provided by you.

Thanks to both of you!