[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gnubol: [rpragana@acm.org: Some comments about a cobol parser]
In a message dated 11/23/99 12:21:59 PM EST,
a hard working Tim Josling, TIMJOSLING@prodigy.net writes:
<<
My test parser just parses. No error production, though I have an idea how
to do
good enough error recovery..
>>
Permit a suggested terminology. We could have positive logic rules
(productions) and error productions. These look the same to the parser tool.
Error recovery is sometimes used to refer to the engagement of mechanisms
built into the code generated by the parser tool.
I suggest that restricted use of the word. Users make coding mistakes, by
compensating for it in the rules we are in a pedestrian sense recovering from
the coders error; that is a somewhat confusing use of the word in the
technical work context, because if we have coded some rule that actually
traps the error, then the generated compiler is not in error recovery mode;
it thinks it is just reducing or shifting.
Backtracking is a kind of error recover mode. But that is bending the word in
a way because the exact purpose of backtracking is to prevent the other
categories of error recovery.
Some tools generate an algorithm for us that can actually keep going after
real scan interuption, though staggered this. Some parsers will try to skip
as many as three tokens in order to get to something it can recognize. This
count (3) is usually mediated by a parm for the grammar rule interpretation
when we are trying to generate the compiler. This type of recovery can
_sometimes_ leave you in bad shape.
A regular positive logic case might be
IF cond THEN stmt_block ELSE stmt_block END-IF.
{ life is fine };
It would not be too surprising if we saw someone code an error production to
trap excessive END-IFs
IF cond THEN stmt_block ELSE stmt_block END-IF END-IF.
{ life is not so fine, extra END-IF ignored (call it unbalanced) };
That would be an error production, but it does not actually involve 'error
recovery', in the constrained sense of the phrase.
Yet another form such as this
IF cond THEN stmt_block ELSE stmt_block END-IF error EOS
{ life is real bad };
uses the special error symbol. This is a production that engages the error
recovery mechanism of the grammar tool generated compiler algorithm and gives
the free fall a place to land. Thus it involves hunches about where the
coder makes mistakes.
Yet another rule might be
IF cond THEN stmt_block error ELSE stmt_block END-IF
{ life is real bad down deep in the nest };
This too engages the error recovery mode of the algorithm in the compiler.
You can not actually code the error recovery mode. That is the problem, once
the compiler algorithm goes into error 'recovery' mode we are atleast
somewhat out of control. The error symbol helps minimize this problem, and
error productions (which just look like normal productions to the tool) help
head things off at the pass. Error productions, in cases they trap, actually
prevent error recovery mode. :-)
Best Wishes,
Bob Rayhawk
RKRayhawk@aol.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.