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

Re: gnubol: Hacks needed to parse COBOL



At 09:48 AM 12/3/99 +1000, Tim Josling wrote:
>"J & C Migrations, Pty." wrote:
>> At 06:13 AM 12/2/99 +1000, Tim Josling wrote:
>> >/* problem 11.
>> >   - you need infinite lookahead to determine whether you are expecting a
>> >procedure name or an expression after 'perform'.
>> >     You could look up the type in the symbol table but what about forward
>> >references etc.
>>
>> I think that with a single look-ahead you can determine whether the word
>> that follows the PERFORM is a reserved word ...
>
>Consider:
>
>01 n pic 9.
>
>perform *n* times
>    display ...
>end-perform
>.
>perform *M*
>        *n* times
>.
>goback.
>
>Section M.
>p1.
>
>After the perform, you can have an identifier which can be a procedure
>name or a data item. Both can be qualified to at least one extra level
>(two more tokens) before you know which one it is. The end-perform tells
>you that it is an in-line perform with a possible expression following,
>othwise a procedure name must follow. I think this is the simplest
>solution.

Tim, data-name references are guaranteed to be defined when you are parsing
the Procedure Division, so the PERFORM *n* TIMES case shouldn't be a
problem, and any qualification of *n* should have been already reduced by
the time you are back in the PERFORM production.  In the PERFORM *M* *n*
TIMES case, again *M* qualification is reduced to a symbol, and the symbol
table lookup should tell you that *M* is not a data-name.  Since *M* is not
a reserved word, it must be a reference to either a known procedure, or one
yet to be defined.

Regards,
Jonathan

------------------------------------------------------------
J & C Migrations, Pty.          
566 Centre Street               http://www.jcmigrations.com
Newton, MA 02458-2325           Tel. +1 (617) 916-5114
USA                             Fax. +1 (617) 916-5113
E-mail: mailto:jb@jcmigrations.com

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