Article View: comp.std.c
Article #1230FREOPEN/FOPEN
From: The Karate Kid
Date: Sat, 29 Aug 1992 05:21
Date: Sat, 29 Aug 1992 05:21
42 lines
1830 bytes
1830 bytes
Hi folks,
I am not sure if this topic should come in this newsgroup or in the
comp.compilers newsgroup. But this one looks more appropriate. So here goes.
Thanks to all the folks who respond.
I am trying to parse two different files using the lex/bison combo. I have
two different parsers created by two different parser specifications to
bison. Suppose I want the first parser to read from file A and the second
parser to read from file B.
I reassing stdin to file A by the command:
freopen("A", "r", stdin);
The parser processes the file A and returns to the calling program. My
problems start after this. I am not able to figure out how to make the
second parser read from file B. The lexical analyzer is the same. I tried
the following command but it did not work:
freopen("B", "r", stdin);
I even tried storing the return value of the first freopen call in a
FILE pointer and passed it as the third argument to the second freopen call.
In both the cases, the lexical analyzer returns an EOF character as the next
read token.
Am I doing something fundamentally wrong (which is quite possible since I am
not at all comfortabl dealing with streams, specially figuring out the
difference between a STREAM and a FILE);
Thanks in advance
ramanand@pumpkin.ece.uc.edu
--
mandayrv@ucunix.san.uc.edu
Technical Details
Message-ID:
<1992Aug29.052141.8736@ucunix.san.uc.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!sun-barr!cs.utexas.edu!uwm.edu!linac!att!news.cs.indiana.edu!uceng.uc.edu!ucunix.san.uc.edu!mandayrvShow Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!sparky!uunet!sun-barr!cs.utexas.edu!uwm.edu!linac!att!news.cs.indiana.edu!uceng.uc.edu!ucunix.san.uc.edu!mandayrv From: mandayrv@ucunix.san.uc.edu (The Karate Kid) Subject: FREOPEN/FOPEN Message-ID: <1992Aug29.052141.8736@ucunix.san.uc.edu> Followup-To: ramanand@pumpkin.ece.uc.edu Keywords: Lex/Yacc, parsing multiple files. Organization: University of Cincinnati Distribution: usa Date: Sat, 29 Aug 92 05:21:41 GMT Lines: 44