IBM / zopeneditor-about

IBM Z Open Editor: File issues here!
https://ibm.github.io/zopeneditor-about
Apache License 2.0
50 stars 20 forks source link

COBOL COPYBOOK Improperly reporting TOKEN errors #186

Open gecolbert opened 2 years ago

gecolbert commented 2 years ago

Development environment used

Problem Description

Detailed steps for reproducing the problem:

  1. First step Edit a Cobol COPYBOOK with multiple tokens: 000001 01 :PREF:-LOC-ADDR-TABLE-REC. 000002 :LB: :PREF:-LOCALITY-TABLE. 000003 :LC: :PREF:-LOCALITY-TRLR 000004 OCCURS 0 TO 35 TIMES 000005 DEPENDING ON :PREF:-NUM-OF-TRAILERS 000006 INDEXED BY :PREF:-TRLR-INDX. 000007 :LD: :PREF:-LOCALITY-FROM-DATE 000008 PIC S9(07) COMP-3. 000009 :LD: :PREF:-LOCALITY-THRU-DATE 000010 PIC S9(07) COMP-3. 000011 :LD: :PREF:-LOCALITY-CDE 000012 OCCURS 102 TIMES 000013 ASCENDING KEY IS :PREF:-LOCALITY-CDE 000014 INDEXED BY :PFIDX:LOC-INDX 000015 PIC X(02). 000016 :LD: FILLER PIC X(10). 000017

zOpen Editor reports multiple TOKEN ERRORS

Expected behavior

Should be accepted as valid COPYBOOK01 COPYBOOK02 COPYBOOK structure

FALLAI-Denis commented 2 years ago

Hi @gecolbert

You touch on one of the problems I expressed in discussion #184 The language server is not a language compiler.

That said, if the description of your COPYBOOK is perfectly legal in terms of form, I think there is a design problem in substance: the level numbers should not be symbolic parameters, and I doubt that it there really is a need for them to be. You could just as easily put real values on your number levels and do a replacement when calling COPYBOOK (the IBM documentation on the compiler gives examples of this use case). As far as we are concerned, our COPYBOOKs of data descriptions do not contain any symbolic parameters and are "totally COBOL", which does not prevent us from making replacements during COPY. This has another advantage: our COPYBOOKs can be used in our data manipulation tool which can associate a (actually) COBOL COPYBOOK with a file and interpret its content by means of the COPYBOOK.

Example:

image

Despite this, unless I am mistaken, the language server detects a false error because it misinterprets REPLACING ...

FALLAI-Denis commented 2 years ago

To solve the initial problem, the language server, but also the textmate grammar, would have to accept at the place where a level number is expected, a text answering the following pattern:

/0[1-9]|[1-4][0-9]|66|77|88|(?P<sep>[\:])(?:\w|\-)+(?P=sep)/

From https://regex101.com/

1st Alternative 0[1-9]

2nd Alternative [1-4][0-9]

3rd Alternative 66

4th Alternative 77

5th Alternative 88

6th Alternative (?P<sep>[\:])(?:\w|\-)+(?P=sep)

FALLAI-Denis commented 2 years ago

About last (or second problem) concerning "replacing" on "ascending key is", this works: put "PREF-LOCALITY-CDE" as a subordonate entry of the OCCURS.

I think where is a problem un Language Server that don't accept "ASCENDING/DESCENDINK KEY" on the subject of the OCCURS.

image

Perhaps need to open a new issue for this second problem ?

gecolbert commented 2 years ago

The structure of this copybook is perfectly legal (for Enterprise Cobol) in terms of form.

While I fully agree that the use of tokens in this structure is the result of an overly exuberant programmer and are completely un-necessary, the obstacles to fixing it in my system make the implementation of z Open Editor nearly impossible.

This copybook was introduced into my production system in 1992. It is a core part of the processing for billions of dollars of transactions every month. Just changing the :LB: tag to an 05 will require a three month long project of obtaining change approval, scheduling of the distribution of the change to multiple external agencies, and complete end-to-end testing of our entire system. All of this not to correct a problem or enhance any system functionality.

The arduous effort of change management to critical systems makes it necessary for any new tools to be capable of properly emulating the Enterprise Cobol compiler's behavior. I need an editor that fully implements the language without having to make system changes to accommodate the editor.

FALLAI-Denis commented 2 years ago

Hi @gecolbert

To avoid problems linked to the language server, you can pause it: "F1" + "pause"

image

Cf. #154 Cobol Language Server - "Full red program" after LS analysis.