Re: Automatic detection of a COBOL dialect ?

From: Frederico Fonseca (real-email-in-msg-spam_at_email.com)
Date: 09/08/04


Date: Wed, 08 Sep 2004 18:30:02 +0100

On 8 Sep 2004 08:37:32 -0700, partoche@caramail.com (diesmo) wrote:

>Hello!
>
>I am trying to enhance a javaCC parser for COBOL, which only accept
>free format with "*>" comments.
>
>I must say i have little knowledge about COBOL.
>For now, I automatically detect fixed or free format, like this :
> - if the first line (without spaces) starts with a number, then it
>is fixed,
> - else it is free format.
>
>This seems to work (if the cols 1-6 in fixed format, when trimed,
>always contains a number :) ).
This is an incorrect assumption.

If you have
ABCD IDENTIFICATION DIVISION.
       PROGRAM-ID. testing.
       ENVIRONMENT DIVISION.
EFGH DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 V1 pic x(11) value "ABC-DEF-GHI".
       PROCEDURE DIVISION.
       MAIN.
           DISPLAY V1.
it is fixed format and does not have any number on the 1-6 cols.

One thing that "might" work would be
if position 7 on any line contains a letter other than "D" then it is
free format, or is wrongly coded.

Now you could still have a valid free format program that just
happened to only have "D"'s on position 7. Very unlikely though.

But if you are parsing a copybook on it's own (you didn't tell us what
your parser does), then it is possible that a freeformat copybook will
have only numbers on cols 1-6.

>
>For "variable" format, it is more tricky... Cols 1-6 may contain
>anything, it seems.
>
>Does anyone know a trick to distinguish a fixed format cobol program
>from a variable format one ?
>For example, if the column 1-6 only contains spaces, then it is
>variable format ?
>Or a way to determin the dialect (assuming each dialect uses only one
>format)?
>Or is it impossible, and the user must specify the format manually ?
Same vendor can use both free and fixed format. There are rules to
determine this.

>
>Thanks in advance.
>
>Regards,
>diesmo.

Frederico Fonseca
ema il: frederico_fonseca at syssoft-int.com



Relevant Pages

  • Re: How do I loose 2 decimal places in a combo box
    ... fixed format and zero decimal format on other occasions when I used Access ... I am using a combo box in a form bound to the members id in the members ...
    (microsoft.public.access.tablesdbdesign)
  • Re: What is wrong with this search for the character PV/PQ
    ... You are compiling fixed format source in which two lines extend beyond ... If you compile it for free format you have old style comments. ...
    (comp.lang.fortran)
  • Automatic detection of a COBOL dialect ?
    ... I must say i have little knowledge about COBOL. ... For now, I automatically detect fixed or free format, like this: ... Does anyone know a trick to distinguish a fixed format cobol program ...
    (comp.lang.cobol)
  • Re: NASA orbit simulation software
    ... My own experiences in various software systems suggest that while there may be an abstract "fixed format", a dozen different programs will have at least ten different formats. ... Build another dozen and it begins to make sense to enlist a standards organization to start creating standard. ... what's the best launch configuration? ...
    (sci.space.tech)
  • Re: about c to fortran
    ... printf("%30.20lf %30.20lf\n", DUMMY, PI); ... If you're used to using C, free format will be easier ... So you can edit free format, and compile fixed format. ...
    (comp.lang.fortran)