File I/O with lex/yacc

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Aug 31 07:27:31 AEST 1990


In article <3918 at bingvaxu.cc.binghamton.edu> vu0310 at bingvaxu.cc.binghamton.edu.cc.binghamton.edu (R. Kym Horsell) writes:
-In article <1990Aug29.172830.14348 at cunixf.cc.columbia.edu> gld at cunixd.cc.columbia.edu (Gary L Dare) writes:
->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.

Perhaps whoever coded the template assumed that you'd have a C
compiler that worked properly.

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

No, just do the initialization dynamically rather than statically.

You should basically NEVER use the main() routines from the lex & yacc
libraries.  They were provided just for wimps.



More information about the Comp.unix.questions mailing list