help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enabeling location tracking for bison 1.75


From: Laurence Finston
Subject: Re: Enabeling location tracking for bison 1.75
Date: Fri, 11 Jun 2004 12:07:00 +0200 (MEST)

In order for `YYLLOC_DEFAULT' to work, you need to set the locations of the
symbols on the right-hand side.
I think the best way to do this is in
`yylex()', however I believe it's also possible to do so in `yyparse()'.
The Bison manual discusses ways of setting locations.

Laurence


On Fri, 11 Jun 2004, Oliver B. Fischer wrote:

> Dear list,
>
> I would like to provide a better error message to the users of my
> application. To achieve this I would like to enable location tracking in
> my bison parser. Sadly, I am not able to convince it.
>
> I redefined YYLLOC_DEFAULT
>
> #define YYLLOC_DEFAULT(Current, Rhs, N)          \
>    Current.first_line   = Rhs[1].first_line;      \
>    Current.first_column = Rhs[1].first_column;    \
>    Current.last_line    = Rhs[N].last_line;       \
>    Current.last_column  = Rhs[N].last_column;     \
>    fprintf(stderr, "loc(%d) [l%d,c%d l%d,c%d] [l%d,c%d l%d,c%d]\n", N, \
>      Rhs[1].first_line, Rhs[1].first_column, \
>      Rhs[1].last_line, Rhs[1].last_column, \
>      Rhs[N].first_line, Rhs[N].first_column, \
>      Rhs[N].last_line, Rhs[N].last_column);
>
> and put
>
> %locations
>
> in my grammar file.
>
> If I parse an input file, my scanner never gives me the true position of
> any symbol. I get ony 0s.
>
> Can someone help me?
>
> Regards,
>
> Oliver Fischer
>
>
>
> _______________________________________________
> address@hidden http://lists.gnu.org/mailman/listinfo/help-bison
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]