Error reporting with YACC (or Bison)
21 Sep 2000 18:13:36 -0400

          From comp.compilers

Related articles
Error reporting with YACC (or Bison) (2000-09-21)
Re: Error reporting with YACC (or Bison) (Timur Safin) (2000-09-23)
Re: Error reporting with YACC (or Bison) (Joachim Pimiskern) (2000-09-28)
| List of all articles for this month |

Newsgroups: comp.compilers
Date: 21 Sep 2000 18:13:36 -0400
Organization: - Before you buy.
Keywords: yacc, errors, comment

(This is pretty heady newsgroup, so I'm almost embarrassed to post this
question here. If there is a more appropriate group for this type of
question, please let me know. OK, onto the question...)

I used Flex and Bison to write an interpreter for a simple c-like
language. When Bison encounters a syntax error it spits out "parse
error". I want to give more descriptive error messages, such
as "expecting semicolon after line 3". How would I go about this?

The best I can think of so far is to create productions in my grammar
for every bogus syntax I can think of, and generate errors when they
are recognized.

Is there a better way using these tools?

[Not really. Yacc doesn't give you much help at error recovery. People
have tried to do better error reports over the years, see the comp.compilers
archives. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.