line numbers & yyerror

"Vana" <>
17 Jan 2006 21:37:33 -0500

          From comp.compilers

Related articles
line numbers & yyerror (Vana) (2006-01-17)
| List of all articles for this month |

From: "Vana" <>
Newsgroups: comp.compilers
Date: 17 Jan 2006 21:37:33 -0500
Organization: Compilers Central
Keywords: yacc, question
Posted-Date: 17 Jan 2006 21:37:33 EST

Hi everyone,

I have a working compiler where the scanner and parser were created
using flex and bison respectively. I want to redefine yyerror so that
the line number is passed as an argument. The plan is to pass the line
info to the parser through yylval and then use it when needed.

From what I can see in the bison manual, this can be done if bison
creates a pure parser. Is there any other way? And if I do use
%pure-parser after all, will there be any modifications other than
those mentioned in section 4.2.4 "Calling Conventions for Pure
Parsers" of the manual? I'm asking because the compiler is already
complete, and I'd like to change the code as little as possible.



PS. I was thinking about buying "lex & yacc" and someone suggested
"Introduction to Compiler Construction With Unix" instead. Any
comments? My local bookstores don't carry either one, so I can't
browse through them before I buy :(
[They're quite different. If you want to know how to use lex&yacc,
buy lex&yacc. If you want some orked out example compilers that
use lex and yacc for the scanner and parser, get Introduction. -John]

Post a followup to this message

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