Path: utzoo!attcan!utgpu!watmath!att!bellcore!decvax!ima!esegue!compilers-sender From: lai@mips.com (David Lai) Newsgroups: comp.compilers Subject: Re: Error reporting in LR parsers Message-ID: <1989Aug8.130702.957@esegue.uucp> Date: 8 Aug 89 13:07:02 GMT Sender: compilers-sender@esegue.uucp Reply-To: lai@mips.com (David Lai) Organization: MIPS Computer Systems, Inc. Lines: 20 Approved: compilers@esegue.segue.bos.ma.us X-Mailer: ELM [version 2.2 PL7] In <1989Aug6.024931.10014@esegue.uucp>, Dave Jones gives a rebuttal stating how a default reduction in yacc has eliminated acceptable tokens from the token list when an error occurs. The problem can be solved by generating the list of acceptable tokens *before* returning the error token. This method requires that you test the tokens before returning them to yacc (in the scanner). In the case given 'i = j k', the scanner upon reading 'k' checks the parser state to see whether an identifier is acceptable in this state. This will be the state prior to the default reduction, where + and * are still acceptable. The list of acceptable tokens is remembered and the erroneous token is returned. The 'yyerror' function then prints out the (perhaps decoded) list of acceptable tokens. -- David Lai (lai@mips.com || {ames,prls,pyramid,decwrl}!mips!lai) -- -- Send compilers articles to compilers@ima.isc.com or, perhaps, Levine@YALE.EDU { decvax | harvard | yale | bbn }!ima. Meta-mail to ima!compilers-request. Please send responses to the author of the message, not the poster.