File I/O with lex/yacc

R. Kym Horsell vu0310 at bingvaxu.cc.binghamton.edu
Fri Aug 31 02:25:18 AEST 1990


In article <1990Aug29.172830.14348 at cunixf.cc.columbia.edu> gld at cunixd.cc.columbia.edu (Gary L Dare) writes:
>
>Is there any way to get around the use of standard input/output in a
>lex file???  The C file generated by lex (from the lexical analyzer
>spec you feed in) has the following line hard-coded:
>
>	FILE *yyin = {stdin}, *yyout = {stdout};

This is a rather unfortunate idea from those responsible -- I have
discovered some C compilers that don't even *support* initialization
of pointers (dumb linkers?) so it should have been taken care of
by the main supplied in the lex & yacc libraries.

If *you* put another initialization into your lex file (which
you *could* do) you would probably get a compiler error (double
definition). 

The cleanest solution is therefore to write your *own* main
and do the assignments yourself.

-Kym Horsell



More information about the Comp.unix.questions mailing list