[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnubol: A question
for Randall Bart or whomever might have a defensible opinion.
I'm looking at how we might resolve the syntactic ambiguity of
abbreviated conditionals and condition names at parse time rather
than later in he compilation. The problem was cited by Christopher
Clark and I have included the relevant part of his message at the end
of this one.
My question is really about abbreviated conditionals, apart from this
classic gotcha. What effect do parenthesized expressions have on
abbreviation? If I encounter the following
IF a = b OR ( c < d AND e < f ) OR g
and "g" is indeed a simple variable, should I interpret this to mean
IF a = b OR ( c < d AND e < f ) OR e < g
or perhaps
IF a = b OR ( c < d AND e < f ) OR a = g
or should it be diagnosed? I've never been sure we've gotten this
one right in the past, evidenced by the fact that I can't remember
which way we did it. I probably got an expert interpretation then,
but I need one again.
Thanks,
Mike
Christopher's example:
...
01 X PIC 9 VALUE 1.
01 Y PIC 9 VALUE 2.
* 88 Z VALUE 2.
01 Z PIC 9 VALUE 2.
PROCEDURE DIVISION.
MAIN.
IF X = Y OR Z
DISPLAY "s"
ELSE
DISPLAY "f"
END-IF.
===========>8===============
And point out that the IF statement _parses_ differently depending on which
version of Z is included, since as a field, the actual test is:
(X = Y) OR (X = Z)
<value1> = <value2> OR <value3>
=> <simple-condition> OR <value3>
=> <abbreviated-combined-condition>
but if the 88 version is included, the actual test is:
(X = Y) OR Z => (X = Y) OR (Y = 2)
...
--
This message was sent through the gnu-cobol mailing list. To remove yourself
from this mailing list, send a message to majordomo@lusars.net with the
words "unsubscribe gnu-cobol" in the message body. For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@lusars.net.