yacc & lex - cupla questions
Jeff Hollingsworth
hollings at poona.cs.wisc.edu
Tue Jul 31 02:39:45 AEST 1990
In article <32114 at cup.portal.com>, chucka at 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 at cs.wisc.edu Home: (608) 256-4839
More information about the Comp.unix.wizards
mailing list