Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.unix.questions Subject: Re: File I/O with lex/yacc Keywords: lex, yacc, file i/o Message-ID: <13712@smoke.BRL.MIL> Date: 30 Aug 90 21:27:31 GMT References: <1990Aug29.122152.1600@virtech.uucp> <1990Aug29.172830.14348@cunixf.cc.columbia.edu> <3918@bingvaxu.cc.binghamton.edu> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 21 In article <3918@bingvaxu.cc.binghamton.edu> vu0310@bingvaxu.cc.binghamton.edu.cc.binghamton.edu (R. Kym Horsell) writes: -In article <1990Aug29.172830.14348@cunixf.cc.columbia.edu> gld@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.