Re: [Flex-help] handling EOF with flex
flex is a tool for generating scanners
Brought to you by:
wlestes
From: John G. <jgw...@da...> - 2008-03-31 20:23:03
|
Can you just do a 'getline' type thing, take the string, and pass it in as a string buffer to the Lexer? Then you don't have to mess around with yywrap. It also makes the lexing a bit more atomic. == John == > -----Original Message----- > From: fle...@li... [mailto:flex-help- > bo...@li...] On Behalf Of Martin Weise > Sent: Monday, March 31, 2008 10:36 AM > To: fle...@li... > Subject: [Flex-help] handling EOF with flex > > Hi @all > > I guess my question is posted several times, but I did not find a > solution that works for me. > I want to do the following thing: > The user can enter a command: load 'ex.wip' > After pressing ENTER, this line is lexed through flex and loads the file, > which then is processed via flex. > > This is done by: > FILE *file = freopen(name.c_str(), "r", yyin); > > I encounter problems when trying to catch the EOF, as > I want to return to the prompt, means the stdin. > > As far as I have read, I must overwrite yywrap. > I did this: > int yywrap() > { > yyrestart(stdin); > return 0; > } > > For debuging reasons I placed a cout in my local function, but as there > is > no cout, it seems that the yywrap function is never called. > > I also tried this: > <<EOF>> { BEGIN(0); yyin = stdin; cout <<"teset"; return > yytext[0]; } > > in my flex file. But the result is also no output. > > So how do I handle an EOF, and return to the prompt ? > > > > Regards > Martin Weise > > ------------------------------------------------------------------------ - > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketp l > ace > _______________________________________________ > Flex-help mailing list > Fle...@li... > https://lists.sourceforge.net/lists/listinfo/flex-help |