Le 13 sept. 2013 à 10:42, 王波 <wangbo15541...@hotmail.com> a écrit :

> Hi,
> 
>    Flex/Bison is powerful.  As a developer, I love them.
> 
>    Now, I meet with a problem and can't find a good way to resolve it. 
>    when Flex read "\n", I add my line number, then ignore it. Flex will read 
> another word, then return to bison as a token. Bison will start to reduce and 
> action my function. But in my function, I will use the line number which is 
> wrong obviously.
> 
>    I have a way to resolve it. When Flex read "\n", I think it can return 
> some special character(key word) to make Bison to reduce the statement, then 
> Bison can ignore the special character.
> 
>   I think Bison should support this way.

Your problem statement is not entirely clear: you don't state what
you do with the line number.  But anyway, using the current (scanner's)
line number is just as wrong as would be reading its current yytext:
just don't do that.

If you want location information (line number of whatever), just
enable location support, and read the doc (or conversely :).
The doc features complete examples tracking locations, be sure
to read them carefully.
_______________________________________________
help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to