Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: error recovery
Message-ID: <1989Apr24.203827.5969@utzoo.uucp>
Organization: U of Toronto Zoology
References: <1279@lzfme.att.com> <4389@goofy.megatest.UUCP>
Date: Mon, 24 Apr 89 20:38:27 GMT

In article <4389@goofy.megatest.UUCP> djones@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@zoo.toronto.edu
