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: Akim Demaille
Subject: Re: bison doesn't parse my include file
Date: Wed, 11 Jan 2012 15:43:31 +0100

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.


reply via email to

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