[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gnubol: New bison Grammar available (long)
In a message dated 12/26/99 5:11:41 PM EST, tej@melbpc.org.au writes:
<<
> The following is not intended to harp on a point, or to make anything out
of
> it more than the technical interaction already posted about the
shift/reduce
> conflict on the ELSE clauses.
Bob can you suggest some test cases and I will run them as a
priority.
>>
actually just two deep will do it.
IF this
THEN
IF that
THEN do some things
ELSE do some different things
ELSE do some very different things
END-IF.
about the only thing special is to avoid explicit termination of the inner
IF, thus presenting your parser with an opportunity to yield innappropriately
to the second ELSE.
Your %prec PREC_LOWER_THAN_END_IF, as initially published, is also lower that
ELSE!
Your extended statement IF-THEN-ELSE will not reduce when confronted with
ELSE (because it thinks it is hoping for an END-IF), since it will not
reduce, the parser _will_ shift! There is no such rule as an
IF-THEN-ELSE-ELSE, so the code example will produce a parse error.
by coding %prec PREC_LOWER_THAN_END_IF lower than ELSE, and tacking that onto
the end of the extended IF-THEN-ELSE, you commanded the parser to make a
mistake.
It will take a more elaborate interaction to reach this but, surely you have
the intellectual skills necessary to see that the alternating error
conditionals of the various verbs that sport that have the same issue. You
will dive head long into sequences like
ARITH SIZE_ERROR ... NOT_SIZE_ERROR ... NOT_SIZE_ERROR
shift parse errors because the %prec at the end of the fully elaborate dual
phrase form will
not be high enough to kick off the third phrase. It will be named right,
something impressive, like
%prec THIS_HAS_JUST_GOTTA_SHIFT_END_ARITH_BUT_REDUCE_ON_CONDITIONAL
but it will not, if it is defined low. In fact it will shift every thing. In
fact it should shift all of the following garbage (technical term):
ARITH SIZE_ERROR ... NOT_SIZE_ERROR ... TO
ARITH SIZE_ERROR ... NOT_SIZE_ERROR ... BY
ARITH SIZE_ERROR ... NOT_SIZE_ERROR ... GIVING
ARITH SIZE_ERROR ... NOT_SIZE_ERROR ... PICTURE
ARITH SIZE_ERROR ... NOT_SIZE_ERROR ... SELECT
The algorithm will shift these, and then commence error recovery. That seems
almost okay.
but when an enclosing statement is
ARITH SIZE_ERROR ...
you do not want the interior statement to keep shifting
ARITH SIZE_ERROR ... NOT_SIZE_ERROR ... NOT_SIZE_ERROR
Instead when the enclosing statement is
ARITH SIZE_ERROR ...
you want the interior statement to reduce
ARITH SIZE_ERROR ... NOT_SIZE_ERROR ...
that reduction will be amongst statements of a stmt_block_recurse, as
we pop out of there, the lookahead now finds a better bind point, the
enclosing staement ...
NOT_SIZE_ERROR
In transposition, you can do all that the other way around
ARITH NOT_SIZE_ERROR ...
ARITH SIZE_ERROR ... NOT_SIZE_ERROR ...
SIZE_ERROR
The technical issue is the same as on the far right edge of the fully
populated IF-THEN-ELSE, out there you do not want another shift, you want a
reduction when you see an ELSE (although you do want a shift when you see
END-IF).
Piece of cake.
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.