Xref: utzoo comp.unix.questions:25125 comp.misc:9967 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!rpi!leah!bingvaxu!vu0310 From: vu0310@bingvaxu.cc.binghamton.edu (R. Kym Horsell) Newsgroups: comp.unix.questions,comp.misc Subject: Re: File I/O with lex/yacc Keywords: lex, yacc, file i/o Message-ID: <3918@bingvaxu.cc.binghamton.edu> Date: 30 Aug 90 16:25:18 GMT References: <2320@cirrusl.UUCP> <1990Aug29.122152.1600@virtech.uucp> <1990Aug29.172830.14348@cunixf.cc.columbia.edu> Reply-To: vu0310@bingvaxu.cc.binghamton.edu.cc.binghamton.edu (R. Kym Horsell) Organization: SUNY Binghamton, NY Lines: 21 In article <1990Aug29.172830.14348@cunixf.cc.columbia.edu> gld@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