Skip to content

Range value in condition levels are not parsed correctly #1778

@fm-117

Description

@fm-117

Describe the bug
Some value declarations are not parsed correctly and lead to an exception.

To Reproduce
(Type)Cobol code that cause the bug : (if any)

       IDENTIFICATION DIVISION.
       PROGRAM-ID. MyPGM.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 item PIC 9(4).
          88 ranges VALUE 0001 THRU
                          0005.
       procedure division.
           goback
           .
       END PROGRAM MyPGM.

Expected behavior
No error.

Check this code, the keywords THROUGH and THRU should be added to distinguish between literals and level number in that case.

//Try to guess if it is a LevelNumber or Literal depending on previous tokens
bool currentTokenIsExpectedToBeALiteral =
lastSignificantToken.TokenType == TokenType.OCCURS ||
lastSignificantToken.TokenType == TokenType.VALUE ||
lastSignificantToken.TokenType == TokenType.VALUES ||
(beforeLastSignificantToken.TokenType == TokenType.VALUE && lastSignificantToken.TokenType == TokenType.IS) ||
(beforeLastSignificantToken.TokenType == TokenType.VALUES && lastSignificantToken.TokenType == TokenType.ARE);

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions