home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / std / c / 2536 < prev    next >
Encoding:
Text File  |  1992-08-29  |  1.7 KB  |  57 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!uwm.edu!linac!att!news.cs.indiana.edu!uceng.uc.edu!ucunix.san.uc.edu!mandayrv
  3. From: mandayrv@ucunix.san.uc.edu (The Karate Kid)
  4. Subject: FREOPEN/FOPEN
  5. Message-ID: <1992Aug29.052141.8736@ucunix.san.uc.edu>
  6. Followup-To: ramanand@pumpkin.ece.uc.edu
  7. Keywords: Lex/Yacc, parsing multiple files.
  8. Organization: University of Cincinnati
  9. Distribution: usa
  10. Date: Sat, 29 Aug 92 05:21:41 GMT
  11. Lines: 44
  12.  
  13. Hi folks,
  14.  
  15. I am not sure if this topic should come  in this newsgroup or in the
  16. comp.compilers newsgroup. But this one looks more appropriate. So here goes.
  17. Thanks to all the folks who respond.
  18.  
  19.  
  20. I am trying to parse two different files using the lex/bison combo. I have
  21. two different parsers created by two different parser specifications to
  22. bison. Suppose I want the first parser to read from file A and the second
  23. parser to read from file B.
  24.  
  25. I reassing stdin to file A by the command:
  26.     
  27.     freopen("A", "r", stdin);
  28.  
  29.  
  30. The parser processes the file A and returns to the calling program. My
  31. problems start after this. I am not able to figure out how to make the
  32. second parser read from file B. The lexical analyzer is the same. I tried
  33. the following command but it did not work:
  34.  
  35.     freopen("B", "r", stdin);
  36.  
  37.  
  38. I even tried storing the return value of the first freopen call in a 
  39. FILE pointer and passed it as the third argument to the second freopen call.
  40. In both the cases, the lexical analyzer returns an EOF character as the next
  41. read token.
  42.  
  43. Am I doing something fundamentally wrong (which is quite possible since I am
  44. not at all comfortabl dealing with streams, specially figuring out the
  45. difference between a STREAM and a FILE);
  46.  
  47.  
  48. Thanks in advance
  49.  
  50.  
  51. ramanand@pumpkin.ece.uc.edu
  52.  
  53. -- 
  54.   mandayrv@ucunix.san.uc.edu
  55.  
  56.  
  57.