eclipse-che4z / che-che4z-lsp-for-cobol

COBOL Language Support provides autocomplete, highlighting and diagnostics for COBOL code and copybooks
Other
80 stars 55 forks source link

TYPEDEF not supported #1889

Closed GitMensch closed 1 year ago

GitMensch commented 1 year ago

Description

Cannot parse TYPEDEF / TYPE.

Steps to reproduce

Create file with the following content

       IDENTIFICATION   DIVISION.
       PROGRAM-ID.      prog.
       DATA             DIVISION.
       WORKING-STORAGE  SECTION.
       01  MESSAGE-TEXT-2T IS TYPEDEF.
         02 AUSGABE-FILE-NAME     PIC X(50).
             05 FILLER PIC 9999.
       01 MT2 TYPE MESSAGE-TEXT-2T.

get error messages as follows:

[{
    "resource": "/tmp/prog.cob",
    "owner": "_generated_diagnostic_collection_name_#0",
    "severity": 8,
    "message": "No viable alternative at input IS TYPEDEF",
    "source": "COBOL Language Support (parsing)",
    "startLineNumber": 6,
    "startColumn": 31,
    "endLineNumber": 6,
    "endColumn": 38
},{
    "resource": "/tmp/prog.cob",
    "owner": "_generated_diagnostic_collection_name_#0",
    "severity": 8,
    "message": "A \"PICTURE\" or \"USAGE INDEX\" clause was not found for elementary item MT2",
    "source": "COBOL Language Support (parsing)",
    "startLineNumber": 9,
    "startColumn": 12,
    "endLineNumber": 9,
    "endColumn": 15
},{
    "resource": "/tmp/prog.cob",
    "owner": "_generated_diagnostic_collection_name_#0",
    "severity": 8,
    "message": "Syntax error on 'TYPE' expected {BINARY, BLANK, COMP, COMPUTATIONAL, COMPUTATIONAL-1, COMPUTATIONAL-2, COMPUTATIONAL-3, COMPUTATIONAL-4, COMPUTATIONAL-5, COMP-1, COMP-2, COMP-3, COMP-4, COMP-5, DISPLAY, DISPLAY-1, DYNAMIC, EXTERNAL, FUNCTION-POINTER, GLOBAL, GROUP-USAGE, INDEX, IS, JUST, JUSTIFIED, LEADING, NATIONAL, OBJECT, OCCURS, PACKED-DECIMAL, PIC, PICTURE, POINTER, POINTER-32, PROCEDURE-POINTER, REDEFINES, SIGN, SYNC, SYNCHRONIZED, TRAILING, USAGE, UTF-8, VALUE, VALUES, VOLATILE, '.'}",
    "source": "COBOL Language Support (parsing)",
    "startLineNumber": 9,
    "startColumn": 16,
    "endLineNumber": 9,
    "endColumn": 20
}]

Expected behavior

Support for user-defined types as specified by IBM.

Additional information

This is an ISO2002 feature not available yet on Enterprise COBOL for z/OS; it is likely to be added "relative soon" (like other ISO2002 features that first got distributed with IBM COBOL for x86 and then gets "merged" into the big iron version).

Nurkambay commented 1 year ago

@GitMensch thank you for the issue

So far it isn't supported by a compiler we support. it is listed as a 'potential reserved word' in the latest guide. https://publibfp.dhe.ibm.com/epubs/pdf/igy6lr40.pdf

For now, we are postponing it. Does not make any sense to tolerate this syntax because we will face an error if we try to use a user-defined type variable. This syntax should be fully supported or not supported at all.

zimlu02 commented 1 year ago

Hi @GitMensch,

as TYPEDEF is not a keyword supported by the IBM compiler, we don't plan to support it.

GitMensch commented 1 year ago

It is a working keyword in IBM COBOL for x86 (now also working with 64bit) already; it is likely to be added to one of the next Enterprise COBOL for z/OS - but most important - it is something that should be available with the new dialect option, no?

zimlu02 commented 1 year ago

I agree we may add it back to the backlog once this is really added to Enterprise COBOL for z/OS. But no - this is not something that the new 'dialect' option would support.