Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!ucla-cs!zen!ucbvax!decvax!ima!johnl From: johnl@ima.UUCP Newsgroups: comp.compilers Subject: Re: Yacc poll Message-ID: <661@ima.ISC.COM> Date: Mon, 17-Aug-87 03:17:07 EDT Article-I.D.: ima.661 Posted: Mon Aug 17 03:17:07 1987 Date-Received: Tue, 18-Aug-87 05:23:32 EDT References: <642@ima.ISC.COM> <378@hubcap.UUCP>, <654@ima.ISC.COM> Sender: johnl@ima.ISC.COM Reply-To: decvax!utzoo!henry Lines: 27 Approved: compilers@ima.UUCP > ... It occurs to me that it shouldn't > be all that hard to change the yacc parser so that it implements the kind of > error recovery that people have been suggesting for RD, to fake up a stream > of tokens that lets the parse continue. Has anyone done that, or are there > pitfalls I hadn't noticed? -John] This might be practical, although you would probably have to extend yacc a bit to make it work well: it is essential that error repair prefer terminating over extending potentially-infinite syntax like parameter lists. My gut feeling is that the bottom-up nature of LALR parsing gives you rather less information about what's going on, perhaps enough to make the idea impractical. My LALR is rusty enough that I'm not sure of this, though. Certainly it's harder to do than the top-down version. [That had occurred to me, but I suspect that heuristics like preferring a token that reduces to one that shifts would help. Besides, you have the same problem in the top down case: Assume the input string is "foo = bar + ;" and after it's parsed the +, the lexer were unwise enough to pass back an open paren as its invented token, because, say, that was the first thing in the legal list. Due to an nroff snafu, I haven't finished reading the paper in the previous article -- they may have addressed this. -John] -- Send compilers articles to ima!compilers or, in a pinch, to Levine@YALE.ARPA Plausible paths are { ihnp4 | decvax | cbosgd | harvard | yale | cca}!ima Please send responses to the originator of the message -- I cannot forward mail accidentally sent back to compilers. Meta-mail to ima!compilers-request