how to find end of file in flex (pallavi)
6 Aug 2001 04:01:57 -0400

          From comp.compilers

Related articles
how to find end of file in flex (2001-08-06)
| List of all articles for this month |

From: (pallavi)
Newsgroups: comp.compilers
Date: 6 Aug 2001 04:01:57 -0400
Keywords: lex, C++, question
Posted-Date: 06 Aug 2001 04:01:57 EDT

I Have A Pb While Detecting The End Of The File
I Ahve A One Flex Code That Scans File And One Wroapper Over This
This Wrapper Call The Lexer And Read One Token Through yylex()
And It Reads The Tokens Till The End Of File. But It Going Into The
Infinite Loop After Detecting The End Of File
I Have Used
<<EOF>> Construct Of Flex
<<EOF>> {cout<<"shree EOF file"<<endl;return 0;}
Also I Have Declared
static inline int yywrap() {return 1;}

It Is Printing Shree EOF File
But After It Won'T Stop , Going Into Infinite Loop
Pls Help Me
To Detect The End Of File
How To Do This
I Am Calling Lex In Wrapper Class As
unsigned int var;
var= yylex();
//till the end of file
while( var != 0)
//doing something

//checking whether it is newline, if it is then
// do something

//again reading
//get next token
         var = yylex();

But When EOF Occures Then Should Give 0 In Var, But It'S Not Giving
Pls Tell Me How To Do This

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.