Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!yale!mintaka!spdcc!iecc!compilers-sender From: djones@megatest.com (Dave Jones) Newsgroups: comp.compilers Subject: Re: Parser Error Detection and Recovery Keywords: yacc, errors, debug Message-ID: <16273@prometheus.megatest.UUCP> Date: 25 Mar 91 23:28:02 GMT References: <9103211951.AA01615@fiu.edu> Sender: compilers-sender@iecc.cambridge.ma.us Reply-To: djones@megatest.com (Dave Jones) Organization: Megatest Corporation, San Jose, Ca Lines: 26 Approved: compilers@iecc.cambridge.ma.us >From article <9103211951.AA01615@fiu.edu>, by georgev@fiu.edu (Vincent George): > [There has been considerable discussion of this in the past. Yacc's > default reductions make error recovery hard, since by the time it realizes > there's an error it may have lost much of the context that one would want > to use to recover from the error. -John] The default reductions have never given me any trouble. As you will recall, they do make it very tedious to list all the legal tokens when an error occurs. However, the original yacc has a bug related to default-reductions which makes proper error-recovery impossible: It creates states with default reductions and a shift-action on "error". The bug is a typo. To fix it, find the following line in file y3.c if(temp1[1] > 0) lastred = 0; Change it to read if(temp1[2] > 0) lastred = 0; [Well, what do you know. -John] -- Send compilers articles to compilers@iecc.cambridge.ma.us or {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.