Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!mcnc!decvax!ima!esegue!compilers-sender
From: djones@megatest.com (Dave Jones)
Newsgroups: comp.compilers
Subject: Re: Error reporting in LR parsers
Message-ID: <1989Aug11.140755.12273@esegue.uucp>
Date: 11 Aug 89 14:07:55 GMT
References: <1989Aug8.130702.957@esegue.uucp)
Sender: compilers-sender@esegue.uucp
Reply-To: djones@megatest.com (Dave Jones)
Organization: Megatest Corporation, San Jose, Ca
Lines: 28
Approved: compilers@esegue.segue.bos.ma.us

From article <1989Aug8.130702.957@esegue.uucp), by lai@mips.com (David Lai):
) 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.  

As I (and one or two other people) pointed out the last time this
subject came up, it is not necessary for the parser to keep a set of
acceptable tokens. It can keep a set of states which are discarded
by default reductions, (which should be much quicker to calculate),
then calculate the tokens only if they are needed when an error is
detected. Didn't I point this out recently also?

		Dave Jones
[From djones@megatest.com (Dave Jones)]
-- 
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.