help-bison
[Top][All Lists]
Advanced

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

Re: bison doesn't parse my include file


From: Juergen Schumacher
Subject: Re: bison doesn't parse my include file
Date: Wed, 11 Jan 2012 16:23:36 +0100

dear akim,

this was the decisive hint:

It looks like a bad idea to me to use a local variable "fin" in
a scanner action, since you want the stream to survive the
handling of this pattern.

thank you 1000000000000 times.

regards

juergen

Am 11.01.2012 um 15:43 schrieb Akim Demaille:

> 
> Le 10 janv. 2012 à 01:02, Juergen Schumacher a écrit :
> 
>> sorry for bothering anybody,
> 
> Hi Juergen,
> 
> You're not bothering anybody :)
> 
>> i am trying to c++ parse an include file with flex 2.5.35 and bison 2.3 on a 
>> mac os x snow leopard installation - everything without include file works 
>> perfectly.
> 
> I would strongly recommend upgrading Bison, the current release is 2.5.
> 
>> my latest attempt was:
>> 
>> I|i          BEGIN(incl);
>> 
>> <incl>[ \t]*
>> <incl>[^ \t\n]+ {
>>      printf(yytext);
>>      printf("\n");
>> 
>>                     std::ifstream fin(yytext);
>>                     yy_buffer_state* my_buffer_state = 
>> yy_create_buffer(&fin, YY_BUF_SIZE);
>>                     yypush_buffer_state(my_buffer_state);
>>                     BEGIN(INITIAL);
>>                }
>> 
>> i get the stream name correct, but receive an <<EOF>> immediately - instead 
>> of the parsed parameter values -
>> although i can read the stream via lex()...
>> 
>> am i stupid or do i miss some basic parser call...?
>> 
>> any help would be highly appreciated.
> 
> As you may have noticed, there is nothing related to Bison in your
> question: that's only about scanner issues.
> 
> It looks like a bad idea to me to use a local variable "fin" in
> a scanner action, since you want the stream to survive the
> handling of this pattern.
> 
> You could just stick to plain old fopen, even if you are
> actually compiling the scanner in C++, and reuse yyin.  Just like
> in Flex' doc.

--
Dr. Juergen Schumacher
Hochschule fuer Technik Stuttgart
Forschungszentrum zafh.net
Schellingstrasse 24
70174 Stuttgart
Telefon: 0711.8926.2840
Telefax: 0711.8926.2986
Mobil: 0170.3445457
www.zafh.net



reply via email to

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