Related articles |
---|
Switching input buffers in flex zender@nospam.uci.edu (Charlie Zender) (2002-05-23) |
From: | Charlie Zender <zender@nospam.uci.edu> |
Newsgroups: | comp.compilers |
Date: | 23 May 2002 01:21:09 -0400 |
Organization: | University of California at Irvine |
Keywords: | lex |
Posted-Date: | 23 May 2002 01:21:09 EDT |
Hi,
I'm trying to write a lexer that handles #include files and having
trouble passing control back to the input buffer for the parent file
when the EOF of the #include'd file is reached. According to the
example in the flex manpage, all I need to do is call
yy_switch_to_buffer(YY_BUFFER_STATE new_buffer)
but things do not appear to be that simple. Is it true that I must
also make sure that yywrap() returns true (non-zero)? And must I
also manually reconnect yyin to the FILE handle of the parent
file? or is this reconnect handled internally by yy_switch_to_buffer?
Thanks,
Charlie
--
Charlie Zender, zender at uci dot edu, (949) 824-2987, Department of
Earth System Science, University of California, Irvine CA 92697-3100
[The yywrap() function is an old kludge, and should always return 1.
The buffer structure keeps track of its input file, so you don't have
to fiddle with yyin. Look at the code in lex.yy.c, which isn't really
very complicated. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.