|YACC: syntax errors firstname.lastname@example.org (1997-01-16)|
|Re: YACC: syntax errors email@example.com (1997-01-17)|
|Re: YACC: syntax errors firstname.lastname@example.org (Henner Zeller) (1997-01-19)|
|From:||email@example.com (Scott Nicol)|
|Date:||17 Jan 1997 23:27:41 -0500|
|Organization:||APK Net, Ltd.|
>Is there any way of getting detailed error information out of YACC...
>so I can get more specific about syntax errors than just putting out
>a 'syntax error' message? I've tried using the 'error' keyword
>but even using it sparsely comes up with a lot of reduce/reduce conflicts.
>[Not without hacking the generated parser, which many people have done.
Yes, you can hack the parser to look at the debug information
(i.e. the stuff generated to y.output) so that it can report what
tokens would have been acceptable in the current state, but that could
be a long list and might not be too useful. If you suggest what the
error might be, you could end up confusing the programmer even more if
the suggestion isn't correct.
I prefer error messages that just say:
foo.c line 50: Syntax error near "flub"
Nothing too suggestive or direct, unless you know for sure what the
The easiest way to do this is to write your own yyerror(). In your
yyerror(), print the current filename (you should know this, set a
variable whenever you open yyin) and line number (undocumented but
available from most lex implementations as yylineno), and the last
text read in (yytext).
Return to the
Search the comp.compilers archives again.