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

Parsing nested statements: was Re: gnubol: subsets



Take the example

add z to y
   not on size error
      add a to b
         on size error
              display ...
              display
              add b to c
                  not on size error
                     display ...
              end-add
      end-add
. (period)


There is a lot of suspense here. About where statements end, whether there is a
syntax error.

I don't think any tool will handle this well without assistance; particularly to
get reasonable error recovery and messages. I'm trying to formulate a prescanning
algorithm that will allow bison to do it. After a 90 minute walk I still did not
have it worked out.

I had assumed you would need two productions; one for imperative statement and
one for conditional statement - for each of the verbs that can be either type.
You can reuse most of the component phrases so it is not a big deal (so far).

It gets better - the IF statement allows precisely one conditional statement on
the end of the list of imperative statements. The language in the standard does
not help (calling them imperative statements).

An example

IF a > b
    display ...
    add a to b
           on size error
                   display ...
ELSE
    display ...
     subtract retro-adjust-factor from running-total
             on size error
                  display ...
END-IF

This is an imperative statement I think.

Tim Josling

RKRayhawk@aol.com wrote:

> In a message dated 11/20/99 10:26:11 PM EST, mck@tivoli.mv.com writes,
> sketching a pair of ADD statements, first : ...

> On _second_ approximation, it is worse. You also need rules for the

> unconditional ADD, (that is one with no optional ON SIZE ERROR.But from the
> point of view of my interest in error trapping, there is yet

> more.  Suppose that we get all those rules in there, or some fewer number
> that does the job. ...

> But yes, I think there are atleast two, sometimes four in these burdensome
> sets.
> ...
> There is a variation of this that is even more strange, but I don't think it
> is any different to code. A conditiional branch can have, of course, a
> PERFORM.


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