Related articles |
---|
how to find end of file in flex pallavi@poseidontech.com (2001-08-06) |
From: | pallavi@poseidontech.com (pallavi) |
Newsgroups: | comp.compilers |
Date: | 6 Aug 2001 04:01:57 -0400 |
Organization: | http://groups.google.com/ |
Keywords: | lex, C++, question |
Posted-Date: | 06 Aug 2001 04:01:57 EDT |
Hi
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
Flex,
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
#define YY_SKIP_YYWRAP
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
Pallavi
Return to the
comp.compilers page.
Search the
comp.compilers archives again.