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

Re: FW: gnubol: How do we parse this language, anyway?



This is the point where I stopped worrying about it, Tim.  This is
not merely a grammar ambiguity.  This is a case where I, presumably a
reasonably intelligent human being, cannot parse it either, without
trying to divine the intention of the programmer.

As much as Bill would have us believe otherwise, SEARCH and EVALUATE
are different in kind from the other verbs which permit conditional
phrases.  It is not difficult to construct a perfectly consistent
logical system, using terminators only as needed, when the number of
conditional phrases is limited to a small number (OK, theoretically a
finite number), but not otherwise.  Your example shows that the WHEN
phrase for SEARCH and EVALUATE are not, in general, syntactically
distinguishable, but even if they were, one would still be unable to
nest SEARCH within SEARCH or EVALUATE within EVALUATE, with an
implied termination of the contained verb.  Forgive me for ignoring
WHEN OTHER in this discussion, but it is not required either.

Best regards,

Mike

>>>>> "Tim" == Tim Josling <TIMJOSLING@prodigy.net>
>>>>> wrote the following on Fri, 10 Dec 1999 22:41:12 +1000

  Tim> Bill, I am interested in Microfocus COBOL, but also COBOL for
  Tim> FUNCTION currentsynonym("MVS"). Here are a couple of test
  Tim> cases for the nested conditional search/eval.

  Tim> As Bob suggested, I am going to have a very sharp demarcation
  Tim> between parsing and the rest so I should be able to handle
  Tim> changes down the track if needed. I am really intrigued how
  Tim> Microfocus would handle this kind of thing.

  Tim> Regards, Tim Josling

       <snip>

       IDENTIFICATION DIVISION.
       PROGRAM-ID. COBOL-TEST.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  a.
         03  b occurs 10 indexed by ix pic x.
       01  a2.
         03  b2 occurs 10 indexed by ix2 pic x.
       01  c   pic 9.
       PROCEDURE DIVISION.
       001.
           move "1234567890" to a.
           search b
                  when b (ix) = "6"
                       set c to ix
                       evaluate true
                           when c = 1
                                display "surprise"
                           when c = 6
                                display "no surprise"
      ***                 when other
      ***                       display "surprise"
      ***               end-evaluate
                  when b (ix) = "7"
                        display "5 found"
           .



--
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.