Path: utzoo!attcan!uunet!cs.utexas.edu!usc!bloom-beacon!mit-eddie!genrad!decvax!ima!esegue!compilers-sender From: nielses@imada.dk (Soee Niels) Newsgroups: comp.compilers Subject: Error messages and Yacc Message-ID: <1989Jul28.210350.3619@esegue.uucp> Date: 28 Jul 89 21:03:50 GMT Sender: compilers-sender@esegue.uucp Reply-To: nielses@imada.dk (Soee Niels) Organization: Dept. of Mathematics and Computer Science, Odense University, Denmark Lines: 25 Approved: compilers@esegue.segue.bos.ma.us We are using yacc to write a compiler, and we have problems as we want to give some meaningful error messages to the user. Yacc knows which symbol is valid from every state, and we want to use this information to write something like: LEFTPAR or SEMICOLON expected. One possible solution to the problem is a function "yyexpected" that could return a list of possible terminal symbols. Does any of you have this function, or is there another solution to the problem? Thank you in advance. My email address is niels@ifad.dk, but maybe the answer is of interest to the newsgroup. [This is not as easy as it looks, because yacc combines states wherever possible, which means that the legitimate follow set in each state is often a lot larger than the grammar would make it. There has been a lot of work done on improving yacc's notoriously weak error handling, and nobody has asked about this for a while, so I'd be interested in hearing what's new in yacc error recovery. -John] -- 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.