[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnubol: Nested conditional statements
I tried out nesting conditional search and evaluate on IBM's
mainframe compiler (cobol for os/390). The results give some
insight into how the compiler operates.
I had something like
evaluate num1
when 1
search arr1 varying index1
when arr1 (index1) = "a"
display "a"
when arr1 (index1) = "b"
display "b"
when arr1 (index1) = "c"
display "c"
when 2
display "2"
when other
display "other"
#
The compiler returned three errors with a return code of 12
(unable to generate code). First it said that the nested search
was not terminated and it had inserted an end-search at the
fullstop (#). This is obviously incorrect (obvious to the
programmer that is). Then it complained that '2' is not a valid
condition. The '2' would have been valid as part of the evaluate,
where partial conditions - values of the evaluated expression -
are allowed, but not after the 'when' in a search. Finally it
complained about the 'other' as a not expected word.
>From this it would appear that the scanning that IBM does is
fairly simple. It scans ahead looking for certain phrase starting
words that cannot be in the current verb. It is not smart enough
to realise that 'when other' for example must be part of another
verb. This also shows it is not doing backtracking.
When I put in the end-search all was well of course.
Reportedly Microfocus cobol can handle this sort of thing. I
would love to see what it does with this.
I have been off the air for a few days upgrading to Red Hat linux
6.1 (had a media error with the CD I bought - not from Red Hat).
It looks really nice with enlightenment and Gnome and all - well
done guys.
Tim Josling
--
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.