error recovery

Henry Spencer henry at utzoo.uucp
Tue Apr 25 06:38:27 AEST 1989


In article <4389 at goofy.megatest.UUCP> djones at megatest.UUCP (Dave Jones) writes:
>... error-recovery in a recursive descent parser is even
>trickier than in an LR parser!

Nonsense.  If you insist on doing it as part of the parser, it gets messy,
but there's an easy way around that.  Have the parser tell the scanner what
kind of tokens it wants at each point, rather than just asking for "the next
token", and do the error recovery in the scanner.  The parser always sees a
syntactically correct program, and never has to get into the messy business
of popping an activation stack.  With the necessary cooperation from the
parser, this is about a page of code all told.  It works well, too -- often
much better than the messy contortions in yacc.  (Yes, I've done both.)
-- 
Mars in 1980s:  USSR, 2 tries, |     Henry Spencer at U of Toronto Zoology
2 failures; USA, 0 tries.      | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list