gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [open-cobol-list] Re. Small Cobol changes for MVS compatibility


From: Bill Klein
Subject: RE: [open-cobol-list] Re. Small Cobol changes for MVS compatibility
Date: Tue Nov 16 12:59:03 2004

First let me say that I *hate* the COPY/REPLACING and REPLACE rules in both
the '85 and '02 Standards.  I get confused every time that I try and figure
out exactly what they mean.  HOWEVER, let me try and give an example of what
I *think* the ('02) Standard is saying.

Given "library text" (original source of:

, text-1  text-2, ; text-3, , text-4 

and the COPY statement of
   COPY library-text
    Replacing ==text-1== by =repl-A==
              ==text-2 text-3== by ==repl-B, , , == .

what happens is:

1) You look for the "left-most text word" in the library text that is NOT a
separator comma or semicolon.  This is "text-1"

2) You then place any library text that precedes this into the "resultant
text" (so in this case, you place
   , 
into the resultant text.

3) You check if "text-1" matches pseudo-text-1 - which it does, so you place
the EXACT pseudo-text-2 into the resulting text - which in this case is
    repl-A

4) "text-2" is now the "leftmost" text word of the library text.  It doesn't
match any individual pseudo-text-1, but for PURPOSES OF MATCHING
   text-2, ; text-3
has the ", ; "treated as a single space.  Therefore, this does match the
second pseudo-text-1.

5) You then place the EXACT pseudo-text-2 (from the match) into the
resultant text, so you place
   repl-B, , , 
(with a trailing space) into the resultant text.

6) now the new "leftmost" text word is
    , 
(with a trailing space) - but the ", , " before text-4 is IGNORED for
matching purposes, but is placed into the resultant text (as it preceded the
next text word used for matching).

7) the text word used for the next comparison (after the ignored separator
comma) is text-4 - which doesn't match any pseudo-text-1, so it is placed in
the resultant text.

***

Therefore, (if all goes well) the resultant text is:

, repl-A repl-B, , , , , text-4

Now, in fact all of those ", " (separator commas) do NOTHING in syntax
processing (although is some really obscure cases they can cause problems).
But (if I am correct - and I sure won't swear to it) that is what is
SUPPOSED to happen (in both the '85 and the '02 Standards).

> -----Original Message-----
> From: address@hidden 
> [mailto:address@hidden On 
> Behalf Of Roger While
> Sent: Tuesday, November 16, 2004 3:35 AM
> To: address@hidden
> Cc: address@hidden
> Subject: RE: [open-cobol-list] Re. Small Cobol changes for 
> MVS compatibility
> 
> Hi Bill,
> Agreed, however, I was trying to make clear the position as
> regards the trailing space in the pseudo-text which IS unambiguous.
> (At least to my interpretation) (Ans is fully clear with 
> respect to the 
> example
>   from Mr. Korn)
> 
> Interesting, quoting the paragraph GR10(a) fully -
> "The leftmost library text-word that is not a separator comma or a 
> separator semicolon is the first text-word
> used for comparison. Any text-word or space preceding this 
> text-word is 
> copied into the resultant text.
> Starting with the first text-word for comparison and first 
> pseudo-text-1, 
> text-1, word-1, literal-3, or
> partial-word-1 that was specified in the REPLACING phrase, the entire 
> REPLACING phrase operand that
> precedes the reserved word BY is compared to an equivalent number of 
> contiguous library text-words."
> 
> In particular, the second sentence. What can be "preceding" 
> when the first 
> sentence talks about
> "leftmost" ?
> 
> Roger
> 
> At 16:24 15.11.2004 -0600, you wrote:
> >Roger,
> >   You couldn't be MORE mistaken about what the '02 Standard 
> says (and 
> > this
> >IS consistent with the '85 Standard) when you say,
> >
> >"If you say ==<space>TEXT<space>== BY
> > > ==<space>TEXT2<space>== , then 2002 states that
> > > this is EXACTLY what will be searched for"
> >
> >See: GR10(a) on page 34 which states, (in part),
> >
> >"The leftmost library text-word that is not a separator comma or a 
> >separator
> >semicolon is the first text-word used for comparison."
> >
> >In other words,
> >
> >    ==text-word==
> >
> >DOES match
> >
> >   ==, . text-word==
> >
> >and also matches
> >
> >   ==<space>text-word==
> >
> >(all spaces and non-spaces and equivalent separators) are treated as
> >IRRELEVANT before the first text-word.
> >
> >It *is* true that the '85 Standard (and the '02) Standard 
> BOTH state that
> >when a match is found, that you MUST put all of 
> pseudo-text-2 (the stuff
> >after the BY) into the resulting text.
> >
> >This is why I indicated that *if* the current implementation is NOT 
> >placing
> >spaces in the resulting text (when they appear in 
> pseudo-text-2) that is
> >NON-conforming.
> >
> > > -----Original Message-----
> > > From: address@hidden
> > > [mailto:address@hidden On
> > > Behalf Of Roger While
> > > Sent: Monday, November 15, 2004 2:59 PM
> > > To: address@hidden
> > > Subject: [open-cobol-list] Re. Small Cobol changes for MVS
> > > compatibility
> > >
> > > David, I'm fairly OK with 1 and 2.
> > > But definitely not with 3.
> > > I was always mystified by the way compilers jumped through
> > > hoops to supposedly adhere to the nonsense 85 standard.
> > > In the 2002 standard, things are absolutely clear.
> > > If you say ==<space>TEXT<space>== BY
> > > ==<space>TEXT2<space>== , then 2002 states that
> > > this is EXACTLY what will be searched for and EXACTLY what
> > > will be replaced.
> > > The only extra processing is :
> > > "Each occurrence of a separator comma, semicolon, or space in
> > > pseudo-text-1
> > > or in the library text is
> > > considered to be a single space. Each sequence of one or 
> more space
> > > separators is considered to be
> > > a single space."
> > >
> > > In fact, because of the 85 confusion, MicroFocus says this :
> > > "(ANS85) If certain conventions are followed in library text,
> > > parts of
> > > names, for example the prefix portion of data-names, can be
> > > changed with
> > > the REPLACING phrase. To use this type of "partial word
> > > replacement" the
> > > portion of the words to be modified must be enclosed in one of the
> > > following ways:
> > > In pairs of left and right parentheses. For example, (ABC)
> > > Within colons. For example :XYZ: "
> > >
> > > So, regardless of what Open Cobol does or does not do, I 
> would change
> > > your copy statements to be unambiguous. In my opinion,
> > > putting spaces at
> > > the end of
> > > pseudo-text and expecting the compiler to know what you mean
> > > is asking for
> > > trouble.
> > > Take out the trailing space at the end of pseudo-text-1 and
> > > -2, and then
> > > you have a prog that
> > > should compile with any standard (theoretically) .
> > >
> > > Roger
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: InterSystems CACHE
> FREE OODBMS DOWNLOAD - A multidimensional database that combines
> robust object and relational technologies, making it a perfect match
> for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
> _______________________________________________
> open-cobol-list mailing list
> address@hidden
> https://lists.sourceforge.net/lists/listinfo/open-cobol-list
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]