Path: utzoo!attcan!uunet!cs.utexas.edu!uwm.edu!uwvax!poona.cs.wisc.edu!hollings From: hollings@poona.cs.wisc.edu (Jeff Hollingsworth) Newsgroups: comp.unix.wizards Subject: Re: yacc & lex - cupla questions Message-ID: <10916@spool.cs.wisc.edu> Date: 30 Jul 90 16:39:45 GMT References: <1990Jul26.175831.1216@uicbert.eecs.uic.edu> <32114@cup.portal.com> Sender: news@spool.cs.wisc.edu Reply-To: hollings@poona.cs.wisc.edu (Jeff Hollingsworth) Organization: University of Wisconsin--Madison Lines: 23 In article <32114@cup.portal.com>, chucka@cup.portal.com (Charles - Anderson) writes: |> | |> >--------------------------------------------------------------------- |> >1.) how does one redefine the i/o in a yacc/lex piece of code? i.e. |> >the code which is generated defaults to stdin and stdout for input and |> >output, respectively. i'd like to redefine these defaults w/o having |> >to hack on the intermediate c-code, since this is a live production |> >project; i'd like to be able to update and modify the program simply by |> >saying "make". |> |> You can use freopen, or if you wish another file use dup. |> A cleaner approach is to use the file variable yyin. Which lex uses to get its input. Thus yyin = fopen(infile, "r") will do the redirection and leave standard in alone. Just do this before calling yyparse(). ------------------------------------------------------------------------------- Jeff Hollingsworth Work: (608) 262-6617 hollings@cs.wisc.edu Home: (608) 256-4839