[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PERFORM token (was RE: gnubol: Hacks needed to parse COBOL
>>>>> "Bill" == William M Klein <wmklein@ix.netcom.com>
>>>>> wrote the following on Thu, 2 Dec 1999 16:25:49 -0600
<snip>
>> I think that with a single look-ahead you can determine whether
>> the word that follows the PERFORM is a reserved word such as
>> UNTIL or VARYING, a verb, or a user defined word, that must be a
>> procedure name. Then you can either verify a previously
>> tabulated name and issue errors, or tabulate the first-used name
>> as a referenced procedure, and leave further error reporting to
>> the semantic phase.
>>
>>
Bill> The statement about a user-defined word following PERFORM
Bill> being a procedure-name is not correct.
Bill> Either Perform paragraph-name *> out-of-line PERFORM
Bill> or
Bill> Perform data-name TIMES *> in-line perform
Bill> is valid
This is a good candidate for semantic classification of ref's but
bear in mind that a procedure ref, when it is a forward reference,
will not be available in the symbol table at the time it's needed. A
lookup failure would have to be interpreted as a procedure name.
I am generally in favor of reference classification, but a purely
syntactic grammar for PERFORM is feasible with lookahead for one
case. This is a pccts grammar with lookahead for "times_phrase".
perform_stmt
: PERFORM
(( times_phrase )? times_phrase perform_body
| { test_phrase }
( UNTIL condition perform_body
| ( varying_phrase )+ perform_body
)
| perform_body
| procedure_ref
{ times_phrase
| { test_phrase }
( UNTIL condition
| ( varying_phrase )+
)
}
)
;
times_phrase
: ( INTEGER | identifier ) TIMES
;
test_phrase
: {WITH} TEST ( BEFORE | AFTER )
;
varying_phrase
: VARYING identifier
FROM (identifier | INTEGER)
BY (identifier | INTEGER)
UNTIL condition
;
perform_body
: ( statement )+ END_PERFORM
;
...
procedure_ref
: PROC_NAME { OF_IN PROC_NAME }
;
--
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.