> > Now, the problem is that for (2) I need to be able to send the
> > data as a C FILE * stream, beacuse that is what flex expects. So
> > what format should my preformatting step output the data in, and
> > how do I convert it to a FILE * structure?
Quote:> Alternatively, (although I have personally never done this) you can
> redefine YY_INPUT to read from whatever you want. The format is
> YY_INPUT(buf,result,max_size), and you can redefine it to read input
> from wherever you want, streams, memory, FILE* or a random number
> generator if you are so inclined. See the flex man page at:
More generally, you can pass the output of flex through a shell script
with sed to get what you want. I've donne this for ages with lex and
yacc, to get C++ long before the actual tools had ever heard of the
language. (I've also done it with yacc to change the error handling
strategy, but that's another story.)
But flex already has options for C++. Just add:
to the top of your flex source. (Except that the version I have uses
a forward declaration of the *class* istream, which doesn't work with
modern libraries. So I still use a filter like:
echo "#include <istream>"
) | sed '
In my own code, the actual input is a MultipleFileIStream (which
derives from istream), and it seems to work.
Beratung in objektorientierer Datenverarbeitung --
-- Conseils en informatique oriente objet
Ziegelhttenweg 17a, 60598 Frankfurt, Germany, Tl.: +49 (0)69 19 86 27
[ about comp.lang.c++.moderated. First time posters: do this! ]