[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: I can't make sure it's a bug. But I think it's important.
From: |
Akim Demaille |
Subject: |
Re: I can't make sure it's a bug. But I think it's important. |
Date: |
Thu, 19 Sep 2013 16:31:35 +0200 |
Le 13 sept. 2013 à 10:42, 王波 <address@hidden> 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.