|Better error messages with yyerror() ffdixon@InterNetivity.com (Frederick F. Dixon) (1997-05-27)|
|Re: Better error messages with yyerror() email@example.com.OZ.AU (1997-05-30)|
|Re: Better error messages with yyerror() firstname.lastname@example.org (Antonio Linares) (1997-05-30)|
|From:||"Antonio Linares" <email@example.com>|
|Date:||30 May 1997 23:12:27 -0400|
|Organization:||Unisource Espana NEWS SERVER|
I recommend you to have a look at the book Lex & Yacc (O'Reilly publisher,
authors John R. Levine!!!, Tony Mason and Doug Brown). There you have a
clear explanation of how to do that without having to patch Lex.
Basically all you do is:
\n.* lineno++; strcpy( linebuf, yytext + 1 ); yyless( 1 );
so linebuf contains a entire copy of the source line. For each token you
read you increase a variable with the yyleng of the token, so when a error
ocurrs you know exactly where you are in the line and you can exactly
display the error position.
[Oh, right, that hack. I should read my own books now and then. -John]
Return to the
Search the comp.compilers archives again.