Flex

Flex

Post by pa.. » Fri, 13 Aug 1999 04:00:00



Hi!

I have a little problem with my .l file

Here is the code in the lex file.

^"#"            BEGIN(p_comment); /* print out whole processor line */
<p_comment>[^\n]*

    fprintf(yyout, "%s",linebuf);
    BEGIN(INITIAL); }
<p_comment>[\n]

    unput('\n');
    BEGIN(INITIAL);
     }

And he is an example of the text file to parse:

#include "toto.h"
#include "dad.h"
#include "mom.h"

...

The problem is that when it parses my text file, the first "#include"
works fine, but at the second and third it doesn't recognize the #
(unknown token). If I remove the circumflex in the lex file, all the
#include are processed correctly. I need the ^ because the # character
needs different processing when it's not at the beginning of the file.

I'm using the latest version of Flex available for Digital Unix 4.0F

Thanks.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

 
 
 

Flex

Post by Vadim Cheka » Sat, 14 Aug 1999 04:00:00



> Hi!

> I have a little problem with my .l file
> The problem is that when it parses my text file, the first "#include"
> works fine, but at the second and third it doesn't recognize the #
> (unknown token). If I remove the circumflex in the lex file, all the
> #include are processed correctly. I need the ^ because the # character
> needs different processing when it's not at the beginning of the file.

try pass to flex debug flag (-d ?)
then your programm will write which rule is matched for each token.

Vadim Chekan.